return or plot a numerical approximation to an integral - Maple Help

Home : Support : Online Help : Education : Student Package : Numerical Analysis : Visualization : Student/NumericalAnalysis/Quadrature

Student[NumericalAnalysis][Quadrature] - return or plot a numerical approximation to an integral

Parameters

 f - algebraic; expression in the variable x x - name; the independent variable of f a,b - numeric; the endpoints of integration opts - (optional) equation(s) of the form keyword=value, where keyword is one of adaptive, boxoptions, functionoptions, iterations, method, outline, output, partition, partitionlist, partitiontype, pointoptions, refinement, showarea, showfunction, showpoints, subpartition, caption, view; the options for numerically approximating the solution to the integral of f

Description

 • The Quadrature command returns a numerical approximation to the integral of f from a to b, using the specified method.
 • Unless the output = sum option is specified, f must be an expression than can be evaluated to a floating-point number at all x in the range a..b. Likewise, the endpoints a and b must be expressions that can be evaluated to floating-point numbers.
 • The Quadrature command is similar to the Student[Calculus1][ApproximateInt] command; however, the Quadrature command provides more methods to approximate integrals numerically. The Quadrature command aims to introduce numerical integration methods, while the Student[Calculus1][ApproximateInt] command aims to introduce the concept of integration itself.

Notes

 • When the output = sum option is given, this procedure operates symbolically; that is, the inputs are not automatically evaluated to floating-point quantities, and computations proceed symbolically and exactly whenever possible. The output will be an inert sum, giving the formula of the quadrature.
 • Otherwise, this procedure operates using floating-point numerics; that is, inputs are first evaluated to floating-point numbers before computations proceed, and numbers appearing in the output will be in floating-point format.
 • Therefore, when output is not sum, the endpoints a and b must be expressions that can be evaluated to floating-point numbers; furthermore, the function f must be an expression that can be evaluated to a floating-point number whenever x is substituted with a floating-point number in the interval [a, b].

Examples

 > $\mathrm{with}\left(\mathrm{Student}[\mathrm{NumericalAnalysis}]\right):$
 > $a:=0:$
 > $b:=48:$
 > $f:=\sqrt{1+{\mathrm{cos}\left(x\right)}^{2}}:$

The command to numerically approximate the integral of the expression above using Simpson's rule is

 > $\mathrm{Quadrature}\left(f,x=a..b,\mathrm{method}=\mathrm{simpson},\mathrm{partition}=4,\mathrm{output}=\mathrm{value}\right)$
 ${56.20282263}$ (1)

The command to create a plot of the above approximation is

 > $\mathrm{Quadrature}\left(f,x=a..b,\mathrm{method}=\mathrm{simpson},\mathrm{partition}=4,\mathrm{output}=\mathrm{plot}\right)$
 > $f:=\frac{x}{\sqrt{{x}^{2}-4}}:$
 > $a:=3:$
 > $b:=3.5:$

The command to numerically approximate the definite integral of the above expression using Romberg integration and to print other relevant information concerning the approximation in the interface is

 > $\mathrm{Quadrature}\left(f,x=a..b,\mathrm{method}={\mathrm{romberg}}_{4},\mathrm{output}=\mathrm{information}\right)$
 INTEGRAL: Int(x/(x^2-4)^(1/2),x=3..3.5) = 0.636213346       APPROXIMATION METHOD: Romberg Integration Method with 4 Applications of Trapezoidal Rule ---------------------------------- INFORMATION TABLE ----------------------------------     Approximate Value         Absolute Error         Relative Error          0.636213346                   5e-10         7.859e-08 % ------------------------------- ROMBERG INTEGRATION TABLE -----------------------------    0.6400461    0.6371906    0.6362387    0.6364590    0.6362151    0.6362135    0.6362748    0.6362135    0.6362133    0.6362133 --------------------------------------------------------------------------------------- Number of Function Evaluations:      9

Now use an adaptive Newton-Cotes order 1 approximation with a specific tolerance on the same expression

 > $\mathrm{Quadrature}\left(f,3..3.5,\mathrm{adaptive}=\mathrm{true},\mathrm{method}=\left[{\mathrm{newtoncotes}}_{1},{10}^{-4}\right],\mathrm{output}=\mathrm{information}\right)$
 INTEGRAL: Int(x/(x^2-4)^(1/2),x=3..3.5) = 0.636213346       APPROXIMATION METHOD: Adaptive Trapezoidal Rule ---------------------------------- INFORMATION TABLE ----------------------------------     Approximate Value         Absolute Error         Relative Error          0.636258036             4.46897e-05          0.007024 % ---------------------------------- ITERATION HISTORY ---------------------------------------    Interval           Status         Present Stack  3.0000..3.5000        fail           EMPTY  3.0000..3.2500        fail           [3.2500, 3.5000]  3.0000..3.1250        fail           [[1], [3.1250, 3.2500]]  3.0000..3.0625        PASS           [[2], [3.0625, 3.1250]]  3.0625..3.1250        PASS           [[1], [3.1250, 3.2500]]  3.1250..3.2500        PASS           [3.2500, 3.5000]  3.2500..3.5000        fail           EMPTY  3.2500..3.3750        PASS           [3.3750, 3.5000]  3.3750..3.5000        PASS           EMPTY -------------------------------------------------------------------------------------------- Number of Function Evaluations:     11