

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Math 151A Homework #4 – due Friday 10/
1 Construct a Lagrange interpolating polynomial approximation to the function f (x) = 2 x^2 − 2 using the points
a. x 0 = 0, x 1 = 1
P 1 (x) =
(x − 1) (0 − 1)
(x − 0) (1 − 0)
= 2 x − 2
b. x 0 = 0, x 1 = 1, x 2 = 2
P 2 (x) =
(x − 1)(x − 2) (0 − 1)(0 − 2)
(x − 0)(x − 1) (2 − 0)(2 − 1)
= (x^2 − 3 x + 2) + 3(x^2 − x) = 2 x^2 + 2
c. x 0 = −1, x 1 = 0, x 2 = 1, x 3 = 2
P 3 (x) =
(x + 1)(x − 1)(x − 2) (0 + 1)(0 − 1)(0 − 2)
(x + 1)(x − 0)(x − 1) (2 + 1)(2 − 0)(2 − 1)
= −(x^3 − 2 x^2 − x + 2) + x^3 − x = 2 x^2 − 2
2 Approximate
2 using Neville’s method with f (x) =
x and x 0 = 0, x 1 = 1,x 2 = 4,x 3 = 9 and x 4 = 16.
Nevilles method looks like this:
function Q = neville(X,Q,x) n = length(X); for i = 2:n for j = 2:i Q(i,j) = (x-X(i-j+1))Q(i,j-1) - (x-X(i))Q(i-1,j-1); Q(i,j) = Q(i,j)/(X(i)-X(i-j+1)); endfor endfor endfunction
Pay attention to the indices, because octave/matlab counts from 1.
This generates:
octave:1> X=[0 1 4 9 16]; octave:2> Q=[0 1 2 3 4;zeros(4,1),zeros(4)]’ Q =
octave:3> neville(X,Q,2) ans =
0.00000 0.00000 0.00000 0.00000 0. 1.00000 2.00000 0.00000 0.00000 0. 2.00000 1.33333 1.66667 0.00000 0. 3.00000 1.60000 1.36667 1.60000 0. 4.00000 2.00000 1.53333 1.37778 1.
And we get
2 ≈ 1 .572. Notice that the square-root function is never called.
3 Find an error bound for approximating f (x) = sin(x) on the interval [0, π] with xi = iπ/ 2 for i = 0, 1 , 2.
|f (x) − P 2 (x)| =
f (3)(ξ) 3!
(x − x 0 )(x − x 1 )(x − x 2 )
| sin(x) − P 2 (x)| =
− cos(ξ) 6
(x − 0)(x − π/2)(x − π)
max 0 ≤x≤π
|(x)(x − π/2)(x − π)|
π^3 12