Sie sind auf Seite 1von 1

Numerical Engineering Analysis

MAE 5093

Computer Project # 1 Interpolation, Differentiation and Integration


Due date: Sep 29, Thursday, class time.
1. [25pt] Write a computer program for Lagrange interpolation function of the function
f (x) = cos(10x) sin(x)

(1)

in the interval 1 x 1. Use equally distributed grid of 9, 17, 33, 65 grid points (e.g., 9 grid points:
n=8, you can construct an 8th order Lagrange polynomial by using 9 points). For each data set (i.e., n=8,
16, 32, 64):
i. Present graphs of f (x) and its Lagrange polynomial approximation p(x).
ii. Evaluate the derivative of your Lagrange Polynomial approximation p0 (x) and compare your results
to the exact derivative of the function f 0 (x) and plot your results.
iii. Discuss your observation about the behavior of the approximation and its derivative. Make comparison
between derivatives obtained using the Lagrange interpolation functions and the second order centereddifference approximation (given by Eq.(2.7) as fj0 = (fj+1 fj1 )/2h).
2. [25pt] Write a computer program for the tridiagonal fourth-order Pade scheme (i.e., see Eq.(2.18) in
Chapter 2).
i. Compute the derivative of f (x) given by Eq.(1) by using the same set of grid points (n=8, 16, 32, and
64), and present sample plots for the derivatives.
ii. Tabulate percent error  at x = 0.5 for these computations and prepare log-log plot for the step size
h and the percent error  (e.g., like Figure 2.1).


exact solution numerical solution


 = 100

exact solution

(2)

iii. Make comparisons between derivatives obtained using the second-order central differences and Lagrange interpolations in Problem 1.
3. [25pt] Write a computer program for the tridiagonal fourth-order Pade scheme to compute the secondorder derivatives (i.e., see Eq.(2.19) in Chapter 2 for the interior points)
1 00
10 00
1 00
1
fi1 + fi + fi+1 = 2 (fi1 2fi + fi+1 )
(3)
12
12
12
h
i. Show that boundary points can be computed by the following third-order formulas
1
00
00
f0 + 11f1 =
(13f0 27f1 + 15f2 f3 )
(4)
h2
1
00
00
11fn1 + fn =
(13fn 27fn1 + 15fn2 fn3 )
(5)
h2
ii. Compute the derivative of f (x) given by Eq.(1) by using the same set of grid points (n=8, 16, 32, and
64), and present sample plots for the second derivatives and compare with exact solution f 00 (x).
iii. Using the computer program of Problem 2, compute second-order derivative by calling the Pade scheme
for the first derivative in two times. Compare your results with the direct second-order derivative
computations performed by using Eqs.(3)-(5)].
4. [25pt] Write a computer program for the numerical integration of the function given by f (x) = ex .
Compute the integral
Z
1

I=

ex dx

by using (i) trapezoidal rule, (ii) Simpsons rule and (iii) trapezoidal rule with end-correction. Tabulate
numerical integration results and absolute errors, for using equally distributed intervals of n=8, 16, 32, and
64 and discuss your observations. Finally, compute the integral by using Gauss-Legendre quadrature by
using n = 5 points and compare with the other methods (trapezoidal, Simpson, End-Correction) using n=5
intervals.
page 1 of 1

Das könnte Ihnen auch gefallen