Answers to Exam 2 Spring 05:
Answers to Exam 2 Fall 03:
Answers to Exam 2 Spring 2002:
You may use a formula sheet: postscript version , and version in pdf format .
n --- p(x) = > l (x) f --- i i i=0with
n x - x --- j l (x) = | | ----- i j=0 x - x j/=i i jsatisfies
p(x ) = f for i = 0,1,..,n. i i
Answer:
Observe that l_i(x_j) = 0 for j /= i, because there is one factor in the numerator that is zero. Furthermore, we see that l_i(x_i) = 1 because numerator and denominator are equal to each other. These observations imply p(x_i) = f_i, i = 0,1,2,..,n.
Answers:
0 1 -3 - 1 ------- = -4 1 - 0 -3-(-4) 1 -3 ------- = 1 -5 - 1 2-1 ------- = -3 1-1 2 - 0 ----- = 0 -2-(-4) 3-2 2 -5 ------- = 1 -5 - 1 3-1 ------- = -2 3 - 0 3 -5 The Newton form is f_0 + f_01*(x-x[0]) + f_012*(x-x[0])*(x-x[1]) + f_0123*(x-x[0])*(x-x[1])*(x-x[2]) = 1 + (-4)*(x-0) + 1*(x-0)*(x-1) + 0*(x-0)*(x-1)*(x-2) = 1 - 4*x + x*(x-1)
0 1 p 01 1 -3 p p 012 12 p 2 -5 p 0123 p 123 23 3 -5with
(1/2 - 1)*1 - (1/2 - 0)*(-3) p = ------------------------------ = -1 01 0 - 1 (1/2 - 2)*(-3) - (1/2 - 1)*(-5) p = --------------------------------- = -2 12 1 - 2 (1/2 - 3)*(-5) - (1/2 - 2)*(-5) p = --------------------------------- = -5 23 2 - 3 (1/2 - 2)*(-1) - (1/2 - 0)*(-2) p = --------------------------------- = -5/4 012 0 - 2 (1/2 - 3)*(-2) - (1/2 - 1)*(-5) p = --------------------------------- = -5/4 123 1 - 3 (1/2 - 3)*(-5/4) - (1/2 - 0)*(-5/4) p = ------------------------------------- = -5/4 0123 0 - 3Thus p(0.5) = -5/4. Notice that, since we are interpolating a second degree polynomial with four points, we already see the final result appearing twice in the next to last column.
1 = a*0 + b -3 = a*1 + b -5 = a*2 + b -5 = a*3 + b or in matrix notation: [ 0 1 ] [ 1 ] [ 1 1 ] [ a ] = [ -3 ] [ 2 1 ] [ b ] [ -5 ] [ 3 1 ] [ -5 ] X [ a ] = f [ b ] To solve the system in the least squares sense, we set up the normal equations: T X *X = [ 0 1 2 3 ] [ 0 1 ] = [ 14 6 ] [ 1 1 1 1 ] [ 1 1 ] [ 6 4 ] [ 2 1 ] [ 3 1 ] T X *f = [ 0 1 2 3 ] [ 1 ] = [ -28 ] [ 1 1 1 1 ] [ -3 ] [ -12 ] [ -5 ] [ -5 ] T T The solution to the system X *X [ a ] = X *f [ b ] is a = -2 and b = 0.
1 3 2 5 17 7 62 9 10 tan(x) = x + --- x + --- x + ---- x + ----- x + O(x ) 3 15 315 2835Use this Maclaurin expansion to construct a Padé approximation for tan(x) as a quotient of two quadrics.
Answer:
( 2 1 3 4 ) ( 2 ) ( 2 ) ( 0 + x + 0 x + --- x + 0 x ) * ( 1 + b x + b x ) - ( a + a x + a x ) ( 3 ) ( 1 2 ) ( 0 1 2 ) expanding product: 2 3 x + b x + b x 1 2 1 3 1 4 1 5 + --- x + --- b x + --- b x 3 3 1 3 2 setting coefficients to consecutive powers of x to zero: 0 x : 0 - a = 0 0 1 x : 1 - a = 0 1 2 x : b - a = 0 1 2 3 1 x : b + --- = 0 2 3 4 1 x : --- b = 0 3 1 we solve this system: 1 b = 0 b = - --- a = 0 a = 1 a = 0 1 2 3 0 1 2 Thus our approximation is x --------------- 1 2 1 - --- x 3
2 x + 3 x - 1 r(x) = -------------- 2 x - 1
Answers :
2 | 2 x + 3 x - 1 | x - 1 2 |---------- - ( x - 1) 1 ----------------- 3 x 2 2 x + 3 x - 1 = 1 ( x - 1 ) + 3 x 3 x 3 r(x) = 1 + ---------- = 1 + --------- 2 2 x - 1 x - 1 -------- x 2 | x - 1 | x 2 |------- - x x --------- - 1 2 x - 1 = x x - 1 3 r(x) = 1 + ----------- 1 x - --- x
Compared to the cost of evaluating the Horner form of numerator and denominator:
2 x + 3 x - 1 (x + 3)*x - 1 -------------- = --------------- 2 (x + 0)*x - 1 x - 1we see that the evaluation takes two multiplications, one division, two additions, and two subtractions. Even if we disregard the +0, the continued-fraction representation is more efficient to evaluate than the quotient of Horner forms.
Answers:
f(x+h) = f(x) + h*f'(x) + h^2*f''(x) + ... f(x+h) - f(x) --------------- = f'(x) + h*f''(x) + ... h
f(x+h) - f(x-h) delta f(x,h) = ----------------- is an even function of h 2 h f(x-h) - f(x+h) delta f(x,-h) = ----------------- = delta f(x,h) - 2 hBecause delta f(x,h) is an even function of h, only even powers of h occur if we expand delta f(x,h) in powers of h. Thus the power series start at h^2, and delta f(x,h) is a second-order approximation for the derivative of f at x.
Answers:
f(x+h) - f(x) Delta f(x,h) = --------------- h f(x+2h) - f(x+h) f(x+h) - f(x) ------------------ - --------------- 2 h h Delta f(x,h) = -------------------------------------- h f(x+2h) - 2 f(x+h) + f(x) = --------------------------- 2 h 3 f(x+3h) - f(x+2h) f(x+2h) - f(x+h) f(x+h) - f(x) Delta f(x,h) = ------------------- - 2 ------------------ + --------------- 3 3 3 h h h f(x+3h) - 3 f(x+2h) + 3 f(x+h) - f(x) = --------------------------------------- 3 h
f(x+h) - f(x-h) delta f(x,h) = ----------------- 2 h f(x+2h) - f(x) f(x) - f(x-2h) ---------------- - ---------------- 2 2 h 2 h delta f(x,h) = ------------------------------------- 2 h f(x+2h) - 2 f(x) + f(x-2h) = ---------------------------- 2 4 h 3 f(x+3h) - f(x+h) f(x+h) - f(x-h) f(x-h) - f(x-3h) delta f(x,h) = ------------------ - 2 ----------------- + ------------------ 3 3 3 8 h 8 h 8 h f(x+3h) - 3 f(x+h) + 3 f(x-h) - f(x-3h) = ----------------------------------------- 3 8 h
Write pseudo-code for Richardson extrapolation to compute a table with n rows using one of the formulas you derived above.
Answers:
2 Delta f(x,h) = f'(x) + C h + C h + ... 1 2 2 2 Delta f(x,rh) = f'(x) + C rh + C r h + ... 1 2 for some constant C and C . 1 2 To eliminate the first-order term, we multiply the first formula by r and subtract from it the second formula: Delta f(x,h)*r - Delta f(x,rh) 2 -------------------------------- = f'(x) + C' h + ... r - 1 2 for some constant C'. 2 To obtain higher-order approximations by extrapolation, we need Delta f(x,r^i h) and use r^i instead of r in the formula to obtain an approximation of order i+1.
Pseudo-code for the algorithm is:
Input: D[i][0] = Delta f(x,r^i*h), for i=0,1,..,n. Output: D[i][j] contains extrapolated values, j <= i. for i from 1 to n do for j from 1 to i do i D[i-1][j-1]*r - D[i][j-1] D[i][j] = ---------------------------- i r - 1
2 4 delta f(x,h) = f'(x) + C h + C h + ... 1 2 2 2 4 4 delta f(x,rh) = f'(x) + C r h + C r h + ... 1 2 for some constant C and C . 1 2 To eliminate the first-order term, we multiply the first formula by r^2 and subtract from it the second formula: 2 delta f(x,h)*r - delta f(x,rh) 4 -------------------------------- = f'(x) + C' h + ... 2 2 r - 1 for some constant C'. 2 To obtain higher-order approximations by extrapolation, we need delta f(x,r^(2*i) h) and use r^(2*i) instead of r^2 in the formula to obtain an approximation of order 2*(i+1).
Pseudo-code for the algorithm is:
Input: d[i][0] = delta f(x,r^i*h), for i=0,1,..,n. Output: d[i][j] contains extrapolated values, j <= i. for i from 1 to n do for j from 1 to i do 2*i d[i-1][j-1]*r - d[i][j-1] d[i][j] = ------------------------------ 2*i r - 1
1 / x I = | e dx / 0Write your answers to the questions below with six decimal places.
Answers:
( 1 ) 1 ( 0 1 ) 1 ( 1/4 1/2 1/4 ) T(h) = T(---) = ---( e + e ) + ---( e + e + e ) ( 4 ) 8 ( ) 4 ( ) = 1.72722
First we compute T(1/8) and T(1/16):
( 1 ) 1 ( 0 1 ) 1 ( 1/8 1/4 3/8 1/2 5/8 3/4 7/8 ) T(---) = ----( e + e ) + ---( e + e + e + e + e + e + e ) ( 8 ) 16 ( ) 8 ( ) 1 ( 1 ) 1 ( 1/8 3/8 5/8 7/8 ) = --- T(---) + ---( e + e + e + e ) 2 ( 8 ) 8 ( ) = 1.72052The relation between two consecutive applications of the composite trapezoidal rule is especially handy as we get to the next stage:
( 1 ) 1 ( 1 ) 1 ( 1/16 3/16 5/16 7/16 9/16 T(----) = --- T(---) + ----( e + e + e + e + e ( 16 ) 2 ( 8 ) 16 ( 11/16 13/16 15/16 ) + e + e + e ) ) = 1.71884Now we are ready to extrapolate:
1.72722 1.72052*4 - 1.72722 1.72052 --------------------- = 1.71829 4 - 1 1.71884*4 - 1.72052 1.71828*16 - 1.71829 1.71884 --------------------- = 1.71828 ---------------------- = 1.71828 4 - 1 16 - 1
Theoretically we have a sixth-order approximation, which means that the error is of order O(h^6). With h = 1/16, we compute (1/16)^6, or about 6*10^(-8), which means that we have about seven significant digits correct.
b / ( a+b ) | f(x) dx is (b-a) f (-----) / ( 2 ) aGive the formula for the composite midpoint rule that applies the midpoint rule to n equally sized subintervals of [a,b].
Answer:
n --- ( ( 1 ) ) b - a h > f( a + (i + --- ) h ) for h = ------- --- ( ( 2 ) ) n i=1
b / b-a | f(x) dx = --- ( f(a) + 4*f((a+b)/2) + f(b) ) / 6 a
Answer:
Simpson's rule uses 3 function evaluations per interval, but when dividing the interval [a,b] into subintervals, the function evaluation at the interior boundaries of the subintervals are shared. Therefore, if we subdivide [a,b] in 3 subintervals, we will use seven function evaluations.
The formula is
b-a ( ---*( f(x(0))+4*f(x(1))+2*f(x(2))+4*f(x(3)) 18 ( ) +2*f(x(4))+4*f(x(5))+f(x(6)) ) )with
x(k) = a + k*(b-a)/6, k = 0,1,..,6
3a / | f(x) dx / aby the rule w_1 f(a) + w_2 f(2a) + w_3 f(3a).
Answers:
3a / | f(x) dx = w f(a) + w f(2a) + w f(3a) / 1 2 3 a 2 to hold for f = 1, x, and x . Therefore, we solve the system 3a / | 1 dx = 2 a = w + w + w / 1 2 3 a 3a / 2 | x dx = 4 a = w a + w 2 a + w 3 a / 1 2 3 a 3a / 2 26 3 2 2 2 | x dx = ---- a = w a + w 4 a + w 9 a / 3 1 2 3 a where a is a parameter. The solution to the linear system is 1 4 1 w = --- a w = --- a w = --- a 1 3 2 3 3 3
The highest algebraic degree of precision we can reach with Gaussian quadrature using three function evaluations is 5 = 2*3 - 1.
Please note the policy on skipping exams:
What this means is that if you decide not to take one midterm exam, your final exam will be weighted for one hundred points more.
What it does NOT mean is that you can drop the score of a midterm exam. If you take the midterm, then your score counts. So, please be prepared when you show up for the exam.