Lecture 14
●
MEEN 357 Homework Solution
1
Lecture14HomeworkSolution2009.doc
RMB
1.
Problem 15.5 of the textbook.
Solution
:
You are given the data
x
1
2
2.5
3
4
5
(
)
f
x
0
5
7
6.5
2
0
Part a):
You are asked to use Newton’s interpolation polynomial determine the
interpolated value at
3.4
x
=
for three cases 1) linear interpolation, 2) quadratic
interpolation and 3) cubic interpolation.
Solution:
One mfile will be used to generate the three answers to Part a).
The script
%Problem 15.1
clc,clear
all
%Need value at x=3.4
%PART a)Linear Interpolation
x=[3,4];
y=[6.5,2];
%You have two easy ways to solve.
%Use function file newtona.m and polyval
[b,P]=newtona(x,y);
yint_a=polyval(P,3.4)
%Use function file in book that we did not cover
yint_a=Newtint(x,y,3.4)
%PART b)Quadratic Interpolation.
You need three points.
%There are two cases as follows
%Two points in front of x=3.4, one point behind
x1=[3,4,5];
y1=[6.5,2,0];
%Two points behind x=3.4, one point in front
x2=[2.5,3,4];
y2=[7,6.5,2];
%Each can be worked by the two methods above
%Use function file newtona.m and polyval
[b,P]=newtona(x1,y1);
yint_b1=polyval(P,3.4)
%Use function file in book that we did not cover
yint_b1=Newtint(x1,y1,3.4)
%Use function file newtona.m and polyval
[b,P]=newtona(x2,y2);
yint_b2=polyval(P,3.4)
%Use function file in book that we did not cover
yint_b2=Newtint(x2,y2,3.4)
%PART c) Cubic Interpolation.
You need four points.
%There are again two cases
%Two points in front of x=3.4, two behind
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Lecture 14
●
MEEN 357 Homework Solution
2
Lecture14HomeworkSolution2009.doc
RMB
x1=[2.5,3,4,5];
y1=[7,6.5,2,0];
%One point in front of x=3.4, three behind
This is the end of the preview.
Sign up
to
access the rest of the document.
 Fall '07
 ANAMALAI
 Numerical Analysis, function file, newtona Newtint, function file newtona.m

Click to edit the document details