Chapter 6: Techniques of Integration
Section 6.7: Numeric Methods
Example 6.7.1
Use the Trapezoid rule with n=10 to approximate the definite integral ∫141+sinxlnx+1 ⅆx.
Solution
Mathematical Solution
Define fx=1+sinxlnx+1, and let h=4−110=310. Then
∫141+sinxlnx+1
≐3/102f1+f4+2∑k=19f1+3/10k
=5.067162904
Of course, a computing device of some sort is used to evaluate and sum the terms in the Trapezoid rule.
Maple Solution
Evaluation via Maple's built-in numeric integrator
Control-drag the given definite integral.
Context Panel: 2-D Math≻Convert To≻Inert Form
Context Panel: Approximate≻10 (digits)
∫141+sinxlnx+1 ⅆx→at 10 digits5.078061188
Maple's built-in Trapezoid rule can be accessed either through the Approximate Integration tutor or through the ApproximateInt command in the Student Calculus1 package.
Figure 6.7.1(a) shows the state of the tutor when the Trapezoid rule has been selected for approximating the given integral with n=10.
The actual value of the integral is determined by Maple's built-in integrator, and the approximate value by the selected numeric method. The last digit of the value obtain by the tutor does not agree with the value obtained in the Mathematical Solution section because of a slight difference in how the numeric evaluation is handled by Maple.
Figure 6.7.1(a) Approximate Integration tutor
The form of the ApproximateInt command that generates the image in the tutor's plot window is available at the bottom of the tutor. Changing output = plot to output = sum causes the return to be the unevaluated sum that implements Maple's form of the Trapezoid rule. Changing output = plot to output = value causes the return to be the sum of exact terms that must be evaluated and added to obtain the Trapezoid rule approximation. However, if there is a floating-point number somewhere in the statement of the integral, then Maple evaluates and adds the terms in the Trapezoid rule numerically. These usages of the ApproximateInt command are illustrated in Table 6.7.1(a).
Initialize
Tools≻Load Package: Student Calculus 1
Loading Student:-Calculus1
Context Panel: Assign to a Name≻F
1+sinxlnx+1→assign to a nameF
Apply the ApproximateInt command with output set to sum
ApproximateIntF,x=1..4,partition=10,method=trapezoid,output=sum
320⁢∑i=092+sin⁡1+310⁢i⁢ln⁡2+310⁢i+sin⁡1310+310⁢i⁢ln⁡2310+310⁢i
Apply the ApproximateInt command with output set to value
ApproximateIntF,x=1..4,partition=10,method=trapezoid,output=value
3+320⁢sin⁡2⁢ln⁡5+310⁢sin⁡110⁢31⁢2⁢5⁢ln⁡4110+310⁢sin⁡15⁢17⁢5⁢ln⁡225+310⁢sin⁡110⁢37⁢2⁢5⁢ln⁡4710+310⁢sin⁡15⁢11⁢5⁢ln⁡165+310⁢sin⁡12⁢5⁢2⁢ln⁡72+310⁢sin⁡15⁢2⁢7⁢5⁢ln⁡195+310⁢sin⁡25⁢2⁢5⁢ln⁡135+310⁢sin⁡110⁢19⁢2⁢5⁢ln⁡2910+310⁢sin⁡110⁢13⁢2⁢5⁢ln⁡2310+320⁢sin⁡ln⁡2
Apply the ApproximateInt command with output set to value, and the right endpoint a float
ApproximateIntF,x=1..4.0,partition=10,method=trapezoid,output=value = 5.067162904
Table 6.7.1(a) Using the ApproximateInt command to implement the Trapezoid rule in Maple
Maple's implementation of the Trapezoid rule differs from the statement in Table 6.7.1. Using the ApproximateInt command, it can be seen that Maple evaluates the integrand at the n−1 interior nodes twice, rather than (as per Table 6.7.1) evaluating once and multiplying by 2.
ApproximateIntfx,x=a..b,partition=n,method=trapezoid,output=sum
12⁢b−a⁢∑i=0n−1f⁡a+i⁢b−an+f⁡a+i+1⁢b−ann
The Trapezoid rule is implemented from first principles in Table 6.7.1(b). The integrand is defined as the function fx; and the stepsize, as h. The endpoints are written as floats so that the evaluation of the sum is numeric, and not symbolic.
Context Panel: Assign Function
fx=F→assign as functionf
Context Panel: Assign Name
h=4−110→assign
Context Panel: Evaluate and Display Inline
h2f1.+f4.+2∑k=19f1.+k h = 5.067162905
Table 6.7.1(b) Implementing the Trapezoid rule from first principles
<< Previous Section 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