University of Palestine Gaza Strip Civil Engineering College Numerical Analysis CIVL 3309 Dr. Suhail Lubbad

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 19

University of Palestine

Gaza Strip

Civil Engineering College


Numerical analysis
CIVL 3309
Formerly CVL 3308

Dr. Suhail Lubbad


Discussion
Polynomial Interpolation
MineNewtonIterpolation.m

This is a code for Newton interpolation polynomial


By Suhail Lubbad

Type in your X-coordinates: [8, 12]


Type in your Y-coordinates: [log10(8) log10(12)]
Type in your point to be interpolated: 10
b0=0.9031

b1=0.0440

The polynomial fn = b 0 % b 1∗& x−8'


&3097830190103∗x ' 2481066671566207
Fn = %
70368744177664 4503599627370496
Fn = Fn& x'= x.∗4.402281476392034e-2%5.509074688805808e-1

fn &10'=0.90309%0.0440228∗2=0.991136
This is a code for Newton interpolation polynomial
By Suhail Lubbad

Type in your X-coordinates: [12 8]


Type in your Y-coordinates: [log10(12) log10(8)]
Type in your point to be interpolated: 10

b0 =1.0792
b1=0.0440
The polynomial fn = b 0 % b 1∗& x−12'
&3097830190103∗x ' 2481066671566207
Fn = %
70368744177664 4503599627370496
Fn = Fn& x' = x.∗4.402281476392034e-2 % 5.509074688805808e-1

fn &10'=1.07918%0.0440228∗−2=0.991136
What if we change the order of points?
Error Analysis
Who can tell how?
Type in your X-coordinates: [8 9 11]
Type in your Y-coordinates: log10([8 9 11])
Type in your point to be interpolated: 10

b0=0.9031
b1 =0.0512
b2=−0.0025
The polynomial fn = b0 % b1∗& x−8' % b2∗&& x−8'∗& x−9''
&460740962066175∗x' &5824124857451819∗& x−8'∗& x−9'' 2224191880634243
Fn = − %
9007199254740992 2305843009213693952 4503599627370496
2.
Fn & x' = x.∗9.409131844565875e-2 − x. ∗2.525811529310436e-3 % 3.120113773025415e-1

fn&10'=0.90309%0.0511525∗2%−0.00252581∗2=1.000343
I will make the 5th order polynomial
Where error can't be calculated

In class, we discuss what the question asked for

including the error


b0 =2.0000 b1=15.0000 b2 =−3.3333 b3=−3.4226 b 4 =1.8477 b5 =−0.4812

The polynomial fn =
b0
%b1∗& x−8/5'
%b 2∗&& x−2 '∗& x−8/5''
%b3∗&& x−2'∗& x−5/2'∗& x−8/5''
%b 4∗&& x−2'∗& x−5 /2'∗& x−8 /5'∗& x−16/5''
%b5∗&& x−2'∗& x−4'∗& x−5/2'∗& x−8/5'∗& x−16/5''

Fn=15∗x−&10∗& x−2'∗& x−8/5''/3−&575∗& x−2'∗& x−5/ 2'∗& x−8/5''/168%


&3725∗& x−2'∗& x−5/2'∗& x−8/5'∗& x−16/5''/2016−
&485∗& x−2'∗& x−4'∗& x−5/2'∗& x−8/5'∗& x−16/5''/1008−22

Fn & x'=x.∗&−2.045234126984127e2 ' % x.2.∗1.598360119047619e2 −


x.3.∗5.376731150793651e1 % x.4.∗8.24702380952381 −
x.5.∗4.811507936507937e-1%6.39e2 ./7.0

fn& 2.8'=2%15∗1.2%−3.33333∗0.96%−3.42262∗0.288%
1.84772∗−0.1152%−0.481151∗0.13824=15.534914
Blue is the original data

Green is the interpolation curve P5(x)

The red spot is the interpolated point


How to perform computation
Find
f[x1 x0]
f[x2 x1]
f[x3 x2]
f[x4 x3] and so on
Then compute
f[x2 x1 x0]
f[x3 x2 x1]
f[x4 x3 x2]
Then
f[x4 x3 x2 x1]
f[x3 x2 x1 x0]
Then
f[x4 x3 x2 x1 x0]
x = sym('x');
y = sym('y');

A = 2*x+y

fprintf(A) % doesn`t work


% convert it to a char first then use the fprintf

fprintf('%s\n',char(A))

A = char(A)
fprintf('%s\n',A);
Get a blank paper
And
Try this that follows
Estimate O(27) using Newton Linear and Quadratic interpolation.

Estimate the error in both cases.

You might also like