Documente Academic
Documente Profesional
Documente Cultură
b. Systems of Linear Algebraic Equations: These problems are similar in spirit to roots of
equations in the sense that they are concerned with values that satisfy equations.
However, in contrast to satisfying a single equation, a set of values is sought that
simultaneously satisfies a set of linear algebraic equations. Such equations arise in a
variety of problem contexts and in all disciplines of engineering. They originate in the
mathematical modeling of large systems of interconnected elements such as structures,
electric circuits, and fluid networks. However, they are also encountered in other areas
of numerical methods such as curve fitting and differential equations.
d. Curve Fitting: It is a process to fit curves to data points. The techniques developed for
this purpose can be divided into two general categories: regression and interpolation.
Regression is employed where there is a significant degree of error associated with the
data. Experimental results are often of this kind. For these situations, the strategy is to
derive a single curve that represents the general trend of the data without necessarily
matching any individual points. In contrast, interpolation is used where the objective is
to determine intermediate values between relatively error-free data points. Such is
usually the case for tabulated information. For these situations, the strategy is to fit a
curve directly through the data points and use the curve to predict the intermediate
values.
Start
Input initial
estimate of
solution
Numerical method’s
process
Output
Improved Convergence
approximation
YES
Same value
NO up to YES Solution
required
accuracy
End
• Relative error: Relative true error, 𝜖𝜖𝑡𝑡 is defined as the ratio between the true error and
the true value. It can also be given in terms of percentage
𝐸𝐸𝑡𝑡
𝜀𝜀𝑡𝑡 = (2.2)
True value
or it can also be expressed in percentage
𝐸𝐸𝑡𝑡
𝜀𝜀𝑡𝑡 = × 100% (2.3)
True value
• Absolute error: The absolute error is the magnitude of the difference between the exact
value and the approximation
𝐸𝐸𝑎𝑎𝑎𝑎𝑎𝑎 = |True Value − Approximation| (2.4)
• Approximate error: Often the true value is unknown, which is usually the case in
numerical computing. In this case errors are quantified using approximate values only.
An iterative method produces an approximate value at the end of each iteration. The
approximate error 𝐸𝐸𝑎𝑎 , is defined as the difference between the present approximate
value and the previous approximation.
𝐸𝐸𝑎𝑎 = (Present approx − Previous approx) (2.5)
• Relative approximate error: The relative approximate error is the ratio of approximate
error with present approximation
10 | P a g e Uzair Suria
(Present approx − Previous approx)
𝜀𝜀𝑎𝑎 = (2.6)
Present approx
Example 1-1
and compare it with the true value ‘𝑒𝑒 −8.3 = 2.485168 × 10−4 ’.
Solution
i. The series must be expanded till 25th term: Individual terms and their sum is given below
11 | P a g e Uzair Suria
Example 1-1 continued…
ii. The second series must also be expanded till 25th term: Individual terms in denominator
and their sum is given as:
12 | P a g e Uzair Suria
Example 1-2
Use zero- through sixth-order Taylor series (𝑛𝑛 = 0 to 𝑛𝑛 = 6) to approximate 𝑓𝑓(𝑥𝑥) = cos 𝑥𝑥 at
𝑥𝑥𝑖𝑖+1 = 𝜋𝜋�3, given that the function 𝑓𝑓(𝑥𝑥) and all its derivatives exists at 𝑥𝑥𝑖𝑖 = 𝜋𝜋�4.
Solution
𝜋𝜋 𝜋𝜋 𝜋𝜋
ℎ = 𝑥𝑥𝑖𝑖+1 − 𝑥𝑥𝑖𝑖 = − =
3 4 12
Following table shows the partial sum of the series up to 6th order along with its associated
error.
Order 𝒇𝒇(𝒏𝒏) (𝒙𝒙) 𝝅𝝅 No. of terms Partial Sum 𝑬𝑬𝒂𝒂
𝒇𝒇(𝒏𝒏) � �
𝟒𝟒
0 - - 1 0.70710 -
1
1 − sin 𝑥𝑥 − 2 0.52196 0.354
√2
1
2 − cos 𝑥𝑥 − 3 0.49773 0.048
√2
1
3 sin 𝑥𝑥 4 0.49987 0.00243
√2
1
4 cos 𝑥𝑥 5 0.5000076 0.0002678
√2
1
5 − sin 𝑥𝑥 − 6 0.500000304 0.000014494
√2
1
6 − cos 𝑥𝑥 − 7 0.499999 0.000000632
√2
13 | P a g e Uzair Suria
2 ROOTS OF EQUATIONS
2.1 Bisection Method
The bisection method, which is alternatively called binary chopping, interval halving, or
Bolzano’s method, is one type of incremental search method in which the interval is always
divided in half. It is used to compute roots for non-linear and transcendental equations.
Step 1: Choose lower 𝑥𝑥𝑙𝑙 and upper 𝑥𝑥𝑢𝑢 guesses for the root such that the
function changes sign over the interval. This can be checked by ensuring
that 𝑓𝑓(𝑥𝑥𝑙𝑙 ) < 0 and 𝑓𝑓(𝑥𝑥𝑢𝑢 ) > 0.
Step 2: An estimate of the root 𝑥𝑥𝑟𝑟 is determined by
𝑥𝑥𝑙𝑙 + 𝑥𝑥𝑢𝑢
𝑥𝑥𝑟𝑟 =
2
Step 3: Make the following evaluations to determine in which subinterval
the root lies:
a) If 𝑓𝑓(𝑥𝑥𝑟𝑟 ) < 0, then the root lies between 𝑓𝑓(𝑥𝑥𝑟𝑟 ) and 𝑓𝑓(𝑥𝑥𝑢𝑢 ). Therefore
set 𝑥𝑥𝑙𝑙 = 𝑥𝑥𝑟𝑟 and return to step 2
b) If 𝑓𝑓(𝑥𝑥𝑟𝑟 ) > 0, then the root lies between 𝑓𝑓(𝑥𝑥𝑙𝑙 ) and 𝑓𝑓(𝑥𝑥𝑟𝑟 ). Therefore
set 𝑥𝑥𝑢𝑢 = 𝑥𝑥𝑟𝑟 and return to step 2
c) Terminate computation when the required precision is achieved OR
terminate when 𝑓𝑓(𝑥𝑥𝑙𝑙 ) = 𝑓𝑓(𝑥𝑥𝑢𝑢 ) = 0.
14 | P a g e Uzair Suria
Example 2-1
Find the root of the equation, 𝑓𝑓(𝑥𝑥) = 𝑥𝑥𝑒𝑒 𝑥𝑥 − 5, by using bisection method. Computed result
must be precise up to three decimal places.
Solution
𝑓𝑓(0) = −5
𝑓𝑓(1) = −2.3
𝑓𝑓(2) = 0.4
From above, it is clear that the root lies between 𝑥𝑥 = 1 and 𝑥𝑥 = 2.
Following table simplifies and shows each iteration detail comprehensively:
Iteration
𝒙𝒙𝒍𝒍 𝒙𝒙𝒖𝒖 𝒙𝒙𝒓𝒓 𝒇𝒇(𝒙𝒙𝒓𝒓 )
#
1 1.00000 2.00000 1.50000 1.72253
2 1.00000 1.50000 1.25000 -0.63707
3 1.25000 1.50000 1.37500 0.43823
4 1.25000 1.37500 1.31250 -0.12347
5 1.31250 1.37500 1.34375 0.15112
6 1.31250 1.34375 1.32813 0.01229
7 1.31250 1.32813 1.32031 -0.05597
8 1.32031 1.32813 1.32422 -0.02193
9 1.32422 1.32813 1.32617 -0.00485
10 1.32617 1.32813 1.32715 0.00372
11 1.32617 1.32715 1.32666 -0.00057
12 1.32666 1.32715 1.32690 0.00158
13 1.32666 1.32690 1.32678 0.00050
15 | P a g e Uzair Suria
Practice Questions
1. Compute a root of the function 𝑓𝑓(𝑥𝑥) = 2𝑥𝑥 − 3𝑥𝑥 in the interval using bisection method.
1
2. Find the root of the equation 𝑓𝑓(𝑥𝑥) = 𝑥𝑥 − sin 𝑥𝑥 − by using bisection method. The
2
result must be precise up to 2 decimal places.
Step 1: Choose lower 𝑥𝑥𝑙𝑙 and upper 𝑥𝑥𝑢𝑢 guesses for the root such that the
function changes sign over the interval. This can be checked by ensuring
that 𝑓𝑓(𝑥𝑥𝑙𝑙 ) < 0 and 𝑓𝑓(𝑥𝑥𝑢𝑢 ) > 0.
Step 2: An estimate of the root 𝑥𝑥𝑟𝑟 is determined by
𝑓𝑓(𝑥𝑥𝑢𝑢 )(𝑥𝑥𝑙𝑙 − 𝑥𝑥𝑢𝑢 )
𝑥𝑥𝑟𝑟 = 𝑥𝑥𝑢𝑢 −
𝑓𝑓(𝑥𝑥𝑙𝑙 ) − 𝑓𝑓(𝑥𝑥𝑢𝑢 )
Step 3: Make the following evaluations to determine in which subinterval
the root lies:
a) If 𝑓𝑓(𝑥𝑥𝑟𝑟 ) < 0, then the root lies between 𝑓𝑓(𝑥𝑥𝑟𝑟 ) and 𝑓𝑓(𝑥𝑥𝑢𝑢 ). Therefore
set 𝑥𝑥𝑙𝑙 = 𝑥𝑥𝑟𝑟 and return to step 2
b) If 𝑓𝑓(𝑥𝑥𝑟𝑟 ) > 0, then the root lies between 𝑓𝑓(𝑥𝑥𝑙𝑙 ) and 𝑓𝑓(𝑥𝑥𝑟𝑟 ). Therefore
set 𝑥𝑥𝑢𝑢 = 𝑥𝑥𝑟𝑟 and return to step 2
c) Terminate computation when the required precision is achieved OR
terminate when 𝑓𝑓(𝑥𝑥𝑙𝑙 ) = 𝑓𝑓(𝑥𝑥𝑢𝑢 ) = 0.
16 | P a g e Uzair Suria
Figure 2-2 The graph shows numerous iterations and shows that after each iteration, the approximation gets closer to the
real value
Consider three points:𝐴𝐴�𝑥𝑥𝑙𝑙 , 𝑓𝑓(𝑥𝑥𝑙𝑙 )�, 𝐵𝐵�𝑥𝑥𝑢𝑢 , 𝑓𝑓(𝑥𝑥𝑢𝑢 )� and 𝐶𝐶�𝑥𝑥𝑟𝑟 , 𝑓𝑓(𝑥𝑥𝑟𝑟 )�, where 𝑥𝑥𝑟𝑟 = 𝑥𝑥𝑟𝑟1
Using theory of similar triangles:
𝑓𝑓(𝑥𝑥𝑙𝑙 ) 𝑓𝑓(𝑥𝑥𝑢𝑢 )
=
𝑥𝑥𝑟𝑟 − 𝑥𝑥𝑙𝑙 𝑥𝑥𝑟𝑟 − 𝑥𝑥𝑢𝑢
𝑓𝑓(𝑥𝑥𝑙𝑙 )(𝑥𝑥𝑟𝑟 − 𝑥𝑥𝑢𝑢 ) = 𝑓𝑓(𝑥𝑥𝑢𝑢 )(𝑥𝑥𝑟𝑟 − 𝑥𝑥𝑙𝑙 )
𝑥𝑥𝑟𝑟 𝑓𝑓(𝑥𝑥𝑙𝑙 ) − 𝑥𝑥𝑢𝑢 𝑓𝑓(𝑥𝑥𝑙𝑙 ) = 𝑥𝑥𝑟𝑟 𝑓𝑓(𝑥𝑥𝑢𝑢 ) − 𝑥𝑥𝑙𝑙 𝑓𝑓(𝑥𝑥𝑢𝑢 )
𝑥𝑥𝑟𝑟 �𝑓𝑓(𝑥𝑥𝑙𝑙 ) − 𝑓𝑓(𝑥𝑥𝑢𝑢 )� = 𝑥𝑥𝑢𝑢 𝑓𝑓(𝑥𝑥𝑙𝑙 ) − 𝑥𝑥𝑙𝑙 𝑓𝑓(𝑥𝑥𝑢𝑢 )
𝑥𝑥𝑢𝑢 𝑓𝑓(𝑥𝑥𝑙𝑙 ) − 𝑥𝑥𝑙𝑙 𝑓𝑓(𝑥𝑥𝑢𝑢 )
𝑥𝑥𝑟𝑟 =
𝑓𝑓(𝑥𝑥𝑙𝑙 ) − 𝑓𝑓(𝑥𝑥𝑢𝑢 )
This can be further simplified:
𝑥𝑥𝑢𝑢 𝑓𝑓(𝑥𝑥𝑙𝑙 ) 𝑥𝑥𝑙𝑙 𝑓𝑓(𝑥𝑥𝑢𝑢 )
𝑥𝑥𝑟𝑟 = −
𝑓𝑓(𝑥𝑥𝑙𝑙 ) − 𝑓𝑓(𝑥𝑥𝑢𝑢 ) 𝑓𝑓(𝑥𝑥𝑙𝑙 ) − 𝑓𝑓(𝑥𝑥𝑢𝑢 )
17 | P a g e Uzair Suria
𝑥𝑥𝑢𝑢 𝑓𝑓(𝑥𝑥𝑙𝑙 ) 𝑥𝑥𝑙𝑙 𝑓𝑓(𝑥𝑥𝑢𝑢 )
𝑥𝑥𝑟𝑟 = + 𝑥𝑥𝑢𝑢 − 𝑥𝑥𝑢𝑢 −
𝑓𝑓(𝑥𝑥𝑙𝑙 ) − 𝑓𝑓(𝑥𝑥𝑢𝑢 ) 𝑓𝑓(𝑥𝑥𝑙𝑙 ) − 𝑓𝑓(𝑥𝑥𝑢𝑢 )
𝑥𝑥𝑢𝑢 𝑓𝑓(𝑥𝑥𝑢𝑢 ) − 𝑥𝑥𝑙𝑙 𝑓𝑓(𝑥𝑥𝑢𝑢 )
= 𝑥𝑥𝑢𝑢 +
𝑓𝑓(𝑥𝑥𝑙𝑙 ) − 𝑓𝑓(𝑥𝑥𝑢𝑢 )
𝑓𝑓(𝑥𝑥𝑢𝑢 )(𝑥𝑥𝑙𝑙 − 𝑥𝑥𝑢𝑢 )
𝑥𝑥𝑟𝑟 = 𝑥𝑥𝑢𝑢 −
𝑓𝑓(𝑥𝑥𝑙𝑙 ) − 𝑓𝑓(𝑥𝑥𝑢𝑢 )
Example 2-2
Compute a real root of 𝑥𝑥 3 − 3𝑥𝑥 − 5 using Regula Falsi method precise up to 3 decimal places.
Solution
𝑓𝑓(2) = −3
𝑓𝑓(3) = 13
From above, it is clear that the root lies between 𝑥𝑥 = 2 and 𝑥𝑥 = 3.
13(2 − 3)
𝑥𝑥𝑟𝑟 = 3 − = 2.1875
−3 − 13
𝑓𝑓(𝑥𝑥𝑟𝑟 ) = −1.09497
Therefore, now 𝑥𝑥𝑙𝑙 = 𝑥𝑥𝑟𝑟 = 2.1875
Following table simplifies and shows each iteration detail comprehensively:
Iteration 𝒙𝒙𝒍𝒍 𝒙𝒙𝒖𝒖 𝒙𝒙𝒓𝒓 𝒇𝒇(𝒙𝒙𝒓𝒓 )
#
1 2.00000 3.00000 2.18750 -1.09497
2 2.18750 3.00000 2.25062 -0.35183
3 2.25062 3.00000 2.27037 -0.10836
4 2.27037 3.00000 2.27640 -0.03294
5 2.27640 3.00000 2.27823 -0.00997
6 2.27823 3.00000 2.27878 -0.00302
The root of the given equation is 2.278 precise up to 3 decimal places.
Practice Questions
1. Find the real root of the equation 𝑓𝑓(𝑥𝑥) = 𝑥𝑥𝑒𝑒 𝑥𝑥 − cos 𝑥𝑥 precise up to 4 decimal places
2. Find the real root of an equation 𝑓𝑓(𝑥𝑥) = 3𝑥𝑥 + sin 𝑥𝑥 − 𝑒𝑒 𝑥𝑥 , where 𝑥𝑥 ∈ [0, 1]. Perform
only five iterations. (Ans. 0.3604217)
18 | P a g e Uzair Suria
2.3 Fixed Point Iteration Method
Open methods (such as bisection and regula falsi method) employ a formula to predict the root.
Such a formula can be developed for simple fixed-point iteration (or, as it is also called, one-
point iteration or successive substitution) by rearranging the function 𝑓𝑓(𝑥𝑥) = 0 so that 𝑥𝑥 is on
the left-hand side of the equation:
𝑥𝑥 = 𝑔𝑔(𝑥𝑥)
This transformation can be accomplished either by algebraic manipulation or by simply adding
𝑥𝑥 to both sides of the original equation. For example:
𝑥𝑥 2 − 2𝑥𝑥 + 3 = 0
can simply be rewritten as
𝑥𝑥 2 + 3
𝑥𝑥 =
2
while sin 𝑥𝑥 = 0 can be rewritten as
𝑥𝑥 = sin 𝑥𝑥 + 𝑥𝑥
19 | P a g e Uzair Suria
Figure 2-3 Graphical
representation of fixed-
point method. Graphs (a)
and (b) represents
convergence while (c)
and (d) represent
divergence
Example 2-3
𝑛𝑛 𝑥𝑥𝑛𝑛 𝑔𝑔(𝑥𝑥𝑛𝑛 )
1 0.0000000 0.6666667
2 0.6666667 0.5952958
3 0.5952958 0.6093276
4 0.6093276 0.6066777
20 | P a g e Uzair Suria
Example 2-3 continued…
𝑛𝑛 𝑥𝑥𝑛𝑛 𝑔𝑔(𝑥𝑥𝑛𝑛 )
5 0.6066777 0.6071822
6 0.6071822 0.6070863
7 0.6070863 0.6071046
8 0.6071046 0.6071011
9 0.6071011 0.6071018
10 0.6071018 0.6071016
Step 1: Let 𝑥𝑥0 be any value of 𝑥𝑥 (in the domain where 𝑓𝑓(𝑥𝑥) changes sign),
or the initial approximate given.
Step 2: Use following iteration formula until results up to the required
precision is obtained
𝑓𝑓(𝑥𝑥𝑖𝑖 )
𝑥𝑥𝑖𝑖+1 = 𝑥𝑥𝑖𝑖 − 𝑖𝑖 = 0, 1, 2, … , 𝑛𝑛
𝑓𝑓′(𝑥𝑥𝑖𝑖 )
21 | P a g e Uzair Suria
Example 2-4
Find the root of the equation 3𝑥𝑥 − cos 𝑥𝑥 − 1 = 0 using Newton-Raphson method, precise upto
4 decimal places
Solution:
𝑓𝑓(𝑥𝑥) = 3𝑥𝑥 − cos 𝑥𝑥 − 1
𝑓𝑓(0) = −2
𝑓𝑓(1) = 1.4596
Therefore 𝑥𝑥 ∈ [0, 1], and
𝑓𝑓(𝑥𝑥𝑛𝑛 ) = 3𝑥𝑥𝑛𝑛 − cos 𝑥𝑥𝑛𝑛 − 1
𝑓𝑓 ′(𝑥𝑥𝑛𝑛) = 3 + sin 𝑥𝑥𝑛𝑛
Using Newton-Raphson method:
𝑓𝑓(𝑥𝑥𝑛𝑛 )
𝑥𝑥𝑛𝑛+1 = 𝑥𝑥𝑛𝑛 −
𝑓𝑓 ′ (𝑥𝑥𝑛𝑛 )
3𝑥𝑥𝑛𝑛 − cos 𝑥𝑥𝑛𝑛 − 1
= 𝑥𝑥𝑛𝑛 −
3 + sin 𝑥𝑥𝑛𝑛
𝑥𝑥𝑛𝑛 sin 𝑥𝑥𝑛𝑛 + cos 𝑥𝑥𝑛𝑛 + 1
=
3 + sin 𝑥𝑥𝑛𝑛
22 | P a g e Uzair Suria
Figure 2-5 Graphical representation of limitations of Newton-Raphson
Method. (a) root Jumping, (b) oscillation near local maxima or minima,
(c) another form of root jumping, and (d) zero gradient at an
approximation (zero in denominator)
Practice Questions
Find the root of the following equations precise up to 4 decimal points:
i. 𝑥𝑥 − cos 𝑥𝑥 = 0; 𝑥𝑥 ∈ [0,1]
ii. 2𝑥𝑥 − ln 𝑥𝑥 − 7 = 0; 𝑥𝑥 ∈ [4, 5]
iii. 2𝑥𝑥 − log 𝑥𝑥 − 7 = 0; 𝑥𝑥 ∈ [3, 4]
iv. 𝑥𝑥 sin 𝑥𝑥 + cos 𝑥𝑥 = 0; 𝑥𝑥0 = 𝜋𝜋
Answers: (i)0.7390, (ii)4.2199, (iii)3.7893 (iv)2.7983
23 | P a g e Uzair Suria
3 FINITE DIFFERENCES AND
INTERPOLATION
3.1 Finite Differences
Given that 𝑦𝑦 = 𝑓𝑓(𝑥𝑥) for a set of values of 𝑥𝑥, such that:
𝑥𝑥: 𝑥𝑥0 𝑥𝑥1 𝑥𝑥2 … 𝑥𝑥𝑛𝑛
𝑦𝑦: 𝑦𝑦0 𝑦𝑦1 𝑦𝑦2 … 𝑦𝑦𝑛𝑛
Then the process of finding the values of 𝑦𝑦 corresponding to any value of 𝑥𝑥 = 𝑥𝑥𝑖𝑖 between 𝑥𝑥0
and 𝑥𝑥𝑛𝑛 is called interpolation. Thus, interpolation is the technique of estimating the value of a
function for any intermediate value of the independent variable while the process of computing
the value of the function outside the given range is called extrapolation.
The study of the interpolation is based on the concept of differences of a function which is
discussed below
24 | P a g e Uzair Suria
Example 3-1
Solution
The description of domain of 𝑥𝑥 given in the question can be interpreted as follows: 𝑥𝑥 starts from
−2 and ascends to the value of 3 with steps of 1 unit.
𝒙𝒙 𝒚𝒚 𝚫𝚫𝒚𝒚 𝚫𝚫𝟐𝟐 𝒚𝒚 𝚫𝚫𝟑𝟑 𝒚𝒚 𝚫𝚫𝟒𝟒 𝒚𝒚 𝚫𝚫𝟓𝟓 𝒚𝒚
−𝟐𝟐 16
−15
−𝟏𝟏 1 14
−1 −12
𝟎𝟎 0 2 24
1 12 0
𝟏𝟏 1 14 24
15 36
𝟐𝟐 16 50
65
𝟑𝟑 81
Note that the 𝑛𝑛𝑡𝑡ℎ differences column will have constant value and (𝑛𝑛 + 1)𝑡𝑡ℎ differences
column will have a value of zero for 𝑛𝑛𝑡𝑡ℎ degree polynomial.
25 | P a g e Uzair Suria
3.1.2.1 Backward Difference Tables
The differences can be systematically listed in a backward difference table. In a difference
table 𝑥𝑥 is called an argument, and 𝑦𝑦 is called the function or the entry.
26 | P a g e Uzair Suria
Example 3-1
Construct a differences table for the function 𝑓𝑓(𝑥𝑥) = 3𝑥𝑥 3 − 2𝑥𝑥 2 + 𝑥𝑥 + 5; where 𝑥𝑥 = 0(1) ⋅ 4
Solution
The description of domain of 𝑥𝑥 given in the question can be interpreted as follows: 𝑥𝑥 starts from
0 and ascends to the value of 4 with steps of 1 unit.
𝒙𝒙 𝒚𝒚 𝛁𝛁𝒚𝒚 𝛁𝛁𝟐𝟐 𝒚𝒚 𝛁𝛁𝟑𝟑 𝒚𝒚 𝛁𝛁𝟒𝟒 𝒚𝒚
0 5
2
1 7 14
16 18
2 23 32 0
48 18
3 71 50
98
4 169
27 | P a g e Uzair Suria
𝒙𝒙 𝒚𝒚 𝛅𝛅𝒚𝒚 𝛅𝛅𝟐𝟐 𝒚𝒚 𝛅𝛅𝟑𝟑 𝒚𝒚 𝛅𝛅𝟒𝟒 𝒚𝒚 𝛅𝛅𝟓𝟓 𝒚𝒚
𝒙𝒙𝟎𝟎 𝑦𝑦0
δ𝑦𝑦1/2
𝒙𝒙𝟎𝟎 + 𝒉𝒉 𝑦𝑦1 δ2 𝑦𝑦1
𝛿𝛿𝑦𝑦3/2 δ3 𝑦𝑦3/2
𝒙𝒙𝟎𝟎 + 𝟐𝟐𝟐𝟐 𝑦𝑦2 δ2 𝑦𝑦2 δ4 𝑦𝑦2
δ𝑦𝑦5/2 δ3 𝑦𝑦5/2 δ5 𝑦𝑦5/2
𝒙𝒙𝟎𝟎 + 𝟑𝟑𝟑𝟑 𝑦𝑦3 δ2 𝑦𝑦3 δ4 𝑦𝑦3
δ𝑦𝑦7/2 δ3 𝑦𝑦7/2
𝒙𝒙𝟎𝟎 + 𝟒𝟒𝟒𝟒 𝑦𝑦4 δ2 𝑦𝑦4
δ𝑦𝑦9/2
𝒙𝒙𝟎𝟎 + 𝟓𝟓𝟓𝟓 𝑦𝑦5
28 | P a g e Uzair Suria
Example 3-2
Prove that
i. Δ𝐸𝐸 −1 sin 𝑥𝑥 = ∇ sin 𝑥𝑥
Δ𝑓𝑓(𝑥𝑥)
ii. Δ log 𝑓𝑓(𝑥𝑥) = log �1 + �𝑓𝑓(𝑥𝑥)�
𝑥𝑥
iii. Δ2 𝐸𝐸 −1 𝑒𝑒 𝑥𝑥 ⋅ �𝐸𝐸 𝑒𝑒 �Δ2 𝑒𝑒 𝑥𝑥 � = 𝑒𝑒 𝑥𝑥
Solution
i. Taking left hand side (and ℎ = 1)
= Δ𝐸𝐸 −1 sin 𝑥𝑥
= Δ sin(𝑥𝑥 − ℎ)
= sin(𝑥𝑥 − ℎ + ℎ) − sin(𝑥𝑥 − ℎ)
= sin(𝑥𝑥) − sin(𝑥𝑥 − ℎ) = ∇ sin 𝑥𝑥
= ∇ sin 𝑥𝑥
Proved
ii. Taking left hand side (and ℎ = 1)
= Δ log 𝑓𝑓(𝑥𝑥)
= log 𝑓𝑓(𝑥𝑥 + ℎ) − log 𝑓𝑓(𝑥𝑥)
𝑓𝑓(𝑥𝑥 + ℎ)
= log � �
𝑓𝑓(𝑥𝑥)
𝑓𝑓(𝑥𝑥 + ℎ) − 𝑓𝑓(𝑥𝑥) + 𝑓𝑓(𝑥𝑥)
= log � �
𝑓𝑓(𝑥𝑥)
Δ𝑓𝑓(𝑥𝑥) + 𝑓𝑓(𝑥𝑥)
= log � �
𝑓𝑓(𝑥𝑥)
Δ𝑓𝑓(𝑥𝑥)
= log �1 + �
𝑓𝑓(𝑥𝑥)
Proved
iii. Taking left hand side (and ℎ = 1)
𝐸𝐸𝑒𝑒 𝑥𝑥
= Δ2 𝐸𝐸 −1 𝑒𝑒 𝑥𝑥
Δ2 𝑒𝑒 𝑥𝑥
2 𝑥𝑥−ℎ
𝑒𝑒 𝑥𝑥+ℎ
= Δ 𝑒𝑒
Δ2 𝑒𝑒 𝑥𝑥
Δ2 𝑒𝑒 𝑥𝑥−ℎ+𝑥𝑥+ℎ−𝑥𝑥
=
Δ2
𝑥𝑥
= 𝑒𝑒
Proved
29 | P a g e Uzair Suria
Practice Questions
Evaluate:
i. Δ tan−1 𝑥𝑥
ii. Δ(𝑒𝑒 𝑥𝑥 log 2𝑥𝑥)
iii. Δ2 cos 2𝑥𝑥
iv. Δ𝑛𝑛 𝑒𝑒 𝑥𝑥
30 | P a g e Uzair Suria
Example 3-3
Prove whether the following relations are correct or not:
Δ+∇
i. 𝜇𝜇𝜇𝜇 ≡
2
ii. Δ∇≡ ∇ − Δ
𝛿𝛿 2
iii. 1 + 𝜇𝜇2 𝛿𝛿 2 ≡ �1 + �
2
Solution
i. Taking LHS
1
𝜇𝜇𝜇𝜇 = �𝐸𝐸 1⁄2 + 𝐸𝐸 −1⁄2 ��𝐸𝐸 1⁄2 − 𝐸𝐸 −1⁄2 �
2
1 2⁄2
= �𝐸𝐸 − 𝐸𝐸 −2⁄2 �
2
1
= (𝐸𝐸 − 𝐸𝐸 −1 )
2
1
= (𝐸𝐸 − 1 + 1−𝐸𝐸 −1 )
2
[(𝐸𝐸 − 1) + (1 − 𝐸𝐸 −1 )]
=
2
Δ+∇
=
2
Correct Relation
ii. Taking LHS
Δ∇= (𝐸𝐸 − 1)(1 − 𝐸𝐸 −1 )
= 𝐸𝐸 − 1 − 1 + 𝐸𝐸 −1
= 𝐸𝐸 − 2 + 𝐸𝐸 −1
Taking RHS
∇ − Δ = 1 − 𝐸𝐸 −1 − 𝐸𝐸 + 1
= 2 − 𝐸𝐸 −1 − 𝐸𝐸
LHS ≠ RHS
Incorrect Relation
iii. Taking LHS
2
𝐸𝐸 1⁄2 + 𝐸𝐸 −1⁄2 2
2 2
1 + 𝜇𝜇 𝛿𝛿 = 1 + � � ⋅ �𝐸𝐸 1⁄2 − 𝐸𝐸 −1⁄2 �
2
𝐸𝐸 + 2 + 𝐸𝐸 −1
=1+� � (𝐸𝐸 − 2 + 𝐸𝐸 −1 )
4
𝐸𝐸 2 − 2 − 𝐸𝐸 −2
=1+
4
𝐸𝐸 2 + 2 − 𝐸𝐸 −2
= … (1)
4
Now taking RHS
2 2
�𝐸𝐸 1⁄2 − 𝐸𝐸 −1⁄2 �
= �1 + �
2
2
𝐸𝐸 − 2 + 𝐸𝐸 −1
= �1 + �
2
2
2 + 𝐸𝐸 − 2 + 𝐸𝐸 −1
=� �
2
31 | P a g e Uzair Suria
Example 3-3 continued…
2
𝐸𝐸 + 𝐸𝐸 −1
=� �
2
𝐸𝐸 2 + 2 + 𝐸𝐸 −2
= … (2)
4
(1) = (2)
Correct Relation
Practice Questions
Prove that
Δ ∇
i. Δ + ∇= −
∇ Δ
ii. Δ3 𝑦𝑦2 = ∇3 𝑦𝑦5
iii. (1 + Δ)(1 − ∇) = 1
iv. Δ∇= ∇Δ = 𝛿𝛿 2
32 | P a g e Uzair Suria
Example 3-4
Find the missing term in the table
𝑥𝑥: 2 3 4 5 6
𝑦𝑦: 45.0 49.2 54.1 … 67.4
Solution
Analytical Solution:
Since four entries are given, 𝑓𝑓(𝑥𝑥) can be represented by 3rd degree polynomial such that
Δ3 𝑦𝑦 = Constant
Then
Δ4 𝑦𝑦 = 0
= (𝐸𝐸 − 1)4 = 0
Using binomial theorem
(𝐸𝐸 − 1)4 𝑦𝑦0 = (𝐸𝐸 4 − 4𝐸𝐸 3 + 6𝐸𝐸 2 − 4𝐸𝐸 + 1)𝑦𝑦0
= 𝑦𝑦4 − 4𝑦𝑦3 + 6𝑦𝑦2 − 4𝑦𝑦1 + 𝑦𝑦0 = 0
Since Δ4 𝑦𝑦 = 0, then
240.2 − 4𝑎𝑎 = 0
𝒂𝒂 = 𝟔𝟔𝟔𝟔. 𝟎𝟎𝟎𝟎
Practice Question
Find the missing values in the following data (refer to p955, Example 29.10, Higher
Engineering Math by BS Grewal 42e):
𝑥𝑥: 45 50 55 60 65
𝑦𝑦: 3.0 … 2.0 … -2.4
33 | P a g e Uzair Suria
3.2.2 Newton’s Forward Interpolation Formula
Let the function 𝑦𝑦 = 𝑓𝑓(𝑥𝑥) take the values 𝑦𝑦0 , 𝑦𝑦1 , 𝑦𝑦2 , … corresponding to the values 𝑥𝑥0 , 𝑥𝑥0 +
ℎ, 𝑥𝑥0 + 2ℎ, … of 𝑥𝑥. Suppose it is required to evaluate 𝑓𝑓(𝑥𝑥) for 𝑥𝑥 = 𝑥𝑥0 + 𝑝𝑝ℎ, where 𝑝𝑝 is any
real number.
𝑥𝑥−𝑥𝑥0
For any real number 𝑝𝑝 �where 𝑝𝑝 = �, 𝐸𝐸 is defined such that
ℎ
Example 3-5
Find the cubic polynomial whose values are given in the table below. Also find 𝑓𝑓(1.5)
𝑥𝑥: 0 1 2 3 4 5
𝑦𝑦: -3 3 11 27 57 107
Solution
𝒙𝒙 𝒚𝒚 𝚫𝚫𝒚𝒚 𝚫𝚫𝟐𝟐 𝒚𝒚 𝚫𝚫𝟑𝟑 𝒚𝒚 𝚫𝚫𝟒𝟒 𝒚𝒚 𝚫𝚫𝟓𝟓 𝒚𝒚
𝟎𝟎 −3
6
𝟏𝟏 3 2
8 6
𝟐𝟐 11 8 0
16 6 0
𝟑𝟑 27 14 0
30 6
𝟒𝟒 57 20
50
𝟓𝟓 107
𝑥𝑥 − 𝑥𝑥0 𝑥𝑥 − 0
𝑝𝑝 = = = 𝑥𝑥
ℎ 1
34 | P a g e Uzair Suria
Example 3-5 continued…
Newton’s Forward Difference formula gives
𝑝𝑝(𝑝𝑝 − 1) 2 𝑝𝑝(𝑝𝑝 − 1)(𝑝𝑝 − 2) 3
𝑓𝑓(𝑥𝑥) = 𝑓𝑓(𝑥𝑥0 ) + 𝑝𝑝Δ𝑓𝑓(𝑥𝑥0 ) + Δ 𝑓𝑓(𝑥𝑥0 ) + Δ 𝑓𝑓(𝑥𝑥0 )
2! 3!
substituting 𝑝𝑝 = 𝑥𝑥, 𝑓𝑓(𝑥𝑥0 ) = −3
𝑥𝑥(𝑥𝑥 − 1)(2) 𝑥𝑥(𝑥𝑥 − 1)(𝑥𝑥 − 2)(6)
𝑓𝑓(𝑥𝑥) = −3 + 6𝑥𝑥 + +
2 3×2
= −3 + 6𝑥𝑥 + 𝑥𝑥 2 − 𝑥𝑥 + (𝑥𝑥 2 − 𝑥𝑥)(𝑥𝑥 − 2)
= −3 + 6𝑥𝑥 + 𝑥𝑥 2 − 𝑥𝑥 + 𝑥𝑥 3 − 2𝑥𝑥 2 − 𝑥𝑥 2 + 2𝑥𝑥
𝒇𝒇(𝒙𝒙) = 𝒙𝒙𝟑𝟑 − 𝟐𝟐𝒙𝒙𝟐𝟐 + 𝟕𝟕𝟕𝟕 − 𝟑𝟑
For 𝑥𝑥 = 1.5
𝑓𝑓(𝑥𝑥 = 1.5) = 1.53 − 2 × 1.52 + 7 × 1.5 − 3
𝑓𝑓(1.5) = 𝟔𝟔. 𝟑𝟑𝟑𝟑𝟑𝟑
35 | P a g e Uzair Suria
Example 3-6 continued…
𝑥𝑥 − 𝑥𝑥𝑛𝑛 1.45 − 1.5
𝑝𝑝 = = = −0.5
ℎ 0.1
Newton’s Backward Difference formula gives
𝑝𝑝(𝑝𝑝 + 1) 2 𝑝𝑝(𝑝𝑝 + 1)(𝑝𝑝 + 2) 3
𝑦𝑦𝑝𝑝 = 𝑦𝑦𝑛𝑛 + 𝑝𝑝∇𝑦𝑦𝑛𝑛 + ∇ 𝑦𝑦𝑛𝑛 + ∇ 𝑦𝑦𝑛𝑛
2! 3!
substituting 𝑝𝑝 = −0.5, 𝑓𝑓(𝑥𝑥𝑛𝑛 ) = 4.5
−0.5 × 0.5 −0.5(0.5)(1.5)
𝑓𝑓(1.45) = 4.5 − 0.5 × 1 + (0.2) + (−0.2)
2 3×2
−(0.5)(0.5)(1.5)(2.5) −(0.5)(0.5)(1.5)(2.5)(3.5)
+ (−0.4) + (−0.5)
4×3×2 5×4×3×2
= 4.0167
It should be noted Newtons backward Interpolation formula is used for interpolating the values
of y near the end of a set of tabulated values and extrapolating the values of y a little ahead of
yn
Practice Problems
1. Calculate 𝑓𝑓(0.125) using the following table:
𝑥𝑥: 0 0.25 0.5 0.75 1.0
𝑦𝑦: 2 2.1 2.3 2.7 3.5
2. From the following table, estimate the number of students who obtained marks less than
or equal to 45
Marks 30-40 40-50 50-60 60-70 70-80
No. of Students 31 42 51 35 31
3. The sales in the departmental store for the last five years are given.
Year 2008 2010 2012 2014 2016
Sales (in Lacs) 40 43 48 52 57
Estimate the sales for the year 2013.
4. Using Newton’s Backward Formula, find the polynomial for the given data. Hence,
also evaluate 𝑓𝑓(2.5).
𝑥𝑥: 0 1 2 3
𝑦𝑦: 1 3 7 13
36 | P a g e Uzair Suria
3.3 Interpolation with Unequal Intervals
The various interpolation formulae derived so far possess the disadvantages of being applicable
only to equally spaced values of the argument. It is, therefore, desirable to develop interpolation
formulae for unequally spaced values of 𝑥𝑥. Now two such formulae will be introduced:
37 | P a g e Uzair Suria
Example 3-7
Find the polynomial using the following data, and hence find 𝑓𝑓(0.3)
𝑥𝑥: 0 1 3 4 7
𝑦𝑦: 1 3 49 129 813
Solution
where,
38 | P a g e Uzair Suria
𝑛𝑛
𝑥𝑥 − 𝑥𝑥𝑗𝑗
𝐿𝐿𝑖𝑖 (𝑥𝑥) = �
𝑥𝑥𝑖𝑖 − 𝑥𝑥𝑗𝑗
𝑗𝑗=0
𝑗𝑗≠𝑖𝑖
39 | P a g e Uzair Suria
For two roots 𝛼𝛼 and 𝛽𝛽, such that 𝑔𝑔(𝑥𝑥) = (𝑥𝑥 − 𝛼𝛼)(𝑥𝑥 − 𝛽𝛽)
𝑔𝑔(𝑥𝑥) = 𝑥𝑥 2 − (𝛼𝛼 + 𝛽𝛽)𝑥𝑥 + 𝛼𝛼𝛼𝛼
Similarly, for three roots 𝛼𝛼, 𝛽𝛽 and 𝛾𝛾, such that 𝑔𝑔(𝑥𝑥) = (𝑥𝑥 − 𝛼𝛼)(𝑥𝑥 − 𝛽𝛽)(𝑥𝑥 − 𝛾𝛾)
𝑔𝑔(𝑥𝑥) = 𝑥𝑥 3 − (𝛼𝛼 + 𝛽𝛽 + 𝛾𝛾)𝑥𝑥 2 + (𝛼𝛼𝛼𝛼 + 𝛼𝛼𝛼𝛼 + 𝛽𝛽𝛽𝛽)𝑥𝑥 − (𝛼𝛼𝛼𝛼𝛼𝛼)
Example 3-8
Use the following data of the function 𝑓𝑓(𝑥𝑥) = 𝑥𝑥 log 𝑥𝑥, with Lagrange’s formula,
𝑥𝑥: 3 7 9 12
𝑦𝑦: 1.4313 5.9156 8.5881 12.9501
and find
i. Quadratic polynomial approximation and its value at 𝑥𝑥 = 5
ii. Cubic polynomial approximation and its value at 𝑥𝑥 = 5
iii. Absolute error for the results in (i) and (ii)
Solution
i. For quadratic polynomial, 𝑛𝑛 = 2
(𝑥𝑥 − 𝑥𝑥1 )(𝑥𝑥 − 𝑥𝑥2 ) (𝑥𝑥 − 𝑥𝑥0 )(𝑥𝑥 − 𝑥𝑥2 ) (𝑥𝑥 − 𝑥𝑥0 )(𝑥𝑥 − 𝑥𝑥1 )
𝑓𝑓2 (𝑥𝑥) = 𝑦𝑦0 + 𝑦𝑦1 + 𝑦𝑦
(𝑥𝑥0 − 𝑥𝑥1 )(𝑥𝑥0 − 𝑥𝑥2 ) (𝑥𝑥1 − 𝑥𝑥0 )(𝑥𝑥1 − 𝑥𝑥2 ) (𝑥𝑥2 − 𝑥𝑥0 )(𝑥𝑥2 − 𝑥𝑥1 ) 2
(𝑥𝑥 − 7)(𝑥𝑥 − 9) (𝑥𝑥 − 3)(𝑥𝑥 − 9)
𝑓𝑓2 (𝑥𝑥) = × 1.4313 + × 5.9156
(3 − 7)(3 − 9) (7 − 3)(7 − 9)
(𝑥𝑥 − 3)(𝑥𝑥 − 7)
+ × 8.5881
(9 − 3)(9 − 7)
𝑥𝑥 2 − 16𝑥𝑥 + 63 𝑥𝑥 2 − 12𝑥𝑥 + 27
= × 1.4313 + × 5.9156
24 −8
𝑥𝑥 2 − 10𝑥𝑥 + 21
+ × 8.5881
12
1.4313 5.9156 8.5881 2
=� − + � 𝑥𝑥
24 8 12
16 × 1.4313 12 × 5.9156 10 × 8.5881
+ �− + − � 𝑥𝑥
24 8 12
63 × 1.4313 27 × 5.9156 21 × 8.5881
+� − + �
24 8 12
𝑓𝑓2 (𝑥𝑥) = 0.03586𝑥𝑥 2 + 0.7624𝑥𝑥 − 1.178
𝑓𝑓2 (5) = 3.53
40 | P a g e Uzair Suria
(𝑥𝑥 − 7)(𝑥𝑥 − 9)(𝑥𝑥 − 12) (𝑥𝑥 − 3)(𝑥𝑥 − 9)(𝑥𝑥 − 12)
𝑓𝑓3 (𝑥𝑥) = (1.4313) + (5.9156)
(3 − 7)(3 − 9)(3 − 12) (7 − 3)(7 − 9)(7 − 12)
(𝑥𝑥 − 3)(𝑥𝑥 − 7)(𝑥𝑥 − 12) (𝑥𝑥 − 3)(𝑥𝑥 − 7)(𝑥𝑥 − 9)
+ (8.5881) + (12.9501)
(9 − 3)(9 − 7)(9 − 12) (12 − 3)(12 − 7)(12 − 9)
𝑥𝑥 3 − 28𝑥𝑥 2 + 255𝑥𝑥 − 756 𝑥𝑥 3 − 24𝑥𝑥 2 + 171𝑥𝑥 − 324
𝑓𝑓3 (𝑥𝑥) = (1.4313) + (5.9156)
−216 40
𝑥𝑥 3 − 22𝑥𝑥 2 + 141𝑥𝑥 − 252 𝑥𝑥 3 − 19𝑥𝑥 2 + 111𝑥𝑥 − 189
+ (8.5881) +
−36 135
⋅ 12.9501
𝑓𝑓3 (𝑥𝑥) = −0.00137𝑥𝑥 3 + 0.06186𝑥𝑥 2 + 0.61060𝑥𝑥 − 0.92025
𝑓𝑓3 (5) = 3.50811
41 | P a g e Uzair Suria
Example 3-9
Use the following table to form first order spline approximation of the data:
𝑥𝑥: 0 1 2
𝑦𝑦: 1 3 30
Solution
𝑥𝑥 − 𝑥𝑥𝑖𝑖 𝑥𝑥 − 𝑥𝑥𝑖𝑖−1
𝑓𝑓𝑖𝑖 (𝑥𝑥) = 𝑦𝑦𝑖𝑖−1 + 𝑦𝑦
𝑥𝑥𝑖𝑖−1 − 𝑥𝑥𝑖𝑖 𝑥𝑥𝑖𝑖 − 𝑥𝑥𝑖𝑖−1 𝑖𝑖
For 0 ≤ 𝑥𝑥 ≤ 1,
𝑥𝑥 − 1 𝑥𝑥 − 0
𝑓𝑓1 (𝑥𝑥) = ×1+ ×3
0−1 1−0
= −𝑥𝑥 + 1 + 3𝑥𝑥
= 2𝑥𝑥 + 1
For 1 ≤ 𝑥𝑥 ≤ 2
𝑥𝑥 − 2 𝑥𝑥 − 1
𝑓𝑓2 (𝑥𝑥) = ×3+ × 30
1−2 2−1
= −3𝑥𝑥 + 6 + 30𝑥𝑥 − 30
= 27𝑥𝑥 − 24
2𝑥𝑥 + 1 0 ≤ 𝑥𝑥 < 1
𝑓𝑓(𝑥𝑥) = �
27𝑥𝑥 − 24 1 ≤ 𝑥𝑥 ≤ 2
Practice Problem
Use the following table to form first order spline approximation of the data and hence find
𝑣𝑣(16)
𝑡𝑡 (𝑠𝑠) 0 10 15 20 22.5
𝑣𝑣 (𝑚𝑚𝑠𝑠 −1 ) 0 227.04 362.78 517.35 602.97
42 | P a g e Uzair Suria
4 NUMERICAL CALCULUS
Calculus is the mathematics of change. Because engineers must continuously deal with systems
and processes that change, calculus is an essential tool of our profession. Standing at the heart
of calculus are the related mathematical concepts of differentiation and integration.
Mathematically, the derivative, which serves as the fundamental vehicle for differentiation,
represents the rate of change of a dependent variable with respect to an independent variable.
As shown in Fig. 4-1, the mathematical definition of the derivative begins with a difference
approximation:
Δ𝑦𝑦 𝑓𝑓(𝑥𝑥𝑖𝑖 + Δ𝑥𝑥) − 𝑓𝑓(𝑥𝑥𝑖𝑖 )
=
Δ𝑥𝑥 Δ𝑥𝑥
where 𝑦𝑦 and 𝑓𝑓(𝑥𝑥) are alternative representatives for the dependent variable and 𝑥𝑥 is the
independent variable. If Δ𝑥𝑥 approaches zero, as occurs in moving from Fig. 4-1(a) to (c), the
difference becomes a derivative
𝑑𝑑𝑑𝑑 𝑓𝑓(𝑥𝑥𝑖𝑖 + Δ𝑥𝑥) − 𝑓𝑓(𝑥𝑥𝑖𝑖 )
= lim
𝑑𝑑𝑑𝑑 Δ𝑥𝑥→0 Δ𝑥𝑥
where 𝑑𝑑𝑑𝑑/𝑑𝑑𝑑𝑑, (which can also be represented by 𝑦𝑦′ or 𝑓𝑓 ′ (𝑥𝑥), is the first derivative of 𝑦𝑦 with
respect to 𝑥𝑥 evaluated at 𝑥𝑥𝑖𝑖
Figure 4-1 The graphical definition of a derivative: as 𝚫𝚫𝒙𝒙 approaches zero in going from (a) to (c), the difference
approximation becomes a derivative.
43 | P a g e Uzair Suria
The inverse process to differentiation in calculus is integration. Mathematically, integration is
represented by:
𝑏𝑏
𝐼𝐼 = � 𝑓𝑓(𝑥𝑥)𝑑𝑑𝑑𝑑
𝑎𝑎
which stands for the integral of the function 𝑓𝑓(𝑥𝑥) with respect to the independent variable 𝑥𝑥,
evaluated between the limits 𝑥𝑥 = 𝑎𝑎 and 𝑥𝑥 = 𝑏𝑏.
44 | P a g e Uzair Suria
4.1 Numerical Differentiation
It is the process of calculating the value of the derivative of a function at some assigned value
of 𝑥𝑥 from the given set of values (𝑥𝑥𝑖𝑖 , 𝑦𝑦𝑖𝑖 ). The choice of the interpolation formula to be used,
will depend on the assigned value of 𝑥𝑥 at which 𝑑𝑑𝑑𝑑/𝑑𝑑𝑑𝑑 is desired.
If the values of 𝑥𝑥 are equispaced and 𝑑𝑑𝑑𝑑/𝑑𝑑𝑑𝑑 is required near the beginning of the table,
Newton's forward formula is used. If it is required near the end of the table, Newton's backward
formula is employed.
Consider a function 𝑓𝑓(𝑥𝑥) = 𝑦𝑦, tabulated for the values 𝑥𝑥𝑖𝑖 = 𝑥𝑥0 + 𝑖𝑖ℎ, 𝑖𝑖 = 0, 1, 2, … , 𝑛𝑛, then:
Example 4-1
Use the following table to evaluate 𝑓𝑓 ′ (0.25), 𝑓𝑓 ′′ (0.25), and 𝑓𝑓 ′′′ (0.25)
𝑥𝑥: 0 0.5 1 1.5 2.0
𝑦𝑦: 2.0286 2.4043 2.7637 3.1072 3.4350
45 | P a g e Uzair Suria
Example 4-1 continued…
Solution
𝒙𝒙 𝒚𝒚 𝚫𝚫𝒚𝒚 𝚫𝚫𝟐𝟐 𝒚𝒚 𝚫𝚫𝟑𝟑 𝒚𝒚 𝚫𝚫𝟒𝟒 𝒚𝒚
𝟎𝟎 2.0286
0.3757
𝟎𝟎. 𝟓𝟓 2.4043 −0.0163
0.3594 4 × 10−4
−2
𝟏𝟏. 𝟎𝟎 2.7637 −0.0159
× 10−4
0.3435 2 × 10−4
𝟏𝟏. 𝟓𝟓 3.1072 −0.0157
0.3278
𝟐𝟐. 𝟎𝟎 3.4350
𝑥𝑥 − 𝑥𝑥0 0.25 − 0
𝑝𝑝 = = = 0.5
ℎ 0.5
𝑑𝑑𝑑𝑑 1 2(0.5) − 1 3(0.5)2 − 6(0.5) + 2
= �0.3757 + (−0.0163) + 4 × 10−4
𝑑𝑑𝑑𝑑 0.5 2 6
2(0.5)3 − 9(0.5)2 + 11(0.5) − 3
+ (−2 × 10−4 ) + ⋯ �
12
= 0.7513
𝑑𝑑2 𝑥𝑥 1 −4
6(0.5)2 − 18(0.5) + 11
= �−0.0163 + (0.5 − 1)4 × 10 + (−2 × 10−4 )
𝑑𝑑𝑦𝑦 2 0.52 12
+ ⋯�
= −0.0664
𝑑𝑑 3 𝑥𝑥 1 2(0.5) − 3
3
= 3
�4 × 10−4 + (−2 × 10−4 ) + ⋯ �
𝑑𝑑𝑦𝑦 0.5 2
= 4.8 × 10−3
46 | P a g e Uzair Suria
And according to the chain rule
𝑑𝑑𝑑𝑑 𝑑𝑑𝑑𝑑 𝑑𝑑𝑑𝑑
= ×
𝑑𝑑𝑑𝑑 𝑑𝑑𝑑𝑑 𝑑𝑑𝑑𝑑
𝑑𝑑𝑑𝑑 1 2𝑝𝑝 + 1 2 3𝑝𝑝2 + 6𝑝𝑝 + 2 3 2𝑝𝑝3 + 9𝑝𝑝2 + 11𝑝𝑝 + 3 4
= �∇𝑦𝑦𝑛𝑛 + ∇ 𝑦𝑦𝑛𝑛 + ∇ 𝑦𝑦𝑛𝑛 + Δ 𝑦𝑦0 + ⋯ �
𝑑𝑑𝑑𝑑 ℎ 2 6 12
Similarly,
𝑑𝑑 2 𝑥𝑥 1 2 3
6𝑝𝑝2 + 18𝑝𝑝 + 11 4
= �∇ 𝑦𝑦𝑛𝑛 + (𝑝𝑝 + 1)∇ 𝑦𝑦𝑛𝑛 + ∇ 𝑦𝑦𝑛𝑛 + ⋯ �
𝑑𝑑𝑦𝑦 2 ℎ2 12
and
𝑑𝑑 3 𝑥𝑥 1 3 2𝑝𝑝 + 3 4
= �∇ 𝑦𝑦𝑛𝑛 + ∇ 𝑦𝑦𝑛𝑛 + ⋯ �
𝑑𝑑𝑦𝑦 3 ℎ3 2
Example 4-2
Following table shows the distance travelled by an object with respect to time
𝑡𝑡 8 9 10 11 12
𝐷𝐷 17.453 21.460 25.752 30.301 35.084
a) Find the velocity at 𝑡𝑡 = 11.5 by using Newton Backward Differentiation method
b) The distance travelled by the object is given by 𝐷𝐷 = 7𝑡𝑡 + 70𝑒𝑒 −𝑡𝑡/10 − 70 . Use
analytical differentiation method to determine the velocity at 𝑡𝑡 = 11.5 and compare
it with the result of (a).
Solution
a) Using Backward Differentiation Method
𝒕𝒕 𝑫𝑫 𝛁𝛁𝛁𝛁 𝛁𝛁𝟐𝟐 𝐃𝐃 𝛁𝛁𝟑𝟑 𝐃𝐃 𝛁𝛁𝟒𝟒 𝐃𝐃
𝟖𝟖 17.453
4.007
𝟗𝟗 21.460 0.285
4.292 −0.028
𝟏𝟏𝟏𝟏 25.752 0.257 0.005
4.549 −0.023
𝟏𝟏𝟏𝟏 30.301 0.234
4.783
𝟏𝟏𝟏𝟏 35.084
11.5 − 12
𝑝𝑝 = = −0.5
1
𝑑𝑑𝑑𝑑 1 2(−0.5) + 1 3(−0.5)2 + 6(−0.5) + 2
= �4.783 + 0.234 + (−0.023)
𝑑𝑑𝑑𝑑 1 2 6
2(−0.5)3 + 9(−0.5)2 + 11(−0.5) + 3
+ 0.005 + ⋯ �
12
= 4.7665
47 | P a g e Uzair Suria
b) Using analytical Method
𝐷𝐷ʹ (𝑡𝑡) = 7 − 7𝑒𝑒 𝑡𝑡⁄10
𝑣𝑣(11.5) = 4.7835
4.7835 − 4.7665
𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸 = � � × 100 = 0.355%
4.7835
𝑥𝑥0 +𝑛𝑛ℎ
𝐼𝐼 = � 𝑓𝑓(𝑥𝑥)𝑑𝑑𝑑𝑑
𝑥𝑥0
where
𝑝𝑝(𝑝𝑝 − 1) 2 𝑝𝑝(𝑝𝑝 − 1)(𝑝𝑝 − 2) 3 𝑝𝑝(𝑝𝑝 − 1)(𝑝𝑝 − 2)(𝑝𝑝 − 3) 4
𝑦𝑦 = 𝑦𝑦0 + 𝑝𝑝Δ𝑦𝑦0 + Δ 𝑦𝑦0 + Δ 𝑦𝑦𝑜𝑜 + Δ 𝑦𝑦0
2! 3! 4!
+⋯
and
𝑥𝑥 − 𝑥𝑥0
𝑝𝑝 =
ℎ
therefore
𝑑𝑑𝑑𝑑 1
= ⟹ 𝑑𝑑𝑑𝑑 = ℎ 𝑑𝑑𝑑𝑑
𝑑𝑑𝑑𝑑 ℎ
When
48 | P a g e Uzair Suria
𝑥𝑥 = 𝑥𝑥0 ⟹ 𝑝𝑝 = 0
𝑥𝑥 = 𝑥𝑥𝑛𝑛 ⟹ 𝑝𝑝 = 𝑛𝑛
Now,
𝑥𝑥𝑛𝑛
𝑝𝑝(𝑝𝑝 − 1) 2 𝑝𝑝(𝑝𝑝 − 1)(𝑝𝑝 − 2) 3
𝐼𝐼 = � �𝑦𝑦0 + 𝑝𝑝Δ𝑦𝑦0 + Δ 𝑦𝑦0 + Δ 𝑦𝑦𝑜𝑜
𝑥𝑥0 2! 3!
𝑝𝑝(𝑝𝑝 − 1)(𝑝𝑝 − 2)(𝑝𝑝 − 3) 4
+ Δ 𝑦𝑦0 + ⋯ � 𝑑𝑑𝑑𝑑
4!
Substituting values
𝑝𝑝
𝑝𝑝(𝑝𝑝 − 1) 2 𝑝𝑝(𝑝𝑝 − 1)(𝑝𝑝 − 2) 3
𝐼𝐼 = ℎ � �𝑦𝑦0 + 𝑝𝑝Δ𝑦𝑦0 + Δ 𝑦𝑦0 + Δ 𝑦𝑦𝑜𝑜
0 2! 3!
𝑝𝑝(𝑝𝑝 − 1)(𝑝𝑝 − 2)(𝑝𝑝 − 3) 4
+ Δ 𝑦𝑦0 + ⋯ � 𝑑𝑑𝑑𝑑
4!
𝑝𝑝
𝑝𝑝2 − 𝑝𝑝 2 𝑝𝑝3 − 3𝑝𝑝2 + 2𝑝𝑝 3 𝑝𝑝4 − 6𝑝𝑝3 + 11𝑝𝑝2 − 6𝑝𝑝 4
= ℎ � �𝑦𝑦0 + 𝑝𝑝Δ𝑦𝑦0 + Δ 𝑦𝑦0 + Δ 𝑦𝑦𝑜𝑜 + Δ 𝑦𝑦0
0 2 6 24
+ ⋯ � 𝑑𝑑𝑑𝑑
𝑝𝑝2 𝑝𝑝3 𝑝𝑝2 Δ2 𝑦𝑦0 𝑝𝑝4 3𝑝𝑝3 2𝑝𝑝2 Δ3 𝑦𝑦0
= ℎ �𝑝𝑝𝑦𝑦0 + Δ𝑦𝑦0 + � − � +� − + �
2 3 2 2! 4 3 2 6
𝑛𝑛
𝑝𝑝5 6𝑝𝑝4 11𝑝𝑝3 6𝑝𝑝2 Δ4 𝑦𝑦0
+� − + − � +⋯�
5 4 3 2 24 0
49 | P a g e Uzair Suria
ℎ
= (𝑦𝑦 + 𝑦𝑦2 )
2 1
and
𝑥𝑥0 +𝑛𝑛ℎ
ℎ
� 𝑓𝑓(𝑥𝑥) 𝑑𝑑𝑑𝑑 = (𝑦𝑦 + 𝑦𝑦𝑛𝑛 )
𝑥𝑥0+(𝑛𝑛−1)ℎ 2 𝑛𝑛−1
Alternatively,
𝑥𝑥0 +𝑛𝑛ℎ 𝑛𝑛−1
ℎ
� 𝑓𝑓(𝑥𝑥) 𝑑𝑑𝑑𝑑 = �𝑦𝑦0 + �2 � 𝑦𝑦𝑖𝑖 � + 𝑦𝑦𝑛𝑛 �
𝑥𝑥0 2
𝑖𝑖=1
Example 4-3
Evaluate the integral
1
1
𝑑𝑑𝑑𝑑 �
0 1 + 𝑥𝑥
i. using Trapezoidal rule and taking ℎ = 0.25
ii. using exact solution and finding error in (i).
Solution
𝑥𝑥 0.0 0.25 0.50 0.75 1.0
𝑓𝑓(𝑥𝑥) 1.00 0.800 0.667 0.5714 0.500
i. using trapezoidal rule:
1 3
ℎ
� 𝑓𝑓(𝑥𝑥) 𝑑𝑑𝑑𝑑 = �𝑦𝑦0 + �2 � 𝑦𝑦𝑖𝑖 � + 𝑦𝑦4 �
0 2
𝑖𝑖=1
0.25
= [1 + 2(0.8 + 0.667 + 0.5714) + 0.5]
2
= 0.6970238
ii. exact solution is given by:
1
1
� 𝑑𝑑𝑑𝑑 = |ln(𝑥𝑥 + 1)|10
0 1 + 𝑥𝑥
= 0.6931472
𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸 = |𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸𝐸 − 𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴𝐴| = 0.0038767
Example 4-3
50 | P a g e Uzair Suria
𝑏𝑏 − 𝑎𝑎 6 − 1
ℎ=
= = 0.5
𝑛𝑛 10
𝑥𝑥 1 1.5 2 2.5 3 3.5
𝑦𝑦 2.9093 2.63816 2.30807 1.97932 1.68305 1.4353
𝑥𝑥 4 4.5 5 5.5 6
𝑦𝑦 1.2432 1.10832 1.02872 1.00024 1.01736
0.5
𝐼𝐼 = [2.90930 + 2(2.63816 + 2.30807 + 1.97932 + 1.68305 + 1.43530 + 1.24320 + 1.10832
2
+ 1.02872 + 1.00024) + 1.01736]
𝐼𝐼 = 8.19384
Practice Questions
Evaluate following integrals
1
i. ∫0 x3 dx; take n = 5
1
ii. ∫0 dx/(1 + x2 ); h = 0.25
Summing up all the results, Composite Simpson’s Rule is obtained (Where 𝑛𝑛 must always be
even.):
Alternatively,
51 | P a g e Uzair Suria
𝑥𝑥2𝑛𝑛 𝑛𝑛 𝑛𝑛−1
ℎ
� 𝑓𝑓(𝑥𝑥) 𝑑𝑑𝑑𝑑 = �𝑦𝑦0 + 4 � 𝑦𝑦2𝑖𝑖−1 + 2 � 𝑦𝑦2𝑖𝑖 + 𝑦𝑦2𝑛𝑛 �
𝑥𝑥0 3
𝑖𝑖=1 𝑖𝑖=1
Example 4-4
Evaluate the given integral using Simpson’s One Third Rule, taking 𝑛𝑛 = 6
4
𝐼𝐼 = � �1 + 𝑥𝑥 3
1
Solution
4−1
= 0.5 ℎ=
6
𝑥𝑥 1.0 1.5 2.0 2.5 3.0 3.5 4.0
𝑦𝑦 1.41421 2.09165 3.00000 4.07738 5.29150 6.62382 8.06226
ℎ
𝐼𝐼 = [𝑦𝑦 + 4(𝑦𝑦1 + 𝑦𝑦3 + 𝑦𝑦5 ) + 2(𝑦𝑦2 + 𝑦𝑦4 ) + 𝑦𝑦6 ]
3 0
0.5
= [1.41421 + 4(2.09165 + 4.07738 + 6.62382) + 2(3 + 5.29150) + 8.06226]
2
= 12.872
Practice Problem
Evaluate following integrals
𝜋𝜋
2
1. � sin(2𝑥𝑥) ⋅ 𝑒𝑒 −𝑥𝑥 𝑑𝑑𝑑𝑑 ; Using Simpson’s 1/3rd Rule. Take (a) 𝑛𝑛 = 2 and (b) 𝑛𝑛 = 10
0
4
2. � 𝑒𝑒 𝑥𝑥 𝑑𝑑𝑑𝑑 and compare with exact solution
0
5.2
3. � log 𝑥𝑥 𝑑𝑑𝑑𝑑 Using (a) Trapezoidal Rule, (b) Simpson’s 1/3rd Rule
4
52 | P a g e Uzair Suria
Adding all similar expressions from 𝑥𝑥0 to 𝑥𝑥0 + 𝑛𝑛ℎ, where 𝑛𝑛 is multiple of three, following
expression is obtained:
𝑥𝑥0 +𝑛𝑛ℎ
3ℎ
� 𝑓𝑓(𝑥𝑥)𝑑𝑑𝑑𝑑 = �𝑦𝑦 + 𝑦𝑦𝑛𝑛 + 3(𝑦𝑦1 + 𝑦𝑦2 + 𝑦𝑦4 + 𝑦𝑦5 + ⋯ + 𝑦𝑦𝑛𝑛−1 )
8 0
𝑥𝑥0
+ 2(𝑦𝑦3 + 𝑦𝑦6 + ⋯ + 𝑦𝑦𝑛𝑛−3 )�
Alternatively,
𝑛𝑛−1 𝑛𝑛⁄3−1 𝑛𝑛⁄3−1
𝑥𝑥0 +𝑛𝑛ℎ
3ℎ
� 𝑓𝑓(𝑥𝑥)𝑑𝑑𝑑𝑑 = �𝑦𝑦 + 3 �� 𝑦𝑦𝑖𝑖 − � 𝑦𝑦3𝑖𝑖 � + 2 � 𝑦𝑦3𝑖𝑖 + 𝑦𝑦𝑛𝑛 �
𝑥𝑥0 8 0
𝑖𝑖=1 𝑖𝑖=1 𝑖𝑖=1
The above expression is known as Simpson’s Three Eighth Rule. In this rule the number of sub-
intervals should be taken as multiple of 3.
Example 4-5
Evaluate the given integral using Simpson’s Three Eighth Rule, taking 𝑛𝑛 = 6
6
𝑑𝑑𝑑𝑑
𝐼𝐼 = � 2
0 1 + 𝑥𝑥
Solution
ℎ=1
𝑥𝑥 0 1 2 3 4 5 6
𝑦𝑦 1 0.5 0.2 0.1 0.0588 0.0385 0.027
3ℎ
𝐼𝐼 = [𝑦𝑦 + 3(𝑦𝑦1 + 𝑦𝑦2 + 𝑦𝑦4 + 𝑦𝑦5 ) + 2𝑦𝑦3 + 𝑦𝑦6 ]
8 0
3(1)
= [1 + 3(0.5 + 0.2 + 0.0588 + 0.0385) + 2(0.1) + 0.027]
8
= 1.3571 … 𝐀𝐀𝐀𝐀𝐀𝐀.
Example 4-6
53 | P a g e Uzair Suria
3(2)
= [4 + 3(6 + 16 + 60 + 94) + 2(34) + 136]
8
= 552
ii.
𝑑𝑑𝑑𝑑 1 2𝑝𝑝 − 1 2
𝑎𝑎 = = �Δ𝑦𝑦0 + Δ 𝑦𝑦0 �
𝑑𝑑𝑑𝑑 ℎ 2
1 2(1) − 1
= �2 + × 8�
2 2
= 3 … 𝐀𝐀𝐀𝐀𝐀𝐀.
54 | P a g e Uzair Suria
5 NUMERICAL SOLUTION OF
DIFFERENTIAL EQUATIONS
The methods of solution so far presented are applicable to a limited class of differential
equations. Frequently differential equations appearing in physical problems do not belong to
any of these familiar types and one is obliged to resort to numerical methods. These methods
are of even greater importance when it is realized that computing machines are now available
which reduce numerical work considerably.
Several numerical methods are available for the solution of first order differential equations of
the form:
𝑑𝑑𝑑𝑑
= 𝑓𝑓(𝑥𝑥, 𝑦𝑦), given 𝑦𝑦(𝑥𝑥0 ) = 𝑦𝑦0
𝑑𝑑𝑑𝑑
These methods yield solutions either as a power series in 𝑥𝑥 from which the values of y can be
found by direct substitution, or as a set of values of 𝑥𝑥 and 𝑦𝑦.
Euler and Runge-Kutta methods are used for computing over a limited range of x-values
whereas Milne and Adams-Bashforth methods may be applied for finding y over a wider range
of x-values. These later methods require starting values which are found by Picard's or Taylor
series or Runge-Kutta methods.
The initial condition is specified at the point 𝑥𝑥0 . Such problems in which all the initial
conditions are given at the initial point only are called initial value problems. But there are
problems involving second and higher order differential equations in which the conditions may
be given at two or more points. These are known as boundary value problems. In this chapter,
methods for solving initial value problems will be explained first and then a method of solving
boundary value problems will be provided
55 | P a g e Uzair Suria
2. Exact Differential Equations
A differential equation of the form:
𝑑𝑑𝑑𝑑
𝑀𝑀(𝑥𝑥, 𝑦𝑦) + 𝑁𝑁(𝑥𝑥, 𝑦𝑦) =0
𝑑𝑑𝑑𝑑
such that 𝑀𝑀𝑦𝑦 = 𝑁𝑁𝑥𝑥 is known as Exact differential equation
56 | P a g e Uzair Suria
3. Find the value of gradient at newly calculated (𝑥𝑥1 , 𝑦𝑦1 ) and draw a line from previous
tangent at (𝑥𝑥1 , 𝑦𝑦1 ) with the same gradient as 𝑓𝑓(𝑥𝑥1 , 𝑦𝑦1 ). Repeat step 2 to find (𝑥𝑥2 , 𝑦𝑦2 ).
𝑦𝑦4
𝑦𝑦3
𝑦𝑦2
𝑦𝑦1
𝑦𝑦0
Example 5-1
Solve the differential equation 𝑦𝑦 ′ = (𝑦𝑦 − 𝑥𝑥)⁄(𝑦𝑦 + 𝑥𝑥), and find the value of 𝑦𝑦 in five steps
when 𝑥𝑥 = 0.1, given that when 𝑥𝑥 = 0, 𝑦𝑦 = 1.
Solution:
0.1 − 0
ℎ= = 0.02
5
1−0
𝑦𝑦1 = 𝑦𝑦𝑥𝑥=0.02 = 1 + 0.02 � � = 1.02
1+0
1.02 − 0.02
𝑦𝑦2 = 𝑦𝑦𝑥𝑥=0.04 = 1.02 + 0.02 � � = 1.039
1.02 + 0.02
Similarly, 𝑦𝑦3 = 1.058, 𝑦𝑦4 = 1.076 and 𝑦𝑦5 = 1.093
𝒙𝒙 = 𝟎𝟎. 𝟏𝟏, 𝒚𝒚 = 𝟏𝟏. 𝟎𝟎𝟎𝟎𝟎𝟎 … 𝐀𝐀𝐀𝐀𝐀𝐀.
57 | P a g e Uzair Suria
5.1.2.2 Modified Euler’s Method (MEM)
Modified Euler’s method provides greater accuracy over the original Euler’s method. The core
idea is the use a gradient at (𝑥𝑥𝑛𝑛 , 𝑦𝑦𝑛𝑛 ) that is the average of gradient at (𝑥𝑥𝑛𝑛 , 𝑦𝑦𝑛𝑛 ) and
∗ ).
(𝑥𝑥𝑛𝑛+1 , 𝑦𝑦𝑛𝑛+1 ∗
The term 𝑦𝑦𝑛𝑛+1 represents initial approximation of 𝑦𝑦𝑛𝑛+1 through original Euler’s
method. This method is also known as Predictor – Corrector method.
Given that 𝑦𝑦 ′ = 𝑓𝑓(𝑥𝑥, 𝑦𝑦), then the corrector equation is given by
ℎ ∗ )]
𝑦𝑦𝑛𝑛+1 = 𝑦𝑦𝑛𝑛 + [𝑓𝑓(𝑥𝑥𝑛𝑛 , 𝑦𝑦𝑛𝑛 ) + 𝑓𝑓(𝑥𝑥𝑛𝑛+1 , 𝑦𝑦𝑛𝑛+1
2
where 𝑦𝑦 ∗ is predictor, and it is given by
∗
𝑦𝑦𝑛𝑛+1 = 𝑦𝑦𝑛𝑛 + ℎ ⋅ 𝑓𝑓(𝑥𝑥𝑛𝑛 , 𝑦𝑦𝑛𝑛 )
𝑙𝑙3
𝑙𝑙1 𝑙𝑙2
∗
𝑦𝑦𝑛𝑛+1
𝑦𝑦𝑛𝑛+1
𝑙𝑙4
𝑦𝑦𝑛𝑛
𝑥𝑥𝑛𝑛 𝑥𝑥𝑛𝑛+1
Figure 5-2 Graphical representation of Modified Euler’s Method, where 𝒍𝒍𝟏𝟏 is tangent line at 𝒙𝒙𝒏𝒏 , 𝒍𝒍𝟐𝟐 is tangent at 𝒙𝒙𝒏𝒏+𝟏𝟏 ,
𝒍𝒍𝟑𝟑 is the line whose gradient is the average of 𝒍𝒍𝟏𝟏 and 𝒍𝒍𝟐𝟐 , and 𝒍𝒍𝟒𝟒 is parallel to 𝒍𝒍𝟑𝟑 drawn from (𝒙𝒙𝒏𝒏 , 𝒚𝒚𝒏𝒏 ).
58 | P a g e Uzair Suria
Example 5-2
Solve the differential equation 𝑦𝑦 ′ = 𝑥𝑥 + 𝑦𝑦, given that 𝑦𝑦 = 0 when 𝑥𝑥 = 0. Take ℎ = 0.2 and
perform 5 iterations.
Solution:
Taking 𝑥𝑥0 = 0, 𝑦𝑦0 = 0:
𝑦𝑦1∗ = 𝑦𝑦0 + ℎ 𝑓𝑓(𝑥𝑥0 , 𝑦𝑦0 )
= 0 + 0.2(0)
=0
ℎ
𝑦𝑦1 = 𝑦𝑦0 + [𝑓𝑓(𝑥𝑥0 , 𝑦𝑦0 ) + 𝑓𝑓(𝑥𝑥1 , 𝑦𝑦1∗ )]
2
0.2
=0+ (0 + 0.2)
2
= 0.02
Similarly, other values can also be found. Alternatively, CASIO fx – 991ES PLUS can also
be used to evaluate the values quickly.
Practice Problem
Solve the given I.V.P up to 3 iterations by using modified Euler’s method with ℎ = 0.1
𝑦𝑦 ′ + 𝑦𝑦 tan 𝑥𝑥 = sin 2𝑥𝑥
given that 𝑦𝑦(0) = 1
(1.04305 Ans.)
59 | P a g e Uzair Suria
𝑘𝑘1 = 𝑓𝑓(𝑥𝑥𝑛𝑛 , 𝑦𝑦𝑛𝑛 )
1 1
𝑘𝑘2 = 𝑓𝑓 �𝑥𝑥𝑛𝑛 + ℎ, 𝑦𝑦𝑛𝑛 + 𝑘𝑘1 ℎ�
2 2
1 1
𝑘𝑘3 = 𝑓𝑓 �𝑥𝑥𝑛𝑛 + ℎ, 𝑦𝑦𝑛𝑛 + 𝑘𝑘2 ℎ�
2 2
𝑘𝑘4 = 𝑓𝑓(𝑥𝑥𝑛𝑛 + ℎ, 𝑦𝑦𝑛𝑛 + 𝑘𝑘3 ℎ)
Example 5-3
Solve the differential equation 𝑦𝑦 ′ = 𝑦𝑦 − 𝑦𝑦 2 , given that 𝑦𝑦(0) = 0.5 and perform only three
iterations taking ℎ = 0.1. Also compare the approximation with exact solution.
Solution:
When 𝒏𝒏 = 𝟎𝟎, 𝒙𝒙 = 𝟎𝟎, 𝒚𝒚 = 𝟎𝟎. 𝟓𝟓
𝑘𝑘1 = 0.5 − 0.52 = 0.25
𝑘𝑘2 = [0.5 + 0.5(0.25)(0.1)] − [0.5 + 0.5(0.25)(0.1)]2 = 0.24984
𝑘𝑘3 = [0.5 + 0.5(0.2498)(0.1)] − [0.5 + 0.5(0.2498)(0.1)]2 = 0.24984
𝑘𝑘4 = [0.5 + (0.2498)(0.1)] − [0.5 + (0.2498)(0.1)]2 = 0.24937
then
0.1
𝑦𝑦1 = 0.5 + [0.25 + 2 × 0.24984 + 2 × 0.24984 + 0.24937] = 0.52498
6
When 𝒏𝒏 = 𝟏𝟏, 𝒙𝒙 = 𝟎𝟎. 𝟏𝟏, 𝒚𝒚 = 𝟎𝟎. 𝟓𝟓𝟓𝟓𝟓𝟓𝟓𝟓𝟓𝟓
𝑘𝑘1 = 0.52498 − 0.524982 = 0.24938
𝑘𝑘2 = [0.52498 + 0.5(0.24938)(0.1)] − [0.52498 + 0.5(0.24938)(0.1)]2
= 0.24860
𝑘𝑘3 = [0.52498 + 0.5(0.24860)(0.1)] − [0.52498 + 0.5(0.24860)(0.1)]2
= 0.24860
𝑘𝑘4 = [0.52498 + 0.24860(0.1)] − [0.52498 + 0.24860(0.1)]2 = 0.24751
then
0.1
𝑦𝑦2 = 0.52498 + [0.24938 + 2(0.24860) + 2(0.24860) + 0.24751] = 0.54983
6
When 𝒏𝒏 = 𝟐𝟐, 𝒙𝒙 = 𝟎𝟎. 𝟐𝟐, 𝒚𝒚 = 𝟎𝟎. 𝟓𝟓𝟓𝟓𝟓𝟓𝟓𝟓𝟓𝟓
𝑘𝑘1 = 0.54983 − 0.549832 = 0.24751
𝑘𝑘2 = [0.54983 + 0.5(0.24751)(0.1)] − [0.54983 + 0.5(0.24751)(0.1)]2
= 0.24613
𝑘𝑘3 = [0.54983 + 0.2(0.24613)(0.1)] − [0.54987 + 0.2(0.24613)(0.1)]2
= 0.24700
𝑘𝑘4 = [0.54983 + 0.24700(0.1)] − [0.54987 + 0.24700(0.1)]2 = 0.24444
then
0.1
𝑦𝑦3 = 0.54987 + [0.24751 + 2(0.24613) + 2(0.24700) + 0.24444] = 0.57451
6
𝑥𝑥 0 0.1 0.2 0.3
𝒚𝒚 𝟎𝟎. 𝟓𝟓 𝟎𝟎. 𝟓𝟓𝟓𝟓𝟓𝟓𝟓𝟓𝟓𝟓 𝟎𝟎. 𝟓𝟓𝟓𝟓𝟓𝟓𝟓𝟓𝟓𝟓 𝟎𝟎. 𝟓𝟓𝟓𝟓𝟓𝟓𝟓𝟓𝟓𝟓
Exact Analysis:
60 | P a g e Uzair Suria
𝑑𝑑𝑑𝑑
= 𝑦𝑦 − 𝑦𝑦 2
𝑑𝑑𝑑𝑑
1
𝑑𝑑𝑑𝑑 = 𝑑𝑑𝑑𝑑
𝑦𝑦(1 − 𝑦𝑦)
Applying partial fractions:
𝐴𝐴 𝐵𝐵 1
+ ≡
𝑦𝑦 1 − 𝑦𝑦 𝑦𝑦(1 − 𝑦𝑦)
𝐴𝐴(1 − 𝑦𝑦) + 𝐵𝐵𝐵𝐵 ≡ 1
When 𝑦𝑦 = 1, 𝐵𝐵 = 1, and when 𝑦𝑦 = 0, 𝐴𝐴 = 1
1 1 1
≡ +
𝑦𝑦(1 − 𝑦𝑦) 𝑦𝑦 1 − 𝑦𝑦
Now,
1 1
� 1 𝑑𝑑𝑑𝑑 = � � + � 𝑑𝑑𝑑𝑑
𝑦𝑦 1 − 𝑦𝑦
ln(1 − 𝑦𝑦)
𝑥𝑥 + 𝐶𝐶 = ln 𝑦𝑦 +
−1
𝑥𝑥 + 𝐶𝐶 = ln 𝑦𝑦 − ln(1 − 𝑦𝑦)
𝑦𝑦
𝑥𝑥 + 𝐶𝐶 = ln � �
1 − 𝑦𝑦
When 𝑥𝑥 = 0, 𝑦𝑦 = 0.5
0.5
𝐶𝐶 = ln � �=0
1 − 0.5
𝑦𝑦
𝑥𝑥 = ln � �
1 − 𝑦𝑦
Now,
𝑦𝑦
𝑒𝑒 𝑥𝑥 =
1 − 𝑦𝑦
𝑥𝑥 (1
𝑒𝑒 − 𝑦𝑦) = 𝑦𝑦
𝑒𝑒 𝑥𝑥 = 𝑦𝑦 + 𝑒𝑒 𝑥𝑥 𝑦𝑦
𝑒𝑒 𝑥𝑥 = 𝑦𝑦(1 + 𝑒𝑒 𝑥𝑥 )
𝑒𝑒 𝑥𝑥
𝑦𝑦 =
1 + 𝑒𝑒 𝑥𝑥
Comparing Results
Note: The difference of approximation with exact values is negligible, and therefore it is
considered/approximated as zero.
61 | P a g e Uzair Suria
5.2 Partial Differential Equations
There are many boundary value problems which involve partial differential equations. Only a
few of these equations can be solved by analytical methods. In most cases, we depend on the
numerical solution of such partial differential equations. Of the various numerical methods
available for solving these equations, the method of finite differences is most commonly used.
In this method, the derivatives appearing in the equation and the boundary conditions are
replaced by their finite-difference approximations. Then the given equation is changed to a
difference equation which is solved by iterative procedures. This process is slow but gives good
results of boundary value problems. An added advantage of this method is that the computation
can be done by electronic computer.
2
𝜕𝜕 2 𝑢𝑢 𝜕𝜕 2 𝑢𝑢
∇ 𝑢𝑢 = 2 + 2 = 0
𝜕𝜕𝑥𝑥 𝜕𝜕𝑦𝑦
Poisson’s equation is a variation of the Laplace’s equation, and is given by:
𝜕𝜕 2 𝑢𝑢 𝜕𝜕 2 𝑢𝑢
∇2 𝑢𝑢 = + = 𝑓𝑓(𝑥𝑥, 𝑦𝑦)
𝜕𝜕𝑥𝑥 2 𝜕𝜕𝑦𝑦 2
Substituting the values of 1st and 2nd partial derivatives in to Laplace’s Equation gives:
1 1
∇2 𝑢𝑢 = 2
�𝑢𝑢𝑖𝑖−1,𝑗𝑗 − 2𝑢𝑢𝑖𝑖,𝑗𝑗 + 𝑢𝑢𝑖𝑖+1,𝑗𝑗 � + 2 �𝑢𝑢𝑖𝑖,𝑗𝑗−1 − 2𝑢𝑢𝑖𝑖,𝑗𝑗 + 𝑢𝑢𝑖𝑖+𝑗𝑗+1 � = 0
ℎ ℎ
Making 𝑢𝑢𝑖𝑖,𝑗𝑗 the subject of the equation gives:
62 | P a g e Uzair Suria
1
𝑢𝑢𝑖𝑖,𝑗𝑗 = �𝑢𝑢 + 𝑢𝑢𝑖𝑖+1,𝑗𝑗 + 𝑢𝑢𝑖𝑖,𝑗𝑗+1 + 𝑢𝑢𝑖𝑖,𝑗𝑗−1 �
4 𝑖𝑖−1,𝑗𝑗
where
𝑢𝑢𝑖𝑖+1,𝑗𝑗 = 𝑢𝑢(𝑥𝑥 + ℎ, 𝑦𝑦)
𝑢𝑢𝑖𝑖−1,𝑗𝑗 = 𝑢𝑢(𝑥𝑥 − ℎ, 𝑦𝑦)
𝑢𝑢𝑖𝑖,𝑗𝑗−1 = 𝑢𝑢(𝑥𝑥, 𝑦𝑦 − 𝑘𝑘)
𝑢𝑢𝑖𝑖,𝑗𝑗+1 = 𝑢𝑢(𝑥𝑥, 𝑦𝑦 − 𝑘𝑘)
Consider a rectangular region 𝑹𝑹 for which 𝑢𝑢 (𝑥𝑥, 𝑦𝑦) is known at the boundary. Divide this
region into a network of square mesh of side ℎ.
𝑌𝑌
𝑢𝑢1,4 𝑏𝑏5,4
𝑢𝑢2,4 𝑢𝑢3,4 𝑢𝑢4,4
𝑏𝑏1,3 𝑏𝑏5,3
𝑢𝑢2,3 𝑢𝑢3,3 𝑢𝑢4,3
𝑏𝑏1,2 𝑏𝑏5,2
𝑢𝑢2,2 𝑢𝑢3,2 𝑢𝑢4,2
𝑋𝑋
𝑏𝑏1,1 𝑏𝑏2,1 𝑏𝑏3,1 𝑏𝑏4,1 𝑏𝑏5,1
The equation derived shows that the value of 𝑢𝑢𝑖𝑖,𝑗𝑗 at any interior mesh point is the average of
its values at four neighboring points to the left, right, above and below. This equation is called
the standard 5-point formula.
Alternatively, a diagonal 5-point formula can be used, and it is given by:
1
𝑢𝑢𝑖𝑖,𝑗𝑗 = �𝑢𝑢𝑖𝑖−1,𝑗𝑗+1 + 𝑢𝑢𝑖𝑖+1,𝑗𝑗−1 + 𝑢𝑢𝑖𝑖+1,𝑗𝑗+1 + 𝑢𝑢𝑖𝑖−1,𝑗𝑗−1 �
4
Diagonal 5-point formula is less accurate than Standard 5-point formula, yet it is a reasonably
good approximation for obtaining starting values at mesh points.
Usually, Diagonal 5-point formula is used find the value of 𝑢𝑢 at interior mesh points, then
further iterations are done using Standard 5-point formula. The method commonly employed
to solve the resulting simultaneous equations is Liebman’s method, also known as Gauss-Seidal
method (iterative)
When only the standard 5-point formula is used, then Gauss elimination method with
backwards substitution (exact) and Gauss-Jordan elimination method (also exact) are employed
to solve the resulting simultaneous equations.
63 | P a g e Uzair Suria
𝑢𝑢𝑖𝑖,𝑗𝑗+1 𝑢𝑢𝑖𝑖−1,𝑗𝑗−1 𝑢𝑢𝑖𝑖+1,𝑗𝑗+1
(a) (b)
Figure 5-4 Representation of finite difference approximation of Laplace’s equation. (a) Standard 5-Point formula, (b)
Diagonal 5-Point formula
Example 5-4
A square plate of side 12 cm made of homogenous material is kept at constant temperature
of 0° C and 100° C as shown in the figure. Using a grid of 4 cm, find the steady state of
temperature at mesh points
64 | P a g e Uzair Suria
𝑌𝑌
𝑢𝑢 = 0
𝑢𝑢 = 100
𝑢𝑢 = 100
𝑋𝑋
𝑢𝑢 = 100
Solution:
𝑌𝑌
𝑢𝑢1,3 𝑢𝑢2,3
𝑢𝑢0,3
𝑢𝑢3,3
𝑢𝑢0,2
𝑢𝑢1,2 𝑢𝑢2,2 𝑢𝑢3,2
𝑢𝑢0,1
𝑢𝑢1,1 𝑢𝑢2,1 𝑢𝑢3,1
𝑋𝑋
𝑢𝑢0,0 𝑢𝑢1,0 𝑢𝑢2,0 𝑢𝑢3,0
65 | P a g e Uzair Suria
Applying Gauss-Jordan method and converting the above matric in reduced row echelon
form:
1 1
1 − − 0 | 50
1 ⎛ 4 4 ⎞
− 𝑅𝑅1 ⟶ ⎜1 −4 0 1 | −200⎟
4
1 0 −4 1 | −100
⎝0 1 1 −4 | −100⎠
1 1 |
1 − − 0 50
4 4 |
⎛ ⎞
15 1 |
⎜0 − 1 −250⎟
𝑅𝑅2 − 𝑅𝑅1 ⎜ 4 4 | ⎟
⟶⎜ ⎟
𝑅𝑅3 − 𝑅𝑅1 1 15 |
⎜0 − 1 −150⎟
⎜ 4 4 | ⎟
|
0 1 1 −4 −100
⎝ | ⎠
1 1 |
1 − − 0 50
4 4 |
⎛ ⎞
1 4 | 200
⎜0 1 − − ⎟
4 ⎜ 15 15 | 3 ⎟
− 𝑅𝑅2 ⟶ ⎜ ⎟
15 1 15 |
⎜0 − 1 −150⎟
⎜ 4 4 | ⎟
|
0 1 1 −4 −100
⎝ | ⎠
4 1 | 200
1 0 − −
⎛ 15 15 | 3 ⎞
1
R1 + R2 ⎜0 1 − 1 4 | 200 ⎟
4 −
⎜ 15 15 | 3 ⎟
1 ⟶⎜ ⎟
𝑅𝑅3 − 𝑅𝑅2 56 16 | 500
4 ⎜0 0 − − ⎟
𝑅𝑅4 − 𝑅𝑅2 ⎜ 15 15 | 3 ⎟
16 56 | 500
0 0 − −
⎝ 15 15 | 3 ⎠
4 1 | 200
1 0 − −
⎛ 15 15 | 3 ⎞
⎜0 1 − 1 4 | 200 ⎟
15 −
⎜ 15 15 | 3 ⎟
− R3 ⟶ ⎜
56 2 | 625 ⎟
⎜0 0 1 − ⎟
⎜ 7 | 14 ⎟
16 56 | 500
0 0 − −
⎝ 15 15 | 3 ⎠
1 | 550
1 0 0 −
4 ⎛ 7 | 7 ⎞
𝑅𝑅1 + 𝑅𝑅3 2 | 975
15 ⎜0 1 0 − − ⎟
1 ⎜ 7 | 14 ⎟
𝑅𝑅2 + 𝑅𝑅3 ⟶ ⎜ 2 | 625 ⎟
15 ⎜0 0 1 − ⎟
16 ⎜ 7 | 14 ⎟
𝑅𝑅4 − 𝑅𝑅3
15 24 | 1500
0 0 0 − −
⎝ 7 | 7 ⎠
66 | P a g e Uzair Suria
1 | 550
1 0 0 −
7 | 7 ⎞
⎛
2 | 975
⎜0 1 0 − ⎟
7 ⎜ 7 | 14 ⎟
− 𝑅𝑅4 ⟶ ⎜
24 2 | 625⎟
⎜0 0 1 − ⎟
⎜ 7 | 14 ⎟
| 125
0 0 0 1
⎝ | 2 ⎠
| 175
1 0 0 0
1 | 2 ⎞
𝑅𝑅1 + 𝑅𝑅4 ⎛
7 | 175
⎜0 1 0 0 ⎟
2 ⎜ | 2 ⎟
𝑅𝑅2 + 𝑅𝑅4 ⟶ ⎜ 125⎟
7 |
⎜0 0 1 0 ⎟
2 ⎜ | 2 ⎟
𝑅𝑅3 + 𝑅𝑅4
7 | 125
0 0 0 1
⎝ | 2 ⎠
Therefore,
𝑢𝑢11 175/2
𝑢𝑢21 175/2
� 𝑢𝑢 � = � �
12 125/2
𝑢𝑢22 125/2
The standard 5-point is arranged such that the required variables are the subject of the
relation.
𝑢𝑢11 = 0.25𝑢𝑢21 + 0.25𝑢𝑢12 + 50
𝑢𝑢21 = 0.25𝑢𝑢22 + 0.25𝑢𝑢11 + 50
𝑢𝑢12 = 0.25𝑢𝑢11 + 0.25𝑢𝑢22 + 25
𝑢𝑢22 = 0.25𝑢𝑢12 + 0.25𝑢𝑢21 + 25
1st Iteration
(1)
𝑢𝑢11 = 0.25(100) + 0.25(100) + 50 = 100
(1)
𝑢𝑢21 = 0.25(100) + 0.25(100) + 50 = 100
(1)
𝑢𝑢12 = 0.25(100) + 0.25(100) + 25 = 75
(1)
𝑢𝑢22 = 0.25(75) + 0.25(100) + 25 = 68.75
2nd Iteration
67 | P a g e Uzair Suria
(2)
𝑢𝑢22 = 0.25(65.625) + 0.25(90.625) + 25 = 64.064
3rd Iteration
(3)
𝑢𝑢11 = 0.25(90.625) + 0.25(65.625) + 50 = 89.0625
(3)
𝑢𝑢21 = 0.25(64.064) + 0.25(89.0625) + 50 = 88.2816
(3)
𝑢𝑢12 = 0.25(89.0625) + 0.25(64.064) + 25 = 63.2816
(3)
𝑢𝑢22 = 0.25(63.2816) + 0.25(88.2816) + 25 = 62.8908
4th Iteration
(4)
𝑢𝑢11 = 0.25(88.2816) + 0.25(63.2816) + 50 = 87.8908
(4)
𝑢𝑢21 = 0.25(62.8908) + 0.25(87.8908) + 50 = 87.6954
(4)
𝑢𝑢12 = 0.25(87.8908) + 0.25(62.8908) + 25 = 62.6954
(4)
𝑢𝑢22 = 0.25(62.6954) + 0.25(87.6954) + 25 = 62.5977
5th Iteration
(5)
𝑢𝑢11 = 0.25(87.6954) + 0.25(62.6954) + 50 = 87.5977
(5)
𝑢𝑢21 = 0.25(62.5977) + 0.25(87.5977) + 50 = 87.5489
(5)
𝑢𝑢12 = 0.25(87.5977) + 0.25(62.5977) + 25 = 62.5489
(5)
𝑢𝑢22 = 0.25(62.5489) + 0.25(87.5489) + 25 = 62.5244
6th Iteration
(6)
𝑢𝑢11 = 0.25(87.5489) + 0.25(62.5489) + 50 = 87.5244
(6)
𝑢𝑢21 = 0.25(62.5244) + 0.25(87.5244) + 50 = 87.5122
(6)
𝑢𝑢12 = 0.25(87.5244) + 0.25(62.5244) + 25 = 62.5122
(6)
𝑢𝑢22 = 0.25(62.5122) + 0.25(87.5122) + 25 = 62.5061
7th Iteration
(7)
𝑢𝑢11 = 0.25(87.5122) + 0.25(62.5122) + 50 = 87.5061
(7)
𝑢𝑢21 = 0.25(62.5061) + 0.25(87.5061) + 50 = 87.5030
(7)
𝑢𝑢12 = 0.25(87.5061) + 0.25(62.5061) + 25 = 62.5030
(7)
𝑢𝑢22 = 0.25(62.5030) + 0.25(87.5030) + 25 = 62.5015
Therefore, the internal values correct up to 2 d.p are
𝑢𝑢11 87.50
𝑢𝑢21 87.50
� 𝑢𝑢 � = � �
12 62.50
𝑢𝑢22 62.50
Example 5-5
The values of 𝑢𝑢(𝑥𝑥, 𝑦𝑦) on the boundary of a square is shown in the figure. Evaluate the
function 𝑢𝑢(𝑥𝑥, 𝑦𝑦) that satisfies the Laplace’s equation, ∇2 𝑢𝑢 = 0, at the pivotal point of this
figure
68 | P a g e Uzair Suria
𝑌𝑌
2000 500
𝑢𝑢1 𝑢𝑢2
1000 𝑋𝑋
500 0 0
Solution:
Since all the adjacent boundary values at 𝑢𝑢4 are 0, then taking the value of 𝑢𝑢4 = 0 is a good
approximation. Hence, the first approximation of the internal points are as follows:
(0) 1
𝑢𝑢1 = (1000 + 1000 + 𝑢𝑢4 + 2000)
4
1
= (1000 + 1000 + 0 + 2000) = 1000 (diag. )
4
(0) 1
𝑢𝑢2 = (500 + 1000 + 𝑢𝑢1 + 𝑢𝑢4 )
4
1
= (500 + 1000 + 1000 + 0) = 625 (stnd. )
4
(0) 1
𝑢𝑢3 = (500 + 𝑢𝑢4 + 𝑢𝑢1 + 2000)
4
1
= (500 + 0 + 1000 + 2000) = 875 (stnd. )
4
(0) 1
𝑢𝑢4 = (0 + 0 + 𝑢𝑢2 + 𝑢𝑢3 )
4
1
= (0 + 0 + 625 + 875) = 375 (stnd. )
4
Using Gauss-Seidle Method, the 5 – point standard iteration formulae can be written as
follows:
(𝑛𝑛+1) (𝑛𝑛) (𝑛𝑛)
𝑢𝑢1 = 0.25�1000 + 2000 + 𝑢𝑢3 + 𝑢𝑢2 �
(𝑛𝑛+1) (𝑛𝑛+1) (𝑛𝑛)
𝑢𝑢2 = 0.25�500 + 1000 + 𝑢𝑢1 + 𝑢𝑢4 �
(𝑛𝑛+1) (𝑛𝑛) (𝑛𝑛+1)
𝑢𝑢3 = 0.25�500 + 2000 + 𝑢𝑢4 + 𝑢𝑢1 �
(𝑛𝑛+1) (𝑛𝑛+1) (𝑛𝑛+1)
𝑢𝑢4 = 0.25�0 + 0 + 𝑢𝑢2 + 𝑢𝑢3 �
1st Iteration
69 | P a g e Uzair Suria
(1)
𝑢𝑢3 = 0.25(500 + 2000 + 375 + 1125) = 1000
(1)
𝑢𝑢4 = 0.25(0 + 0 + 750 + 1000) = 438
2nd Iteration
(2)
𝑢𝑢1 = 0.25(1000 + 2000 + 1000 + 750) = 1188
(2)
𝑢𝑢2 = 0.25(500 + 1000 + 1188 + 438) = 782
(2)
𝑢𝑢3 = 0.25(500 + 2000 + 438 + 1188) = 1032
(2)
𝑢𝑢4 = 0.25(0 + 0 + 782 + 1032) = 454
3rd Iteration
(3)
𝑢𝑢1 = 0.25(1000 + 2000 + 1032 + 782) = 1204
(3)
𝑢𝑢2 = 0.25(500 + 1000 + 1204 + 454) = 790
(3)
𝑢𝑢3 = 0.25(500 + 2000 + 454 + 1204) = 1040
(3)
𝑢𝑢4 = 0.25(0 + 0 + 790 + 1040) = 458
4th Iteration
(4)
𝑢𝑢1 = 0.25(1000 + 2000 + 1040 + 790) = 1208
(4)
𝑢𝑢2 = 0.25(500 + 1000 + 1208 + 458) = 792
(4)
𝑢𝑢3 = 0.25(500 + 2000 + 458 + 1208) = 1042
(4)
𝑢𝑢4 = 0.25(0 + 0 + 792 + 1042) = 459
5th Iteration
(5)
𝑢𝑢1 = 0.25(1000 + 2000 + 1042 + 792) = 1209
(5)
𝑢𝑢2 = 0.25(500 + 1000 + 1209 + 459) = 792
(5)
𝑢𝑢3 = 0.25(500 + 2000 + 459 + 1209) = 1042
(5)
𝑢𝑢4 = 0.25(0 + 0 + 792 + 1042) = 459
Since there is no significant change between last two consecutive iterations, the values have
converged. Hence,
𝑢𝑢1 1209
𝑢𝑢2 792
�𝑢𝑢 � = � �
3 1042
𝑢𝑢4 459
70 | P a g e Uzair Suria
6 SYSTEM OF LINEAR EQUATIONS
A system of linear equations consists of two or more linear equations made up of two or more
variables such that all equations in the system are considered simultaneously. To find the
unique solution to a system of linear equations, a numerical value for each variable in the
system must be found that will satisfy all equations in the system at the same time. Some linear
systems may not have a solution and others may have an infinite number of solutions. In order
for a linear system to have a unique solution, there must be at least as many equations as there
are variables. Even so, this does not guarantee a unique solution
71 | P a g e Uzair Suria
𝑎𝑎11 ⋯ 𝑎𝑎1𝑛𝑛 𝑏𝑏1
� ⋮ ⋱ ⋮ �⋮�
𝑎𝑎𝑚𝑚1 ⋯ 𝑎𝑎𝑚𝑚𝑚𝑚 𝑏𝑏𝑛𝑛
The separator line is used for visual reference and has no significance on the calculations or
the purpose of augmented matrix.
A consistent system is a dependent system if the equations have an infinite number of solutions.
For example, two lines with the same slope and the same y-intercepts will coincide and the two
equations represents the same line, and every point on the line represents a coordinate pair that
satisfies the system thereby giving infinite number of solutions. Alternatively, solution of two
equations representing non-parallel planes will also have infinite number of solutions since the
intersection of two planes results in a line.
For a system to be dependent, following condition must be met
Rank of Matrix 𝐴𝐴 < Rank of Reduced Matrix 𝐴𝐴𝑏𝑏
72 | P a g e Uzair Suria
in order to evaluate the remaining unknowns. Applying Gauss elimination will convert the
matrix in row echelon form (REF).
Basically, all variables in the last row are eliminated except for one, all variables in the row
above are eliminated, except two, and so on and so forth to the top equation, which has all the
variables. Then back substitution is used to solve for one variable at a time by plugging the
known values into the equations from the bottom up.
A matrix is in row echelon form (ref) when it satisfies the following conditions.
• The first non-zero element in each row, called the leading entry, is 1.
• Each leading entry is in a column to the right of the leading entry in the previous row.
In case of consistent independent system, all the elements on principle diagonal will be
leading entry with a value of unity.
• Rows with all zero elements, if any, are below rows having a non-zero element.
Example 6-1
Solve the given system of equation by using Gauss Elimination method:
2𝑥𝑥 + 5𝑦𝑦 + 3𝑧𝑧 = 9
3𝑥𝑥 + 𝑦𝑦 + 2𝑧𝑧 = 3
𝑥𝑥 + 2𝑦𝑦 − 𝑧𝑧 = 6
Solution:
The augmented matrix form of the given system is:
2 5 3 | 9
�3 1 2 | 3�
1 2 −1 | 6
Applying gauss elimination:
73 | P a g e Uzair Suria
1 2 −1 | 6
𝑅𝑅3 ⇆ 𝑅𝑅1 ⟶ �3 1 2 | 3�
2 5 3 | 9
1 2 −1 | 6
𝑅𝑅2 − 3𝑅𝑅1
⟶ �0 −5 5 | −15�
𝑅𝑅3 − 2𝑅𝑅1
0 1 5 | −3
1 2 −1 | 6
1
− 𝑅𝑅2 ⟶ �0 1 −1 | 3�
5
0 1 5 | −3
1 2 −1 | 6
𝑅𝑅3 − 𝑅𝑅2 ⟶ �0 1 −1 | 3�
0 0 6 | −6
1 2 −1 | 6
1
𝑅𝑅 ⟶ �0 1 −1 | 3�
6 3
0 0 1 | −1
The form obtained above is REF, and
2 5 3 | 9 1 2 −1 | 6
�3 1 2 | 3� ≡ �0 1 −1 | 3�
1 2 −1 | 6 0 0 1 | −1
Using back substitution
𝑧𝑧 = −1
𝑦𝑦 − 𝑧𝑧 = 3
𝑦𝑦 = 3 + 𝑧𝑧
=3−1
=2
𝑥𝑥 + 2𝑦𝑦 − 𝑧𝑧 = 6
𝑥𝑥 = 6 + 𝑧𝑧 − 2𝑦𝑦
= 6 − 1 − 2(2)
=1
Therefore,
𝑥𝑥 1
�𝑦𝑦� = � 2�
𝑧𝑧 −1
74 | P a g e Uzair Suria
6.3.2.1 Steps for Solution through Gauss – Jordan Elimination
The basic steps to solve a linear system through Gaussian elimination are as follows:
1. Write the system of equations in augmented matrix form
2. Perform elementary row operation to convert all the leading entries to unity and get
zeros below and above the leading entries. Elementary row operation is one of the
following
• Multiply all the elements of the row by a non-zero constant
• Add or subtract a non-zero multiple of one row to another
• Switch two rows
3. The final form of the augmented matrix will give the value of variables, without the
need of back substitution.
Example 6-2
Solve the given system of equation by using Gauss – Jordan Elimination method:
𝑥𝑥 + 2𝑦𝑦 + 3𝑧𝑧 = 6
3𝑥𝑥 − 2𝑦𝑦 + 𝑧𝑧 = 2
4𝑥𝑥 + 2𝑦𝑦 + 𝑧𝑧 = 7
Solution:
The augmented matrix form of the given system is:
1 2 3 | 6
�3 −2 1 | 2�
4 2 1 | 7
Applying Gauss – Jordan elimination:
1 2 3 | 6
𝑅𝑅2 − 3𝑅𝑅1
⟶ �0 −8 −8 | −16�
𝑅𝑅3 − 4𝑅𝑅1
0 −6 −11 | −17
1 2 3 | 6
1
− 𝑅𝑅2 ⟶ �0 1 1 | 2�
8
0 −6 −11 | −17
1 0 1 | 2
𝑅𝑅1 − 2𝑅𝑅2
⟶ �0 1 1 | 2�
𝑅𝑅3 + 6𝑅𝑅2
0 0 −5 | −5
1 0 1 | 2
1
− 𝑅𝑅2 ⟶ �0 1 1 | 2�
5
0 0 1 | 1
1 0 0 | 1
𝑅𝑅1 − 𝑅𝑅3
⟶ �0 1 0 | 1�
𝑅𝑅2 − 𝑅𝑅3
0 0 1 | 1
Hence,
𝑥𝑥 1
�𝑦𝑦� = �1�
𝑧𝑧 1
75 | P a g e Uzair Suria
Example 6-3
Solve the given system of equation by using Elimination method:
𝑥𝑥 − 𝑦𝑦 + 𝑧𝑧 = 1
2𝑥𝑥 + 𝑦𝑦 − 𝑧𝑧 = 2
5𝑥𝑥 − 2𝑦𝑦 + 2𝑧𝑧 = 5
Solution:
The augmented matrix form of the given system is:
1 −1 1 | 1
� 2 1 −1 | 2�
5 −2 2 | 5
Applying Gaussian elimination:
1 −1 1 | 1
𝑅𝑅2 − 2𝑅𝑅1
⟶� 0 3 −3 | 0�
𝑅𝑅3 − 5𝑅𝑅1
0 3 −3 | 0
1 −1 1 | 1
1
𝑅𝑅 ⟶ � 0 1 −1 | 0�
3 2
0 3 −3 | 0
1 −1 1 | 1
𝑅𝑅3 − 3𝑅𝑅2 ⟶ �0 1 −1 | 0�
0 0 0 | 0
Since 𝑟𝑟𝑟𝑟𝑟𝑟𝑟𝑟(𝐴𝐴𝑏𝑏 ) < number of unknowns, the system has infinite solutions. To obtain the
infinite solution, let 𝑧𝑧 = 𝑘𝑘, where 𝑘𝑘 ∈ ℝ, then
𝑦𝑦 − 𝑧𝑧 = 0
𝑦𝑦 = 𝑧𝑧
= 𝑘𝑘
𝑥𝑥 − 𝑦𝑦 + 𝑧𝑧 = 1
𝑥𝑥 = 1 − 𝑧𝑧 + 𝑦𝑦
= 1 − 𝑘𝑘 + 𝑘𝑘
=1
Hence,
𝑥𝑥 1
𝑦𝑦
� � = �𝑘𝑘 �
𝑧𝑧 𝑘𝑘
76 | P a g e Uzair Suria
Example 6-4
Solve the given homogenous system of equation by using Elimination method:
𝑥𝑥1 + 𝑥𝑥2 + 2𝑥𝑥3 = 0
𝑥𝑥1 − 2𝑥𝑥2 + 𝑥𝑥3 = 0
3𝑥𝑥1 + 𝑥𝑥2 + 𝑥𝑥3 = 0
Solution:
The augmented matrix form of the given system is:
1 1 2 | 0
�1 −2 1 | 0�
3 1 1 | 0
Applying Gaussian elimination:
1 1 2 | 0
𝑅𝑅2 − 𝑅𝑅1
⟶� 0 −3 −1 | 0�
𝑅𝑅3 − 3𝑅𝑅1
0 −2 −5 | 0
|
1 1 2 0
|
⎛ ⎞
1 1 |
− 𝑅𝑅2 ⟶ ⎜0 1 0⎟
3 ⎜ 3 | ⎟
|
0 −2 −5 0
⎝ | ⎠
|
1 1 2 0
|
⎛ ⎞
1 |
⎜
𝑅𝑅3 + 2𝑅𝑅2 ⟶ ⎜0 1 0⎟
3 | ⎟
⎜ ⎟
13 |
0 0 − 0
⎝ 3 | ⎠
|
1 1 2 0
|
⎛ ⎞
3 1 |
− 𝑅𝑅3 ⟶ ⎜0 1 0⎟
13 ⎜ 3 | ⎟
|
0 0 1 0
⎝ | ⎠
Hence,
𝑥𝑥1 0
�𝑥𝑥2 � = �0�
𝑥𝑥3 0
77 | P a g e Uzair Suria
6.4 LU Decomposition
Up till now, Gauss – elimination or its variation has been used to solve the system of linear
algebraic equation
𝐴𝐴𝐴𝐴 = 𝐵𝐵
Although it certainly represents a sound way to solve such systems, it becomes inefficient when
solving equations with the same coefficients 𝐴𝐴, but with different right-hand-side constants 𝐵𝐵.
Recall that Gauss elimination involves two steps: forward elimination and back substitution.
Of these, the forward-elimination step comprises the bulk of the computational effort. This is
particularly true for large systems of equations.
LU decomposition methods separate the time-consuming elimination of the matrix 𝐴𝐴 from the
manipulations of the right-hand side 𝐵𝐵. Thus, once 𝐴𝐴 has been “decomposed,” multiple right-
hand-side vectors can be evaluated in an efficient manner.
78 | P a g e Uzair Suria
𝐿𝐿𝐿𝐿 = 𝐵𝐵
To compute matrices 𝐿𝐿 and 𝑈𝑈, following relation can be used:
1 0 0 𝑢𝑢11 𝑢𝑢12 𝑢𝑢13 𝑎𝑎11 𝑎𝑎12 𝑎𝑎13
�𝑙𝑙21 1 0� � 0 𝑢𝑢22 𝑢𝑢23 � = �𝑎𝑎21 𝑎𝑎22 𝑎𝑎23 �
𝑙𝑙31 𝑙𝑙32 1 0 0 𝑢𝑢33 𝑎𝑎31 𝑎𝑎32 𝑎𝑎33
Following steps are to be followed to solve a linear system using Crout’s method
1. Using 𝐴𝐴 = 𝐿𝐿𝐿𝐿, find the matrix 𝐿𝐿 and 𝑈𝑈
2. Using 𝐿𝐿𝐿𝐿 = 𝐵𝐵, find the matrix 𝑌𝑌
3. Using 𝑈𝑈𝑈𝑈 = 𝑌𝑌, find the matrix 𝑋𝑋
Example 6-5
Solve the given system of equations by using Doolittle method:
4𝑥𝑥1 + 3𝑥𝑥2 − 𝑥𝑥3 = −2
−2𝑥𝑥1 − 4𝑥𝑥2 + 5𝑥𝑥3 = 20
𝑥𝑥1 + 2𝑥𝑥2 + 6𝑥𝑥3 = 7
Solution:
𝐴𝐴 = 𝐿𝐿𝐿𝐿
4 3 −1 1 0 0 𝑢𝑢11 𝑢𝑢12 𝑢𝑢13
�−2 −4 5� = �𝑙𝑙21 1 0� � 0 𝑢𝑢22 𝑢𝑢23 �
1 2 6 𝑙𝑙31 𝑙𝑙32 1 0 0 𝑢𝑢33
4 3 −1 𝑢𝑢11 𝑢𝑢12 𝑢𝑢13
�−2 −4 𝑙𝑙
5� = � 21 11 𝑢𝑢 𝑙𝑙 𝑢𝑢
21 12 + 𝑢𝑢 22 𝑙𝑙21 13 + 𝑢𝑢23
𝑢𝑢 �
1 2 6 𝑙𝑙31 11𝑢𝑢 𝑙𝑙 𝑢𝑢
31 12 + 𝑙𝑙 𝑢𝑢
32 22 𝑙𝑙 𝑢𝑢
31 13 + 𝑙𝑙 𝑢𝑢
32 23 + 𝑢𝑢 33
Now,
𝑢𝑢11 = 4 𝑢𝑢12 = 3 𝑢𝑢13 = −1
𝑙𝑙21 𝑢𝑢11 = −2 𝑙𝑙21 𝑢𝑢12 + 𝑢𝑢22 = −4 𝑙𝑙21 𝑢𝑢13 + 𝑢𝑢23 = 5
2 1 𝑢𝑢22 = −4 − 𝑙𝑙21 𝑢𝑢12 𝑢𝑢23 = 5 − 𝑙𝑙21 𝑢𝑢13
𝑙𝑙21 = − = − 1 1
4 2
𝑢𝑢22 = −4 − �− � (3) 𝑢𝑢23 = 5 − �− � (−1)
2 2
5 9
𝑢𝑢22 = − 𝑢𝑢23 =
2 2
𝑙𝑙31 𝑢𝑢11 = 1 𝑙𝑙31 𝑢𝑢12 + 𝑙𝑙32 𝑢𝑢22 = 2 𝑙𝑙31 𝑢𝑢13 + 𝑙𝑙31 𝑢𝑢23 + 𝑢𝑢33 = 6
1 2 − 𝑙𝑙31 𝑢𝑢12 𝑢𝑢33 = 6 − 𝑙𝑙31 𝑢𝑢13 − 𝑙𝑙32 𝑢𝑢23
𝑙𝑙31 = 𝑙𝑙32 = 1 1 9
𝑢𝑢11 𝑢𝑢22 𝑢𝑢33 = 6 − � � (−1) − �− � � �
1 1 4 2 2
𝑙𝑙31 = 2 − � � (3) 17
4 𝑙𝑙32 = 4
5 𝑢𝑢33 =
− 2
2
1
𝑙𝑙32 = −
2
Since
𝐴𝐴𝐴𝐴 = 𝐵𝐵
Taking 𝐴𝐴 = 𝐿𝐿𝐿𝐿, therefore
𝐿𝐿𝐿𝐿𝐿𝐿 = 𝐵𝐵
Taking 𝑈𝑈𝑈𝑈 = 𝑌𝑌, hence
𝑈𝑈𝑈𝑈 = 𝑌𝑌
and
79 | P a g e Uzair Suria
𝐿𝐿𝐿𝐿 = 𝐵𝐵
1 0 0
1 𝑦𝑦1 −2
⎛− 1 0⎞ 𝑦𝑦
⎜ 2 ⎟ � 2 � = � 20 �
1 1 𝑦𝑦3 7
− 1
⎝ 4 2 ⎠
𝑦𝑦1 = −2
1
− 𝑦𝑦1 + 𝑦𝑦2 = 20
2
1
𝑦𝑦2 = 20 + 𝑦𝑦1
2
1
= 20 + (−2)
2
= 19
1 1
𝑦𝑦1 − 𝑦𝑦2 + 𝑦𝑦3 = 7
4 2
1 1
𝑦𝑦3 = 7 − 𝑦𝑦1 + 𝑦𝑦2
4 2
1 1
= 7 − (−2) + (19)
4 2
= 17
But,
𝑈𝑈𝑈𝑈 = 𝑌𝑌
4 3 −1
5 9 𝑥𝑥 −2
⎛0 − ⎞ 1
⎜ 2 2 ⎟ � 𝑥𝑥2 � = � 19 �
17 𝑥𝑥3 17
0 0
⎝ 2⎠
𝑥𝑥3 = 2
5 9
− 𝑥𝑥2 + 𝑥𝑥3 = 19
2 2
9
19 − 𝑥𝑥3
𝑥𝑥2 = 2
5
−
2
9
19 − (2)
= 2
5
−
2
= −4
4𝑥𝑥1 + 3𝑥𝑥2 − 𝑥𝑥3 = −2
−2 − 3𝑥𝑥2 + 𝑥𝑥3
𝑥𝑥1 =
4
−2 − 3(−4) + (2)
=
4
=3
Therefore, 𝑥𝑥1 = 3, 𝑥𝑥2 − 4, 𝑥𝑥3 = 2
80 | P a g e Uzair Suria
Practice Question
Use Doolittle’s method of matrix decomposition to solve the following linear system:
2𝑥𝑥1 + 𝑥𝑥2 + 3𝑥𝑥3 = 11
4𝑥𝑥1 + 3𝑥𝑥2 + 10𝑥𝑥3 = 28
2𝑥𝑥1 + 4𝑥𝑥2 + 17𝑥𝑥3 = 31
Following steps are to be followed to solve a linear system using Crout’s method
1. Using 𝐴𝐴 = 𝐿𝐿𝐿𝐿, find the matrix 𝐿𝐿 and 𝑈𝑈
2. Using 𝐿𝐿𝐿𝐿 = 𝐵𝐵, find the matrix 𝑌𝑌
81 | P a g e Uzair Suria
3. Using 𝑈𝑈𝑈𝑈 = 𝑌𝑌, find the matrix 𝑋𝑋
Example 6-6
Solve the given system of equations by using Crout’s method:
2𝑥𝑥1 + 𝑥𝑥2 + 3𝑥𝑥3 = 11
4𝑥𝑥1 − 3𝑥𝑥2 + 10𝑥𝑥3 = 28
2𝑥𝑥1 + 4𝑥𝑥2 + 17𝑥𝑥3 = 7
Solution:
𝐴𝐴 = 𝐿𝐿𝐿𝐿
2 1 3 𝑙𝑙11 0 0 1 𝑢𝑢12 𝑢𝑢13
�4 −3 10� = �𝑙𝑙21 𝑙𝑙22 0 � �0 1 𝑢𝑢23 �
2 4 17 𝑙𝑙31 𝑙𝑙32 𝑙𝑙33 0 0 1
2 1 3 𝑙𝑙11 𝑙𝑙11 𝑢𝑢12 𝑙𝑙11 𝑢𝑢13
�4 −3 10� = �𝑙𝑙21 𝑙𝑙21 𝑢𝑢12 + 𝑙𝑙22 𝑙𝑙21 𝑢𝑢13 + 𝑙𝑙22 𝑢𝑢23 �
2 4 17 𝑙𝑙31 𝑒𝑒31 𝑢𝑢12 + 𝑒𝑒32 𝑒𝑒31 𝑢𝑢13 + 𝑒𝑒23 𝑢𝑢23 + 𝑒𝑒33
From above,
5 0 0 2 1
19 1 −
⎛7 0 ⎞ ⎛ 5 5⎞
𝐿𝐿 = ⎜ 5 ⎟ and 𝑈𝑈 = ⎜0 1 32⎟
41 327 19
3
⎝ 5 19 ⎠ ⎝0 0 1⎠
Now,
𝐿𝐿𝐿𝐿 = 𝐵𝐵
5 0 0
19 𝑦𝑦1 11
⎛7 0 ⎞ 𝑦𝑦
⎜ 5 ⎟ � 2 � = � 28�
41 327 𝑦𝑦3 7
3
⎝ 5 19 ⎠
4
𝑦𝑦1 ⎛ 5 ⎞
12
�𝑦𝑦2 � = ⎜ ⎟
𝑦𝑦3 ⎜ 19 ⎟
46
⎝327⎠
Using the relation 𝑈𝑈𝑈𝑈 = 𝑌𝑌
2 1
1 −
⎛ 5 5 ⎞ 𝑥𝑥1 4/5
⎜0 1 32⎟ � 2 � = � 12/19 �𝑥𝑥
19 𝑥𝑥3 46/327
⎝0 0 1⎠
122
𝑥𝑥1 ⎛109⎞
12
�𝑥𝑥2 � = ⎜ ⎟
𝑥𝑥3 ⎜ 19 ⎟
46
⎝327⎠
82 | P a g e Uzair Suria
6.4.3 Cholesky Decomposition
Cholesky decomposition or Cholesky factorization is a decomposition of a Hermitian (a matrix
that is equal to its own conjugate transpose), positive-definite matrix into the product of a lower
triangular matrix and its conjugate transpose, which is useful for efficient numerical solutions.
When it is applicable, the Cholesky decomposition is roughly twice as efficient as the Doolittle
Decomposition for solving systems of linear equations.
Cholesky decomposition is given by
𝐴𝐴 = 𝐿𝐿𝐿𝐿
if 𝑈𝑈 = 𝐿𝐿𝑇𝑇 , then
𝐴𝐴 = 𝐿𝐿𝐿𝐿𝑇𝑇
Therefore
𝑎𝑎11 𝑎𝑎12 𝑎𝑎13
�𝑎𝑎21 𝑎𝑎22 𝑎𝑎23 �
𝑎𝑎31 𝑎𝑎32 𝑎𝑎33
Moreover,
𝐿𝐿𝐿𝐿𝑇𝑇 𝑋𝑋 = 𝐵𝐵
And let 𝐿𝐿𝑇𝑇 𝑋𝑋 = 𝑌𝑌, then
𝐿𝐿𝐿𝐿 = 𝐵𝐵
Following steps are to be followed to solve a linear system using Cholesky method
1. Using 𝐴𝐴 = 𝐿𝐿𝐿𝐿𝑇𝑇 , find the matrix 𝐿𝐿 and 𝐿𝐿𝑇𝑇
2. Using 𝐿𝐿𝐿𝐿 = 𝐵𝐵, find the matrix 𝑌𝑌
3. Using 𝐿𝐿𝑇𝑇 𝑋𝑋 = 𝑌𝑌, find the matrix 𝑋𝑋
Example 6-7
Solve the given system of equations by using Cholesky method:
4𝑥𝑥1 + 2𝑥𝑥2 + 14𝑥𝑥3 = 14
2𝑥𝑥1 + 17𝑥𝑥2 − 5𝑥𝑥3 = −101
14𝑥𝑥1 − 5𝑥𝑥2 + 83𝑥𝑥3 = 155
Solution:
𝐴𝐴 = 𝐿𝐿𝐿𝐿𝑇𝑇
4 2 14 𝑙𝑙11 0 0 𝑙𝑙11 𝑙𝑙21 𝑙𝑙31
� 2 17 −5� = �𝑙𝑙21 𝑙𝑙22 0 � � 0 𝑙𝑙22 𝑙𝑙32 �
14 −5 83 𝑙𝑙31 𝑙𝑙32 𝑙𝑙33 0 0 𝑙𝑙33
2
4 2 14 𝑙𝑙11 𝑙𝑙11 𝑙𝑙21 𝑙𝑙11 𝑙𝑙31
2 2
� 2 17 −5� = �𝑙𝑙21 𝑙𝑙11 𝑙𝑙21 + 𝑙𝑙22 𝑙𝑙21 𝑙𝑙31 + 𝑙𝑙22 𝑙𝑙32 �
14 −5 83 𝑙𝑙31 𝑙𝑙11 𝑙𝑙31 𝑙𝑙21 + 𝑙𝑙32 𝑙𝑙22 𝑙𝑙312
+ 𝑙𝑙322 2
+ 𝑙𝑙33
From above,
𝑙𝑙11 = 2, 𝑙𝑙21 = 1, 𝑙𝑙31 = 7, 𝑙𝑙22 = 4, 𝑙𝑙32 = −3 and 𝑙𝑙33 = 5
83 | P a g e Uzair Suria
2 0 0 2 1 7
𝐿𝐿 = �1 4 0� and 𝐿𝐿𝑇𝑇 = �0 4 −3�
7 −3 5 0 0 5
Using 𝐿𝐿𝐿𝐿 = 𝐵𝐵
2 0 0 𝑦𝑦1 14
�1 4 0 � � 𝑦𝑦2 � = �−101�
7 −3 5 𝑦𝑦3 155
Then
𝑦𝑦1 7
�𝑦𝑦2 � = �−27�
𝑦𝑦3 5
Using the relation 𝐿𝐿𝑇𝑇 𝑋𝑋 = 𝑌𝑌
2 1 7 𝑥𝑥1 7
�0 4 −3 � � 𝑥𝑥2 � = � −27�
0 0 5 𝑥𝑥3 5
𝑥𝑥1 3
�𝑥𝑥2 � = �−6�
𝑥𝑥3 1
Example 6-8
Solve the given system of equations by using Jacobi’s Iterative method:
84 | P a g e Uzair Suria
5𝑥𝑥1 − 2𝑥𝑥2 + 3𝑥𝑥3 = −1
−3𝑥𝑥1 + 9𝑥𝑥2 + 𝑥𝑥3 = 2
2𝑥𝑥1 − 𝑥𝑥2 − 7𝑥𝑥3 = 3
Solution:
The given system is already in diagonally dominant form. Now, making dominant variable
subject of the equation:
85 | P a g e Uzair Suria
after the German mathematicians Carl Friedrich Gauss and Philipp Ludwig von Seidel and is
an improvement to the Jacobi method. Though it can be applied to any matrix with non-zero
elements on the diagonals, convergence is only guaranteed if the matrix is either diagonally
dominant, or symmetric and positive definite.
Example 6-9
Solve the given system of equations by using Gauss – Seidel Iterative method:
𝑥𝑥1 + 𝑥𝑥2 + 54𝑥𝑥3 = 110
6𝑥𝑥1 + 15𝑥𝑥2 + 2𝑥𝑥3 = 72
27𝑥𝑥1 + 6𝑥𝑥2 − 𝑥𝑥3 = 85
Solution:
The given system can be represented in diagonally dominant form by rewriting:
27𝑥𝑥1 + 6𝑥𝑥2 − 𝑥𝑥3 = 85
6𝑥𝑥1 + 15𝑥𝑥2 + 2𝑥𝑥3 = 72
𝑥𝑥1 + 𝑥𝑥2 + 54𝑥𝑥3 = 110
Now, making dominant variable subject of the equation:
(𝑛𝑛+1) 1 (𝑛𝑛) (𝑛𝑛)
𝑥𝑥1 = �85 − 6𝑥𝑥2 + 𝑥𝑥3 �
27
(𝑛𝑛+1) 1 (𝑛𝑛+1) (𝑛𝑛)
𝑥𝑥2 = �72 − 6𝑥𝑥1 − 2𝑥𝑥3 �
15
(𝑛𝑛+1) 1 (𝑛𝑛+1) (𝑛𝑛+1)
𝑥𝑥3 = �110 − 𝑥𝑥1 − 𝑥𝑥2 �
54
(0) (0) (0)
Since no initial approximate is given, 𝑥𝑥1 = 𝑥𝑥2 = 𝑥𝑥3 = 0
When 𝑛𝑛 = 0
86 | P a g e Uzair Suria
(1) 1 85 478
𝑥𝑥3 = �110 − − �
54 27 135
= 1.91316
Practice Questions
1. Solve the following system of linear equations using Gauss Seidel method of iteration.
Perform only four iterations
10𝑥𝑥1 − 2𝑥𝑥2 − 𝑥𝑥3 − 𝑥𝑥4 = 3
−2𝑥𝑥2 + 10𝑥𝑥2 − 𝑥𝑥3 − 𝑥𝑥4 = 15
−𝑥𝑥1 − 𝑥𝑥2 + 10𝑥𝑥3 − 2𝑥𝑥4 = 27
−𝑥𝑥1 − 𝑥𝑥2 − 2𝑥𝑥3 + 10𝑥𝑥4 = −9
Ans.
(4)
𝑥𝑥1 = 0.9968
(4)
𝑥𝑥2 = 1.99818
(4)
𝑥𝑥3 = 2.99866
(4)
𝑥𝑥4 = −0.000709
2. Solve the following system of linear equations using Jacobi’s method of iteration.
Perform iterations till the results converge in two decimal places.
𝑥𝑥1 + 2𝑥𝑥2 + 10𝑥𝑥3 = 35
10𝑥𝑥1 + 3𝑥𝑥2 + 𝑥𝑥3 = 19
3𝑥𝑥1 + 10𝑥𝑥2 + 2𝑥𝑥3 = 29
Ans.
(13)
𝑥𝑥1 = 1.0000188886
(13)
𝑥𝑥2 = 2.000020935
(13)
𝑥𝑥3 = 3.000014781
87 | P a g e Uzair Suria
88 | P a g e Uzair Suria
7 INVERSE INTERPOLATION AND
CURVE FITTING
7.1 Lagrange’s Inverse Interpolation
Inverse interpolation is defined as the process of finding the value of the argument
corresponding to a given value of the function lying between two tabulated functional values.
In this method, the formula used is same as Lagrange’s Interpolation, except that the values of
𝑥𝑥 and 𝑦𝑦 are switched with each other. General form of Lagrange’s inverse interpolation
formula is given by:
(𝑓𝑓 − 𝑓𝑓1 )(𝑓𝑓 − 𝑓𝑓2 ) … (𝑓𝑓 − 𝑓𝑓𝑛𝑛 ) (𝑓𝑓 − 𝑓𝑓0 )(𝑓𝑓 − 𝑓𝑓2 ) … (𝑓𝑓 − 𝑓𝑓𝑛𝑛 )
𝑥𝑥 = 𝑥𝑥0 + 𝑥𝑥 + ⋯
(𝑓𝑓0 − 𝑓𝑓1 )(𝑓𝑓0 − 𝑓𝑓2 ) … (𝑓𝑓0 − 𝑓𝑓𝑛𝑛 ) (𝑓𝑓1 − 𝑓𝑓0 )(𝑓𝑓1 − 𝑓𝑓2 ) … (𝑓𝑓1 − 𝑓𝑓𝑛𝑛 ) 1
(𝑓𝑓 − 𝑓𝑓0 )(𝑓𝑓 − 𝑓𝑓1 ) … (𝑓𝑓 − 𝑓𝑓𝑛𝑛−1 )
+ 𝑥𝑥
(𝑓𝑓𝑛𝑛 − 𝑓𝑓0 )(𝑓𝑓𝑛𝑛 − 𝑓𝑓1 ) … (𝑓𝑓𝑛𝑛 − 𝑓𝑓𝑛𝑛−1 ) 𝑛𝑛
Example 7-1
Use Lagrange’s inverse interpolation to find the value of 𝑥𝑥 when 𝑦𝑦 = 85. Use the following
table in your calculations
𝑥𝑥 2 5 8 14
𝑦𝑦 94.8 87.9 81.3 68.7
Solution:
(𝑓𝑓 − 𝑓𝑓1 )(𝑓𝑓 − 𝑓𝑓2 )(𝑓𝑓 − 𝑓𝑓3 ) (𝑓𝑓 − 𝑓𝑓0 )(𝑓𝑓 − 𝑓𝑓2 )(𝑓𝑓 − 𝑓𝑓3 )
𝑥𝑥 = 𝑥𝑥0 + 𝑥𝑥
(𝑓𝑓0 − 𝑓𝑓1 )(𝑓𝑓0 − 𝑓𝑓2 )(𝑓𝑓0 − 𝑓𝑓3 ) (𝑓𝑓1 − 𝑓𝑓0 )(𝑓𝑓1 − 𝑓𝑓2 )(𝑓𝑓1 − 𝑓𝑓3 ) 1
𝑥𝑥 = 6.303830017
89 | P a g e Uzair Suria
7.2 Regression
In statistical modeling, regression analysis is a set of statistical processes for estimating the
relationships among variables. It includes many techniques for modeling and analyzing several
variables, when the focus is on the relationship between a dependent variable and one or more
independent variables.
More specifically, regression analysis helps one understand how the typical value of the
dependent variable (or 'criterion variable') changes when any one of the independent variables
is varied, while the other independent variables are held fixed.
Let
𝑦𝑦� = 𝑎𝑎 + 𝑏𝑏𝑏𝑏, the curve fitting the given data
𝑦𝑦�𝑖𝑖 = value of 𝑦𝑦, obtained from the curve fitting equation 𝑦𝑦� = 𝑎𝑎 + 𝑏𝑏𝑏𝑏 corresponding to the
value of 𝑥𝑥𝑖𝑖
𝑦𝑦𝑖𝑖 = observed value of 𝑦𝑦 at 𝑥𝑥𝑖𝑖
𝜀𝜀𝑖𝑖 = residual (error), and is given by 𝜀𝜀𝑖𝑖 = 𝑦𝑦 − 𝑦𝑦�
Then the standard deviation of the error is given by
𝑠𝑠 = � 𝜀𝜀𝑖𝑖2
𝑠𝑠 = �(𝑦𝑦 − 𝑦𝑦�)2
The aim of method of least square is to produce a curve such that the standard deviation of the
error is minimized.
90 | P a g e Uzair Suria
Simple Linear Regrssion
𝑦𝑦� = 𝑎𝑎 + 𝑏𝑏𝑏𝑏
𝑦𝑦�𝑖𝑖 = 𝑎𝑎 + 𝑏𝑏𝑥𝑥𝑖𝑖
� represents the
Figure 7-1 represents the parameters of method of least squares. 𝜺𝜺𝒊𝒊 is the error (or residual), 𝒚𝒚
�𝒊𝒊 is the value of 𝒚𝒚 from the curve fitting corresponding to 𝒙𝒙𝒊𝒊 and 𝒚𝒚𝒊𝒊 is the observed
linear curve fitting, 𝒚𝒚
value of 𝒚𝒚 at 𝒙𝒙𝒊𝒊 .
The value of 𝑠𝑠 will be minimum when the rate of change of 𝑠𝑠 w.r.t 𝑎𝑎 and 𝑏𝑏 will be zero.
Therefore,
91 | P a g e Uzair Suria
Equation 7.1 and 7.3 are known as normal equations. Normal equations are analytical
approach to reduce the least square error to its minimum value.
Solving the normal equations simultaneously:
(7.1) can be rewritten as
Σ𝑦𝑦 = 𝑛𝑛𝑛𝑛 + 𝑏𝑏Σ𝑥𝑥
Σ𝑦𝑦 − 𝑏𝑏Σ𝑥𝑥
𝑎𝑎 = (7.4)
𝑛𝑛
and (7.3) can be rewritten as
Σ𝑥𝑥𝑥𝑥 = 𝑎𝑎Σ𝑥𝑥 + 𝑏𝑏Σ𝑥𝑥 2
Σ𝑥𝑥𝑥𝑥 − 𝑏𝑏Σ𝑥𝑥 2
𝑎𝑎 = (7.5)
Σ𝑥𝑥
Now equating equations 7.4 and 7.5
Σ𝑦𝑦 − 𝑏𝑏Σ𝑥𝑥 Σ𝑥𝑥𝑥𝑥 − 𝑏𝑏Σ𝑥𝑥 2
=
𝑛𝑛 Σ𝑥𝑥
Σ𝑥𝑥Σ𝑦𝑦 − 𝑏𝑏(Σ𝑥𝑥)2 = 𝑛𝑛Σ𝑥𝑥𝑥𝑥 − 𝑛𝑛𝑛𝑛Σ𝑥𝑥 2
𝑛𝑛Σ𝑥𝑥𝑥𝑥 − Σ𝑥𝑥Σ𝑦𝑦
𝑏𝑏 = (7.6)
𝑛𝑛Σ𝑥𝑥 2 − (Σ𝑥𝑥)2
Example 7-2
The following table gives the age of cars of certain make and annual maintenance costs.
Obtain the regression equation for the cost related to age. Also give a prediction of
maintenance cost of a car that is aged at 12 years.
Age 2 4 6 8
Cost 10 20 25 30
Solution:
Since age is independent, it is denoted by 𝑥𝑥, while annual maintenance cost is represented
by 𝑦𝑦. Now, calculating required data:
Sr. # 𝑥𝑥 𝑦𝑦 𝑥𝑥 2 𝑦𝑦 2 𝑥𝑥𝑥𝑥
1 2 10 4 100 20
2 4 20 16 400 80
3 6 25 36 625 150
4 8 30 64 900 240
𝛴𝛴 20 85 120 2025 490
Avg 5 21.25
4(490) − (20)(85)
𝑏𝑏 =
4(120) − (20)2
= 3.25
𝑎𝑎 = 21.25 − 5(3.25)
=5
Therefore,
92 | P a g e Uzair Suria
𝑦𝑦 = 5 + 3.25𝑥𝑥
If a car is 12 years old, its annual maintenance cost is given by
𝑦𝑦 = 5 + 3.25(12)
= 44
Practice Questions
1. Fit a straight line for the data given by using least square method:
𝑥𝑥 1.01 1.27 1.85 2.38 2.83 3.13 3.96 4.91
𝑦𝑦 0 0.19 0.58 0.96 1.26 1.47 2.07 2.75
Ans. 𝒂𝒂 = −𝟎𝟎. 𝟕𝟕𝟕𝟕𝟕𝟕𝟕𝟕𝟕𝟕; 𝒃𝒃 = 𝟎𝟎. 𝟕𝟕𝟕𝟕𝟕𝟕𝟕𝟕𝟕𝟕
2. Fit a straight line for the data given by using least square method. Also estimate the
force when velocity is 45m/s.
𝑥𝑥 1.01 1.27 1.85 2.38 2.83 3.13 3.96 4.91
𝑦𝑦 0 0.19 0.58 0.96 1.26 1.47 2.07 2.75
then,
�����
𝑎𝑎 = ln 𝑦𝑦 − 𝑏𝑏𝑥𝑥̅
and
𝑛𝑛Σ𝑥𝑥 ln 𝑦𝑦 − Σ𝑥𝑥Σ ln 𝑦𝑦
𝑏𝑏 =
𝑛𝑛Σ𝑥𝑥 2 − (Σ𝑥𝑥)2
After evaluating 𝑎𝑎 and 𝑏𝑏, following relations can be used to determine 𝛽𝛽 and 𝛼𝛼
𝛽𝛽 = 𝑏𝑏
𝛼𝛼 = 𝑒𝑒 𝑎𝑎
Example 7-3
93 | P a g e Uzair Suria
Fit an exponential curve through the given set of data:
94 | P a g e Uzair Suria
𝑎𝑎 ≡ log 𝛼𝛼
𝑏𝑏 ≡ 𝛽𝛽
𝛼𝛼 ≡ 10𝑎𝑎
then,
𝑎𝑎 = ������
log 𝑦𝑦 − 𝑏𝑏 ������
log 𝑥𝑥
𝑛𝑛Σ(log 𝑥𝑥 ⋅ log 𝑦𝑦) − Σ log 𝑥𝑥 Σ log 𝑦𝑦
𝑏𝑏 =
𝑛𝑛Σ(log 𝑥𝑥)2 − (Σ log 𝑥𝑥)2
After evaluating 𝑎𝑎 and 𝑏𝑏, following relations can be used to determine 𝛽𝛽 and 𝛼𝛼
𝛽𝛽 = 𝑏𝑏
𝛼𝛼 = 10𝑎𝑎
Example 7-4
Fit a power curve through the given set of data:
𝑥𝑥 10 20 30 40 50
𝑦𝑦 25 70 380 550 610
Solution:
From the given data following values are evaluated:
Σ log 𝑥𝑥 = 7.0791, Σ log 𝑦𝑦 = 11.3485,
Power Fitting
Σ(log 𝑥𝑥)2 = 10.3277, Σ(log 𝑥𝑥 ⋅ log 𝑦𝑦) = 16.7315 900
Then, 800
5(16.7351) − (7.0791)(11.3485) y = 0.153x2.1789
𝑏𝑏 = 700
5(10.3277) − (7.0791)2
= 2.1789 600
11.3485 7.0791
𝑎𝑎 = − 2.1789 ×
5 5 500
= −0.8152
400
Therefore,
𝛽𝛽 = 𝑏𝑏 300
= 2.1789
𝛼𝛼 = 10𝑎𝑎 200
= 10−0.8152
100
= 0.1530
Thus, the power equation fitting the given data is: 0
𝑦𝑦 = 0.1530𝑥𝑥 2.1789 0 20 40 60
Data Points
Power Fitting Curve
95 | P a g e Uzair Suria
7.2.4 Polynomial Regression
Previously, a procedure was developed to derive the equation of a straight line using the least-
squares criterion. This procedure can be readily extended to fit the data to a higher-order
polynomial. For example, consider a second-order polynomial or quadratic:
𝑦𝑦 = 𝑎𝑎 + 𝑏𝑏𝑏𝑏 + 𝑐𝑐𝑥𝑥 2 + 𝜀𝜀𝑖𝑖
and
𝑦𝑦� = 𝑎𝑎 + 𝑏𝑏𝑏𝑏 + 𝑐𝑐𝑥𝑥 2
then
𝑠𝑠 = �(𝑦𝑦 − 𝑦𝑦�)2
Following the procedure employed in simple linear regression model, the derivative of the
standard deviation of error with respect to each of the unknown coefficients of the polynomial,
is taken and rearranged to obtain following set of normal equations
Σ𝑦𝑦 = 𝑛𝑛𝑛𝑛 + 𝑏𝑏Σ𝑥𝑥 + 𝑐𝑐Σ𝑥𝑥 2
Σ𝑥𝑥𝑥𝑥 = 𝑎𝑎Σ𝑥𝑥 + 𝑏𝑏Σ𝑥𝑥 2 + 𝑐𝑐Σ𝑥𝑥 3
Σ𝑥𝑥 2 𝑦𝑦 = 𝑎𝑎Σ𝑥𝑥 2 + 𝑏𝑏Σ𝑥𝑥 3 + 𝑐𝑐Σ𝑥𝑥 4
The above normal equations can be solved simultaneously to evaluate the values of unknown
coefficients.
Example 7-5
Fit a second order polynomial through the given set of data:
𝑥𝑥 -3 -2 -1 0 1 2 3
𝑦𝑦 4.63 2.11 0.67 0.09 0.63 2.15 4.58
Solution:
The given data along with evaluated values is tabulated below:
Sr. # 𝑥𝑥 𝑥𝑥 2 𝑥𝑥 3 𝑥𝑥 4 𝑦𝑦 𝑥𝑥𝑥𝑥 𝑥𝑥 2 𝑦𝑦
1 -3 9 -27 81 4.63 -13.89 41.67
2 -2 4 -8 16 2.11 -4.22 8.44
3 -1 1 -1 1 0.67 -0.67 0.67
4 0 0 0 0 0.09 0 0
5 1 1 1 1 0.63 0.63 0.63
6 2 4 8 16 2.15 4.3 8.6
7 3 9 27 81 4.58 13.74 41.22
SUM 0 28 0 196 14.86 -0.11 101.23
96 | P a g e Uzair Suria
Thus, normal equations are:
14.86 = 7𝑎𝑎 + 28𝑐𝑐
−0.11 = 28𝑏𝑏
101.23 = 28𝑎𝑎 + 196𝑐𝑐
Solving the above equations simultaneously will yield
𝑏𝑏 = 3.9285 × 10−3
𝑎𝑎 = 0.132857
𝑐𝑐 = 0.4975
Polynomial Fitting
5
y = 0.4975x2 - 0.0039x + 0.1329
4.5
3.5
1.5
0.5
0
-4 -3 -2 -1 0 1 2 3 4
The figure shows the data provided in the question along with the derived fitting curve.
97 | P a g e Uzair Suria