Numerical Methods

profileookt2c
ae_me330_homework6_sp13.pdf

AE/ME 330 Spring 2013, Homework VI, Due Friday, April 19

1. Use 3rd and 6th degree Lagrange interpolation polynomials to approxi- mate the function

f(x) = Sin (ex − 2) using equally spaced data on the interval 0 ≤ x ≤ 2. For each case, plot the exact function f(x), approximation to the function by the Lagrange polynomials (fappx(x)), and the error (f(x) −fappx(x)) on the given interval. Give the error values at x=0.1, 0.9, 1.5, and 1.9.

2. Write a computer routine to approximate the function given in Ques- tion 1 using a natural cubic spline with eleven equally spaced data points on the interval 0 ≤ x ≤ 2. Plot the function, the cubic spline approximation (fappx(x)), and the error (f(x) − fappx(x)) on the given interval. Give the error values at x=0.1, 0.9, 1.5, and 1.9.

3. Derive the following central finite difference formula( df

dx

) i

= 1

12h (−fi+2 + 8fi+1 − 8fi−1 + fi−2)

to approximate the first derivative of the function at xi. Note that fi+2 = f(xi + 2h), fi+1 = f(xi + h), fi−1 = f(xi − h), and fi−2 = f(xi − 2h). Show that the order of this approximation is O(h4). (i) Use the above finite difference formula to calculate the first deriva- tive of the function given in Question 1 at xi = 0.9 with h = 10

−k

for k = 1, 2, 3....., 10. Calculate the absolute error for each case using the exact value of the derivative at the given point. Comment on the results you obtain.

(ii) Now calculate the first derivative of the function given in Question 1 at xi = 0.9 with h = 10

−k for k = 1, 2, 3....., 10 using a first-order accurate forward difference approximation evaluated with fi+1 and fi. Calculate the absolute error for each case using the exact value of the derivative at the given point. Comment on the results you obtain.

(Hint: You may look at absolute error vs. h in a log-log plot for part (i) and part (ii), which may help you to explain the results.)

(OVER)

1

h/2 h

x0 x1 x2

4. Using the non-uniform mesh spacing shown in the figure, derive

(a) a second order accurate one-sided finite difference formula to ap- proximate (df/dx) at x = x0.

(b) a first order accurate one-sided finite difference formula to approx- imate (d2f/dx2) at x = x0.

Show each step clearly in your derivations and give the leading term of the truncation error for each approximation.

2