Previous: Introduction to QUADPACK, Up: Integration [Contents][Index]
Integration of a general function over a finite interval. quad_qag
implements a simple globally adaptive integrator using the strategy of Aind
(Piessens, 1973). The caller may choose among 6 pairs of Gauss-Kronrod
quadrature formulae for the rule evaluation component. The high-degree rules
are suitable for strongly oscillating integrands.
quad_qag
computes the integral
The function to be integrated is \(f(x)\), with dependent variable \(x\), and the function is to be integrated between the limits \(a\) and \(b\). key is the integrator to be used and should be an integer between 1 and 6, inclusive. The value of key selects the order of the Gauss-Kronrod integration rule. High-order rules are suitable for strongly oscillating integrands.
The integrand may be specified as the name of a Maxima or Lisp function or operator, a Maxima lambda expression, or a general Maxima expression.
The numerical integration is done adaptively by subdividing the integration region into sub-intervals until the desired accuracy is achieved.
The keyword arguments are optional and may be specified in any order.
They all take the form key=val
. The keyword arguments are:
epsrel
Desired relative error of approximation. Default is 1d-8.
epsabs
Desired absolute error of approximation. Default is 0.
limit
Size of internal work array. limit is the maximum number of subintervals to use. Default is 200.
quad_qag
returns a list of four elements:
The error code (fourth element of the return value) can have the values:
0
if no problems were encountered;
1
if too many sub-intervals were done;
2
if excessive roundoff error is detected;
3
if extremely bad integrand behavior occurs;
6
if the input is invalid.
Examples:
(%i1) quad_qag (x^(1/2)*log(1/x), x, 0, 1, 3, 'epsrel=5d-8); (%o1) [.4444444444492108, 3.1700968502883E-9, 961, 0]
(%i2) integrate (x^(1/2)*log(1/x), x, 0, 1); 4 (%o2) - 9
Integration of a general function over a finite interval.
quad_qags
implements globally adaptive interval subdivision with
extrapolation (de Doncker, 1978) by the Epsilon algorithm (Wynn, 1956).
quad_qags
computes the integral
The function to be integrated is \(f(x)\), with dependent variable \(x\), and the function is to be integrated between the limits \(a\) and \(b\).
The integrand may be specified as the name of a Maxima or Lisp function or operator, a Maxima lambda expression, or a general Maxima expression.
The keyword arguments are optional and may be specified in any order.
They all take the form key=val
. The keyword arguments are:
epsrel
Desired relative error of approximation. Default is 1d-8.
epsabs
Desired absolute error of approximation. Default is 0.
limit
Size of internal work array. limit is the maximum number of subintervals to use. Default is 200.
quad_qags
returns a list of four elements:
The error code (fourth element of the return value) can have the values:
0
no problems were encountered;
1
too many sub-intervals were done;
2
excessive roundoff error is detected;
3
extremely bad integrand behavior occurs;
4
failed to converge
5
integral is probably divergent or slowly convergent
6
if the input is invalid.
Examples:
(%i1) quad_qags (x^(1/2)*log(1/x), x, 0, 1, 'epsrel=1d-10); (%o1) [.4444444444444448, 1.11022302462516E-15, 315, 0]
Note that quad_qags
is more accurate and efficient than quad_qag
for this integrand.
Integration of a general function over an infinite or semi-infinite interval.
The interval is mapped onto a finite interval and
then the same strategy as in quad_qags
is applied.
quad_qagi
evaluates one of the following integrals
using the Quadpack QAGI routine. The function to be integrated is \(f(x)\), with dependent variable \(x\), and the function is to be integrated over an infinite range.
The integrand may be specified as the name of a Maxima or Lisp function or operator, a Maxima lambda expression, or a general Maxima expression.
One of the limits of integration must be infinity. If not, then
quad_qagi
will just return the noun form.
The keyword arguments are optional and may be specified in any order.
They all take the form key=val
. The keyword arguments are:
epsrel
Desired relative error of approximation. Default is 1d-8.
epsabs
Desired absolute error of approximation. Default is 0.
limit
Size of internal work array. limit is the maximum number of subintervals to use. Default is 200.
quad_qagi
returns a list of four elements:
The error code (fourth element of the return value) can have the values:
0
no problems were encountered;
1
too many sub-intervals were done;
2
excessive roundoff error is detected;
3
extremely bad integrand behavior occurs;
4
failed to converge
5
integral is probably divergent or slowly convergent
6
if the input is invalid.
Examples:
(%i1) quad_qagi (x^2*exp(-4*x), x, 0, inf, 'epsrel=1d-8); (%o1) [0.03125, 2.95916102995002E-11, 105, 0]
(%i2) integrate (x^2*exp(-4*x), x, 0, inf); 1 (%o2) -- 32
Computes the Cauchy principal value of \(f(x)/(x - c)\) over a finite interval. The strategy is globally adaptive, and modified Clenshaw-Curtis integration is used on the subranges which contain the point \(x = c\).
quad_qawc
computes the Cauchy principal value of
using the Quadpack QAWC routine. The function to be integrated is \(f(x)/(x-c)\), with dependent variable \(x\), and the function is to be integrated over the interval \(a\) to \(b\).
The integrand may be specified as the name of a Maxima or Lisp function or operator, a Maxima lambda expression, or a general Maxima expression.
The keyword arguments are optional and may be specified in any order.
They all take the form key=val
. The keyword arguments are:
epsrel
Desired relative error of approximation. Default is 1d-8.
epsabs
Desired absolute error of approximation. Default is 0.
limit
Size of internal work array. limit is the maximum number of subintervals to use. Default is 200.
quad_qawc
returns a list of four elements:
The error code (fourth element of the return value) can have the values:
0
no problems were encountered;
1
too many sub-intervals were done;
2
excessive roundoff error is detected;
3
extremely bad integrand behavior occurs;
6
if the input is invalid.
Examples:
(%i1) quad_qawc (2^(-5)*((x-1)^2+4^(-5))^(-1), x, 2, 0, 5, 'epsrel=1d-7); (%o1) [- 3.130120337415925, 1.306830140249558E-8, 495, 0]
(%i2) integrate (2^(-alpha)*(((x-1)^2 + 4^(-alpha))*(x-2))^(-1), x, 0, 5); Principal Value alpha alpha 9 4 9 4 log(------------- + -------------) alpha alpha 64 4 + 4 64 4 + 4 (%o2) (----------------------------------------- alpha 2 4 + 2 3 alpha 3 alpha ------- ------- 2 alpha/2 2 alpha/2 2 4 atan(4 4 ) 2 4 atan(4 ) alpha - --------------------------- - -------------------------)/2 alpha alpha 2 4 + 2 2 4 + 2
(%i3) ev (%, alpha=5, numer); (%o3) - 3.130120337415917
Calculates a Fourier cosine or Fourier sine transform on a semi-infinite
interval using the Quadpack QAWF function. The same approach as in
quad_qawo
is applied on successive finite intervals, and convergence
acceleration by means of the Epsilon algorithm (Wynn, 1956) is applied to the
series of the integral contributions.
quad_qawf
computes the integral
The weight function \(w\) is selected by trig:
cos
sin
The integrand may be specified as the name of a Maxima or Lisp function or operator, a Maxima lambda expression, or a general Maxima expression.
The keyword arguments are optional and may be specified in any order.
They all take the form key=val
. The keyword arguments are:
epsabs
Desired absolute error of approximation. Default is 1d-10.
limit
Size of internal work array. (limit - limlst)/2 is the maximum number of subintervals to use. Default is 200.
maxp1
Maximum number of Chebyshev moments. Must be greater than 0. Default is 100.
limlst
Upper bound on the number of cycles. Must be greater than or equal to 3. Default is 10.
quad_qawf
returns a list of four elements:
The error code (fourth element of the return value) can have the values:
0
no problems were encountered;
1
too many sub-intervals were done;
2
excessive roundoff error is detected;
3
extremely bad integrand behavior occurs;
6
if the input is invalid.
Examples:
(%i1) quad_qawf (exp(-x^2), x, 0, 1, 'cos, 'epsabs=1d-9); (%o1) [.6901942235215714, 2.84846300257552E-11, 215, 0]
(%i2) integrate (exp(-x^2)*cos(x), x, 0, inf); - 1/4 %e sqrt(%pi) (%o2) ----------------- 2
(%i3) ev (%, numer); (%o3) .6901942235215714
Integration of
\(\cos(\omega x) f(x)\)
or
\(\sin(\omega x)\)
over a finite interval,
where
\(\omega\)
is a constant.
The rule evaluation component is based on the modified
Clenshaw-Curtis technique. quad_qawo
applies adaptive subdivision with
extrapolation, similar to quad_qags
.
quad_qawo
computes the integral using the Quadpack QAWO
routine:
The weight function \(w\) is selected by trig:
cos
sin
The integrand may be specified as the name of a Maxima or Lisp function or operator, a Maxima lambda expression, or a general Maxima expression.
The keyword arguments are optional and may be specified in any order.
They all take the form key=val
. The keyword arguments are:
epsrel
Desired relative error of approximation. Default is 1d-8.
epsabs
Desired absolute error of approximation. Default is 0.
limit
Size of internal work array. limit/2 is the maximum number of subintervals to use. Default is 200.
maxp1
Maximum number of Chebyshev moments. Must be greater than 0. Default is 100.
limlst
Upper bound on the number of cycles. Must be greater than or equal to 3. Default is 10.
quad_qawo
returns a list of four elements:
The error code (fourth element of the return value) can have the values:
0
no problems were encountered;
1
too many sub-intervals were done;
2
excessive roundoff error is detected;
3
extremely bad integrand behavior occurs;
6
if the input is invalid.
Examples:
(%i1) quad_qawo (x^(-1/2)*exp(-2^(-2)*x), x, 1d-8, 20*2^2, 1, cos); (%o1) [1.376043389877692, 4.72710759424899E-11, 765, 0]
(%i2) rectform (integrate (x^(-1/2)*exp(-2^(-alpha)*x) * cos(x), x, 0, inf)); alpha/2 - 1/2 2 alpha sqrt(%pi) 2 sqrt(sqrt(2 + 1) + 1) (%o2) ----------------------------------------------------- 2 alpha sqrt(2 + 1)
(%i3) ev (%, alpha=2, numer); (%o3) 1.376043390090716
Integration of \(w(x) f(x)\) over a finite interval, where \(w(x)\) is a certain algebraic or logarithmic function. A globally adaptive subdivision strategy is applied, with modified Clenshaw-Curtis integration on the subintervals which contain the endpoints of the interval of integration.
quad_qaws
computes the integral using the Quadpack QAWS routine:
The weight function \(w\) is selected by wfun:
1
2
3
4
The integrand may be specified as the name of a Maxima or Lisp function or operator, a Maxima lambda expression, or a general Maxima expression.
The keyword arguments are optional and may be specified in any order.
They all take the form key=val
. The keyword arguments are:
epsrel
Desired relative error of approximation. Default is 1d-8.
epsabs
Desired absolute error of approximation. Default is 0.
limit
Size of internal work array. limitis the maximum number of subintervals to use. Default is 200.
quad_qaws
returns a list of four elements:
The error code (fourth element of the return value) can have the values:
0
no problems were encountered;
1
too many sub-intervals were done;
2
excessive roundoff error is detected;
3
extremely bad integrand behavior occurs;
6
if the input is invalid.
Examples:
(%i1) quad_qaws (1/(x+1+2^(-4)), x, -1, 1, -0.5, -0.5, 1, 'epsabs=1d-9); (%o1) [8.750097361672832, 1.24321522715422E-10, 170, 0]
(%i2) integrate ((1-x*x)^(-1/2)/(x+1+2^(-alpha)), x, -1, 1); alpha Is 4 2 - 1 positive, negative, or zero? pos; alpha alpha 2 %pi 2 sqrt(2 2 + 1) (%o2) ------------------------------- alpha 4 2 + 2
(%i3) ev (%, alpha=4, numer); (%o3) 8.750097361672829
Integration of a general function over a finite interval.
quad_qagp
implements globally adaptive interval subdivision with
extrapolation (de Doncker, 1978) by the Epsilon algorithm (Wynn, 1956).
quad_qagp
computes the integral
The function to be integrated is \(f(x)\), with dependent variable \(x\), and the function is to be integrated between the limits \(a\) and \(b\).
The integrand may be specified as the name of a Maxima or Lisp function or operator, a Maxima lambda expression, or a general Maxima expression.
To help the integrator, the user must supply a list of points where the integrand is singular or discontinuous.
The keyword arguments are optional and may be specified in any order.
They all take the form key=val
. The keyword arguments are:
epsrel
Desired relative error of approximation. Default is 1d-8.
epsabs
Desired absolute error of approximation. Default is 0.
limit
Size of internal work array. limit is the maximum number of subintervals to use. Default is 200.
quad_qagp
returns a list of four elements:
The error code (fourth element of the return value) can have the values:
0
no problems were encountered;
1
too many sub-intervals were done;
2
excessive roundoff error is detected;
3
extremely bad integrand behavior occurs;
4
failed to converge
5
integral is probably divergent or slowly convergent
6
if the input is invalid.
Examples:
(%i1) quad_qagp(x^3*log(abs((x^2-1)*(x^2-2))),x,0,3,[1,sqrt(2)]); (%o1) [52.74074838347143, 2.6247632689546663e-7, 1029, 0]
(%i2) quad_qags(x^3*log(abs((x^2-1)*(x^2-2))), x, 0, 3); (%o2) [52.74074847951494, 4.088443219529836e-7, 1869, 0]
The integrand has singularities at 1
and sqrt(2)
so we supply
these points to quad_qagp
. We also note that quad_qagp
is
more accurate and more efficient that quad_qags
.
Control error handling for quadpack. The parameter should be one of the following symbols:
current_error
The current error number
control
Controls if messages are printed or not. If it is set to zero or less, messages are suppressed.
max_message
The maximum number of times any message is to be printed.
If value is not given, then the current value of the parameter is returned. If value is given, the value of parameter is set to the given value.
Previous: Introduction to QUADPACK, Up: Integration [Contents][Index]