Chapter 6: Techniques of Integration
Section 6.7: Numeric Methods
Example 6.7.8
Sketch a derivation of the Trapezoid rule.
Solution
Mathematical Solution
use plots,plottools,Student:-VectorCalculus in module() local p1,p2,p3,p4,p5,p6,p7,g,v1,v2,v3,v4; g:=x->x*(1-x^2); p1:=plot(g,-.02..1,color=black,tickmarks=[0,0],axis[2]=[color=white]): p2:=polygon([[.248,0],[.248,g(.248)],[.5,g(.5)],[.5,0]],transparency=.7,color=red); p3:=polygon([[.502,0],[.502,g(.502)],[.75,g(.75)],[.75,0]],transparency=.7, color=green); p4:=textplot({[.25,-.01,typeset(x[k])],[.5,-.01,typeset(x[k+1])],[.75,-.01,x[k+2]]}); p5:=textplot({[.18,g(.25),typeset(``(x[k],f[k]))],[.35,g(.5),typeset(``(x[k+1],f[k+1]))],[.88,g(.75),typeset(``(x[x+2],f[k+2]))]}); p6:=textplot([.375,.05,typeset(h)]); v1:=RootedVector(root=[.35,.05],<-.1,0>); v2:=RootedVector(root=[.4,.05],<.1,0>); p7:=PlotVector([v1,v2],color=black); print(display(p1,p2,p3,p4,p5,p6,p7)); end module: end use:
Figure 6.7.7(a) Two contiguous trapezoids
use plots,plottools,Student:-VectorCalculus in module() local p1,p2; p1:=polygon([[0,0],[3,0],[2,1],[0,1]],color=red,transparency=.7); p2:=textplot({[1,1.1,typeset(f[k])],[1.25,-.12,typeset(f[k+1])],[.1,.5,typeset(h)]}); print(display(p1,p2,scaling=constrained,tickmarks=[0,0],axes=None)); end module: end use:
Figure 6.7.7(b) A single trapezoid
Figure 6.7.7(a) shows two contiguous trapezoids under the graph of fx. The red trapezoid lies between the nodes xk and xk+1; the green, between xk+1 and xk+2.
Figure 6.7.7(b) shows the red trapezoid from Figure 6.7.7(a) rotated so that the two parallel sides (the bases) are horizontal, and the height h corresponds to the "width" h=b−a/n in an array of n trapezoids on the interval a,b.
The area of the generic trapezoid is Ak=h2fk+fk+1, the average of the bases times the height.
The sum of the areas of the n trapezoids is
∑k=1nAk
=h2f0+f1+f1+f2+⋯+fn−2+fn−1+fn−1+fn
=h2 f0+2∑k=1n−1fk+fn
The left base in the leftmost trapezoid, and the right base in the rightmost trapezoid appear only once in the sum. Every other base appears twice, once as the right base in a contiguous pair, and once as the left. This should be clear from Figure 6.7.7(a) where the base with length fk+1 appears as a base in both the red and green (contiguous) trapezoids.
Maple Solution
Area of one trapezoid
Enter the area of the generic trapezoid.
Context Panel: Assign to a Name≻A[k]
h2 fk+fk+1→assign to a nameAk
Area of five trapezoids
Expression palette: summation template Sum the area of trapezoids for k=0,1,…,4 Press the Enter key.
Context Panel: Simplify≻Simplify
Context Panel: Factor
∑k=04Ak
12⁢h⁢f0+f1+12⁢h⁢f1+f2+12⁢h⁢f2+f3+12⁢h⁢f3+f4+12⁢h⁢f4+f5
= simplify
12⁢h⁢f0+h⁢f1+h⁢f2+h⁢f3+h⁢f4+12⁢h⁢f5
= factor
12⁢h⁢f0+2⁢f1+2⁢f2+2⁢f3+2⁢f4+f5
Generalize to the partition x0,…,xn
Note the factor of h/2 in front of the parentheses. Inside the parentheses the terms f0 and f5 represent the values of fx at the first and last nodes, namely, x0=a and xn=b, respectively. The remaining terms in the parentheses are "twice the sum of the function values at the nodes between first and last." Hence, the generalization to
h2 fa+fb+2∑k=1n−1fk
where fk=fa+k h, and h=b−a/2.
<< Previous Example Section 6.7 Next Example >>
© Maplesoft, a division of Waterloo Maple Inc., 2024. All rights reserved. This product is protected by copyright and distributed under licenses restricting its use, copying, distribution, and decompilation.
For more information on Maplesoft products and services, visit www.maplesoft.com
Download Help Document