0% found this document useful (0 votes)
173 views3 pages

L015 Trapezoidal Rule and Simpson's Rule

The document compares the Trapezoidal Rule and Simpson's Rule for numerical integration. Both rules approximate definite integrals by partitioning the interval into subintervals and summing the function values at specific points. The Trapezoidal Rule is less accurate than Simpson's Rule, which can give the exact answer for integrals of polynomials of degree three or less. The document provides examples of using both rules on a calculator to approximate definite integrals and compares the required number of subintervals for each to achieve a given accuracy.

Uploaded by

Julián Kaihara
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
173 views3 pages

L015 Trapezoidal Rule and Simpson's Rule

The document compares the Trapezoidal Rule and Simpson's Rule for numerical integration. Both rules approximate definite integrals by partitioning the interval into subintervals and summing the function values at specific points. The Trapezoidal Rule is less accurate than Simpson's Rule, which can give the exact answer for integrals of polynomials of degree three or less. The document provides examples of using both rules on a calculator to approximate definite integrals and compares the required number of subintervals for each to achieve a given accuracy.

Uploaded by

Julián Kaihara
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Return to List of Lessons Calculator Lessons 15 Trapezoidal Rule and Simpsons Rule Trapezoidal Rule The trapezoidal rule

can be expressed as

Where h =

f ( x)dx

n 1 h f ( a ) + f ( b ) + 2 f (a + kh) 2 k =1

ba and n is the number of intervals into which we have partitioned [a, b]. n To prepare for the trapezoidal rule create a directory called TRAP and get into it. In the
equation writer create the expression

F ( A + kH )
k =1

N 1

and store it in a variable called SM.

Now put 5 zeros on the stack and save them in variables called F, B, A, N, and H. Your soft key menus should now be F1-H, F2-N, F3-A, F4-B, F5-F, and F6-SM. Finally, to make sure everything works the way we want it to, we must make sure the calculator is set to approximation mode and that system flag 3 is checked (Function num). We will test our trapezoidal rule with the integral exercise we will set our numeric display to FIX 2. Define the function F(X) = 3X2, save the value 4 in B, 1 in A, and 8 in N. The following sequence will compute the approximation by the trapezoidal rule: (1) F4-B F3-A - F2-N LS F1-H F6-SM EVAL 2 F4-B F5-F + F3-A F5-F + F1-H 2
4

3 x 2 dx with n = 8, and for this

You should now see the answer 63.21 on the stack. We know from the fundamental theorem of calculus that

3 x 2 dx = 63, so our trapezoidal rule approximation leaves a bit

to be desired. Try it again with n = 16. This time the answer is 63.05, which is a bit better. Repeating with n = 32 gives the integral as 63.01, and with n = 64 gives it as 63.00. It is not the purpose of these lessons to teach programming, but in this case a program to do the above computations is so easy and so useful that it would be a shame not to do it. Press RS (the + sign key) then repeat the sequence (1) above and press ENTER. Now store this in a variable called TRAPR. Now store 8 in N and press TRAPR, and see 63.21 for an answer. Change N to 16 and press TRAPR to get the answer 63.05, etc. There is a very important procedure that one learns in a numerical analysis course that requires several applications of the trapezoidal rule with each application having n

twice as big as the previous one. To double the value on N, one could press N 2 LS N. A program to do this would be N 2 LS N . Enter this program and save it as DBLR. Set N = 8 again and press TRAPR to get the answer 63.21. Now press DBLR followed by TRAPR to get 63.05, etc. NOTE: An equally easy program could be written to execute the algorithm given in Lesson 11 for Newtons Method. Readers who are interested in becoming proficient as program the calculator should start with An Introduction to Programming HP Graphing Calculators.
Simpsons Rule

Simpsons rule can be expressed as


n n 1 1 2 2 h f ( x)dx f (a ) + f (b) + 4 f (a + (2k + 1)h) + 2 f (a + 2kh) 3 k =0 k =1

where h =

ba and n, the number of subintervals into which [a, b] has been partitioned, n is even. To prepare for the Simpsons rule press get into the directory immediately above TRAP then create a directory called SIMP and get into it. In the equation writer create the expression expression
N 1 2 k =0

F ( A + 2kH ) and store it in a variable called SM2.


k =1

N 1 2

Next create the

F ( A + (2k + 1) H ) and store it as SM4.

Now put 5 zeros on the stack and

save them in variables called F, B, A, N, and H. Your soft key menus should now be F1H, F2-N, F3-A, F4-B, F5-F, and F6-SM4. After pressing NXT, the first menu key will be F1-SM2. Finally, to make sure everything works the way we want it to, we must make sure the calculator is set to approximation mode and that system flag 3 is checked (Function num). We will now use Simpsons rule to approximate the same integral we used above for the trapezoidal rule again with n = 8 and the display set to FIX 2. Define the function F(X) = 3X2, save the value 4 in B, 1 in A, and 8 in N. The following sequence will compute the approximation by Simpsons rule: (2) F4-B F3-A - F2-N LS F1-H NXT F1-SM2 EVAL 2 NXT F6-SM4 EVAL 4 + F4-B F5-F + F3-A F5-F + F1-H 3

We should now see the answer 63.00 on the stack. This would lead us to conclude that Simpsons rule is significantly more accurate than the trapezoidal rule. That is a correct conclusion, but for the wrong reason. It turns out that Simpsons rule will give the exact answer for the definite integral of any polynomial of degree three or less. We will return to the relative accuracy of the two approximation methods in a later. First, the reader

may wish to make a program called SIMPR from the algorithm (2) similar to TRAPR described above. One may also wish to copy DBLR from directory TRAP to SIMP, but this is not particularly recommended. Simpsons rule is not typically used the way the trapezoidal rule is used so DBLR will not be as useful in SIMP as it is in TRAP. Now, to get more convincing evidence of the increased accuracy of Simpsons rule, we will consider the integral
x e dx
2

with the display mode set to FIX 3. First use


X2

the definite integral function of the calculator to find the value of this integral to three decimal places. Now, in both TRAP and SIMP define the function F ( X ) = e then set B = 1 and A = 0. In each of TRAP and SIMP, try to find the smallest value of N that will give the same answer as the definite integral command gave to three decimal places. HINT: For the trapezoidal rule N will have to be in the 20s, for Simpsons rule it will be less than 10. Return to List of Lessons

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy