0% found this document useful (0 votes)
21 views5 pages

LAB4

للاب كمبيوتر ٤
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views5 pages

LAB4

للاب كمبيوتر ٤
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Numerical Computation

Lab ( 5 )

Interpolation with equal intervals


Newton-Gregory Backward Difference Interpolation Formula

Name:

Reg No:

Signature:

Objective:

 Understand the backward difference formula.


 Obtaining backward difference programmatically.

Algorithm:

Assuming that (n-1) values f(a),f(a +h), f(a +2h), … f(a0 +nh) are given for
the function f(x) corresponding to an independent variable of (x) with equal
intervals x= a, a+h, a+2h,…a+nh. According to backward difference operator
, we have:

f(a+nh)= f(a) + nf(a) +[n(n+1)/2!]* 2f(a) +[n(n+1)(n+2)/3!]*


3f(a)+… +

[n(n+1)(n+2) … (n+n-1)/n!]* n f(a).

Eng. Shada khanbari. ‫ الصفحة‬14


Numerical Computation

Example:

The following are data from the steam table:

Temperature C0 140 150 160 170 180


Pressure kg 3.685 4.854 6.302 8.076 10.225
f/cm2

Find all the pressure points of the steam for a temperature using " backward
" interpolation formula, and plot the result.

The program:

% Author: Eng.Mohammed Elmaisary


% Email : [email protected]
% Lecture Teacher in University of Aden
% Created in academic year : 2016 - 2017

% Given
h = 10;
x = 140:h:180;
y = [3.685 , 4.854, 6.302, 8.076, 10.225];

%% NGF Newton-Gregory Forward method


% Construct backward difference table for n+1 values

d1 = diff(y,1);
d2 = diff(y,2);
d3 = diff(y,3);
d4 = diff(y,4);

% Draw the given points in circle shape


plot(x,y,'LineStyle','none','Marker','o');
hold on;

%% NGF Newton-Gregory backward method


a = x(end);
n = (T - a) ./ h;

NGB = y(end) + n .* d1(end) + n.*(n+1).* d2(end)./factorial(2) +


n.*(n+1).*(n+2).* d3(end)./factorial(3) + n.*(n+1).*(n+2).*(n+3).*
d4(end)./factorial(4);

plot(T,NGB,'g');
hold off;

Eng. Shada khanbari. ‫ الصفحة‬15


Numerical Computation

plotting the output:

Observation and Investigation Questions:

Write down the above code and run it. Check that no errors appeared after
you have executed it. Check that the output popped up like the above figure.

1) List out the backward difference table, getting from d1,d2,d3, and d4?

Eng. Shada khanbari. ‫ الصفحة‬16


Numerical Computation

2) What do the circled points represent, list them? What is the order of the
NGB polynomial?

3) How many interpolated points between T = 150 and T = 160, write down
the command generating them, and their corresponding NGB

4) What the hold command do? Is the curve passing through all the circled
points?

Eng. Shada khanbari. ‫ الصفحة‬17


Numerical Computation

Homework:

1. Find the pressure of the steam for a temperature of 1420C , and plot
the result.

2. The following data gives the melting point of an alloy of lead where t is
the temperature in deg-C and p is the percentage of lead in the alloy:

P 40 50 60 70 80 90

t 184 204 226 250 276 304

Find the melting point of the alloy at 84 percent of lead. And show the
output screen.

Eng. Shada khanbari. ‫ الصفحة‬18

You might also like