Numerical Analysis
Numerical Analysis
(3)
1
Interpolation
Assumption:
x0 , x1 ,..., xn are distinct
2
Theorem:
There is a unique polynomial fn(x) of order ≤ n such that:
f n ( xi ) = f ( xi ) for i = 0,1,...,n
Polynomial Interpolation
f ( x1 ) − f ( x0 )
f1 ( x) = f ( x0 ) + (x − x0 )
x1 − x0
Example:
Find a polynomial that interpolates (1, 2) and (2, 4).
Solution
4−2
f1 ( x) = 2 + (x − 1) = 2 x
2 −1
Example:
Find log (10) for the function f(x) = log(x) when
log (8) = 0.9030900, log (12) = 1.0791812
Solution
Be aware that:
When X0 = 8, then f(X0) = 0.9030900
When X1 = 12, then f(X1) = 1.0791812
Then apply on :
f ( x1 ) − f ( x0 )
f1 ( x) = f ( x0 ) + (x − x0 )
x1 − x0
Then get value of log(10) : that mean get value of f(10)
4
Quadratic Interpolation
Given any three points (𝑥0 , 𝑓(𝑥0 )), (𝑥1 , 𝑓(𝑥1 )), 𝑎𝑛𝑑 (𝑥2 , 𝑓(𝑥2 ))
The polynomial that interpolates the three points is:
𝑓(𝑥 ) = 𝑏0 + 𝑏1 (𝑥 − 𝑥0 ) + 𝑏2 (𝑥 − 𝑥0 )(𝑥 − 𝑥1 ) + ⋯
𝑤ℎ𝑒𝑟𝑒:
) االولىx – الحاليهx ( هات كل واحد مع اللي قبله و اقسم على
𝑏0 = 𝑓 (𝑥0 )
𝑓(𝑥1 ) − 𝑓(𝑥0 )
𝑏1 = 𝑓[𝑥0 , 𝑥1 ] =
𝑥1 − 𝑥0
𝑓(𝑥2 ) − 𝑓(𝑥1 )
− 𝑏1
𝑥2 − 𝑥1
𝑏2 = 𝑓 [𝑥0 , 𝑥1 , 𝑥2 ] =
𝑥2 − 𝑥0
Example:
Find f(x) for (0, -1) , (1, -1), (2, 7)
Example:
Given the function f(x) = ln(x) when
ln (1) = 0, ln (4) = 1.38629, ln (6) = 1.7917
Find f(x) as quadratic function then find f(3).
5
Newton's Interpolation
Example:
Using newton's interpolation to get interpolating polynomial for
(-2, -27), (0, -1), (1, 0)
Solution
t1 = -2, y1 = -27
Use :
1 0 0 𝑥1 𝑦1
[1 (𝑡2 − 𝑡1 ) 0 ] . [𝑥2 ] = [𝑦2 ]
1 (𝑡3 − 𝑡1 ) (𝑡3 − 𝑡1 )(𝑡3 − 𝑡2 ) 𝑥3 𝑦3
1 0 0 𝑥1 −27
[1 2 0 ] . [𝑥2 ] = [ −1 ]
1 3 3 𝑥3 0
: نحل المعادالت رياضيا, بعد ضرب المصفوفتين
X1 = -27 , X2 = 13 , X3 = -4
P (t) = -27 + 13 (t – (-2)) - 4 (t – (-2)) (t – 0)
6
Newton Divided Differences Interpolation
7
f(x)=
F[x0] +
F [x0, x1] (x-x0) +
F [x0, x1, x2] (x-x0) (x-x1) +
F [x0, x1, x2, x3] (x-x0) (x-x1) (x-x2) +
F [x0, x1, x2, x3, x4] (x-x0) (x-x1) (x-x2) (x-x3)
Example:
xi 0 1 -1
𝒇 (𝒙𝒊 ) -5 -3 -15
f [ x1 ] − f [ x0 ] − 3 − (−5)
f [ x0 , x1 ] = =2
x1 − x0 1− 0
f [ x2 ] − f [ x1 ] − 15 − (−3)
f [ x1 , x2 ] = =6
x2 − x1 −1 −1
f [ x1 , x2 ] − f [ x0 , x1 ] 6 − (2)
f [ x0 , x1 , x2 ] = = −4
x2 − x0 − 1 − (0)
f2(x)= F[x0] + F [x0, x1] (x - x0) + F [x0, x1, x2] (x - x0) (x - x1)
f 2 ( x) = −5 + 2( x − 0) − 4( x − 0)( x − 1)
8
Notes:
] f [ x2 ] − f [ x1
= ] f [ x1 , x2
x2 − x1 = ] 𝑓[𝑥1 , 𝑥2
]االول[𝑓]−االخير[𝑓
االخير−االول
المقام
9