Docsity

Homework 1 Practice - Numerical Methods | AME 60614, Assignments of Aerospace Engineering

Toggle sidebar
bg1
AME 521: Numerical Methods
Fall 2004, Homework 1
J. M. Powers
prepared by Weiming Li
Due: Friday, 17 September 2004
1. Apply the Lagrange, Hermite and cubic spline methods to interpolate f(1.05) from
the following data. What parts of the data does each method actually use? How do
the results compare?
x 0.90 1.00 1.10 1.20
f(x) = sin x0.78333 0.84147 0.89121 0.93204
f0(x) = cos x0.62161 0.54030 0.45360 0.36236
2. Given a function f(x) on [a, b] and the points a=x0< x1<· · · < xN=b, a useful
quadratic interpolating spline can be constructed; it satisfies the following conditions:
(i) s(x0) = f(x0),
sxi+xi+1
2=fxi+xi+1
2,for each i= 0,1,...,N −1,
s(xN) = f(xN);
(ii) s∈C1[a, b];
(iii) for each i= 0,1,...,N −1, hi=xi+1 −xi,
s(x) = ai+bi(x−xi) + ci(x−xi)2, xi≤x≤xi+1.
(a) Show that conditions (i),(ii),(iii) lead to the equations:
a0=f(x0),
ai+1
2bihi+1
4cih2
i=fxi+hi
2,for each i= 0,1,...,N −1,
aN−1+bN−1hN−1+cN−1h2
N−1=f(xN),
ai=ai−1+bi−1hi−1+ci−1h2
i−1,for each i= 1,...,N −1,
bi=bi−1+ 2ci−1hi−1,for each i= 1,...,N −1.
(b) Show that the results of part (a) lead to the equations:
3
8b0h0+1
8b1h0=fx0+h0
2−f(x0),
1
8bi−1hi−1+3
8bi(hi+hi−1) + 1
8bi+1hi=fxi+hi
2−fxi−1+hi−1
2
for each i= 1,...,N −2,
1
8bN−2hN−2+bN−13
8hN−2+1
3hN−1=4
3fxN−1+hN−1
2−
fxN−2+hN−2
2−1
3f(xN).
(c) Devise an algorithm to find b0,...,bN−1.
(d) Given b0,...,bN−1, derive formulas for a0,...,aN−1, c0, . . . , cN−1.
(e) Let f(x) = ex, x0= 0, x1= 0.2, x2= 0.6, x3= 0.9. Find the quadratic interpo-
lating spline s(x) for f(x), and compute s(0.5). Is s(0.5) a good approximation
to f(0.5) ?
1
pf2

Partial preview of the text

Download Homework 1 Practice - Numerical Methods | AME 60614 and more Assignments Aerospace Engineering in PDF only on Docsity!

AME 521: Numerical Methods

Fall 2004, Homework 1

J. M. Powers prepared by Weiming Li Due: Friday, 17 September 2004

  1. Apply the Lagrange, Hermite and cubic spline methods to interpolate f (1.05) from the following data. What parts of the data does each method actually use? How do the results compare? x 0.90 1.00 1.10 1. f (x) = sin x 0.78333 0.84147 0.89121 0. f ′ (x) = cos x 0.62161 0.54030 0.45360 0.
  2. Given a function f (x) on [a, b] and the points a = x 0 < x 1 < · · · < xN = b, a useful quadratic interpolating spline can be constructed; it satisfies the following conditions:

(i) s (x 0 ) = f (x 0 ) , s

(xi+xi+ 2

= f

(xi+xi+ 2

, for each i = 0, 1 ,... , N − 1 , s (xN ) = f (xN ); (ii) s ∈ C^1 [a, b]; (iii) for each i = 0, 1 ,... , N − 1 , hi = xi+1 − xi, s (x) = ai + bi(x − xi) + ci(x − xi)^2 , xi ≤ x ≤ xi+1.

(a) Show that conditions (i),(ii),(iii) lead to the equations: a 0 = f (x 0 ) , ai + 12 bihi + 14 cih^2 i = f

xi + h 2 i

, for each i = 0, 1 ,... , N − 1 , aN − 1 + bN − 1 hN − 1 + cN − 1 h^2 N − 1 = f (xN ) , ai = ai− 1 + bi− 1 hi− 1 + ci− 1 h^2 i− 1 , for each i = 1,... , N − 1 , bi = bi− 1 + 2ci− 1 hi− 1 , for each i = 1,... , N − 1. (b) Show that the results of part (a) lead to the equations: 3 8 b^0 h^0 +^

1 8 b^1 h^0 =^ f^

x 0 + h 20

− f (x 0 ) , 1 8 bi−^1 hi−^1 +^

3 8 bi^ (hi^ +^ hi−^1 ) +^

1 8 bi+1hi^ =^ f^

xi + h 2 i

− f

xi− 1 + hi 2 −^1

for each i = 1,... , N − 2 , 1 8 bN^ −^2 hN^ −^2 +^ bN^ −^1

8 hN^ −^2 +^

1 3 hN^ −^1

= 43 f

xN − 1 + hN 2 −^1

f

xN − 2 + hN 2 −^2

− 13 f (xN ). (c) Devise an algorithm to find b 0 ,... , bN − 1. (d) Given b 0 ,... , bN − 1 , derive formulas for a 0 ,... , aN − 1 , c 0 ,... , cN − 1. (e) Let f (x) = ex, x 0 = 0, x 1 = 0. 2 , x 2 = 0. 6 , x 3 = 0.9. Find the quadratic interpo- lating spline s (x) for f (x), and compute s (0.5). Is s (0.5) a good approximation to f (0.5)?

  1. Use three different methods, the trapezoidal, Simpson’s rule and the trapezoidal with end correction, to numerically integrate

f (x) =

(x − 1)^2 + 0. 002

(x − 0 .2)^2 + 0. 005

− 5; 0 ≤ x ≤ 1.

Get the exact integration. Plot the error associated with each as a function of the discretization size, N, on a log-log scale. Also, investigate the machine round-off error by increasing N to a very large value.

  1. By the transformation x = a + (^) Nb− +1a t, a family of the Newton-Cotes quadrature of the “open” type with equidistant abscissae can be established as ∫ (^) b

a

f (x)dx = (b − a)

∑^ N

j=

Hj f

a + j

b − a N + 1

Show that their weight coefficients Hj are defined by

Hj = (−1)N^ −j^

N

N + 1

N − 1

j − 1

) ∫ N +

0

t − 1 N

dt t − j

Evaluate these coefficients for N = 2,... , 6 points and prove that they satisfy the symmetry requirement Hj = HN −j+1. [Useful formulas:

(t− 1 N

= (^) N !((tt−− 1 1)!−N )! ,

(N − 1

j− 1

= (^) (j−(1)!(N^ −N1)! −j)! ]

  1. (a) Use Laguerre-Gauss quadrature to approximate the integral

∫ (^) ∞

0

e−^10 x^ sin xdx and

0

e−x 1 + e−^2 x^

dx

using N = 2, 3 , 4 , 5 points and compare the results with the true value. (b) Use Hermite-Gauss quadrature to approximate the integral ∫ (^) +∞

−∞

|x|e−^3 x

2 dx and

−∞

|x|e−x

2 cos xdx

using N = 2, 3 , 4 , 5 points and compare the results with the true value.