6. Newton interpolation
Find Newton interpolating polynomial that fit the following data
(x0, y0), (x1, y1), (x2, y2), (x3, y3)
x y y
y
y
x0 y0
1 0
1 0
y y
A
x x
x1 y1
2 0
B A
D
x x
2 1
2 1
y y
B
x x
3 0
E D
F
x x
x2 y2
3 1
C B
E
x x
3 2
3 2
y y
C
x x
x3 y3
7. Then interpolating polynomial will be as follows:
0 0 1 0 1 2
3 0 (x x (x x )(x x ) D (x x )(x x )(x x ) F
P y + +
- - - - - -
Example: Find interpolating polynomial that fit the following data
using Newton method
(1, 3), (3, 7), (8, 12), (10, 20)
9. Problems
1- (1,3) , (5,-7) , (-13,4) , (2,47) , (-6,15)
Find Lagrange & Newton interpolating polynomials that fit
the above data.
2- Find Lagrange & Newton interpolating polynomial that fit
the following data, then find P(5).
x -1 3 9 13 20
y 5 7 -15 4 9
10. Curve fitting
Find the first degree polynomial y = ax + b that best fit N
data points (x1, y1), (x2, y2), (x3, y3),… , (xN, yN)
Solution
Construct the following 2 equations
2
i
i i i
N N N
i =1 i =1 i =1
x y a x b x
+ , i i
i =1
N N
i =1
y a x bN
+
i = 1, 2, …, N
11. Example: Find a straight line that best fit the data (-1, 3), (1, 7), (3, 2)
Solution: Let the straight line is y = ax + b, we have to
2
i
i i i
3 3 3
i =1 i =1 i =1
x y a x + b x
, i i
i =1
3 3
i =1
y a x + 3b
i xi
2
i
x yi xi yi
1 -1 1 3 -3
2 1 1 7 7
3 3 9 2 6
Sum i
3
i=1
x
=3 2
i
3
i=1
x
=11 i
3
i=1
y
= 12 i i
3
i=1
x y
= 10
Thus 10 11a +3 b
, 12 3a +3 b
a = -1/4, b = 17/4
12. Curve fitting
Find the second degree polynomial y = ax2
+ bx + c that best fit N data
points (x1, y1), (x2, y2), (x3, y3),… , (xN, yN)
Solution
Construct the following 3 equations
2 4 3 2
i i i i i
i=1
N N N N
i=1 i=1 i=1
x y a x b x c x
+ + ,
3 2
i i i i i
i=1
N N N N
i=1 i=1 i=1
x y a x b x c x
+ + ,
2
i i i
N N N
i=1 i=1 i=1
y a x b x cN
+ + i = 1, 2, …, N
13. Example: Find a quadratic polynomial that best fit the data (-2, 2),
(-1, 1), (0, 1), (2, 2)
Solution: Let the approximated quadratic polynomial is
y = ax2
+ bx + c and we have to evaluate constants a, b and c.
We have to construct the following equations
2 4 3 2
i i i i i
i=1
4 4 4 4
i=1 i=1 i=1
x y a x + b x +c x
,
3 2
i i i i i
i=1
4 4 4 4
i=1 i=1 i=1
x y a x + b x +c x
,
2
i i i
4 4 4
i=1 i=1 i=1
y a x + b x + 4 c
14. i xi
2
i
x 3
i
x 4
i
x yi xi yi
2
i
x yi
1 -2 4 -8 16 2 -4 8
2 -1 1 -1 1 1 -1 1
3 0 0 0 0 1 0 0
4 2 4 8 16 2 4 8
Sum -1 9 -1 33 6 -1 17
Therefore 17 33a-b+9 c
, 1 a+9 b c
, 6 9a-b+4c
Solve the 3 equations to get a, b, c
15. Fitting exponential curves to data points
To find an exponential curve y = aebx
that best fit set of given N data
Points (x1, y1), (x1, y1), (x2, y2), (x3, y3),…, (xN, yN), we have first to
modify the exponential curve to first degree polynomial by taking
n to both sides such that
n y = bx + n a
We can express this equation in simplest form such that
Y = Ax+ B
Where Y = n y, A = b and B = n a
16. Construct the equations
2
i
i i i
N N N
i =1 i =1 i =1
x Y A x + B x
, i i
i =1
N N
i =1
Y A x + B N
,
i = 1, 2, …, N
Example: Find the constants of the curve y = aebx
that best fit the
data (2, 1), (1, 3), (0, 1)
17. Solution: we have to get the approximated values for a and b that
best fit the above data, given N = 3, then we put the above
exponential form as a first degree polynomial so that the equation
will be Y = Ax+ B, where Y = n y, A = b and B = n a.
Construct the 2 equations
2
i
i i i
3 3 3
i =1 i =1 i =1
x Y A x + B x
, i i
i =1
3 3
i =1
Y A x +3 B
18. According to the above three points, we can calculate i
3
i=1
x
, 2
i
3
i=1
x
,
i
3
i=1
Y
, i i
3
i=1
x Y
using the following table
i xi yi
2
i
x Yi = n yi xi Yi
1 2 1 4 Y1= n 1= 0 0
2 1 3 1 Y2= n 3 n 3
3 0 1 0 Y3= n 1= 0 0
Sum i
3
i=1
x
=3 2
i
3
i=1
x
= 5 i
3
i=1
Y
= n 3 i i
3
i=1
x Y
= n 3
Therefore n 3 5 A + 3 B
, n3 3 A + 3 B
Solve the 2 equations to get constants A and B,
where A = b and B = n a.
19. Fitting rational function to data points
To find the constants of the rational function y = 1
ax b
+
that best fit
set of given data (x1, y1), (x1, y1), (x2, y2), (x3, y3),…, (xN, yN), we
have first to modify the rational function to first degree polynomial
by putting Y = 1
y
and we can express this equation in simplest form
such that Y = ax + b.
Construct the equations
2
i
i i i
N N N
i =1 i =1 i =1
x Y A x + B x
, i i
i =1
N N
i =1
Y A x + B N
,
i = 1, 2, …, N
20. Example: Find the constants of the rational function
y = 1
ax b
+
that best fit the data (2, 1/3), (1, 1), (0, 1/2)
Solution:
We have first to modify the rational function to first degree
polynomial by putting Y = 1
y
and we can express this
equation in simplest form such that Y = ax + b.
Construct the 2 equations
2
i
i i i
3 3 3
i =1 i =1 i =1
Y
x a x + b x
, i i
i =1
3 3
i =1
Y a x + 3 b
21. According to the above data, i
3
i=1
x
, 2
i
3
i=1
x
, i
3
i=1
Y
, i i
3
i=1
x Y
can
be calculated as follows
i xi yi
2
i
x Yi =
i
1
y xi Yi
1 2 1/3 4 Y1=
1
1
y
= 3 6
2 1 1 1 Y2=
2
1
y
= 1 1
3 0 1/2 0 Y3=
3
1
y
=2 0
Sum i
3
i=1
x
=3
3
2
i
i=1
x
= 5 i
3
i=1
Y
= 6 i i
3
i=1
x Y
= 7
Therefore 7 5 a +3 b
, 6 3a +3 b
Solve the 2 equations to get a & b
22. Fitting any function (y = a x)
+ b) to data points
To find y = a x)
+ b that best fit set of given data (xi, yi),
i = 1, 2, 3,…, N, where x)
is any given continuous function.
Construct the 2 equations i
i i i
N N N
i =1 i =1 i =1
2
) ) )
x y a x ] + b x
,
i i
i =1
N N
i =1
)
y a x + b N
, i = 1, 2, 3,…, N
23. i
N
i=1
x )
, i
N
i=1
y
, 2
i
N
i=1
x )]
, i i
N
i=1
x ) y
evaluated as follows
i xi i
x )
yi i
2
x )]
i
x )
yi
1 x1 1
x )
y1 1
2
x )]
1
x )
y1
2 x2 2
x )
y2 2
2
x )]
2
x )
y2
3 x3 3
x )
y3 3
2
x )]
3
x )
y3
N xN N
x )
yN
2
N
x )]
N
x )
ym
Sum i
N
i=1
x )
i
N
i=1
y
2
i
N
i=1
x )]
i i
N
i=1
x ) y
24. Example: Find a & b of the curve y = a sin(x) + b that best fit
the data (1, 0), (2, 3), (5, 1)
Solution: We have to construct the 2 equations
i i i i
3 3 3
i =1 i =1 i =1
2
)] ) )
[sin(x y a sin(x ] + b sin(x
,
i i
i =1
3 3
i =1
)
y a sin(x + 3 b
25. xi i
sin x )
yi i
2
[sin x )]
[ i
sin x )
] yi
1 sin 1)
= 0.841 0 0.7073 0
2 sin 2)
= 0.91 3 0.8281 2.73
5 sin 5)
= -0.959 1 0.9197 -0.959
3
i=1
i
sin x )
= 0.792 i
3
i=1
y
= 4
3
i=1
2
i
[sin x )]
= 2.4551
3
i=1
i i
[sin x )] y
= 1.771
i
i =1
3
)
sin(x
, i
3
i =1
2
)
sin(x ]
, i i
3
i =1
)]
[sin(x y
, i
3
i =1
y
are evaluated as
follows
Therefore 1.771 2.4551a +0.792 b
, 4 0.792 a +3b
, solve to
get a and b
26. Problems
1- Find the linear equation that best fit the following data
a) (1, -1), (4, 11), (-1, -9) and (-2, -13)
b) (-3, 70), (1, 21), (-7, 110) and (5, -35)
2- Find the parabolic equation that best fit the following data
a) (-1, 10), (0, 9), (1, 7), (2, 5), (3, 4),(4, 3),(5, 0), (6, -1)
b) (-4.5, 0.7), (-3.2, 2.3), (-1.4, 3.8), (0.8, 5.0),(2.5, 5.5), (4.1, 5.6)
27. 3- Find the exponential curve y = aebx
that best fit the following
data
a) (11, 7), (23, 13), (32, 25)
b) (21, 17), (41, 3), (68, 5), (93, 15)
4- Find the curve y = a cos(x) + bx that best fit the following data
a) (31, 17), (23, 13), (12, 15)
b) (21, 19), (35, 23), (68, 5), (93, 15)
5- Find the constants of the curve y = a sinx + b ln x + c ex
that
best fit the data points (11, 7), (23, 13), (50, 27)