Mts202 Note by RCF Futa
Mts202 Note by RCF Futa
MTS 202
NUMERICAL ANALYSIS 1
Contents
o Error analysis
o Approximation
o Transcendental equations
o Systems of linear equations
For more info, call: 08139279193 or 090331701334 or visit RCF FUTA, academic unit
2
For more info, call: 08139279193 or 090331701334 or visit RCF FUTA, academic unit
3
Inherent Error: this is the error which is already present in the given data
Computational Error: this is the error committed due to the use of computing aids. It is also
known as round off error.
Human Error: this is the error committed in the process of measurement, collection and
computation of data.
2.0. APPROXIMATION
Some methods of approximation are as follows:
Solution
1
𝑓(𝑥) = = (𝑥 − 1)−1⁄2
(𝑥 − 1)1⁄2
1 3 5
𝑓 ∗ (4) = (4)−1⁄2 + (4)−3⁄4 + (4)−5⁄2 + (4)−7⁄2 + ⋯
2 8 16
901
= = 0.577194106
1561
1 1
𝑓(4) = 1 ⁄2
= = 0.577350269
(4 − 1) √3
= 2.70 × 10−4
EXERCICES
For more info, call: 08139279193 or 090331701334 or visit RCF FUTA, academic unit
4
This is a series for expressing functions which have no polynomial in a polynomial form. The
Taylor series expansion for the function 𝑓(𝑥) about a point 𝑥 = 𝑎is given as:
This is a division of Taylor series expansion only about the point 𝑥 = 0. The
Maclaurin’s series expansion for the function 𝑓(𝑥) is given as:
𝑓 ′′ (0) 2 𝑓 ′′′ (0) 3 𝑓 𝑛 (0) 𝑛
𝑓(𝑥) = 𝑓(0) + 𝑥𝑓 ′ (0) + 𝑥 + 𝑥 + ⋯+ 𝑥
2! 3! 𝑛!
E.g. Evaluate 𝑓(5) using the first four terms of Maclaurin’s series expansion of 𝑓(𝑥) = 𝐼𝑛(1 + 𝑥).
Also calculate relative error.
Solution
1 1
𝑓 ′′ (𝑥) = − (1+𝑥)2 𝑓 ′′ (0) = − (1)2 = −1
2 2
𝑓 ′′′ (𝑥) = (1+𝑥)3 𝑓 ′′′ (0) = (1)3 = 2
(−1) 2 (2) 3
𝑓(𝑥) = (0) + 𝑥(1) +
𝑥 + 𝑥
2! 3!
1 1
= 𝑥 − 𝑥2 + 𝑥3
2 3
𝑔𝑖𝑣𝑒𝑛
1 1 205
𝑓 ∗ (5) = 5 − (5)2 + (5)3 = = 34.1666666667
2 3 6
Then 𝑓(5) = 𝐼𝑛 (1 + 5) = 𝐼𝑛 6 = 1.791759469
𝑓(5) − 𝑓 ∗ (5) 1.791759469 − 34.1666666667
𝑅𝑒𝑙𝑎𝑡𝑖𝑣𝑒 𝐸𝑟𝑟𝑜𝑟 = | |=| | = 18.06877974
𝑓(5) 1.791759469
For more info, call: 08139279193 or 090331701334 or visit RCF FUTA, academic unit
5
EXERCISES
There is no direct method for solving transcendental equations or higher order algebraic equations.
2. Numerical methods
Theorem: suppose the function 𝑓(𝑥) is continuous and defined in an interval I=[a,b]. We also
suppose that at least one of the roots of 𝑓(𝑥) lie within this interval. Then the value of 𝑓(𝑥) at x=a
and x=b must have positive signs such that
Given the interval I=[a, b], we calculate the value of 𝑓(𝑥) at the midpoint x0 of the interval
𝑎+𝑏
i.e. 𝑥0 = 2
For more info, call: 08139279193 or 090331701334 or visit RCF FUTA, academic unit
6
𝑓(𝑥) = 2𝑥 3 − 5
Solutions
𝑓(𝑥) = 2𝑥 3 − 5
𝑓(1) = 2(1)3 − 5 = −3
𝑓(2) = 2(2)3 − 5 = 11
Since𝑓(1)𝑓(2) = −33 < 0, then the root lies between the interval [1, 2]
𝑎+𝑏
𝑥1 = , 𝑎 = 1 𝑎𝑛𝑏 𝑏 = 2
2
1+2
=> 𝑥1 = = 1.5
2
𝑓(1.5) = 2(1.5)3 − 5 = 1.75
F(x)
Since𝑓(1)𝑓(1.5) = −5.25 < 0, then the root lies between the interval [1, 1.5]
1 + 1.5
𝑥2 = = 1.25
2
3
𝑓(1.25) = 2(1.25) − 5 = −1.09375
Since 𝑓(1.25)𝑓(1.5) − 1.91406 < 0, then the root lies between the interval [1.25, 1.5]
1.25 + 1.5
𝑥3 = = 1.375
2
𝑓(1.375) = 2(1.375)3 − 5 = 0.1992
Since 𝑓(1.25)𝑓(1.375) = −0.2179 < 0, then the root lies between the interval [1.25, 1.375]
Derivation of formula
For more info, call: 08139279193 or 090331701334 or visit RCF FUTA, academic unit
7
𝑓(𝑏)−𝑓(𝑎)
𝑚= 𝑏−𝑎
………3.3
𝑓(𝑎)−𝑐
From (3.1), we have 𝑚= 𝑎
………3.4
𝑓(𝑏)−𝑐
And from (3.2), we have 𝑚= 𝑏
………3.5
𝑓(𝑎)−𝑐 𝑓(𝑏)−𝑐
Equating 3.4 and 3.5, we have 𝑎
= 𝑏
𝑏(𝑎) − 𝑏𝑐 = 𝑎𝑓(𝑏) − 𝑎𝑐
𝑏𝑓(𝑎)−𝑎𝑓(𝑏)
𝑐= 𝑏−𝑎
……..3.6
𝑎𝑓(𝑏) − 𝑏𝑓(𝑎)
𝑥0 =
𝑓(𝑏) − 𝑓(𝑎)
Use the False position method to approximate the root of the following
a) 𝑓(𝑥) = 2𝑥 3 − 5
Try the starting the interval [1,2]
Solution
a) 𝑓(𝑥) = 2𝑥 3 − 5
𝑎𝑓(𝑏)−𝑏𝑓(𝑎)
Using 𝑥𝑜 = 𝑓(𝑏)−𝑓(𝑎)
where a=1 and b=2
Since 𝑓(1)𝑓(2) = −33 < 0, then the root lies between the interval [1,2]
(1)(11) − (2)(−3) 11 + 6
𝑥𝑜 = = = 1.21429
11 − (−3) 14
For more info, call: 08139279193 or 090331701334 or visit RCF FUTA, academic unit
8
Since 𝑓(1.21429)𝑓(2) < 0, then the root lies between the interval [1.21429,2]
Since 𝑓(1.304069)𝑓(2) < 0, then the root lies between the interval [1.304069, 2]
Since 𝑓(1.338046)𝑓(2) < 0, then the root lies between the interval [1.338046, 2]
(1.338046)(11) − (2)(−0.208813) 14.718506 + 0.417626
𝑥3 = = = 1.350378
11— (−0.208813) 11.208813
𝑓(𝑥3 ) = 𝑓(1.350378) = 2(1.350378)3 − 5 = −0.075115
Since 𝑓(1.350378)𝑓(2) < 0, then the root lies between the interval [1.350378, 2]
Since 𝑓(1.354784)𝑓(2) < 0, then the root lies between the interval [1.350378, 2]
A more poplar iteration developed initially by Newton and later modified by Raphson. This method is
only applicable to a differentiable function and it is a more efficient procedure for evaluating the root
of equation 𝑓(𝑥) = 0
Given 𝑓(𝑥) = 0
Where 𝑓(𝑥) is differentiable about 𝑥0 , then the Taylor series expansion for 𝑓(𝑥) is given as:
𝑓 ′′ (𝑥0 ) 𝑓 𝑛 (𝑥0 )
𝑓(𝑥) = 𝑓(𝑥0 ) + (𝑥 − 𝑥0 )𝑓 ′ (𝑥0 ) + (𝑥 − 𝑥0 )2 + ⋯ + (𝑥 − 𝑥0 )𝑛
2! 𝑛!
Assume that (𝑥 − 𝑥0 ) is small, then we neglect order 2 and above. Approximating 𝑓(𝑥) = 0, we have
For more info, call: 08139279193 or 090331701334 or visit RCF FUTA, academic unit
9
𝑓(𝑥0 )
𝑥 = 𝑥0 −
𝑓 ′ (𝑥0 )
Generally,
𝑓(𝑥𝑛 )
𝑥𝑛+1 = 𝑥𝑛 −
𝑓 ′ (𝑥𝑛 )
Use the Newton-Raphson’s method to obtain the root of the equation 𝑥 3 − 𝑥 2 − 𝑥 − 1 = 0 within the
interval 1.6 < 𝑥 < 2.1
Solution
𝑓(𝑥) = 𝑥 3 − 𝑥 2 − 𝑥 − 1
Since 𝑓(1.6). 𝑓(2.1) < 0, then the root lies within the interval (1.6, 2.1)
2.1 + 1.6
𝑥0 = = 1.85
2
𝑓 ′ (𝑥) = 3𝑥 2 − 2𝑥 − 1
𝑓(𝑥0 )
𝑥1 = 𝑥0 −
𝑓 ′ (𝑥0 )
0.059125
𝑥1 = 1.85 − = 1.83938
5.5675
Iteration continues till
THEOREM: Let 𝑥 = 𝑥0 be the zero (solution) of f(x) =0 and I be an interval containing the point 𝑥 =
𝑥0 . Let 𝜑(𝑥)𝑎𝑛𝑑 𝜑′ (𝑥) be define and continuous in the Interval I, the arrangement of f(x) =0 be
For more info, call: 08139279193 or 090331701334 or visit RCF FUTA, academic unit
10
defined as 𝑥𝑖 = 𝜑𝑖(𝑥) , (𝑖 = 1,2,3 … . ) then if | 𝜑(𝑥)| < 𝑘 for all𝑥 ∈ 𝐼, 𝑘 < 1, the sequence {xk}
converges to the point x0.
Solution
We get the possible arrangement by making the x in 𝑥 2 − 2𝑥 − 8 = 0 subject of the formula i.e.
1. 2𝑥 = 𝑥 2 − 8
𝒙𝟐 −𝟖
𝒙𝟏 = 𝟐 = 𝝋𝟏 (𝒙)
2
2. 𝑥 = 2𝑥 + 8
𝒙𝟐 = √𝟐𝒙 + 𝟖 = 𝝋𝟐 (𝒙)
3. 𝑥 2 = 2𝑥 + 8 (divide both sides by x)
𝟐𝒙−𝟖
𝒙𝟑 = 𝒙
= 𝝋𝟑 (𝒙)
4. 𝑥(𝑥 − 2) = 8
𝟖
𝒙𝟒 = 𝒙−𝟐 = 𝝋𝟒 (𝒙)
5. 𝑥 2 − 2𝑥 = 8
𝑥 2 − 2𝑥 + 𝑥 = 8 + 𝑥
𝑥2 − 𝑥 = 8 + 𝑥
𝑥(𝑥 − 1) = 8 + 𝑥
𝟖+𝒙
𝒙𝟓 = (𝒙−𝟏) = 𝝋𝟓 (𝒙)
Putting x=5 into the arrangements
𝟓𝟐 −𝟖 𝟐𝟓−𝟖
1. 𝜑1 (𝑥) = 𝟐
= 𝟐
= 8.5
2. 𝜑2 (𝑥)=√2(5) + 8 = √18 = 4.2426
2(5)−8
3. 𝜑3 (𝑥) = 5
= 0.25
8
4. 𝜑4 (𝑥) = 5−2
= 2.6667
8+5
5. 𝜑5 (𝑥) = (5−1)
= 0.75
⋮ ⋮ ⋮ ⋮ ⋮
The example above is a system of m linear equation with n unknowns (where 𝑛, 𝑚 ∈ 𝑅) and it can be
written in mayrix form as:
𝐴𝑋 = 𝐵
For more info, call: 08139279193 or 090331701334 or visit RCF FUTA, academic unit
11
Where; A= matrix of the coefficients 𝑎𝑖𝑗 (𝑖 = 1,2,3, … , 𝑛 & 𝑗 = 1,2,3, … , 𝑚)., X= matrix of the
unknown 𝑥𝑖 (𝑖 = 1,2,3, … , 𝑛) and B= matrix of the constants 𝑏𝑗 (𝑗 = 1,2,3, … , 𝑚),
Then we have
𝑎11 𝑎12 𝑎13 … 𝑎1𝑛 𝑥1 𝑏1
𝑎21
( … 𝑎22 𝑎23 …
… … 𝑎 𝑥 𝑏
2𝑛 ) ( 2 ) = ( 2 )
… … … …
𝑎𝑚1 𝑎𝑚2 𝑎𝑚3 . . 𝑎𝑚𝑛 𝑥3 𝑏𝑚
A. Direct method
a. Matrix inversion
b. Crammers’ rule
c. Gauss’ or Gaussian elimination method
d. Gauss Jordan method
e. Choleski’s method (L-U decomposition)
B. Indirect or iterative method
a. Jacobi (Gauss-Jacobi) method
b. Gauss-Siedel method
A. DIRECT METHOD
𝐴𝑋 = 𝐵
For more info, call: 08139279193 or 090331701334 or visit RCF FUTA, academic unit
12
Solution
1 2 −6 𝑥1 5
(2 −4 5 ) (𝑥2 ) = (6)
3 −16 9 𝑥3 4
1 2 −6
Det A = |𝐴| = [2 −4 5 ] = (−36 + 80) − 2(18 − 15) − 6(−32 + 12) = 44 − 6 + 120
3 −16 9
= 158
−36 + 80 18 − 5 −32 + 12 44 3 −20
𝑚𝑖𝑛𝑜𝑟 𝑜𝑓 𝐴 = ( 18 − 96 9 + 18 −16 − 6 ) = (−78 27 −22)
10 − 24 5 + 12 −4 − 4 −14 17 −8
44 3 −20 + − + 44 −3 −20
𝑐𝑜𝑓𝑎𝑐𝑡𝑜𝑟 𝑜𝑓 𝐴 = (−78 27 −22) (− + −) = ( 78 27 22 )
−14 17 −8 + − + −14 −17 −8
44 78 −14
𝑎𝑑𝑗𝑜𝑖𝑛𝑡 𝑜𝑓 𝐴 = ( −3 27 −17)
−20 22 −8
22 39 7
−
79 79 79
1 1 44 78 −14 3 27 17
𝐴−1 = × Adjoint of A = × ( −3 27 −17) = − −
|𝐴| 158 158 158 158
−20 22 −8
10 11 4
−
( 79 −
79 79 )
22 39 7 110 + 234 − 28
− 4
79 79 79 5 79 1
−1 3 27 17 6 −15 + 162 − 68
𝑋=𝐴 𝐵= − − ( )= = 2
158 158 158 4 158 20
10 11 4 −50 + 66 − 36
( − 79 − (79)
79 79 ) ( 79 )
1 20
𝑥1 4 , 𝑥2 = , 𝑥3 =
2 79
4.2.2. CRAMMERS’ RULE
For more info, call: 08139279193 or 090331701334 or visit RCF FUTA, academic unit
13
2𝑥1 + 𝑥2 − 5𝑥3 + 𝑥4 = 8
𝑥1 − 3𝑥2 − 6𝑥4 = 9
2𝑥2 − 𝑥3 + 2𝑥4 = −5
Solution
= 72 − 2 − 50 + 7
∆= 27
Replace the first column of matrix A by matrix B and calculate the determinant of the resulting matrix
∆𝑥1
8 1 −5 1
∆𝑥1 = | 9 −3 0 −6|
−5 2 −1 2
0 4 −7 6
−3 0 −6 9 0 −6 9 −3 −6 9 −3 0
∆𝑥1 = 8 | 2 −1 2 | − |−5 −1 2 | − 5 |−5 2 2 | − |−5 2 −1|
4 −7 6 0 −7 6 0 4 6 0 4 −7
= 8[−3(−6 + 14) − 0 − 6(−6 + 14)] − [9(−6 + 14) − 0 − 6(35 − 0)]
− 5[9(12 − 8) + 3(−30 − 0) − 6(−20 − 0)] − [9(−14 + 4) + 3(35 − 0) + 0]
∆𝑥1 = 81
For more info, call: 08139279193 or 090331701334 or visit RCF FUTA, academic unit
14
Replace the second column of matrix A by matrix B and calculate the determinant of the resulting
matrix ∆𝑥2
2 8 −5 1
∆𝑥2 = |1 9 0 −6|
0 −5 −1 2
1 0 −7 6
9 0 −6 1 0 −6 1 9 −6 1 9 0
= 2 |−5 −1 2 | − 8 |0 −1 2 | − 5 | 0 −5 2 | − |0 −5 −1|
0 −7 6 1 −7 6 1 0 6 1 0 −7
= 2[9(−6 + 14) − 0 − 6(35 − 0)] − 8[(−6 + 14) − 0 − 6(0 + 1)]
= −276 − 16 + 210 − 26
∆𝑥2 = −108
Replace the third column of matrix A by matrix B and calculate the determinant of the resulting
matrix ∆𝑥3
2 1 8 1
∆𝑥3 = |1 −3 9 −6|
0 2 −5 2
1 4 0 6
−3 9 −6 1 9 −6 1 −3 −6 1 −3 9
= 2 | 2 −5 2 | − |0 −5 2 | + 8 |0 2 2 | − |0 2 −5|
4 0 6 1 0 6 1 4 6 1 4 0
2[−3(−30 − 0) − 9(12 − 8) − 6(0 + 20)]— [(−30 − 0) − 9(0 − 2) − 6(0 + 5)]
= −132 + 42 + 80 − 17
∆𝑥3 = −27
Replace the fourth column of matrix A by matrix B and calculate the determinant of the resulting
matrix ∆𝑥4
2 1 −5 8
∆𝑥4 = |1 −3 0 9|
0 2 −1 −5
1 4 −7 0
−3 0 9 1 0 9 1 −3 9 1 −3 0
= 2 | 2 −1 −5| − |0 −1 −5| − 5 |0 2 −5| − 8 |0 2 −1|
4 −7 0 1 −7 0 1 4 0 1 4 −7
= 2[−3(0 − 35) − 0 + 9(−14 + 4)] − [(0 − 35) − 0 + 9(0 + 1)]
− 5[(0 + 20) + 3(0 + 5) + 9(0 − 2)] − 8[(−14 + 4) + 3(0 + 1) + 0]
For more info, call: 08139279193 or 090331701334 or visit RCF FUTA, academic unit
15
30 + 26 − 85 + 56
∆𝑥4 = 27
∆𝑥1 81
𝑥1 = = =3
∆ 27
∆𝑥2 108
𝑥2 = =− = −4
∆ 27
∆𝑥3 27
𝑥3 = =− = −1
∆ 27
∆𝑥4 27
𝑥4 = = =1
∆ 27
4.2.3. GAUSS’ (GAUSSIAN ELIMINATION) METHOD
This method is used to solve a system of linear equations by transforming it to an upper triangular
matrix using elementary row operations. The resulting matrix is then solved using the backward
substitution method. The elementary row operations are:
Solution
5 −2 3 ⋮ 0 𝑅1 5 −2 3 ⋮ 0 𝑅1 5 −2 3 ⋮ 0
(22 1 −4 ⋮ −7) ~ 5𝑅2 − 2𝑅1 ( 0 9 −26 ⋮ 35 ) ~ 𝑅2 ( 0 9 −26 ⋮ −35 )
3 −8 4 ⋮ 9 5𝑅3 − 3𝑅1 0 −34 11 ⋮ 45 9𝑅3 + 34𝑅2 0 0 −785 ⋮ −785
−785𝑥3 = −785
𝑥3 = 1
For more info, call: 08139279193 or 090331701334 or visit RCF FUTA, academic unit
16
This is an improvement of Gaussian elimination method and it provides an easy way of obtaining
results of system of equations. It reduces the matrix A of the system AX=B to a diagonal matrix by
using the echelon reduction process
𝑥1 + 2𝑥2 + 𝑥3 = 8
2𝑥1 + 3𝑥2 + 4𝑥3 = 20
Solution
1 2 1 ⋮ 8 𝑅1 1 2 1 ⋮ 8
(2 3 4 ⋮ 20) ~ 2𝑅1 − 𝑅2 (0 1 −2 ⋮ −4 )
4 3 2 ⋮ 16 4𝑅1 − 𝑅3 0 5 2 ⋮ 16
𝑅1 1 2 1 ⋮ 8 𝑅1 1 2 1 ⋮ 8
~ 𝑅2 (0 1 −2 ⋮ −4) ~ 𝑅 2 (0 1 −2 ⋮ −4)
𝑅3 − 5𝑅2 0 0 12 ⋮ 36 𝑅3 /12 0 0 1 ⋮ 3
𝑅1 − 𝑅3 1 2 0 ⋮ 5 𝑅1 − 2𝑅2 1 0 0 ⋮ 1
~ 𝑅2 + 2𝑅2 (0 1 0 ⋮ 2) ~ 𝑅2 (0 1 0 ⋮ 2)
𝑅3 0 0 1 ⋮ 3 𝑅3 0 0 1 ⋮ 3
𝑥1 = 1, 𝑥2 = 2 and 𝑥3 = 3
This method is sometimes called L-U decomposition (i.e. lower-upper triangular matrix
decomposition). In this method, we
Decompose matrix A in the system AX=B into the products of lower triangular matrix L and
upper triangular matrix U, using
𝐿𝑈 = 𝐴
Now solve the system of triangular matrices
𝐿𝑌 = 𝐵 𝑎𝑛𝑑 𝑈𝑋 = 𝑌
For more info, call: 08139279193 or 090331701334 or visit RCF FUTA, academic unit
17
Solution
𝐿21 𝑈12 + 𝑈22 = 2.15 => 𝑈22 = 2.15 − (1.67213 × 1.23) = 0.09328
𝐿21 𝑈13 + 𝑈23 = −5.51 => 𝑈23 = −5.51 − (1.67213 × 17.2) = −34.27064
4.34
𝐿31 𝑈11 = −4.34 => 𝐿31 = − 0.610 = −7.11475
11.2−(−7.11475×1.23)
𝐿31 𝑈12 + 𝐿32 𝑈22 = 11.2 => 𝐿32 = 0.09328
= 213.88446
𝐿𝑌 = 𝐵
1 0 0 𝑦1 0.792
( 1.67213 1 0) (𝑦2 ) = ( 12.0 )
−7.11475 213.88446 1 𝑦3 16.3
𝑦1 = 0.792
1.67213𝑦1 + 𝑦2 = 12.0
𝑦2 = 10.67567
For more info, call: 08139279193 or 090331701334 or visit RCF FUTA, academic unit
18
𝑦3 = −2261.42503
0.792
𝑇ℎ𝑎𝑡 𝑖𝑠 𝑌 = ( 10.67567 )
−2261.42503
𝐴𝑙𝑠𝑜 𝑈𝑋 = 𝑌
7448.087887𝑥3 = −2261.42503
2261.42503
𝑥3 = − = −0.30363
7448.087887
⋮ ⋮ ⋮ ⋮ ⋮
For more info, call: 08139279193 or 090331701334 or visit RCF FUTA, academic unit
19
1
𝑥2 = {𝑏 − (𝑎21 𝑥1 + 𝑎23 𝑥3 + ⋯ 𝑎24 𝑥𝑛 )}
𝑎22 2
⋮ ⋮ ⋮ ⋮ ⋮
1
𝑥𝑛 = {𝑏𝑚 − (𝑎𝑚1 𝑥1 + 𝑎𝑚2 𝑥2 + 𝑎𝑚3 𝑥3 + ⋯ 𝑎(𝑚−1)(𝑛−1) 𝑥𝑛 )}
𝑎𝑚𝑛
Substitute 𝑥1 (0) = 0, 𝑥2 (0) = 0 … 𝑥𝑛 (0) = 0 which forms the first set of the solution
The second set of solution (𝑥1 (1) , 𝑥2 (1) , … , 𝑥𝑛 (1) ) will be substituted into the normal form
The iteration goes on till:
o The required number of iteration
o |𝑥𝑛+1 − 𝑥𝑛 | < 𝐸
o The solutions converge
EXAMPLE (Tutorial sheet C – Q18)
17𝑥1 + 6𝑥2 + 𝑥3 = 85
𝑥1 + 𝑥2 + 22𝑥3 = 110
Solution
From (1),
1
𝑥1 = (85 − 6𝑥2 − 𝑥3 ) (18.1)
17
1
𝑥2 = (72 − 6𝑥1 + −2𝑥3 ) (18.2)
18
1
𝑥3 = (110−𝑥1 − 𝑥2 ) (18.3)
22
Putting (𝑥1 (0) , 𝑥2 (0) , 𝑥3 (0) )= (0, 0, 0) into (18.1) – (18.3), we have
1 86
𝑥1 (1) = (85 − 0 − 0) = =5
17 17
1 72
𝑥2 (1) = (72 − 0 − 0) = =4
18 18
1 110
𝑥3 (1) = (110 − 0 − 0) = = 5
22 22
Putting (𝑥1 (1) , 𝑥2 (1) , 𝑥3 (1) ) = (5,4,5) into (18.1) – (18.3), we have
1 56
𝑥1 (2) = [85 − 6(4) − 5] = = 3.29412
17 17
For more info, call: 08139279193 or 090331701334 or visit RCF FUTA, academic unit
20
1 32
𝑥2 (2) = [72 − 6(5) − 2(5)] = = 1.77778
18 18
1 101
𝑥3 (2) = (110 − 5 − 4) = = 4.59091
22 22
Putting (𝑥1 (2) , 𝑥2 (2) , 𝑥3 (2) ) = (3.29412,1.77778,4.59091) into (18.1) – (18.3), we have
1
𝑥1 (3) = [85 − 6(1.77778) − 4.59091] = 4.10249
17
1
𝑥2 (3) = [72 − 6(3.29412) − 2( 4.59091)] = 2.39186
18
1
𝑥3 (3) = (110 − 3.29412 − 1.77778) = 4.76946
22
Putting (𝑥1 (3) , 𝑥2 (3) , 𝑥3 (3) ) = (4.10249, 2.39186, 4.76946) into (18.1) – (18.3), we have
1
𝑥1 (4) = [85 − 6(2.39186) − 4.76946] = 3.87526
17
1
𝑥2 (4) = [72 − 6(4.10249) − 2( 4.76946)] = 2.10256
18
1
𝑥3 (4) = (110 − 4.10249 − 2.39186) = 4.70480
22
Putting (𝑥1 (4) , 𝑥2 (4) , 𝑥3 (4) ) = (3.87526, 2.10256, 4.70480) into (18.1) – (18.3), we have
1
𝑥1 (5) = [85 − 6(2.10256) − 4.70480] = 3.98117
17
1
𝑥2 (5) = [72 − 6(3.87526) − 2( 4.70480)] = 2.18549
18
1
𝑥3 (5) = (110 − 3.87526 − 2.10256) = 4.72828
22
It continues to the 9th iteration
For more info, call: 08139279193 or 090331701334 or visit RCF FUTA, academic unit
21
Since the of 𝑥 (7) 𝑎𝑛𝑑 𝑥 (8) are equal, then we stop at the 9th iteration and we pick
⋮ ⋮ ⋮ ⋮ ⋮
1
𝑥1 = {𝑏 − (𝑎12 𝑥2 + 𝑎13 𝑥3 + ⋯ 𝑎1𝑛 𝑥𝑛 )}
𝑎11 1
1
𝑥2 = {𝑏 − (𝑎21 𝑥1 + 𝑎23 𝑥3 + ⋯ 𝑎24 𝑥𝑛 )}
𝑎22 2
⋮ ⋮ ⋮ ⋮ ⋮
1
𝑥𝑛 = {𝑏 − (𝑎𝑚1 𝑥1 + 𝑎𝑚2 𝑥2 + 𝑎𝑚3 𝑥3 + ⋯ 𝑎(𝑚−1)(𝑛−1) 𝑥𝑛 )}
𝑎𝑚𝑛 𝑚
Substitute 𝑥2 (0) = 0 … 𝑥𝑛 (0) = 0 into the first normal equation and obtain 𝑥1 (1)
Substitute 𝑥1 (1) , 𝑥3 (0) = 0 … 𝑥𝑛 (0) = 0 into the first normal equation and obtain 𝑥2 (1) i.e.
use the updated value of each 𝑥 𝑖 .
Continue till:
o The required number of iteration
o |𝑥𝑛+1 − 𝑥𝑛 | < 𝐸
o The solutions converge
NOTE: Gauss-Siedel method uses the updated value of each 𝑥 𝑖 .
For more info, call: 08139279193 or 090331701334 or visit RCF FUTA, academic unit
22
Solution
1
𝑥1 = (8 − 0.2𝑥2 + 0.15𝑥3 ) (20.1)
5
1
𝑥2 = (6 − 0.05𝑥1 + 0.2𝑥3 ) (20.2)
4
1
𝑥3 = (2 − 0.03𝑥1 − 0.08𝑥2 ) (20.3)
6
Putting (𝑥1 (0) , 𝑥2 (0) , 𝑥3 (0) )= (0, 0, 0) into (20.1) – (20.3), we have
1 8
𝑥1 (1) = (8 − 0 + 0) =
5 5
𝑥1 (1) = 1.6
1 5.92
𝑥2 (1) = (6 − 0.05(1.6) + 0) =
4 4
𝑥2 (1) = 1.48
1 1.8336
𝑥3 (1) = (2 − 0.03(1.6) − 0.08(1.48)) =
6 6
𝑥3 (1) = 0.3056
Putting (𝑥1 (1) , 𝑥2 (1) , 𝑥3 (1) ) = (1.6, 1.48,0.3056) into (20.1) – (20.3), we have
1
𝑥1 (2) = [8 − 0.2(1.48) + 0.15(0.3056)] = 1.54997
5
1
𝑥2 (2) = [6 − 0.05(1.54997) + 0.2(0.3056)] = 1.49591
4
1
𝑥3 (2) = [2 − 0.03(1.54997) − 0.08(1.49591)] = 0.30564
6
Putting (𝑥1 (2) , 𝑥2 (2) , 𝑥3 (2) ) = (1.54997,1.49591,0.30564) into (20.1) – (20.3), we have
1
𝑥1 (3) = [8 − 0.2(1.49591) + 0.15(0.30564)] = 1.54933
5
1
𝑥2 (3) = [6 − 0.05(1.54933) + 0.2(0.30564)] = 1.49592
4
For more info, call: 08139279193 or 090331701334 or visit RCF FUTA, academic unit
23
1
𝑥3 (3) = [2 − 0.03(1.54933) − 0.08(1.49592)] = 0.30564
6
Since the value converges to four decimal places, then we conclude that
CURVE FITTING
Reading recorded values from a test or experiment normally include error of variouski9nd and
therefore, the point plotted from these data are scattered about the position they should ideally occupy.
Unless very few reading are taken, it can be assumed that the inherent error will be of a random nature
resulting in some of the value being slightly too low or too high.
Therefore, curve fitting deals with creation of functions from observed data. The least square
methods is a popular method for fitting curves.
The method of least square determine the best straight line entries by calculation, using the set
recorded results. The underlying idea of the least square approximation is to fit a polynomial function
𝑦 = 𝑓(𝑥)
The set of data in the given observation determine the method to be used. The available solution are:
i. Discrete case
ii. Continuous case
DISCRETE CASE
For more info, call: 08139279193 or 090331701334 or visit RCF FUTA, academic unit
24
𝑦 = 𝑓(𝑥) 𝐸1
Are
We are to fit a polynomial 𝑝(𝑥) to the observation 𝑦𝑖 , 𝑖 = 1,2,3, … , 𝑛 if the difference between
𝑓(𝑥𝑖 ) 𝑎𝑛𝑑 𝑝(𝑥𝑖 ), , 𝑖 = 1,2,3, … , 𝑛 is least. That is, the sum of the differences
𝑦𝑖 − 𝑝(𝑥), 𝑖 = 1,2,3, … , 𝑛
Should be minimum. Consequently, the required equation for the sum of square error to be minimized
is
𝑛
2
𝑆 = ∑(𝑦𝑖 − 𝑝(𝑥)) 𝐸2
𝑖=1
Where
𝑝(𝑥) = 𝑛𝑎0 + 𝑎1 𝑥𝑖 + 𝑎2 𝑥𝑖 2 … + 𝑎𝑛 𝑥𝑖 𝑛 𝐸3
To minimize x, we obtain the stationary value of S with respect to each constant a𝑖 , 𝑖 = 1,2, … , 𝑛.
𝑛
Hence differentiating S partially w.r.t. each constant 𝑎𝑖 and equating each to zero, we have:
𝑛
𝜕𝑆 2
= −2𝑛 ∑(𝑦𝑖 − (𝑛𝑎0 + 𝑎1 𝑥𝑖 + 𝑎2 𝑥𝑖 2 + ⋯ + 𝑎𝑛 𝑥𝑖 𝑛 )) = 0 𝐸5
𝜕𝑎0
𝑖=1
𝑛
𝜕𝑆
= −2 ∑(𝑦𝑖 − (𝑛𝑎0 + 𝑎1 𝑥𝑖 + 𝑎2 𝑥𝑖 2 + ⋯ + 𝑎𝑛 𝑥𝑖 𝑛 ))𝑥𝑖 𝐸6
𝜕𝑎1
𝑖=1
𝑛
𝜕𝑆
= −2 ∑(𝑦𝑖 − (𝑛𝑎0 + 𝑎1 𝑥𝑖 + 𝑎2 𝑥𝑖 2 + ⋯ + 𝑎𝑛 𝑥𝑖 𝑛 ))𝑥𝑖 2 = 0 𝐸7
𝜕𝑎2
𝑖=1
⋮ ⋮ ⋮
𝑛
𝜕𝑆
= −2 ∑(𝑦𝑖 − (𝑛𝑎0 + 𝑎1 𝑥𝑖 + 𝑎2 𝑥𝑖 2 + ⋯ + 𝑎𝑛 𝑥𝑖 𝑛 ))𝑥𝑖 𝑛 = 0 𝐸8
𝜕𝑎𝑛
𝑖=1
∑ 𝑦𝑖 = 𝑛𝑎0 + 𝑎1 ∑ 𝑥𝑖 + 𝑎2 ∑ 𝑥𝑖 2 + … + 𝑎𝑛 ∑ 𝑥𝑖 𝑛 𝐸9
∑ 𝑥𝑖 𝑦𝑖 = 𝑎0 ∑ 𝑥𝑖 + 𝑎1 ∑ 𝑥𝑖 2 + 𝑎2 ∑ 𝑥1 3 + … + 𝑎𝑛 ∑ 𝑥𝑖 𝑛+1 𝐸10
For more info, call: 08139279193 or 090331701334 or visit RCF FUTA, academic unit
25
∑ 𝑥𝑖 2 𝑦𝑖 = 𝑎0 ∑ 𝑥𝑖 2 + 𝑎1 ∑ 𝑥1 3 + 𝑎2 ∑ 𝑥1 4 + … + 𝑎𝑛 ∑ 𝑥𝑖 𝑛+2 𝐸1
⋮ ⋮ ⋮
we can put the system of n+1 equations into matrix form as follow:
𝑛 ∑ 𝑥𝑖 ∑ 𝑥𝑖 2 … ∑ 𝑥𝑖 𝑛 ∑ 𝑦𝑖
𝑎0
∑ 𝑥𝑖 ∑ 𝑥𝑖 2 ∑ 𝑥1 3 … ∑ 𝑥𝑖 𝑛+1 𝑎1 ∑ 𝑥𝑖 𝑦𝑖
𝑎2 =
∑ 𝑥𝑖 2 ∑ 𝑥1 3 ∑ 𝑥1 4 … ∑ 𝑥𝑖 𝑛+2 .. ∑ 𝑥𝑖 2 𝑦𝑖
… … … … … 𝑎
( 𝑛) …
𝑛 𝑛
(∑ 𝑥𝑖 ∑ 𝑥𝑖 𝑛+1 ∑ 𝑥𝑖 𝑛+2 … ∑ 𝑥𝑖 2𝑛 ) (∑ 𝑥𝑖 𝑦𝑖 )
The matrix equation can be solved for 𝑎0 , 𝑎1 , 𝑎2 , … , 𝑎𝑛 using any known methods.
Time(t) 2 3 5 6 9
Reading(x) 7 17 49 71 161
B. quadratic polynomial to the above data by least square3 method and determine which of the
two is better approximation
Solution
𝑖 1 2 3 4 5 ∑
𝑡𝑖 2 3 5 6 9 25
𝑡𝑖 2 4 9 25 36 81 155
𝑡𝑖 3 8 27 125 216 729 1105
𝑡𝑖 4 16 81 625 1296 6561 8579
𝑥𝑖 7 17 49 71 161 305
𝑥𝑖 𝑡𝑖 14 51 245 426 1449 2185
𝑥𝑖 𝑡𝑖 2 28 171 1225 2556 13041 17021
For more info, call: 08139279193 or 090331701334 or visit RCF FUTA, academic unit
26
𝑛 ∑ 𝑡𝑖 𝑎0 ∑ 𝑥𝑖
( ) (𝑎 ) = ( )
1
∑ 𝑡𝑖 ∑ 𝑡1 2 ∑ 𝑥𝑖 𝑡𝑖
5 25 𝑎0 305
( )( ) = ( )
25 155 𝑎1 2185
30𝑎1 = 660
660
𝑎1 = = 22
30
𝑎0 = 61 − 5(22) = −49
𝑛 ∑ 𝑡𝑖 ∑ 𝑡1 2 ∑ 𝒙𝒊
𝑎0
∑ 𝑡𝑖 ∑ 𝑡1 2 ∑ 𝑡1 3 (𝑎1 ) = ∑ 𝑥𝑖 𝑡𝑖
𝑎2
2
(∑ 𝑡 ∑ 𝑡1 3 ∑ 𝑡4 ) 2
(∑ 𝑥𝑖 𝑡 )
5 25 155 𝑎0 305
( 25 155 1105) (𝑎1 ) = ( 2185 )
155 1105 8579 𝑎2 17021
𝑎0 5 25 155 −1 305
(𝑎1 ) = ( 25 155 1105) ( 2185 )
𝑎2 155 1105 8579 17021
𝑎0 5.0333 −0.2 0.1667 305
(𝑎1 ) = ( −2 0.8736 −0.0796) ( 2185 )
𝑎2 0.1667 −0.076 6.944 17021
For more info, call: 08139279193 or 090331701334 or visit RCF FUTA, academic unit
27
𝑎0 −1
(𝑎1 ) = ( 0 )
𝑎2 2
Then the required quadratic equation becomes
𝑝(𝑥) = −1 + 2𝑥 2
CONTINOUS CASE
To find a least square approximation defined over a closed interval [𝑎, 𝑏], then the summation sign in
equation 2must be replaced by integral sign so that the function to be minimized becomes:
𝑏
𝑆 = ∫ [𝑓(𝑥) − 𝑝(𝑥)]2 𝑑𝑥
𝑎
Find the least square straight line that provides the best fit to the curve 𝑦 = √𝑥 over the interval
0≤𝑥≤1
SOLUTION
1 𝑏
𝑆 = ∫ [√𝑥 − (𝑎 + 𝑏𝑥)]2 𝑑𝑥 = ∫ [√𝑥 − 𝑎 − 𝑏𝑥]2 𝑑𝑥
0 𝑎
1`
𝑆 = ∫ (𝑥 − 𝑎√𝑥 − 𝑏𝑥√𝑥 − 𝑎√𝑥 + 𝑎2 + 𝑎𝑏𝑥 − 𝑏𝑥√𝑥 + 𝑎𝑏𝑥 + 𝑏 2 𝑥 2 )𝑑𝑥
0
1
𝑆 = ∫ (𝑥 − 2𝑎√𝑥 − 2𝑏𝑥√𝑥 + 2𝑎𝑏𝑥 + 𝑏 2 𝑥 2 + 𝑎2 )𝑑𝑥
0
𝑑𝑆 4
= − + 𝑏 + 2𝑎 = 0
𝑑𝑎 3
6𝑎 + 3𝑏 = 4 …………………1
𝑑𝑆 4 2
=− +𝑎+ 𝑏 =0
𝑑𝑎 5 3
For more info, call: 08139279193 or 090331701334 or visit RCF FUTA, academic unit
28
4 − 3𝑏
𝑎= ……………………3
6
Putting (3) into (2) we have that
4 − 3𝑏
15 ( ) + 10𝑏 = 12
6
20 − 15𝑏 + 20𝑏 = 24
4
𝑏=
5
4 12 20 − 12
4 −3( ) 4 − 8 1
𝑎= 5 = 5 = 5 = ×
6 6 6 5 6
4
𝑎=
15
For more info, call: 08139279193 or 090331701334 or visit RCF FUTA, academic unit