PerlGSL::RootFinding::SingleDim - A Perlish Interface to the GSL 1D Root Finding Library
use PerlGSL::Integration::SingleDim qw/findroot_1d/; my $result = findroot_1d(sub{ $_[0]**2 - 5 }, 0, 5); # sqrt(5)
This module is an interface to the GSL's Single Dimensional numerical root finding routines. So far only the "bracketing" Brent-Dekker method is implemented.
No functions are exported by default.
This is the main interface provided by the module. It takes three required arguments and an (optional) options hash. The first argument is a subroutine reference defining the function. The next two are numbers defining the lower and upper bound for searching.
The options hash reference accepts the following keys:
epsabs - The maximum allowable absolute error. The default is 0 (ignored).
0
epsrel - The maximum allowable relative error. The default is 1e-4.
1e-4
max_iter - The maximum number of search iterations permitted. The default is 1000.
The return value is the position of the root. Note that if there are multiple roots in the search location only one will be returned; there is no way to tell which it will be.
This module needs the GSL library installed and available. The PERLGSL_LIBS environment variable may be used to pass the --libs linker flags; if this is not specified, the command gsl-config --libs is executed to find them. Future plans include using an Alien module to provide the GSL in a more CPAN-friendly manner.
PERLGSL_LIBS
--libs
gsl-config --libs
Derivative methods may be added, but would require a separate closure representing the derivative of the function (unless numeric derivatives were employed). This makes such mechanisms less useful at least for now, of course, your contributions are always welcome!
PerlGSL
http://www.gnu.org/software/gsl/manual/html_node/One-dimensional-Root_002dFinding.html
http://github.com/jberger/PerlGSL-RootFinding-SingleDim
Joel Berger, <joel.a.berger@gmail.com>
Copyright (C) 2012 by Joel Berger
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
The GSL is licensed under the terms of the GNU General Public License (GPL)
To install PerlGSL::RootFinding::SingleDim, copy and paste the appropriate command in to your terminal.
cpanm
cpanm PerlGSL::RootFinding::SingleDim
CPAN shell
perl -MCPAN -e shell install PerlGSL::RootFinding::SingleDim
For more information on module installation, please visit the detailed CPAN module installation guide.