Starting from:
$35

$29

HW10 (10.1 – 10.4) Solution

10.1 Fundamentals: Integra3on Error

4 pts Pretend I did a Taylor Series analysis for both of the following two quadrature methods, and came up with the given error expressions. That is, each expression indicates how the exact integral Iexact is related to the quadrature method Iapprox over just ONE panel (not the whole [a,b] range).


Iexact
= Iapprox


h2 f '''(x2 )

h3 f ''''(x2 )


h4 f '''''
(x2 )

(i) Method 1:


+




+



+





−!






















one panel
one panel
2



12


60





Iexact
= Iapprox


h4 f '(x2 )


h5 f ''(x2 )

h6 f '''(x2 )

(ii) Method 2:















−!








81

263




For each method …
one panel
one panel
9


































(a)  Apply the definiHon for precision of a method to determine the precision of the method.

(b)  Explain what is the error order with h for the method over the en#re integraHon range

(generally consisHng of many intervals & panels).















Remember: you can’t just write down the precision or order; you have to jus3fy it mathemaHcally.
10.2 Computa3onal Integra3on: Simpson’s method (By-Hand)








4 pts
Remember the “Failure Rate” integral in HW9, for which you calculated the integral by-hand using

the midpoint and trapezoid methods? You evaluated:



























F (70) = ∫070 f (x) dx where
f ( x) = λ e −λx

for λ = 0.01









(a) Repeat the integraHon by-hand using the same n = 8 equally-spaced nodes, except this Hme using the Simpson’s method. (Hint: for this value of n do you need a combo of 1/3- and 3/8-methods??) And (I know this is a pain), because the Simpson’s method is so accurate, you have to do all calculaHons accurate to 8 decimals (predy much all the decimals on your calculator).

(b) Given that the integral has the exact (analyHc) answer F(t) = 1 – e–λt , calculate the percent (rela3ve) error in calculaHng F(70) for the Simpson’s method, and compare that to the errors in HW9 from the Midpoint and Trapezoid rules.

Show all your work on paper, especially the values you’re using for all the nodes, and do each calculaHon accurate to at least 8 decimals.

10.3
Applica3on: MATLAB’s Built-in “integral” func3on
X = ∫2100
(10

t )ln(3t)
dt
2 pts
Use the built-in funcHon integral to solve the following integral:








t
3
+10


(I have no idea what it might mean, it just looks nasty.)







Once you get it working, write out ON PAPER:

1.  Exactly how you called integral (i.e. your command that starts with: X = integral …)

2.  The funcHon you had to write for the “integrand” that integral has to call.

3.  The output value for X (rounded to 4 decimals).

Don’t submit anything to Carmen – I should be able to see exactly everything you did on paper.

10.4 Computa3onal Integra3on: MATLAB (Simpson’s method, and Built-in “integral”)

5 pts
Go back to the MATLAB code you wrote in 9.4 to solve for the failure rate F(70), but now you’re

going to add procedures to: use the Simpson’s method, and use the built-in “integral” funcHon.



Start with your working script from HW9.4 (or “steal” my posted code if yours didn’t work

perfectly), and rename it HW10_4.m. Now add the following funcHonality:

a) 
Create a NEW funcHon: Isimp = Simpson(a,b,n) that outputs the integral of Fun(x)


over [a,b] using n nodes with the Simpsons combined -1/3 and -3/8 rules. Make your life easier


by assuming the number of nodes n will always be even.

b) 






In addiHon to calling the Midpoint and Trapezoid funcHons, have your HW10_4 script call


the new Simpson funcHon to evaluate F. Change your script so that the number of nodes


over which you run these three funcHons is now: n = [2 8 50 500 5000 50000].


(I made them all even now, to be consistent with your assumpDon for the Simpson method.)

c) 
Uses the exact value F(70) = 1 – e(–0.01)(70) to calculate the percent (relaHve) error in the


approximaHons of F from ALL three of your own methods (midpoint, trapezoid, Simpsons) for


all the nodes n above.

d) 
Plots the absolute value of the % error for all three methods as a funcHon of interval size, h.







Please make each line different, so the midpoint method shows circles connected by black


lines, the Trapezoid method shows triangles connected by green lines, and the Simpson’s


method shows squares connected by blue lines. Be sure to use the loglog ploqng command to


allow details to be seen even when the error gets very small. So, use something like this plot


command:

loglog(h,PctErrMid,'ok-', h,PctErrTrap,'^g--', h,PctErrSimp,'sb-.')


Save this plot in pdf form as HW10_4.pdf

e) 
Uses the built-in funcHon integral to solve for F(70) directly (using your Fun.m for f(x)).


That’s it!


Please submit the following things online in the Carmen HW10 locaHon:

•  Your new funcHon Simpson.m , new script HW10_4.m , and plot HW10_4.pdf .

•  Answers to the following quesHons in the comment secHon:

1.  From the integral command in (e): What is the approximate value of F(70) to 8 decimals? What is the percent error in this result?

2.  What is the (approximate) slope of the Simpsons line from your log-log plot? (That should be consistent with the “order” of the method, right?)

3.  From your plot, esHmate how many nodes (n) it would take for your trapezoid method to give the same error for this problem as using the built-in integral command.

More products