Math::...ration(3pm)
π NAME π
Math::GSL::Integration β bestie, this is the module for doing numerical integration (quadrature) of a function in one dimension. In 3pm Perl-doc land, obviously. π
β¨ SYNOPSIS β¨
Okay so here's the vibe, literally the whole thing in code:
use Math::GSL::Integration qw /:all/;
my $function = sub { $_[0]**2 } ;
my ($lower, $upper ) = (0,1);
my ($relerr,$abserr) = (0,1e-7);
my ($status, $result, $abserr, $num_evals) = gsl_integration_qng ( $function,
$lower, $upper, $relerr, $abserr
);
That's it. That's the girl. π
π¦ DESCRIPTION π¦
So like, this module lets you numerically integrate a Perl subroutine. But here's the tea: which quadrature routine you pick fully depends on what your function is giving. Is it smooth? Does it have singularities? Is your range finite, infinite, or semi-infinite? You gotta match the routine to your needs, no cap. πΈ
gsl_integration_workspace_alloc($n)β allocates a workspace big enough to hold$ndouble precision intervals, plus their integration results and error estimates. It's giving "I brought enough room for everybody." πgsl_integration_workspace_free($w)β frees the memory associated with the workspace$w. Release her, she's done. ποΈgsl_integration_qaws_table_alloc($alpha, $beta, $mu, $nu)β allocates space for agsl_integration_qaws_tablestruct describing a singular weight function W(x) with the parameters ($alpha,$beta,$mu,$nu), where W(x) =(x-a)^alpha (b-x)^beta log^mu (x-a) log^nu (b-x). Constraints bestie, listen up:$alpha > -1,$beta > -1, and$mu = 0, 1,$nu = 0, 1. Depending on$muand$nu, the weight function takes four different forms:
W(x) = (x-a)^alpha (b-x)^beta (mu = 0, nu = 0)
W(x) = (x-a)^alpha (b-x)^beta log(x-a) (mu = 1, nu = 0)
W(x) = (x-a)^alpha (b-x)^beta log(b-x) (mu = 0, nu = 1)
W(x) = (x-a)^alpha (b-x)^beta log(x-a) log(b-x) (mu = 1, nu = 1)
The singular points (a,b) don't even have to be specified until the integral is computed β and when they are, they're the endpoints of the integration range. The function returns a pointer to the newly allocated table gsl_integration_qaws_table if no errors were detected, and 0 if something went wrong. π
gsl_integration_qaws_table_set($t, $alpha, $beta, $mu, $nu)β this one modifies the parameters ($alpha,$beta,$mu,$nu) of an existinggsl_integration_qaws_tablestruct$t. Glow-up, not rebuild. β¨gsl_integration_qaws_table_free($t)β frees all the memory associated with thegsl_integration_qaws_tablestruct$t. π§gsl_integration_qawo_table_alloc($omega, $L, $sine, $n)β (the page lists her, she's here, that's the whole description.) πgsl_integration_qawo_table_set($t, $omega, $L, $sine, $n)β changes the parametersomega,Landsineof the existing workspace$t. π«Άgsl_integration_qawo_table_set_length($t, $L)β lets you change the length parameter$Lof the workspace$t. Just the length. Nothing else. Respect her boundaries. πgsl_integration_qawo_table_free($t)β frees all the memory associated with the workspace$t. πgsl_integration_qk15($function,$a,$b,$resabs,$resasc)β listed, no description given. She's mysterious. π¦gsl_integration_qk21($function,$a,$b,$resabs,$resasc)β same deal, no description. πgsl_integration_qk31($function,$a,$b,$resabs,$resasc)β yeah, still no description. πgsl_integration_qk41($function,$a,$b,$resabs,$resasc)β nope, none here either. βgsl_integration_qk51($function,$a,$b,$resabs,$resasc)β she's also just vibing with no notes. π₯gsl_integration_qk61($function,$a,$b,$resabs,$resasc)β the last of the qk girlies with no description. πgsl_integration_qcheb($function, $a, $b, $cheb12, $cheb24)β again, no description on the page. πΈgsl_integration_qkβ literally just the name, bestie, that's all the page gives us. πgsl_integration_qng($function,$a,$b,$epsabs,$epsrel,$num_evals)β okay so this routine, QNG (Quadrature Non-Adaptive Gaussian), is inexpensive in the sense that it evaluates the function way fewer times than the adaptive routines do. Because of that it needs no workspaces, so it's also more memory efficient. For well-behaved functions (smooth and nonsingular) it should be perfectly fine β but for more complicated functions it will not be able to get the required accuracy, or it may just not converge. Know your limits, queen. πgsl_integration_qag($function,$a,$b,$epsabs,$epsrel,$limit,$key,$workspace)β this routine QAG (Quadrature Adaptive Gaussian) ... and that's where the page stops, trailing dots and all. π«gsl_integration_qagi($function,$epsabs,$epsrel,$limit,$workspace)β listed, no description. πgsl_integration_qagiu($function,$a,$epsabs,$epsrel,$limit,$workspace)β listed, no description. π§gsl_integration_qagil($function,$b,$epsabs,$epsrel,$limit,$workspace)β listed, no description. πgsl_integration_qags($func,$a,$b,$epsabs,$epsrel,$limit,$workspace)β she comes with an example, periodt:
($status, $result, $abserr) = gsl_integration_qags (
sub { 1/$_[0]} ,
1, 10, 0, 1e-7, 1000,
$workspace,
);
This function applies the Gauss-Kronrod 21-point integration rule adaptively until an estimate of the integral of $func over ($a,$b) is achieved within the desired absolute and relative error limits, $epsabs and $epsrel. Obsessed with her honestly. π
gsl_integration_qagp($function, $pts, $npts, $epsbs, $epsrel, $limit, $workspace)β listed, no description. (Yes,$epsbs. That's what the page says. I do not make the rules. π)gsl_integration_qawc($function, $a, $b, $c, $epsabs, $epsrel, $limit, $workspace)β listed, no description. βgsl_integration_qaws($function, $a, $b, $qaws_table, $epsabs, $epsrel, $limit, $workspace)β listed, no description. π₯gsl_integration_qawo($function, $a, $epsabs, $epsrel, $limit, $workspace, $qawo_table)β listed, no description. πΈgsl_integration_qawf($function, $a, $epsabs, $limit, $workspace, $cycle_workspace, $qawo_table)β listed, no description. π
This module also includes the following constants, bestie: π
$GSL_INTEG_COSINE$GSL_INTEG_SINE$GSL_INTEG_GAUSS15$GSL_INTEG_GAUSS21$GSL_INTEG_GAUSS31$GSL_INTEG_GAUSS41$GSL_INTEG_GAUSS51$GSL_INTEG_GAUSS61
The following error constants are part of the Math::GSL::Errno module and can be returned by the gsl_integration_* functions: π
$GSL_EMAXITERβ maximum number of subdivisions was exceeded. Ate too much. π€$GSL_EROUNDβ cannot reach tolerance because of roundoff error, or roundoff error was detected in the extrapolation table. Rude. π«GSL_ESINGβ a non-integrable singularity or other bad integrand behavior was found in the integration interval. Not the vibes. πGSL_EDIVERGEβ the integral is divergent, or too slowly convergent to be integrated numerically. She's not converging, bestie, walk away. π
π MORE INFO π
For more information on the functions, we refer you to the GSL official documentation: <http://www.gnu.org/software/gsl/manual/html_node/>
π«Ά AUTHORS π«Ά
Jonathan "Duke" Leto <jonathan@leto.net> and Thierry Moisan <thierry.moisan@gmail.com>
π COPYRIGHT AND LICENSE π
Copyright (C) 2008-2024 Jonathan "Duke" Leto and Thierry Moisan
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
okay that's the whole page, you ate that π this was perl v5.42.3, dated 2026-08-20, and it's the Math::GSL::Integration 3pm page β go integrate something slay, ily, bye πβ¨
π¦ where this page comes from
- ubuntu stonking: libmath-gsl-perl 0.49-1build1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms