0% found this document useful (0 votes)
36 views

Mat 224

The document discusses methods for solving nonlinear equations and systems of linear equations. It describes: 1) Transcendental equations as equations involving transcendental functions like logarithms, trigonometric, or exponential functions. 2) General methods for solving nonlinear equations iteratively including rearranging the equation, choosing an initial value, and iterating until convergence within a specified accuracy. 3) Specific iterative methods like Regula Falsi, Newton-Raphson, and Gauss-Jacobi for solving systems of linear equations.

Uploaded by

tolupeterajibola
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views

Mat 224

The document discusses methods for solving nonlinear equations and systems of linear equations. It describes: 1) Transcendental equations as equations involving transcendental functions like logarithms, trigonometric, or exponential functions. 2) General methods for solving nonlinear equations iteratively including rearranging the equation, choosing an initial value, and iterating until convergence within a specified accuracy. 3) Specific iterative methods like Regula Falsi, Newton-Raphson, and Gauss-Jacobi for solving systems of linear equations.

Uploaded by

tolupeterajibola
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 18

MAT 224

Dr. Alao.
Solution of nonlinear equations
Transcendental Equation: a polynomial containing log, trig or exp

A transcendental equation is an equation that involves transcendental functions, which are functions
that cannot be expressed as a finite combination of algebraic functions (i.e., polynomials) and
elementary functions.

Steps in Problem Solving


 Problem description
 Problem Formulation
 Problem Solution
 Using the solution

General Iteration Method


 ℜ−arrange f ( x )=0 , ¿ form x=g ( x ) { iteration function }
 ∋ x n +1=g ( x n ) ,n ≥ 0
 There are at least n+1 iteration functions for a polynomial of degree n.
 General Stopping Criterion
o For accuracy ¿ k decimal places , continue theiteration until :
1
|x n+ 1−x n|< 2 10−k (k=3 for this course , usually)
 Do not divide through by x
 Condition for Convergence
o | '
|
If g ( x 0 ) <1 , thenthe iteration method converges

Regula-Falsi Method
x ¿ f ( x n ) −x n f ( x ¿ )
x n+1= f ( x )=2 x 3−7 x +2=0 f ( 0 )=2 , f ( 1 )=−3 → x¿ =0 , x n=1
f ( x n) −f ( x ¿ )
0−2 0−0.4 ( 2 ) 0.8
x 1= =0.4 , f ( x 1 )=−0.672 x 2= = =0.2994 , f ( x2 ) =−0.0421
−3−2 −0.672−2 2.672
−0.2994 ( 2 )
x 3= =0.29322 , f ( x 3 ) =−0.002168
−0.0421−2
−0.29322 ( 2 ) −0.2929 ( 2 )
x4= =0.2929 , f ( x 4 )=−0.00006015x 5= =0.29289x ≈ 0.29289
−0.002168−2 −0.0006015−2

−1 −0.5 ( 1 ) −0.3636
x ¿=0 , x 1=1 x 1= =0.5 x 2= =0.3636 x 3= =0.3487¿ so on
−1−1 −0.375−1 −0.0427−1
NEWTON-RAPHSON
f ( xn)
x n+1=x n − '
, n≥ 0
f ( xn )

Example:

f ( x )=x 3−5 x +1f ' ( x )=3 x 2−5 f ( 1 ) =8−10+ 1=−1 , f ( 0 )=1let x 0=0.5
( 0.5 )3−5 ( 0.5 ) +1 1.375
→ x1=0.5− =0.5+ =0.17647
2
3 ( 0.5 ) −5 −4.25
3
0.17647 −5 ( 0.17647 )+ 1 0.12314
x 2=0.17647− =0.17647− ¿ 0.20157
3 ( 0.17647 ) −5 2
−4.9066
( 0.20157 )3−5 ( 0.20157 ) +1
x 3=0.20157− 2
=0.20164
3 ( 0.20157 ) −5
( 0.20164 )3−5 ( 0.20164 ) +1
x 4 =0.20164− 2
≈ 0.20164 → x ≈ 0.20164
3 ( 0.20164 ) −5

0.5
0.5 e −cos 0.5
f ( x )=x e −cos x → f ( x )=e + x e +sin x let x 0=0.5→ x1=0.5−
x ' x x
0.5 0.5
=0.5707
e +0.5 e +sin 0.5
x 2=0.567149x 3=0.567126

SOLUTION OF LINEAR SYSTEMS OF EQUATIONS


Direct Method

Iterative Method
GAUSS-JACOBI

given a system of equations :a 11 x 1 +a 12 x 2+ a13 x 3=b 1a 21 x 1+ a22 x 2 +a23 x3 =b2


a 31 x 1+ a32 x 2+ a33 x 3=b3 Assuming that aii ≠ 0
1
a 11 x 1=b1−a 12 x 2−a13 x3 → ( x1 ) k+1= ( b −a ( x ) −a ( x ) )
a11 1 12 2 k 13 3 k
1
a 22 x 2=b2−a21 x 1−a23 x 3 → ( x 2 )k+ 1= ( b 2−a21 ( x1 ) k −a23 ( x 3 )k )
a22
1
a 33 x 3=b3 −a32 x 2−a31 x 1 → ( x 3 )k +1= ( b 3−a 32 ( x 2 )k −a 31 ( x 1 )k )
a33

Example :4 x1 + x 2 + x 3=2x 1+ 5 x 2 +2 x3 =−6x 1+ 2 x 2 +3 x3 =−4with ( x n )0=0

1 1 1
→ ( x 1) k+1=
4
( 2−( x 2 )k −( x 3 ) k )→ ( x 2) k+1= ( −6−( x 1) k −2 ( x 3 )k )→ ( x 3 )k+1= ( −4−2 ( x 2 )k −( x1 ) k )
5 3
1 1
k =0→ ( x 1) 1=
4
( 2−( x 2 )0 −( x 3 )0 )=0.5→ ( x 2) 1= (−6−( x 1 )0−2 ( x 3 )0 ) =−1.2
5
1 −4
→ ( x 3 )1= (−4−2 ( x 2 )0 −( x 1 )0 )=
3 3

1
k =1→ ( x 1) 2=
4
(
1 6 4 17
2−( x2 )1− ( x3 ) 1) = 2+ + =
4 5 3 15( )
1
5
1
5
8
(
→ ( x 2) 2= (−6−( x 1 )1−2 ( x 3 )1 )= −6+ −0.5 =¿
3 )
1 1
→ ( x 3 )2= (−4−2 ( x2 )1− ( x1 )1 ) = −4 +
3 3 (2 (6 )
5
−0.5 =¿ )
1
k =2→ ( x 1) 2=
4
(
1 6 4 17
2−( x2 )1− ( x3 ) 1) = 2+ + =
4 5 3 15 ( )
1
5
1
5
8
(
→ ( x 2) 2= (−6−( x 1 )1−2 ( x 3 )1 )= −6+ −0.5 =¿
3 )
→ ( x 3 )2=
1
3 (
1
(
−4−2 ( x2 )1− ( x1 )1 ) = −4 +
3
2 (6 )
5
−0.5 =¿ )
1
k =3→ ( x 1) 2=
4
(
1 6 4 17
2−( x2 )1− ( x3 ) 1) = 2+ + =
4 5 3 15( )
1
5
1
5
8
(
→ ( x 2) 2= (−6−( x 1 )1−2 ( x 3 )1 )= −6+ −0.5 =¿
3 )
1 1
→ ( x 3 )2= (−4−2 ( x2 )1− ( x1 )1 ) = −4 +
3 3 (2 (6 )
5
−0.5 =¿ )
1
k =4 → ( x 1) 2=
4
(
1 6 4 17
2−( x2 )1− ( x3 ) 1) = 2+ + =
4 5 3 15 ( )
1
5
1
5
8
(
→ ( x 2) 2= (−6−( x 1 )1−2 ( x 3 )1 )= −6+ −0.5 =¿
3 )
→ ( x 3 )2=
1
3 (
1
(
−4−2 ( x2 )1− ( x1 )1 ) = −4 +
3
2 (6 )
5
−0.5 =¿ )
1
k =5→ ( x 1) 2=
4
(
1 6 4 17
2−( x2 )1− ( x3 ) 1) = 2+ + =
4 5 3 15( )
1
5
1
5
8
(
→ ( x 2) 2= (−6−( x 1 )1−2 ( x 3 )1 )= −6+ −0.5 =¿
3 )
1 1
→ ( x 3 )2= (−4−2 ( x2 )1− ( x1 )1 ) = −4 +
3 3 (2 (6 )
5
−0.5 =¿ )
Example 2
Solvethe systemof eqn :26 x +2 y+ 2 z=12.63 x+ 27 y + z=−14.32 x+3 y +17 z=6
1 1 1
→ x k+1=
26
( 12.6−2 y k −2 z k )→ y k+1= (−14.3−z k −3 x k ) → z k+1= (6−2 x k −3 y k )
27 17

1 12.6 1 −14.3
k =0 x 1=
26
( 12.6−2 y 0−2 z 0 )=
26
y 1= ( −14.3−z 0−3 x 0 ) =
27 27
1 6
z 1= ( 6−2 x 0−3 y 0 )=
17 17

(
k =1x 2=
1
26
12.6−2
27(
−14.3
) ( ))
−2
6
17
=0.4982

y 2=
1
27(−14.3−
6
17 ( ) ( ))
−3
12.6
26
=−0.596547z =
17 (
1
6−2 (
2
26 ) ( 27 ))
12.6
−3
−14.3
=0.38939

1 1
k =2 x 3= ( 12.6−2 y 1−2 z 1) = ( 12.6−2 (−0.596547 ) −2 ( 0.38939 ) )=0.50055
26 26
1 1
y 3= (−14.3−z 1−3 x 1 )= (−14.3−( 0.38939 )−3 ( 0.4982 ) )=−0.5994
27 27
1 1
z 3= ( 6−2 x 1−3 y 1 )= ( 6−2 ( 0.4982 )−3 (−0.596547 ) )=0.3996
17 17

1 1
k =3 x 4 = ( 12.6−2 y 3 −2 z 3 ) = ( 12.6−2 (−0.5994 )−2 ( 0.38939 ) )=0.49998
26 26
1 1
y 4 = (−14.3−z 3−3 x 3 )= (−14.3−( 0.39960 )−3 ( 0.500550 ) )=−0.6
27 27
1 1
z 4 = ( 6−2 x 3−3 y 3 ) = ( 6−2 ( 0.500550 )−3 (−0.5994 ) )=0.3998
17 17

1 1
k =4 x 5= ( 12.6−2 y 4 −2 z 4 )= ( 12.6−2 (−0.6 )−2 ( 0.3998 ) )=0.50001
26 26
1 1
y 5= (−14.3−z 4 −3 x 4 )= (−14.3− ( 0.3998 )−3 ( 0.49998 ) )=−0.59999
27 27
1 1
z 5= ( 6−2 x 4−3 y 4 )= ( 6−2 ( 0.49998 )−3 (−0.6 ) ) =0.4
17 17

x 1 ≈ 0.5 , x 2 ≈−0.6 , x 3 ≈ 0.4

GAUSS-SEIDAL
given a system of equations :a 11 x 1 +a 12 x 2+ a13 x 3=b 1a 21 x 1+ a22 x 2 +a23 x3 =b2
a 31 x 1+ a32 x 2+ a33 x 3=b3 Assuming that aii ≠ 0
1
a 11 x 1=b1−a 12 x 2−a13 x3 → ( x1 ) k+1= ( b −a ( x ) −a ( x ) )
a11 1 12 2 k 13 3 k
1
a 22 x 2=b2−a21 x 1−a23 x 3 → ( x 2 )k+ 1= ( b 2−a21 ( x1 ) k+1−a23 ( x 3 )k )
a22
1
a 33 x 3=b3 −a32 x 2−a31 x 1 → ( x 3 )k +1= ( b 3−a 32 ( x 2 )k+1−a31 ( x 1 )k +1)
a33

Example

45 x +2 y +3 z=58−3 x+ 22 y +2 z=475 x+ y+ 20 z =67.using x i=0


1 1 1
→ x k+1= ( 58−2 y k −3 z k ) , y k+ 1= ( 47−2 z k+1 +3 x k ) , z k+1 = ( 67−5 x k +1− y k +1 )k =0
45 22 20
58
x 1= , y 1=
45
1
22 (
47−0+ 3
58
45( ))
=2.31212, z 1=
1
20 ( 58
67− −2.31212 =2.91217
9 )
1
( 58−2 ( 2.31212 )−3 ( 2.91217 ) )=0.99198 ,
k =1 x 2=
45
1 1
y 2= ( 47−2(2.91217)+ 3 ( 0.99198 ) )=2.00689 , z 2= ( 67−5(0.99198)−2.00689 )=3.00166
22 20

1
( 58−2 ( 2.00689 )−3 ( 3.00166 ) )=0.99958 ,
k =2 x 3=
45
1 1
y 3= ( 47−2(2.91217)+3 ( 0.99198 ) )=1.99979 , z 3= ( 67−5(0.99198)−2.00689 )=3.0020155
22 20

ASSIGNMENT

Gx +3 y+ 52 z=173.61x−27 y +2 z=71.3141 x−2 y +3 z=65.46 x 0=1 , y 0=−1 , z 0=3

Convergence test :diagonal dominance|aii|>|aij|+|aik|+ … ( ∀ i ≠ j ,i ≠ k , … )


for i=3 ,|a33|>|a31|+|a 32|→|3|>|41|+|−2| ,WHICH IS FALSE
→ we cannot guarantee convergence of theGauss−Seidel∨Jacobi method

−1
SEIDAL x k+1 =( 173.61−3 y k −52 z k ) y k +1= ( 71.31−x k +1−2 z k )
27
1
z k+1 = ( 65.46−41 x k+1 +2 y k+1 )
3
−1
k =0x 1=( 173.61+3−52 ( 3 ) )=20.61 y 1= ( 71.31−20.61−6 )=−1.65556
27
1
z 1= ( 65.56−41 ( 20.61 )−2 ( 1.65556 ) )=−260.9537 k =1
3
x 2=( 173.61−52 (−260.9537 )+ 3 (1.65556 ) )=13748.1693
−1
y 2= ( 71.31−2.0 (−260.9537 )−1.0 ( 13748.1693 )) =487.2204
27
1
z 2= ( 65.46−41.0 ( 13748.1693 )+ 2.0 ( 487.2204 )) =−187545.0129
3
the values of x , y∧z tend ¿ ∞

−1 1
JACOBI x k+1 =( 173.61−3 y k −52 z k ) y k +1= ( 71.31−x k −2 z k ) z k+1 = ( 65.46−41 x k + 2 y k )
27 3
−1
k =0x 1=( 173.61+3−52 ( 3 ) )=20.61 y 1= ( 71.31−20.61−6 )=−1.65556
27
1
z 1= ( 65.56−41 ( 20.61 )−2 ( 1.65556 ) )=−260.9537 k =1
3
x 2=( 173.61−52 (−260.9537 )+ 3 (1.65556 ) )=13748.1693
−1
y 2= ( 71.31−2.0 (−260.9537 )−1.0 ( 13748.1693 )) =487.2204
27
1
z 2= ( 65.46−41.0 ( 13748.1693 )+ 2.0 ( 487.2204 )) =−187545.0129
3
the values of x , y∧z tend ¿ ∞

Decision variables

Constraints

Objective Function

Maximise Z = 23x+16y

Maximise Z=12 x+16 y ( objective function )10 x+ 20 y ≤ 120 , 8 x +8 y ≤ 80 , x , y ≥ 0Constraint 1


at x=0 →20 y =120→ y=6at y=0 → 10 x=120 → x=12→ ( 0 , 6 ) , ( 12 , 0 ) Constraint 2
at x=0 →8 y =80 → y =10at y=0 → 8 x =80 → x=10 ( 10 , 0 ) ,(0 , 10)
A ( 0 , 0 ) , B ( 10 , 0 ) , C ( 8 , 2 ) , D ( 0 , 6 ) Z ( A )=0 , Z ( B )=120 , Z ( C ) =96+32=128 , Z ( D )=96
→ Z ismaximised at C=(8 ,2)

Z=50 x+18 y2 x+ y ≤ 100x + y ≤ 80x , y ≥ 0First constraint x=0 : y =100 , ( 0,100 )


y=0: x =50 , ( 50 , 0 ) 2 nd constraint x=0 : y =80 , ( 0 ,80 ) y=0: x =80 , ( 80 ,0 )
A ( 0 , 0 ) , B ( 0 , 80 ) , C ( 20 , 60 ) , D ( 50 , 0 ) Z ( A )=0 , Z ( B )=1440 , Z ( C ) =2080 , Z ( D )=2500
→ Z ismaximised at D
Dr. O.
INTERPOLATION & APPROXIMATION
 Show workings in detail
 Exact value is obtained when using differential equation methods
 Approximate values are from numerical methods

Interpolating Polynomial : Pn ( x )=l 0 ( x ) f ( x 0 ) +l 1 ( x ) f ( x 1 ) +…+ l n ( x ) f ( x n )

f i∧l i ( x ) , i=0 , 1, 2 , … n , are poly of degree n Step function :l i ( x j )= [


0 , i≠ j INTERPOLATI
1 , i= j
ON Uneven intervals:
Lagrange Interpolation
1. Linear interpolation
For n=1 , we have the data : x → f ( x ) , x 0 → f 0 , x 1 → f 1
x−x 1 x −x 0
Lagrange fundamental polynomial :l 0= ,l 1=
x 0−x 1 x 1−x 0
The Lag lininterpolation is: P 1 ( x )=l 0 f 0 +l 1 f 1
2. Quadratic interpolation For n=2 : x → f ( x ) , x 0 → f 0 , x 1 → f 1 , x 2 → f 2
( x −x1 ) ( x−x 2 ) ( x−x 0 ) ( x−x 2 ) ( x−x 0 ) ( x−x 1 )
LFP :l 0 = ,l 1= , l 2=
( x 0 −x1 ) ( x 0−x 2 ) ( x 1−x 0 ) ( x 1−x 2) ( x 2−x 0 ) ( x 2−x 1 )
P2 ( x ) =l 0 f 0 +l 1 f 1+ l 2 f 2
3. Cubic interpolation
For n=2 : x → f ( x ) , x 0 → f 0 , x 1 → f 1 , x 2 → f 2 , x 3 → f 3
( x−x 1 ) ( x−x 2 )( x −x3 ) ( x−x 0 ) ( x−x 2 ) ( x−x 3 ) ( x−x 0 ) ( x−x 1 ) ( x−x 3 ) ( x−
LFP :l 0 = , l 1= , l 2= ,l 3=
( x 0 −x1 ) ( x 0−x 2 ) ( x 0−x 3 ) ( x 1−x 0 )( x1 −x2 ) ( x 1−x 3 ) ( x 2−x 0 ) ( x2 −x1 ) ( x 2−x 3 ) ( x 3−x
P3 ( x )=l 0 f 0 +l 1 f 1 +l 2 f 2+ l3 f 3
Error of interpolation
E ( f , x )=|f ( x )−Pn ( x )| {exact −¿ }

E . g .:Using sin ( 0.1 )=0.099683 ,∧sin ( 0.2 )=0.19867 , find


an≈value of sin ( 0.15 ) by LI .Obtain a bound on the error at x =0.15
Sol :data values of n → poly degree of n−1
x−x 1 x−x 0 x−0.2 x−0.1
P1 ( x ) =l 0 f 0 +l 1 f 1= f 0+ f = ( 0.099683 )+ ( 0.19867 )
x 0−x 1 x 1−x 0 1 0.1−0.2 0.2−0.1
1
¿ ( 0.099683 ( 0.2−x )+ ( x−0.1 )( 0.19867 ) )=10 (0.098807 x+ 0.0001056)
0.1
P1 ( 0.15 )=10 ( 0.098807 ( 0.15 )+ 0.0001056 ) =0.1492665
E . g .:Using Lagrange find the quad poly that takesthe valuesx → y :0 →0 , 1 →1 , 3 →0
( x−x 0 ) ( x−x 2 ) x ( x−3 ) 1
Sol : P2=l 0 f 0+ l 1 f 1+l 2 f 2=l 1 ( 0 ) + ( 1 ) +l 2 ( 0 )¿ = ( 3 x−x 2 )
( x 1−x 0 ) ( x 1−x 2) 1 ( 1−3 ) 2
1 2
→ LQP :f ( x )= (3 x −x )
2

E . g .:Given that f ( 0 )=1 , f ( 1 )=3 , f ( 3 ) =55 ,


find the uniqe poly of degree 2∨less , which fitsthe givendata
( x−1 )( x−3 ) ( x ) ( x−3 ) x ( x−1 )
Sol : P2=l 0 f 0+ l 1 f 1+l 2 f 2= ( 1 )+ ( 3 )+ ( 55 )
(−1 )(−3 ) ( 1 )(−2 ) ( 3 )( 2 )
1 2 3 55 2
¿ ( x −4 x+ 3 ) + ( 3 x−x ) + ( x −x )=1+ x
3 2
2
6
−4 9 55
+ −
3 2 6
2 1 3 7 2
+ x − ¿ 1−6 x− x
3 2 6 ( ) ( )

E . g : f ( x )=sin x+ cos x . Find f ( 12π ) with LIP , comparing withexact


π 0
f ( 10 0 )=1.1585 , f ( 20 0 )=1.2817 , f ( 300 )=1.3660 Sol : =15
12
( x−20 0 ) ( x−300 ) ( x−100 ) ( x−300 ) ( x−200 ) ( x−100 )
P2=l 0 f 0+l 1 f 1 +l 2 f 2= ( 1.1585 ) + ( 1.2817 ) + ( 1.3660 )
(−10 0 )( −200 ) ( −100 ) ( 100 ) ( 200 ) ( 100 )
1
¿ 0
¿
200

Divided Differences
f i+1−f i f 1 −f 0
1 st order : f [ x i , x i+1 ]= , i=0 , 1 ,2 , … , n−1→ f [ x 0 , x 1 ]=
x i+1−x i x1 −x 0
f [ x i+ 1 , x i+2 ] −f [ x i , xi +1 ]
2 nd order : f [ x i , xi +1 , x i+2 ]= , i=0 , 1, 2 , … , n−1
x i+2−x i
f [ x 1 , x 2 ]−f [ x 0 , x1 ]
→ f [ x 0 , x 1 , x 2 ]=
x 2−x 0
=
1
(
f 2−f 1 f 1−f 0

x 2−x 0 x 2−x 1 x 1−x 0 )
1
E . g .: Find 2 nd÷diff of f ( x )= , using a , b , c
x
f [ a ,b ] =
b−a [ ]
f ( b ) −f ( a )
=
1 1 1
− =
b−a b a ( b−a ) ab ab
a−b
=
−1

f [b , c ]=
f c −f b
[ ]
=
1 1 1
c−b c−b c b bc ( c−b ) bc
− =
b−c
=
−1

f [ a ,b , c ] =
f [ b , c ] −f [a , b]
c−a
=
[ ]
1 −1 1
( ) + =
1
c−a bc ab b ( c−a ) a c ( c−a ) abc abc
1 1
− =
c −a
=
1
f 0−f 1 −8−3
E . g .:Obtain÷diff table f (−1 )=−8 , f ( 0 )=3 , f ( 2 )=1 , f ( 3 )=12f [ x 0 , x1 ] = = =11
x 0−x 1 −1−0
f 1−f 2 3−1 f 2−f 3 1−12
f [ x 1 , x 2 ]= = =−1f [ x 2 , x 3 ] = = =11
x 1−x 2 0−2 x 2−x 2 2−3

Newton’s Divided Difference Interpolation


f ( x )=P n ( x )=c0 + ( x −x 0 ) c1 + ( x−x 0 ) ( x−x 1 ) c 2+ …+ ( x−x 0 ) ( x−x 1 ) c n f 0=c 0
f 1−c0 f 1−f 0
f 1=c 0 + ( x 1−x 0 ) c 1 → c 1= = =f [ x 0 , x 1 ]
x 1−x 0 x 1−x 0
f 2 −f 0 −( x 2−x 0 ) f [ x 0 , x 1 ]
f 2=c 0 + ( x 2−x 0 ) c 1+ ( x2 −x 0 )( x 2−x 1 ) c 2 → c 2= =f [ x 0 , x 1 , x 2 ]
( x 2−x 0 ) ( x 2−x 1 )
→ c n=f [ x 0 , x1 , x2 , … , x n ]

→ P n ( x )=f 0 + ( x−x 0 ) f [ x 0 , x1 ] + ( x−x 0 ) ( x−x 1 ) f [ x 0 , x 1 , x 2 ] +…+ ( x−x 0 )( x −x1 ) … ( x−x n−1 ) f [ x 0 , x 1 , … , x n ]

EXAMPLE

f (−4 )=1245 , f (−1 )=33 , f ( 0 )=5 , f ( 2 )=9 , f ( 5 )=1335NDDF for 4 :


P4 ( x )=f 0 + ( x−x 0 ) f [ x 0 , x 1 ] + ( x−x 0 ) ( x−x 1 ) f [ x 0 , x 1 , x 2 ] + ( x−x 0 ) ( x−x 1 )( x−x 2) f [ x 0 , x 1 , x 2 , x 3 ]+ ( x−x 0 )( x−x 1) ( x

f ( x )=1245+ ( x+ 4 )(−404 ) + ( x +4 ) ( x+1 )( 94 ) + ( x+ 4 )( x +1 ) x (−14 ) + ( x+ 4 )( x +1 ) x ( x−2 ) ( 3 )


4 3 2
¿ 3 x −5 x +6 x −14 x +5
Example

f (−2 )=9 , f (−1 )=16 , f ( 0 )=17 , f (1 )=18 , f ( 3 )=44 , f ( 4 ) =81 Interpolate at x=0.5 , x=3.1

as 4 th∧5 th dd are 0
P ( x )=f 0+ ( x−x 0 ) f [ x 0 , x 1 ] + ( x−x 0 ) ( x−x 1) f [ x 0 , x 1 , x 2 ]+ ( x−x 0 )( x −x1 ) ( x−x 2 ) ( x−x 3 ) f [ x 0 , x 1 , x 2 , x 3 ]
¿ 9+ ( x +2 ) 7+ ( x +2 ) ( x+1 )(−3 ) + ( x +2 ) ( x+ 1 ) x ¿ x 3+ 17
3 3
Hence , f ( 0.5 )=0.5 +17=17.125f ( 3.1 ) =3.1 + 17=47.791

Example

f ( 1 ) =3 , f ( 3 )=31 , f ( 4 )=69 , f (5 )=131 , f ( 7 )=351, f ( 10 )=1011 find f ( 3.5 ) , f ( 8 ) , f ' ( 3 ) ∧f ' ' (1.5)

As 4 th dd is 0
f ( x )=f 0 + ( x−x 0 ) f [ x 0 , x1 ]+ ( x−x 0 ) ( x−x 1 ) f [ x 0 , x 1 , x 2 ] + ( x−x 0 ) ( x−x 1 ) ( x−x 2 )( x−x3 ) f [ x 0 , x 1 , x 2 , x 3 ]
¿ 3+ ( x−1 ) 14+ ( x −1 )( x−3 ) 8+ ( x−1 )( x−3 )( x−4 ) 1
2 3 2 3 ' 2 ''
¿ 3+14 x−14 +8 x −32 x+24 + x −8 x + 19 x −12¿ x + x+1→ f =3 x +1 , f =6 x
3 3 ' ''
→ f ( 3.5 )=3.5 + 3.5+1=47.375 , f ( 8 )=8 + 8+1=521f ( 3 ) =3 ( 9 ) +1=28 , f ( 1.5 )=6 ( 1.5 ) =9
Interpolation with Evenly Spaced Points
FORWARD DIFFERENCE
∆ f ( x n+ h )=f n +1∆ f n=f n +1−f n∆ 2 f n=∆ f n +1−∆ f n=f n+ 2−2 f n +1+ f n
3 2 2
∆ f n=∆ f n +1−∆ f n=f n+3−2 f n+2 + f n+1 −( f n+2−2 f n+1 +f n )¿ f n+3−3 f n+ 2+3 f n+1−f n
0
→ ∆ f n is of a similar form ¿ : ( x− y ) → ∆ f n=∑ (−1 ) a f n +k
a a

k=a
a k

k ()

BACKWARD DIFFERENCE
∇ f n=f n −f n−1∇ 2 f n=∇ f n−∇ f n−1=f n−f n−1−f n−1+ f n −2=f n −2 f n−1 +f n−2
3 2 2
∇ f n=∇ f n−∇ f n−1=f n−2 f n−1 + f n−2−( f n−1−2 f n−2+ f n−3 )¿ f n−3 f n−1+3 f n−2−f n−3
n
→ ∆a f n=∑ (−1 ) a f n−k
k=a
k

k ()
Newton’s Forward Difference Interpolation Formula
1
f [ x 0 , x1 , … , xn ]=
n
n
∆ f 0¿ Newto n' s Divided difference
n!h
2 n
∆f0 ∆ f0 ∆ f0
f ( x )=f 0 + ( x−x 0 ) + ( x −x0 ) ( x−x 1 ) 2
+…+ ( x −x 0 )( x −x1) … ( x−x n−1 ) n
h 2h n! h
( x−x 0 ) ∆ f 0 ( x−x 0 ) ( x−x 1 ) ∆2 f 2
E . g .: f 2 ( x )=f 0 + +
h 2 h2

Newton’s Backward Difference Interpolation Formula


1
f [ x n , x1 , … , xn ]=
n
n
∇ f 0¿ Newto n' s Divided difference
n!h
2 n
∇fn ∇ fn ∇ fn
f ( x )=f n + ( x−x n ) + ( x −x n) ( x− xn −1 ) 2
+…+ ( x−x n )( x−x n−1) … ( x−x 0 ) n
h 2h n!h
( x−x 0 ) ∇ f n ( x−x 0 ) ( x−x 1 ) ∇ 2 f n
E . g .: f 2 ( x )=f n + +
h 2 h2
x−x n=sh , x−x n−1=( s +1 ) h , x −xn −i =( s +i ) h
( s )( s+1 ) ∇ 2 f n ( s ) ( s +1 ) ( s+ 2 ) ∇3 f n n
∇ fn
→ f ( x )=f n +s ∇ f n+ + +…+ s ( s+1 ) … ( s+n )
2 3! n!
Example
f ( 0.1 )=1.4 , f ( 0.2 ) =1.56 , f ( 0.3 ) =1.76 , f ( 0.4 )=2 , f ( 0.5 )=2.28 h=0.1Forward difference

x f (x) ∆f ∆ f
2
∆ f
3
∆ f
4

0.1 1.4
0.2 1.56 0.16
0.3 1.76 0.2 0.04
0.4 2 0.24 0.04 0
0.5 2.28 0.28 0.04 0 0

( 0.1 ) ( 0.02 )
2
( x−x 0 ) ∆ f 0 ( x−x 0 ) ( x−x 1 ) ∆ f 0 ¿ 1.4+ ( x−0.1 ) 0.16 + ( x−0.1 )( x−0.2 ) 0.04
f ( x )=f 0 + + 2
h 2h
2
¿ 2 x + x +1.28
Backward

x f (x) ∇f ∇ f
2
∇ f
3
∇ f
4

0.1 1.4
0.2 1.56 0.16
0.3 1.76 0.2 0.04
0.4 2 0.24 0.04 0
0.5 2.28 0.28 0.04 0 0

( 0.1 ) ( 0.02 )
2
( x−x n ) ∇ f n ( x−x n ) ( x−x n−1 ) ∇ f 0 ¿ 2.28+ ( x−0.5 ) 0.28 + ( x−0.5 ) ( x−0.4 ) 0.04
f ( x )=f n + + 2
h 2h
¿ 2 x + x +1.28→ f ( 0.25 ) =1.655 , f ( 0.35 )=1.875
2

2 : x=1 , f ( 0.1 )=−1.699 , f ( 0.3 )=−1.073 , f ( 0.5 )=−0.375 , f ( 0.7 )=0.443 , f ( 0.9 )=1.429
f ( 1.1 ) =2.631 withbackward h=0.2

x f (x) ∇f 2
∇ f
3
∇ f
4
∇ f
5
∇ f
0.1 -1.699
0.3 -1.073 0.62
6
0.5 -0.375 0.69 0.072
8
0.7 0.443 0.81 0.12 0.04
8 8
0.9 1.429 0.98 0.168 0.04 0
6 8
1.1 2.631 1.20 0.216 0.04 0 0
2 8
2 3
∇fn ∇ fn ∇ fn
f ( x )=f n + ( x−x n ) + ( x −x n) ( x− xn −1 ) 2
+ ( x−x n ) ( x−x n−1 ) ( x−x n−2 ) 3
h 2h 3! h
( x−1.1 ) 1.202 ( x−1.1 ) ( x−0.9 ) 0.216 ( x−1.1 )( x−0.9 ) ( x −0.7 ) 0.048
f ( x )=2.631+ + +
0.2 2 ( 0.2 )
2
3 ( 0.2 )
3

f ( x )=2.631+ 6.01 ( x−1.1 )+2.7 ( x−1.1 )( x−0.9 )+ ( x−1.1 )( x−0.9 ) ( x −0.7 )


f ( 1 ) =2.631+6.01 (−0.1 ) +2.7 (−0.1 ) 0.1+ (−0.1 ) ( 0.1 ) (−0.3 )=2.004
NUMERICAL DIFF
'
F rom Newto n s Divided difference
2 n
∆f0 ∆ f0 ∆ f0
f ( x )=f 0 + ( x−x 0 ) + ( x −x0 ) ( x−x 1 ) 2
+…+ ( x −x 0 )( x −x1 ) … ( x−x n−1 ) n
Set x=x 0 +sh
h 2h n! h
1 2 1 n
f ( x )=f ( x 0 +sh )=f 0 + s ∆ f 0 + s ( s−1 ) ∆ f 0 + …+ s ( s−1 ) ( s−2 ) … ( s−n+1 ) ∆ f 0
2 n!
x−x 0 ds 1 df 1 df 1
s= → = = = ¿
h dx h dx h ds h

Example:
'
find y at x=1 :

x y ∆y 2
∆ y
3
∆ y
1 1
2 8 7
3 27 19 12
4 64 37 18 6
h=1 , x 0=1 → x=x 0+ sh=1+s → x=1 → s=0
dy
dx
1
h ( 1
2
1
3
1
2
1
)
→ ( 1 )= ∆ f 0− ∆ 2 f 0 + ∆ 3 f 0 =7− (12 )+ ( 6 )=3
3

NUMERICAL INTEGRATION
Trapezium/Trapezoidal Rule
' 1
¿ Newto n s Forward difference formula :f ( x )=f 0 + ( x−x 0 ) ∆ f ( x0 )
h
let x 0=a , x 1=b , h=b−a=x 1−x 0
b x1 x
∆f0 x
a 0x
( 1
h )
→ I =∫ f ( x ) dx=∫ f 0 + ( x−x 0 ) ∆ f 0 dx=f 0∫ dx +
x
h ∫ x
( x−x 0 ) dx
∆f0 ∆f 0 h h h b−a
¿ ( x 1−x 0 ) f 0+
2h
[ ( x−x 0 ) ]x =( x1 −x0 ) f 0 +
2 x
1

0
2h 1 0
2
( x −x ) =h f 0 + 2 ∆ f 0=h f o + 2 ( f 1−f 0 )= 2 [ f 1 + f 0 ]= 2 ( f ( b )+
Error
b b
b−a
R ( f , x )=∫ f ( x ) dx−I f ( x )=1 : R ( f , x )=∫ dx − ( 2 )=b−a−( b−a )=0
a a 2
b
b−a 1 1
f ( x )=x : R ( f , x )=∫ x dx− ( b+ a )= ( b2−a2 )− ( b 2−a 2) =0 f ( x )=x 2 : R ( f , x )=∫
a 2 2 2

Composite trapezium rule


b x x1 xN
b−a
h= , b=x N , a=x 0∫ f ( x ) dx=∫ f ( x ) x=∫ f ( x ) dx +…+ ∫ f ( x ) dx
N a x x x 0 N −1

h h
¿ [ ( f 0 + f 1 ) + ( f 1+ f 2 ) +…+ ( f N−1 + f N ) ]= [ f 0 +2 ( f 1+ f 2 +…+ f N−1 ) + f N ]
2 2

Example 3.11 Derive the trapezium rule using the Lagrange linear interpolating polynomial

x−b x−a x ( f ( b )−f ( a ) ) +bf ( a )−af ( b )


Lagrange : f ( x )= f ( a) + f ( b )=
a−b b−a b−a

( )
b b 2 2
1 1 b −a
I =∫ f ( x ) dx= ∫ x ( f ( b ) −f ( a ) ) +bf ( a ) −af ( b ) dx = ( f ( b ) −f ( a ) ) + ( b−a ) ( bf ( a )−af ( b ) )
a b−a a b−a 2
( b+a ) b−a
¿ ( f ( b )−f ( a ) ) +bf ( a )−af ( b )= ( f ( b) + f ( a) )
2 2

1
dx
Example 3.12 Find the approximate value of I =∫ , using the trapezium rule with 2, 4 and 8
0 1+ x
equal subintervals. Using the exact solution, find the absolute errors.

b−a 1 1
Taking a=0 , b=1h= = , nodes are N +1N=2: , nodes : 0 ,0.5 ,1
N N 2
1 1
N=4 : , 0 , 0.25 , 0.5 , 0.75 ,1N=8: , 0 , 0.125 ,0.25 , 0.375 , 0.5 , 0.675 , 0.75 , 0.875 ,1
4 8
1
f ( x )=
1+ x
N=2, x 0 0.5 1
f (x) 1 0.667 0.5
N=4 , x 0 0.25 0.5 0.75 1
f (x) 1 0.8 0.667 0.5714 0.5

N=8 , x 0 0.125 0.25 0.5 0.75 0.875 1


f (x) 1 0.8889 0.8 0.667 0.5714 0.5333 0.5

h
N=2: I 1= ( f 0 +2 f 1 + f 2 )=0.25 [ 1+2 ( 0.667 )+ 0.5 ] =0.708334
2
h
N=4 : I 2= ( f 0 +2 f 1 +2 f 2+2 f 3+ f 4 )=0.125 [ 1.0+2 {0.8+ 0.667+0.571429 }+0.5 ] =0.697024
2
h
N=8: I 3= ( f 0+ 2 f 1+ 2 f 2 +2 f 3 +2 f 4 +2 f 5 +2 f 6 + 2 f 7 +f 8 )=0.0625 [ 1.0+2 { 0.888889+0.8+ 0.727273+0.666667
2
The exact value of the integral is I =ln2=0.693147The errors ∈the solutions are the following :
|Exact – I 1|=|0.693147 – 0.708334|=0.015187|Exact – I 2|=|0.693147 – 0.697024|=0.003877
|Exact – I 3|=|0.693147 – 0.694122|=0.000975

2
dx
Evaluate I = ∫ with 4 and 8 subintervals using the trapezium rule. Compare with the exact
1 5+3 x
solution and find the absolute errors in the solutions. Comment on the magnitudes of the errors
obtained. Find the bound on the errors

b−a 1 1
h= = N=4 :h= . The nodes are 1 , 1.25 ,1.5 , 1.75 , 2
N N 4
1
N=8: h= .nodes are 1 ,1.125 , 1.25 , 1.375 ,1.5 , 1.675 , 1.75 ,1.875 , 2.0
8
N=4 , x 1 1.25 1.5 1.75 2
f (x) 0.12 0.114286 0.105263 0.101266 0.094118
5

N=8 , x 1 1.25 1.375 1.5 1.75 1.875 2


f (x) 0.125 0.114286 0.109589 0.105263 0.101266 0.097561 0.094118

Simpson’s 1/3 rule


1 1 2
f ( x )=f 0 + ( x −x 0 ) ∆ f 0 + 2 ( x−x 0 ) ( x−x 1 ) ∆ f 0
h 2h

h
I = ( f 0+ 4 f 1+ f 2)→
3
b−a
6 [
f ( a )+ 4 f
a+b
2 ( )
+f 2
]
Composite Simpson’s 1/3 rule
h
I = ( f 0 + 4 { f 1+ f 3 +…+ f 2 N−1 } +…+2 { f 2 +f 4 +…+ f 2 N −2 }+ f 2 N )
3

Least Squares Methods


Straight-Line Method
Derivation:
y ≈ y λ =a+ b x1 , … , y λ =a +b x ne 1=| y 1− y λ | ,… , e n= y n − y λ = y n −a−b x n
1 n 1 n

n n
∂S ∂S
∑ of squares , S=∑ e 2i =∑ ( y i−a−b x i )2 By principles of least squares : ∂ a = ∂ b =0
i=1 i=1

∂S ∂S 2
→ =−2 ( y i−a−b x i ) =0 → y i =a+b x i→ → =−2 xi ( y i−a−b x i ) =0 → x i yi =a x i+ b xi
∂a ∂b
2
→ Σ y=na+b Σ x , Σ xy =a Σ x +b Σ x
Parabola Method
Derivation: [Must be done in exam]
n n

Let y =a+bx +c x y λ =a+b x n +c xn e n= y n −( a+ b x n+ c x n )→ S=∑ ei =∑ ( y i−a−b x i−c x i )


2 2 2 2 2 2
n
i=1 i=1

∂ S ∂S ∂S ∂S
=−2 ( yi −a−b x i−c x i ) =0 → Σ y=na+ b Σ x +c Σ x
2 2
Principle: = = =0→
∂a ∂b ∂c ∂a
∂S
=−2 x i ( y i−a−b x i−c xi ) =0 → Σ xy=a Σ x +b Σ x+ c Σ x
2 2

∂b
∂S
=−2 x i ( y i−a−b x i−c x i )=0→ Σ x y=a Σ x + b Σ x +c Σ x
2 2 2 2 3 4
∂c

Examples
Find thebest −fit values of a∧b so that y =a+bx
x y xy x
2

0 1 0 0
1 1.8 1.8 1
2 3.3 6.6 4
3 4.5 13.5 9
4 6.3 25.2 16
Σ x =10 Σ y=16.9 Σ xy =47.1 2
Σ x =30
Eqns : Σ y=na+ b Σ x , Σ xy =a Σ x+ b Σ x 2

 One Q: Lagrange, Forward difference, Backward difference


 Numerical differentiation
 Simpsons’ 1/3 rule
 Parabola method
Change of Scale
( x−x 0 )
u= , v= y− y 0 , ( his the interval )
h
x−( middle term ) x−( middle of two middle terms )
if n is odd :u= ,if nis even :u=
h 0.5 h
Equations become Σu=na+ b Σv
Example

x−12.5
u= , v= y−20
2.5
x y u v uv u
2

0 12 -5 -8 40 25
5 15 -3 -5 15 9
10 17 -1 -3 3 1
15 22 1 2 2 1
20 24 3 4 12 9
25 30 5 10 50 25
Σu=0 Σ v=0 Σ uv=122 2
Σ u =70
0=6 a+ 0b → a=0122=0 a+70 b → b=1.743→ v=1.743 u

→ ( y−20 ) =1.743
x−12.5
2.5 ( )
→ y−20=0.697 x−8.7142→ y=0.697 x +11.29

x y u=x−1933 v= y−358 uv u
2
u v
2
u
3
u
4

1929 352 -4 -6
1930 356 -3 -2
1931 357 -2 -1
1932 358 -1 0
1933 360 0 2
1934 361 1 3
1935 361 2 3
1936 360 3 2
1937 359 4 1
0 2 51 60 -69 0 708
Σv=na+b Σ u+c Σ u →2=9 a+60 c− [ 1 ] Σ uv=a Σu+ b Σ u + c Σu → 51=60 b → b=0.85
2 2 3

Σ u v=a Σ u +b Σu + c Σ u →−69=60 a+708 c− [ 2 ]


2 2 3 4

20 247
( Eqn 1 )−Eqn2 → =−648 c → c=−0.2673→ a=2.004→ v=2.004 +0.85 u−0.2673 u2
3 3
2
→ y−358=2.004+0.85 ( x−1933 )−0.27 ( x−1933 ) y=−1010135.076+1044.67 x−0.27 x 2
2 2 3 2 2 3 4
Σ y=na+ b Σ x +c Σ x Σ xy =a Σ x+ b Σ x + c Σ x Σ x y=a Σ x + b Σ x +c Σ x

You might also like