Anda di halaman 1dari 4

Assignment 4 (Be sure to observe the rules about handing in homework)

1. a. (15 points) Use multiple application of trapezoidal formula to evaluate


with O(h2) error. Choose n=1, 2, 4, and 8. Find the true integral value and then calculate the best t (minimum true percent error). b. (15 points) Using the Romberg integration (Richardsons extrapolation), calculate the integral value with O(h8) error. Calculate the best t (minimum true percent error) for each of O(h4), O(h6), and O(h8) extrapolations. Write clearly the formulas used in these extrapolations. Solution a. Analytical solution:
3 0

3 0

xe x dx

I = xe x dx = xe x e x
Multiple Application of Trapezoidal Rule Formula:
N 1 2 4 8 1 Best t = 2.25% 90.385 55.276 44.839 42.098

3 0

=41 .17 1

I=

n 1 ba f ( x0 ) + f ( xn ) + 2 f ( xi ) 2n i =1

b. Formulas used: I I m I l 3 3 O(h8)


1 N 1 2 4 8 Best t 90.385 55.276 44.839 42.098 2 0.031% 43.573 41.360 41.184

O(h4)

16 1 I m Il 15 15

O(h6)

64 1 Im Il 63 63

3 0.002% 41.213 41.172

4 0.0004% 41.171

2.
a. (20 points) Employ Lagrange Interpolation (Slide #10 in CHAP-23e.ppt) to determine the first derivative of y = 2 x 4 6 x 3 12 x 8 at x = 0 based on values at x0 = 0.5 , x1 = 1 , and x2 = 2 . Calculate the true value and the true (%) relative error. b. (15 points) Calculate the first derivative at x = 0 using a centered difference approximation (O(h2) error) based on h = 1 and equally spaced data. Calculate true (%) relative error. Compare the results obtained in part (a) and (b) and try to explain why one is better than the other.

Solution a. The true value: f ' (0) = 8(0) 3 18(0) 2 12 = 12 Given the data: x0 = 0.5 f(x0) = 1.125 x1 = 1 f(x1) = 24 x2 = 2 f(x2) = 48 Using Lagrange interpolation, we compute the derivative as:
f ' (0) = 1.125 2(0) 1 2 2(0) (0.5) 2 2(0) (0.5) 1 + ( 24) + ( 48) ( 0.5 1)(0.5 2) (1 ( 0.5))(1 2) ( 2 ( 0.5))(2 1) = 0.9 24 + 9.6 = 13.5

True percent relative error = | (-12+13.5)/-12|*100 = 12.5% b. Centered difference: f ' (0) = f ( x = 1) f ( x = 1) 24 12 = = 18 1 (1) 1 (1)

True percent relative error = | (-12+18)/-12|*100 = 50%

Since the original function is a 4th order polynomial, the best error (zero) is obtained if we interpolate the function with a 4th order polynomial and take the derivative of it. In other words, the higher the order of the interpolations, the smaller the error. Even though centered difference formula has O(h2) error rate, we can safely assume that it uses a 1st order approximation. Therefore, 2nd order Lagrange achieves a better error rate. Another reason for poor performance of centered formula is the high step size (h=1).

3.
a. (25 points) Use Heuns method with h = 0.5 to solve the following initial-value dy = yx 2 1.1y where y(0) problem numerically over the interval from x = 0 to 2: dx = 1. Iterate the corrector to s = 1%. b. (10 points) Plot your results.
(Note: since each step may involve several iterations, use of Excel or MATLAB is recommended)

Solution: a. For Heuns method, the value of the slope at x = 0 can be computed as which can 1.1 be used to compute the value of y at the end of the interval as
y (0.5) = 1 + (0 1.1(1))0.5 = 0.45

The slope at the end of the interval can be computed as


y ' (0.5) = 0.45(0.5) 2 1.1(0.45) = 0.3825

which can be averaged with the initial slope to predict


y (0.5) = 1 + 1.1 0.3825 0.5 = 0.629375 2

This formula can then be iterated to yield

j
0 1 2 3 4

yi j
0.45 0.6294 0.5913 0.5994 0.5976

a
28.5% 6.45% 1.35% 0.288%

The remaining steps can be implemented with the result

xi 0 0.5 1 1.5 2

yi 1.0000 0.5976 0.4591 0.6269 2.8784

b. The results along with the analytical solution are displayed below:
3 2 1 0 0 1 2

Anda mungkin juga menyukai