INTEGSection: User Contributed Perl Documentation (3)Updated: 2004-06-15 |
INTEGSection: User Contributed Perl Documentation (3)Updated: 2004-06-15 |
Functions are named gslinteg_{algorithm} where {algorithm} is the QUADPACK naming convention. The available functions are:
Each algorithm computes an approximation to the integral, I, of the function f(x)w(x), where w(x) is a weight function (for general integrands w(x)=1). The user provides absolute and relative error bounds (epsabs,epsrel) which specify the following accuracy requirement:
|RESULT - I| <= max(epsabs, epsrel |I|)
The routines will fail to converge if the error bounds are too stringent, but always return the best approximation obtained up to that stage
All functions return the result, and estimate of the absolute error and an error flag (which is zero if there were no problems). You are responsible for checking for any errors, no warnings are issued unless the option {Warn => 'y'} is specified in which case the reason of failure will be printed.
Please check the GSL documentation for more information.
use PDL; use PDL::GSL::INTEG;
my $a = 1.2; my $b = 3.7; my $epsrel = 0; my $epsabs = 1e-6;
# Non adaptive integration
my ($res,$abserr,$ierr,$neval) = gslinteg_qng(\&myf,$a,$b,$epsrel,$epsabs);
# Warnings on
my ($res,$abserr,$ierr,$neval) = gslinteg_qng(\&myf,$a,$b,$epsrel,$epsabs,{Warn=>'y'});
# Adaptive integration with warnings on
my $limit = 1000;
my $key = 5;
my ($res,$abserr,$ierr) = gslinteg_qag(\&myf,$a,$b,$epsrel,
$epsabs,$limit,$key,{Warn=>'y'});
sub myf{
my ($x) = @_;
return exp(-$x**2);
}
Usage:
($res,$abserr,$ierr,$neval) = gslinteg_qng($function_ref,$a,$b,
$epsrel,$epsabs,[{Warn => $warn}]);
Example:
my ($res,$abserr,$ierr,$neval) = gslinteg_qng(\&f,0,1,0,1e-9);
# with warnings on
my ($res,$abserr,$ierr,$neval) = gslinteg_qng(\&f,0,1,0,1e-9,{Warn => 'y'});
sub f{
my ($x) = @_;
return ($x**2.6)*log(1.0/$x);
}
Please check the GSL documentation for more information.
Usage:
($res,$abserr,$ierr) = gslinteg_qag($function_ref,$a,$b,$epsrel,
$epsabs,$limit,$key,[{Warn => $warn}]);
Example:
my ($res,$abserr,$ierr) = gslinteg_qag(\&f,0,1,0,1e-10,1000,1);
# with warnings on
my ($res,$abserr,$ierr) = gslinteg_qag(\&f,0,1,0,1e-10,1000,1,{Warn => 'y'});
sub f{
my ($x) = @_;
return ($x**2.6)*log(1.0/$x);
}
Please check the GSL documentation for more information.
Usage:
($res,$abserr,$ierr) = gslinteg_qags($function_ref,$a,$b,$epsrel,
$epsabs,$limit,[{Warn => $warn}]);
Example:
my ($res,$abserr,$ierr) = gslinteg_qags(\&f,0,1,0,1e-10,1000);
# with warnings on
($res,$abserr,$ierr) = gslinteg_qags(\&f,0,1,0,1e-10,1000,{Warn => 'y'});
sub f{
my ($x) = @_;
return ($x)*log(1.0/$x);
}
Please check the GSL documentation for more information.
Usage:
($res,$abserr,$ierr) = gslinteg_qagp($function_ref,$points,$epsabs,
$epsrel,$limit,[{Warn => $warn}])
Example:
my $points = pdl(0,1,sqrt(2),3); my ($res,$abserr,$ierr) = gslinteg_qagp(\&f,$points,0,1e-3,1000); # with warnings on ($res,$abserr,$ierr) = gslinteg_qagp(\&f,$points,0,1e-3,1000,{Warn => 'y'});
sub f{
my ($x) = @_;
my $x2 = $x**2;
my $x3 = $x**3;
return $x3 * log(abs(($x2-1.0)*($x2-2.0)));
}
Please check the GSL documentation for more information.
Usage:
($res,$abserr,$ierr) = gslinteg_qagi($function_ref,$epsabs,
$epsrel,$limit,[{Warn => $warn}]);
Example:
my ($res,$abserr,$ierr) = gslinteg_qagi(\&myfn,1e-7,0,1000);
# with warnings on
($res,$abserr,$ierr) = gslinteg_qagi(\&myfn,1e-7,0,1000,{Warn => 'y'});
sub myfn{
my ($x) = @_;
return exp(-$x - $x*$x) ;
}
Please check the GSL documentation for more information.
Usage:
($res,$abserr,$ierr) = gslinteg_qagiu($function_ref,$a,$epsabs,
$epsrel,$limit,[{Warn => $warn}]);
Example:
my $alfa = 1;
my ($res,$abserr,$ierr) = gslinteg_qagiu(\&f,99.9,1e-7,0,1000);
# with warnings on
($res,$abserr,$ierr) = gslinteg_qagiu(\&f,99.9,1e-7,0,1000,{Warn => 'y'});
sub f{
my ($x) = @_;
if (($x==0) && ($alfa == 1)) {return 1;}
if (($x==0) && ($alfa > 1)) {return 0;}
return ($x**($alfa-1))/((1+10*$x)**2);
}
Please check the GSL documentation for more information.
Usage:
($res,$abserr,$ierr) = gslinteg_qagl($function_ref,$b,$epsabs,
$epsrel,$limit,[{Warn => $warn}]);
Example:
my ($res,$abserr,$ierr) = gslinteg_qagil(\&myfn,1.0,1e-7,0,1000);
# with warnings on
($res,$abserr,$ierr) = gslinteg_qagil(\&myfn,1.0,1e-7,0,1000,{Warn => 'y'});
sub myfn{
my ($x) = @_;
return exp($x);
}
Please check the GSL documentation for more information.
Usage:
($res,$abserr,$ierr) = gslinteg_qawc($function_ref,$a,$b,$c,$epsabs,$epsrel,$limit)
Example:
my ($res,$abserr,$ierr) = gslinteg_qawc(\&f,-1,5,0,0,1e-3,1000);
# with warnings on
($res,$abserr,$ierr) = gslinteg_qawc(\&f,-1,5,0,0,1e-3,1000,{Warn => 'y'});
sub f{
my ($x) = @_;
return 1.0 / (5.0 * $x * $x * $x + 6.0) ;
}
Please check the GSL documentation for more information.
Usage:
($res,$abserr,$ierr) =
gslinteg_qawc($function_ref,$alpha,$beta,$mu,$nu,$a,$b,
$epsabs,$epsrel,$limit,[{Warn => $warn}]);
Example:
my ($res,$abserr,$ierr) = gslinteg_qaws(\&f,0,0,1,0,0,1,0,1e-7,1000);
# with warnings on
($res,$abserr,$ierr) = gslinteg_qaws(\&f,0,0,1,0,0,1,0,1e-7,1000,{Warn => 'y'});
sub f{
my ($x) = @_;
if($x==0){return 0;}
else{
my $u = log($x);
my $v = 1 + $u*$u;
return 1.0/($v*$v);
}
}
Please check the GSL documentation for more information.
Usage:
($res,$abserr,$ierr) = gslinteg_qawo($function_ref,$omega,$sin_or_cos,
$a,$b,$epsabs,$epsrel,$limit,[opt])
Example:
my $PI = 3.14159265358979323846264338328;
my ($res,$abserr,$ierr) = PDL::GSL::INTEG::gslinteg_qawo(\&f,10*$PI,'sin',0,1,0,1e-7,1000);
# with warnings on
($res,$abserr,$ierr) = PDL::GSL::INTEG::gslinteg_qawo(\&f,10*$PI,'sin',0,1,0,1e-7,1000,{Warn => 'y'});
sub f{
my ($x) = @_;
if($x==0){return 0;}
else{ return log($x);}
}
Please check the GSL documentation for more information.
Usage:
gslinteg_qawf($function_ref,$omega,$sin_or_cos,$a,$epsabs,$limit,[opt])
Example:
my ($res,$abserr,$ierr) = gslinteg_qawf(\&f,$PI/2.0,'cos',0,1e-7,1000);
# with warnings on
($res,$abserr,$ierr) = gslinteg_qawf(\&f,$PI/2.0,'cos',0,1e-7,1000,{Warn => 'y'});
sub f{
my ($x) = @_;
if ($x == 0){return 0;}
return 1.0/sqrt($x)
}
The GSL documentation is online at
http://sources.redhat.com/gsl/ref/gsl-ref_toc.html
The GSL integration routines were written by Brian Gough. QUADPACK was written by Piessens, Doncker-Kapenga, Uberhuber and Kahaner.
Signature: (double a(); double b(); double epsabs();
double epsrel(); double [o] result(); double [o] abserr();
int [o] neval(); int [o] ierr(); int warn(); SV* funcion)
Signature: (double a(); double b(); double epsabs();double epsrel(); int limit();
int key(); double [o] result(); double [o] abserr();int n();int [o] ierr();int warn();; SV* funcion)
Signature: (double a(); double b(); double epsabs();double epsrel(); int limit();
double [o] result(); double [o] abserr();int n();int [o] ierr();int warn();; SV* funcion)
Signature: (double pts(l); double epsabs();double epsrel();int limit(); double [o] result(); double [o] abserr();int n();int [o] ierr();int warn();; SV* funcion)
Signature: (double epsabs();double epsrel(); int limit();
double [o] result(); double [o] abserr(); int n(); int [o] ierr();int warn();; SV* funcion)
Signature: (double a(); double epsabs();double epsrel();int limit();
double [o] result(); double [o] abserr();int n();int [o] ierr();int warn();; SV* funcion)
Signature: (double b(); double epsabs();double epsrel();int limit();
double [o] result(); double [o] abserr();int n();int [o] ierr();int warn();; SV* funcion)
Signature: (double a(); double b(); double c(); double epsabs();double epsrel();int limit();
double [o] result(); double [o] abserr();int n();int [o] ierr();int warn();; SV* funcion)
Signature: (double a(); double b();double epsabs();double epsrel();int limit();
double [o] result(); double [o] abserr();int n();
double alpha(); double beta(); int mu(); int nu();int [o] ierr();int warn();; SV* funcion)
Signature: (double a(); double b();double epsabs();double epsrel();int limit();
double [o] result(); double [o] abserr();int n();
int sincosopt(); double omega(); double L(); int nlevels();int [o] ierr();int warn();; SV* funcion)
Signature: (double a(); double epsabs();int limit();
double [o] result(); double [o] abserr();int n();
int sincosopt(); double omega(); int nlevels();int [o] ierr();int warn();; SV* funcion)
info not available