Trapezoidal Rule - Maple Help

Trapezoidal Rule

 Calling Sequence ApproximateInt(f(x), x = a..b, method = trapezoid, opts) ApproximateInt(f(x), a..b, method = trapezoid, opts) ApproximateInt(Int(f(x), x = a..b), method = trapezoid, opts)

Parameters

 f(x) - algebraic expression in variable 'x' x - name; specify the independent variable a, b - algebraic expressions; specify the interval opts - equation(s) of the form option=value where option is one of boxoptions, functionoptions, iterations, method, outline, output, partition, pointoptions, refinement, showarea, showfunction, showpoints, subpartition, view, or Student plot options; specify output options

Description

 • The ApproximateInt(f(x), x = a..b, method = trapezoid) command approximates the integral of f(x) from a to b by using the trapezoidal Rule. The first two arguments (function expression and range) can be replaced by a definite integral.
 • If the independent variable can be uniquely determined from the expression, the parameter x need not be included in the calling sequence.
 • Given a partition $P=\left(a={x}_{0},{x}_{1},...,{x}_{N}=b\right)$ of the interval $\left(a,b\right)$, the trapezoidal rule approximates the integral on each subinterval $\left({x}_{i-1},{x}_{i}\right)$ by integrating the linear function that interpolates the endpoints $\left({x}_{i-1},f\left({x}_{i-1}\right)\right)$ and $\left({x}_{i},f\left({x}_{i}\right)\right)$.  This value is

$\frac{\left({x}_{i}-{x}_{i-1}\right)\left(f\left({x}_{i-1}\right)+f\left({x}_{i}\right)\right)}{2}$

 • In the case that the widths of the subintervals are equal, the approximation can be written as

$\frac{\left(b-a\right)\left(f\left({x}_{0}\right)+2f\left({x}_{1}\right)+2f\left({x}_{2}\right)+\mathrm{...}+2f\left({x}_{N-1}\right)+f\left({x}_{N}\right)\right)}{2N}$

 • By default, the interval is divided into $10$ equal-sized subintervals.
 • For the options opts, see the ApproximateInt help page.
 • This rule can be applied interactively, through the ApproximateInt Tutor.

Examples

 > $\mathrm{polynomial}≔{\mathrm{CurveFitting}}_{\mathrm{PolynomialInterpolation}}\left(\left[{x}_{0},{x}_{1}\right],\left[f\left(0\right),f\left(1\right)\right],z\right):$
 > $\mathrm{integrated}≔{∫}_{{x}_{0}}^{{x}_{1}}\mathrm{polynomial}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}ⅆz:$
 > $\mathrm{factor}\left(\mathrm{integrated}\right)$
 ${-}\frac{\left({-}{{x}}_{{1}}{+}{{x}}_{{0}}\right){}\left({f}{}\left({0}\right){+}{f}{}\left({1}\right)\right)}{{2}}$ (1)
 > $\mathrm{with}\left({\mathrm{Student}}_{\mathrm{Calculus1}}\right):$
 > $\mathrm{ApproximateInt}\left(\mathrm{sin}\left(x\right),x=0..5,\mathrm{method}=\mathrm{trapezoid}\right)$
 $\frac{{\mathrm{sin}}{}\left(\frac{{1}}{{2}}\right)}{{2}}{+}\frac{{\mathrm{sin}}{}\left({1}\right)}{{2}}{+}\frac{{\mathrm{sin}}{}\left(\frac{{3}}{{2}}\right)}{{2}}{+}\frac{{\mathrm{sin}}{}\left({2}\right)}{{2}}{+}\frac{{\mathrm{sin}}{}\left(\frac{{5}}{{2}}\right)}{{2}}{+}\frac{{\mathrm{sin}}{}\left({3}\right)}{{2}}{+}\frac{{\mathrm{sin}}{}\left(\frac{{7}}{{2}}\right)}{{2}}{+}\frac{{\mathrm{sin}}{}\left({4}\right)}{{2}}{+}\frac{{\mathrm{sin}}{}\left(\frac{{9}}{{2}}\right)}{{2}}{+}\frac{{\mathrm{sin}}{}\left({5}\right)}{{4}}$ (2)
 > $\mathrm{ApproximateInt}\left(x\left(x-2\right)\left(x-3\right),x=0..5,\mathrm{method}=\mathrm{trapezoid},\mathrm{output}=\mathrm{plot}\right)$
 > $\mathrm{ApproximateInt}\left(\mathrm{tan}\left(x\right)-2x,x=-1..1,\mathrm{method}=\mathrm{trapezoid},\mathrm{output}=\mathrm{plot},\mathrm{partition}=50\right)$

To play the following animation in this help page, right-click (Control-click, on Mac) the plot to display the context menu.  Select Animation > Play.

 > $\mathrm{ApproximateInt}\left(\mathrm{ln}\left(x\right),1..100,\mathrm{method}=\mathrm{trapezoid},\mathrm{output}=\mathrm{animation}\right)$