You are on page 1of 4

650:231 M.E.

Computational Analysis and Design, Spring 2010


Quiz 3_Sec01

Use this answer sheet to submit your answer. There are two (2) problems.

Your Name: _______________________

Your ID #: _________________________

PART 2 (50 Points)

This is a closed book exam. Use MATLAB to answer the questions. Calculators are not
allowed and do all calculations by MATLAB. Submit this file, with your answers online.
Use of pre-written programs stored in any portable or local hard drives is not allowed.

1. [35 points] Consider a divided difference (DD) table for four data points (X1, Y1) , (X2,
Y2) , (X3, Y3) and (X4, Y4) as shown.

Xi f[ ] f[ , ] f[ , , ] f[ , , , ]
X1 f[X1] f[X1, X2] f[X1, X2, X3] f[X1, X2, X3, X4]
X2 f[X2] f[X2, X3] f[X2, X3, X4]
X3 f[X3] f[X3, X4]
X4 f[X4]

The recursive formula to be used to construct the divided differences is


f [ X 2 , ⋯ , X k ]−f [ X 1 , ⋯ , X k−1 ]
f [ X 1 , ⋯ , X k ]= ,
X k −X 1
f [ X 3 , ⋯ , X k+1 ] −f [ X 2 , ⋯ , X k ]
f [ X 2 , ⋯ , X k+1 ] = ,
X k+1− X 2
f [ X 4 , ⋯ , X k +2 ]−f [ X 3 , ⋯ , X k+1 ]
f [ X 3 , ⋯ , X k+2 ] = ,
X k+2− X 3
.
.
.
And the zero-th order divided difference is defined by
f [ X i ]=Y i.

(a) [5 points] Give the expression of the first order divided differences in terms of the zero-th
order DD’s.
f [ X 2 ]−f [ X 1 ]
f [ X 1 , X 2 ]=
X 2−X 1
f [ X 3 ]−f [ X 2 ]
f [ X 2 , X 3 ]=
X 3−X 2
f [ X 4 ]−f [ X 3 ]
f [ X 3 , X 4 ]=
X 4− X 3
650:231 M.E. Computational Analysis and Design, Spring 2010
Quiz 3_Sec01

(b) [5 points] Give the expression of the second order divided differences in terms of the first
order DD’s

f [ X 2 , X 3 ]−f [ X 1 , X 2 ]
f [ X 1 , X 2 , X 3 ]=
X 3− X 1
f [ X 3 , X 4 ] −f [ X 2 , X 3 ]
f [ X 2 , X 3 , X 4 ]=
X 4 −X 2

(c) [5 points] Give the expression of the third order divided difference in terms of the second
order DD’s.
f [ X 2 , X 3 , X 4 ] −f [ X 1 , X 2 , X 3 ]
f [ X 1 , X 2 , X 3 , X 4 ]=
X 4− X 1
(d) [15 points] Write a MATLAB function m-file to construct the divided difference table
above. The output should be given by a 4X4 matrix

f[X1] f[X1, X2] f[X1, X2, X3] f[X1, X2, X3, X4]
f[X2] f[X2, X3] f[X2, X3, X4] 0
f[X3] f[X3, X4] 0 0
f[X4] 0 0 0

function [D]=DividedDiff(x,y)
n=length(x);
D=zeros(n,n);
D(:,1)=y(:);
for j=2:n
for i=1:n-(j-1)
D(i,j)=(D(i+1,j-1)-D(i,j-1))/(x(i+j-1)-x(i));
end
end
end

(e) [ 5 points] Give the divided difference table for


1 2 3 4
Xi 1.0 2.0 3.0 4.0
Yi 2.1 1.2 4.3 3.4

>> x=[1 2 3 4];


>> y=[2.1, 1.2, 4.3, 3.4];
>> [D]=DividedDiff(x,y)
D=
2.1000 -0.9000 2.0000 -1.3333
1.2000 3.1000 -2.0000 0
4.3000 -0.9000 0 0
3.4000 0 0 0
650:231 M.E. Computational Analysis and Design, Spring 2010
Quiz 3_Sec01

2

2. [15 points] Consider the function f (x )= 2 x +3 . Use the Newton representation
of the cubic interpolation polynomial with interpolation points, X 1 = 0, X2 = 2, X3 = 1,
X4 = 3 to interpolate function f(x) in the interval 0<x<3.
(a)Plot the data points (Xi, f(Xi)) (i=1,4) as well as the interpolation curve in the interval
--0.5<x<3.5.
(b) Show the codes and commands used.
function NewtonRep
x=[0, 2, 1, 3];
y=sqrt(2*x.^2+3);
[D]=DividedDiff(x,y);
xp=linspace(-0.5,3.5);
yp=D(1,1)+D(1,2)*(xp-x(1))+D(1,3).*(xp-x(1)).*(xp-x(2))+D(1,4).*(xp-
x(1)).*(xp-x(2)).*(xp-x(3));
plot(x,y,'o',xp,yp)
end
650:231 M.E. Computational Analysis and Design, Spring 2010
Quiz 3_Sec01

5.5

4.5

3.5

2.5

1.5
-0.5 0 0.5 1 1.5 2 2.5 3 3.5

You might also like