Student[NumericalAnalysis] - Maple Help

Online Help

All Products    Maple    MapleSim


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

 

Calling Sequence

Parameters

Options

Description

Notes

Examples

Calling Sequence

Quadrature(f, x=a..b, opts)

Quadrature(f, a..b, opts)

Quadrature(Int(f, x=a..b), opts)

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

Options

• 

adaptive = true or false

  

Whether to apply the adaptive version of the specified method. The following methods are available when adaptive is set to true:

– 

Newton-Cotes Rule, open or closed, with a user-specified order

– 

Trapezoid Rule

– 

Boole's Rule

– 

Simpson's Rule

– 

Simpson's 3/8 Rule

  

See method to view the specific calling sequence of method when adaptive=true. By default, the adaptive option is set to false.

• 

boxoptions = list

  

A list of options for the plot of approximating boxes. For more information on plot options, see plot/options.

• 

functionoptions = list

  

A list of options for the plot of the expression f. By default, the expression is plotted as a solid red line. For more information on plot options, see plot/options.

• 

iterations = posint

  

The number of successive refinements in the animation. By default, the value is 6.

• 

method = boole, [boole, positive], [boole, positive, posint], simpson, [simpson, positive], [simpson, positive, posint], simpson[3/8], [simpson[3/8], positive], [simpson[3/8], positive, posint], trapezoid, [trapezoid, positive], [trapezoid, positive, posint], gaussian, gaussian[posint], romberg, newtoncotes[posint], [newtoncotes[posint], positive], [newtoncotes[posint], positive, posint], newtoncotes[closed, posint], or newtoncotes[open, nonnegint]

  

The method of approximating the integral. By default, Simpson's rule is used.

– 

boole = Boole's rule

– 

simpson = Simpson's rule

– 

simpson[3/8] = Simpson's 3/8 rule

– 

trapezoid = trapezoid rule

– 

gaussian[N] = N point Gaussian quadrature rule

– 

romberg = Romberg integration

– 

newtoncotes[N] = Newton-Cotes method of order N

  

Note: Boole's rule (which is the fourth order Newton-Cotes method) is sometimes known as Bode's rule. This is apparently due to an erroneous attribution in the literature. This command will accept either method=boole or method=bode.

  

When the Newton-Cotes method is specified without the open or closed option, the Newton-Cotes closed method is used by default.

  

When the Gaussian quadrature rule is specified without the number of points (or nodes), the 3 point Gaussian quadrature rule is used.

  

The method option sequences method=[meth, positive] and method=[meth,positive, posint], where meth is either boole, simpson, simpson[3/8], trapezoid, or newtoncotes[N] are only valid when adaptive is set to true.

  

In the method = [meth, positive] option calling sequence, meth is the method and the 2nd list entry of type positive is the error tolerance of the approximation.

  

In the method = [meth, positive, posint] option calling sequence, meth is the method, the 2nd list entry of type positive is the error tolerance of the approximation, and the 3rd list entry of type posint is the maximum number iterations to perform.

  

The default tolerance is 10-4 and the default maximum number of iterations depends on the environment variable Digits and is determined using the expression 50*max(Digits, Digits*2-4).

• 

outline = true or false

  

Whether the boxes, as a whole, are outlined. Setting this option to true provides a less cluttered image when the partition is large. By default, this option is set to false.

• 

output = value, sum, plot, animation, or information

  

This option controls the return value of the function.

– 

output=value: The value of the approximation is returned. Plot options are ignored if output=value. This is the default.

– 

output=sum: An inert sum with the appropriate summand is returned. Plot options are ignored if output=sum.

– 

output=plot: A plot, which shows the expression f and an approximation to the integral on (a, b), is displayed.

– 

output=animation: An animation, which shows the expression f and approximations using a sequence of partitions, each of which is a refinement of its predecessor, is displayed.

– 

output=information: Information relevant to the numerical integration is printed in the interface.  Plot options are ignored if output=information.

• 

partition = posint, list(algebraic), random[algebraic], or algebraic

  

The partition option controls the partitioning of the interval [a, b].

  

By default, the interval is divided into 10 equally spaced subintervals.

  

If partition = N is specified, where N is a positive integer, the interval is divided into N equally spaced subintervals. When output = sum, this is the only type of input allowed.

  

If partition = [x1, x2, ...] (a list of algebraic expressions) is specified, the interval is divided into subintervals at the points specified in the list. Note that each expression in the list must be able to be evaluated to a floating-point number. If the endpoints are not included in the list, they are added.

  

If partition = random[c] is given, where c is an algebraic expression, the interval is divided into subintervals with widths randomly chosen from the range 12c,c. Note that c must be able to be evaluated to a positive floating-point number.

  

An arbitrary algebraic expression given as the value of this option is assumed to be a positive integer and is useful only if the output=sum.

• 

partitionlist = list(posint)

  

A list of partitions to use in approximating the integral of f. Each positive integer value divides the interval into that number of equally spaced subintervals.  This option is ignored unless output=information.

• 

partitiontype = normal or subintervals

  

The partitiontype option controls the type of partitioning used in solving the approximation. This option only applies to Newton-Cotes methods, which include the Trapezoid rule, Simpson's rule, Simpson's 3/8 rule, and Boole's rule.

– 

partitiontype=normal: Each end of a partition is used as one single evaluation point in approximating the integral. As a result, the number of partitions must be a multiple of a certain integer depending on the method: a multiple of 2 when using Simpson's rule, a multiple of 3 when using Simpson's 3/8 rule, a multiple of 4 when using Boole's rule, and a multiple of n when using a Newton-Cotes[n] rule. This option does not work with partition=random[c].

– 

partitiontype=subintervals: Each partition is used as a subinterval instead, with each subinterval divided into the appropriate number of partitions for each method. There is no limit on the partition number when using this option. This is the default.

• 

plotoptions = list

  

The final plot options when output=plot or output=animation.

• 

pointoptions = list

  

A list of options for the points on the plot.  This option is ignored if one of the Newton-Cotes methods, which include the Trapezoid rule, Simpson's rule, Simpson's 3/8 rule, and Boole's rule, is used.  This option is also ignored unless output=plot. For more information on plot options, see plot/options.

• 

refinement = halve, random, or numeric in (0,1)

  

In an animation, the refinement controls how an interval is subpartitioned. The default is halve.

  

The value halve indicates that the interval is subdivided into two equal subintervals.

  

The value random indicates that the interval is randomly subdivided. The random value is chosen from the average of two uniform distributions.

  

A numeric value c must be in the open interval (0, 1) and indicates that the interval p,q is broken into the intervals p,p+cqp and p+cqp,q.

• 

showarea = true or false

  

Whether the approximation of the integral of f is displayed on the plot. By default, this option is set to true.

• 

showfunction = true or false

  

Whether the expression f is plotted. By default, this option is set to true.

• 

showpoints = true or false

  

Whether the points at which the function f is evaluated at to obtain the height of the corresponding box are shown. This option is ignored if one of the Newton-Cotes methods, which include the Trapezoid rule, Simpson's rule, Simpson's 3/8 rule, and Boole's rule, is used.  This option is also ignored unless output=plot.

• 

subpartition = all, width, or area

  

In an animation, the subpartition option controls which intervals are subpartitioned each iteration. The default is all.

  

The value all indicates that every subinterval is subpartitioned.

  

The value width indicates that the interval with greatest width is subpartitioned. If there is more than one interval with largest width, the leftmost is chosen.

  

The value area indicates that the interval with greatest area is subpartitioned. If there is more than one interval with largest area, the leftmost is chosen.

• 

caption = anything

  

A caption for the plot. The default caption depends on methods used to find the approximation. For more information about specifying a caption, see plot/typesetting.

• 

view = [realcons..realcons, realcons..realcons]

  

The plot view of the plot when output=plot.  See plot/options for more information.

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

withStudent[NumericalAnalysis]:

a0:

b48:

f1+cosx2:

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

Quadraturef,x=a..b,method=simpson,partition=4,output=value

56.20282263

(1)

The command to create a plot of the above approximation is

Quadraturef,x=a..b,method=simpson,partition=4,output=plot

fxx24:

a3:

b3.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

Quadraturef,x=a..b,method=romberg4,output=information

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

Quadraturef,3..3.5,adaptive=true,method=newtoncotes1,104,output=information

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

See Also

Student[NumericalAnalysis]

Student[NumericalAnalysis][AdaptiveQuadrature]

Student[NumericalAnalysis][VisualizationOverview]

 


Download Help Document

Was this information helpful?



Please add your Comment (Optional)
E-mail Address (Optional)
What is ? This question helps us to combat spam