[go: up one dir, main page]

0% found this document useful (0 votes)
39 views185 pages

Numerical Method 4th Semester Study Notes Nepal

The document provides a comprehensive overview of numerical methods for solving various mathematical problems, including nonlinear equations, interpolation, numerical differentiation, integration, linear algebraic equations, and ordinary and partial differential equations. It covers techniques such as Taylor series, iterative methods, and various rules for numerical integration. Each chapter includes detailed explanations and examples to illustrate the application of these numerical methods.

Uploaded by

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

Numerical Method 4th Semester Study Notes Nepal

The document provides a comprehensive overview of numerical methods for solving various mathematical problems, including nonlinear equations, interpolation, numerical differentiation, integration, linear algebraic equations, and ordinary and partial differential equations. It covers techniques such as Taylor series, iterative methods, and various rules for numerical integration. Each chapter includes detailed explanations and examples to illustrate the application of these numerical methods.

Uploaded by

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

Table of Contents

Chapter 1: Solution of Nonlinear Equations ........................................................................................... 4


Introduction ......................................................................................................................................... 4
Solution by Taylor series .................................................................................................................... 5
Approximation o and errors in Numerical Computation: ................................................................... 8
Absolute and Relative Errors: ....................................................................................................... 12
Iterative methods ............................................................................................................................... 14
Bracketing method ............................................................................................................................ 15
Bisection method .......................................................................................................................... 15
False Position Method................................................................................................................... 19
Open end method .............................................................................................................................. 24
Secant Method .............................................................................................................................. 24
Newton’s method .......................................................................................................................... 26
Fixed point Iteration method ......................................................................................................... 28
Convergence: .................................................................................................................................... 31
Convergence of Bisection method ................................................................................................ 31
Convergence of secant method and false position ........................................................................ 31
Convergence of Fixed point iteration: .......................................................................................... 31
Convergence of Newton’s method ................................................................................................ 32
Chapter 2: Interpolation and approximation ......................................................................................... 33
Interpolation ...................................................................................................................................... 33
Linear interpolation ....................................................................................................................... 34
Lagrange interpolation polynomial ............................................................................................... 36
Newtons Interpolation formula ..................................................................................................... 39
Newton’s forward difference interpolation/ Gregory Newton forward interpolation formula ..... 43
Gregory Newton Backward Interpolation Formula ...................................................................... 45
Curve fitting ...................................................................................................................................... 54
Relationship is linear..................................................................................................................... 54
Fitting Transcendental equations .................................................................................................. 57
Fitting a polynomial function ........................................................................................................ 59
Chapter 3: Numerical Differentiation and Integration .......................................................................... 63
Derivatives using Newton’s Forward Difference formula ................................................................ 63
Derivate using Newton’s Backward Difference Formula ................................................................. 64

1
Maxima and minima of tabulated function ....................................................................................... 68
Differentiating continuous function .................................................................................................. 70
forward Difference Quotient ......................................................................................................... 70
Central Difference Quotient .......................................................................................................... 71
Numerical Integration ....................................................................................................................... 73
Newtons Cotes Formula ................................................................................................................ 73
Trapezoidal rule (2 point formula) ................................................................................................ 74
Composite Trapezoidal Rule ......................................................................................................... 75
Simpson’s 𝟏𝟑 rule( 3 point formula) ............................................................................................ 76
Simpson’s 3/8 rule( 4 point rule) .................................................................................................. 77
Romberg integration formula/ Richardson’s deferred approach to the limit or Romberg method 80
Gaussian integration: ........................................................................................................................ 82
Changing limits of Integration ...................................................................................................... 84
Values for gaussian quadrature ..................................................................................................... 86
Chapter 4: solution of Linear Algebraic Equations............................................................................... 88
Matrices and properties ........................................................................ Error! Bookmark not defined.
Existence of solution ..................................................................................................................... 89
Methods of solutions ......................................................................................................................... 90
Elimination method ....................................................................................................................... 90
Gauss Elimination Method ........................................................................................................... 91
Gauss Jordan Method .................................................................................................................... 94
The inverse of a matrix ................................................................................................................. 97
Method of factorization................................................................................................................. 98
Iterative methods ............................................................................................................................. 106
2.Gauss Seidel Iteration method ................................................................................................. 110
3.Relaxation Iterative method: .................................................................................................... 114
Now, the increments in x, y, z are dx, dy, dz so, dx= -R1/-10 , dy = -R2/-9 and dz = -R3/-11 .... 115
Iterative Table: ............................................................................................................................ 115
Power method: ............................................................................................................................ 115
Chapter 5 Ordinary Differential Equation/ Solution of ordinary differential Equation ...................... 118
Initial value problem ....................................................................................................................... 119
Solution of ordinary differential equations ..................................................................................... 119
1. Taylor’s series ..................................................................................................................... 120
2. Euler’s method ................................................................................................................... 123

2
3. Heun’s method .................................................................................................................... 125
Runge Kutta method ................................................................................................................... 131
Higher order equation ................................................................................................................. 137
RK method for second order differential equations .................................................................... 138
Picard method of successive approximation ................................................................................... 141
Shooting method ............................................................................................................................. 144
Chapter 6: Solution of partial differential equations ........................................................................... 153
Finite difference method: ................................................................................................................ 153
Elliptical equations...................................................................................................................... 155
Chapter 6: Solution of partial differential equations ........................................................................... 170
Finite difference method ................................................................................................................. 170
Elliptical equations...................................................................................................................... 172

3
Chapter 1: Solution of Nonlinear Equations
Introduction

Analysis versus Numerical Analysis

The word analysis in mathematics usually means to solve a problem through


equations. The equations must then be reduced to an answer through procedures
of algebra, calculus, differential equations, partial differential equations.
Numerical analysis is similar in that prospect that the problems are solved but we
only use simple arithmetic add, subtract, multiply, divide or compare only. Since
these operations are exactly those that computers, so numerical analysis and
computer are closely related

Example:

3
We need to find the cube root of 2 i.e. √2 using only arithmetic operations. One
way of solving this could be using trail and error method. We try choosing a value
and multiply itself 3 times so that the value is close to 2. We take new
approximation at get closer the number 2.

1.23 = 1.728 too small

1.43 = 2.744 too large

1.253 = 1.9531 pretty close

1.263 = 2.0004 really close

Now we can say that the cube root of 2 lies between 1.2-1.26, and we can choose
the value according to our need, how accurate we need. Here in above example
we calculated the cube root of 2 just by using simple arithmetic and compare.

Another difference between a numerical result and analytical result is that


numerical result is always approximation. Analytical methods usually give the

4
result in terms of mathematical function that can evaluate for specific instances.
This also has the advantage that the behavior and properties of the function are
often apparent, this is not the case for numerical answer, however numerical
results can be plotted to show some of the behavior of the solution.

While the numerical results are an approximation this can usually be as accurate
as needed. The necessary accuracy is of course determined by application and
need. To achieve high accuracy many operations must be carried out, but as these
operations are carried out the computer so that’s not a big problem.

Solution by Taylor series


Taylor series is often used in determining the order of errors for methods and the
series itself is the basic for some numerical procedures.

Let 𝑦 ′ = 𝑓(𝑥, 𝑦), 𝑦(𝑥0 ) = 𝑦0


(1)

Be the differential equation to which the numerical solution is required.


Expanding 𝑦(𝑥) about 𝑥 = 𝑥0 by Taylor Series we get
(𝑥−𝑥0 )𝑦 ′ (𝑥0 ) (𝑥−𝑥0 )2 𝑦 ′′ (𝑥0 )
y(x) = 𝑦(𝑥0 ) + + +⋯
1! 2!
(2)
(𝑥−𝑥0 )𝑦0′ (𝑥−𝑥0 )2 𝑦0′′
= 𝑦0 + + +⋯ (3)
1! 2!

Putting𝑥 = 𝑥0 + ℎ = 𝑥1 , h=difference we have


ℎ𝑦0′ ℎ2 𝑦0′′ ℎ3 𝑦0′′′
𝑦1 = 𝑦(𝑥1 ) = 𝑦0 + + + … (4)
1! 2! 3!

Here 𝑦0′ , 𝑦0′′ , 𝑦0′′′ … can be found using equation (1) and its successive
differentiation at 𝑥 = 𝑥0 . The series in (4) can be truncated at any stage if ‘h’ is
small. Now having obtained 𝑦1 we can calculate 𝑦1′ , 𝑦1′′ , 𝑦1′′′ from equation (1) at
𝑥 = 𝑥0 + h

Now expanding 𝑦(𝑥 ) by Taylor series about 𝑥 = 𝑥1 , we get


ℎ𝑦1′ ℎ2 𝑦1′′ ℎ3 𝑦1′′′
𝑦2 = 𝑦1 + + + … (5)
1! 2! 3!

5
Proceeding further we get

ℎ𝑦𝑛−1 ′′
ℎ2 𝑦𝑛−2 ′′′
ℎ3 𝑦𝑛−3
𝑦𝑛 = 𝑦𝑛−1 + + + … (6)
1! 2! 3!

By taking sufficient number of terms in above series the value of 𝑦𝑛 can be


obtained without much error

If a Taylor series is truncated while there are still non-zero derivatives of higher
order the truncated power series will not be exact. The error term for a truncated
Taylor Series can be written in several ways but the most useful form when the
series is truncated after 𝑛𝑡ℎ term is

Example:
𝑑𝑦
Using Taylor series method solve = 𝑥 2 − 𝑦, 𝑦(0) = 1 at 𝑥=
𝑑𝑥
0.1,0.2,0.3 &0.4. Compare the values with exact solution.

Solution

Given 𝑦 ′ = 𝑥 2 − 𝑦,𝑦(0) = 1,

𝑥0 = 0, 𝑦0 = 1, h = 0.1, 𝑥 = 0.1, 𝑥 = 0.2, 𝑥 = 0.3, 𝑥 = 0.4

Now

𝑦′ = 𝑥2 − 𝑦 𝑦0′ = 𝑥02 − 𝑦0 = 0 − 1 = −1

𝑦′′ = 2𝑥 − 𝑦 ′ 𝑦0′′ = 2𝑥0 − 𝑦0′ = 2 ∗ 0 − (−1) = 1

𝑦′′′ = 2 − 𝑦 ′′ 𝑦0′′′ = 2 − 𝑦0′′ = 1

𝑦 𝑖𝑣 = −𝑦 ′′′ 𝑦0𝑖𝑣 = −𝑦0′′′ = −1

By Taylor Series

ℎ𝑦0′ ℎ2 𝑦0′′ ℎ3 𝑦0′′′ ℎ4 𝑦0𝑖𝑣


𝑦1 = 𝑦0 + + + + …
1! 2! 3! 4!
𝑦1 = 𝑦(0.1)
0.1(−1) (0.1)2 ∗1 0.13 ∗1 0.14 ∗(−1)
= 1+ + + + …
1! 2! 3! 4!

= 1−0.1 + 0.005 + 0.0001667 − 0.00000417

6
=0.90516

Now

𝑦1′ = 𝑥12 − 𝑦1 = (0.1)2 − 0.90516=-0.89516

𝑦1′′ = 2𝑥1 − 𝑦1′ = 2 ∗ (0.1) − (−0.89516) = 1.09516

𝑦1′′′ = 2 − 𝑦1′′ = 2 − 1.0951 = 0.90484

𝑦1𝑖𝑣 = −𝑦1′′′ = −0.90484

By Taylor Series

ℎ𝑦1′ ℎ2 𝑦1′′ ℎ3 𝑦1′′′ ℎ4 𝑦1𝑖𝑣


𝑦2 = 𝑦1 + + + + …
1! 2! 3! 4!
𝑦2 = 𝑦(0.2)
0.1∗(−0.89516) (0.1)2 ∗1.09516 0.13 ∗0.90484 0.14 ∗(−)
= 0.90516+ + + + …
1! 2! 3! 4!

= 0.9051 − 0.089516 + 0.0054758 + 0.000150 − 0.00000377

=0.821266

Now

𝑦2′ = 𝑥22 − 𝑦2 = (0.2)2 − 0.8212352 = −0.7812352

𝑦2′′ = 2𝑥2 − 𝑦2′ = 2 ∗ (0.2) − (−0.7812352) = 1.1812352

𝑦2′′′ = 2 − 𝑦2′′ = 2 − 1.1812352 = 0.8187648

𝑦2𝑖𝑣 = −𝑦2′′′ = −0.8187648

By Taylor Series

ℎ𝑦2′ ℎ2 𝑦2′′ ℎ3 𝑦2′′′ ℎ4 𝑦2𝑖𝑣


𝑦3 = 𝑦2 + + + + …
1! 2! 3! 4!
𝑦3 = 𝑦(0.3)

0.1 ∗ (−0.7812352) (0.1)2 ∗ 1.1812352


= 0.8212352 + +
1! 2!
3 4
0.1 ∗ 0.8187648 0.1 ∗ (−0.8187648)
+ + …
3! 4!
7
= 0.7491509

Now

𝑦3′ = 𝑥32 − 𝑦3 = (0.3)2 − 0.7491509 = −0.6591509

𝑦3′′ = 2𝑥3 − 𝑦3′ = 2 ∗ (0.3) − (−0.6591509) = 1.2591509

𝑦3′′′ = 2 − 𝑦3′′ = 2 − 1.2591509 = 0.740849

𝑦3𝑖𝑣 = −𝑦3′′′ = −0.740849

By Taylor Series

ℎ𝑦3′ ℎ2 𝑦3′′ ℎ3 𝑦3′′′ ℎ4 𝑦3𝑖𝑣


𝑦4 = 𝑦3 + + + + …
1! 2! 3! 4!
𝑦4 = 𝑦(0.4)

0.1 ∗ (−0.6591509) (0.1)2 ∗ 1.2591509


= 0.7491509 + +
1! 2!
3
0.1 ∗ 0.740849
+ +⋯
3!
= 0.6896519

Similarly we can find the values of 𝑦𝑛 for n=5, 6, 7…..

Approximation and errors in Numerical Computation:

Total Error

Modeling Errors Inherent Errors Numerical Errors Blunders

Human
Imperfection

Missing Data Conversion Round-off Truncation


informatio
n Errors Errors Errors Errors

Computing Numerical
Measurin
machine Method
g method 8
Figure: 1.1 (Taxonomy of Errors)

Modeling errors

Mathematical models are the basis for numerical solution. They are formulated
to represent physical process using certain parameters involved in the situations.
In many situations it is impractical or impossible to include all of the real
problems, so we use certain assumptions for easy calculations. For example while
developing a model for calculating the for acting on a falling body, we may not
be able to estimate the air resistance coefficient properly or determine the
direction and magnitude of wind force acting on the body and so on. To simply
the model we may assume that the force due to the air resistance is linearly
proportional to the velocity of the falling body or we assume that there is no wind
force acting on the body. All such assumption certainly results in errors in the
output from such models.

Inherent Errors

Inherent errors are those that are present in the data supplied to the model.
Inherent error contains data errors and conversion error.

Data error

Data error (known as empirical errors) arises when data for a problem are
obtained by some experimental mean and are therefore of limited accuracy and
precision. This may be due to some limitations in instruments and reading and
therefore may be unavoidable, for example there is no use in performing
arithmetic operations to 4 decimal places when the original data themselves are
correct up to 2 decimal places.

Conversion Error

Conversion errors (representation error) arise due to the limitations of the


computer to store data exactly. We know that the floating point representation
retains only a specific number of digits, that are not retained constitute round off
error.

9
Example

0.110 = 0.00011001
0.410 = 0.01100110
Sum = 0.01111111
0.510 = 0.25+0.125+0.0625+0.03125+0.015625+0.0078125+0.00390625
= 0.49609373

Now from above example we can see that the addition of binary number
conversion to decimal we do not get exact value as decimal number of 0.1 has
non termination binary form 0.000110011001… and so on. The computer has
fixed memory so it uses only certain number for digits after decimal so we get
this type of errors which is caused by conversion.

Numerical Errors

Numerical errors (procedural errors) are introduced during the process of


implementation of numerical methods. They come in two forms round off and
truncation error.

Round off errors

Round off errors occurs when a fixed number of digits are used to represent exact
number, since the number are stored at every stage of computation, round off
error is introduced at the end of every arithmetic operations. Consequently even
though an individual roundoff error could be very small the cumulative effect of
a series of computation can be very significant.

Rounding a number can be done in two way, chopping and symmetric rounding.

Chopping

In chopping the extra digits are dropped, this is also called truncating a number.
Suppose we are using a computer with a fixed word length of four digits then a
number like 42.7893will be stored as 42.78 and the digit 93 will be dropped.

Symmetric round off

In symmetric round off method, the last retained significant digit is “rounded off”
by 1 if the first discarded digit is larger or equal to 5, otherwise the last retained

10
digit is unchanged. For example the number 42.7893 would become 42.79 and
the number 76.5432 would become 76.54.

Sometimes a slightly more refined rule is used when the last the last number is 5,
then the number is unchanged if the last digit is even and is increased by 1 it is
odd.

Truncation error

Truncation error arises from using an approximation in place of an exact


mathematical procedure. Typically it is the error resulting from the truncation of
the numerical process. We often use some finite number of terms to eliminate the
sum of an infinite series, for example

𝑠 = ∑𝑖=0 ai x i is replaced by finite sum, the series is truncated as

x3 𝑥 5 𝑥 7
sin(x) = 𝑥 − + − …
3! 5! 7!
Truncation error can be reduced by using a better numerical model which usually
increases the number of arithmetic operations. E.g. in numerical integration the
truncation error can be reduced by increasing the number of points at which the
function is integrated, but care should be exercised to see that the round off error
which is bound to increase due to increased arithmetic operations does not offset
the reduction in truncation error.

Blunders

Blunders are errors that are caused due to human imperfection. As the name
indicated such errors may cause a very serious disaster in the result since these
errors are due to human mistake. It should be possible to avoid them to a large
extent by acquiring a sound knowledge of all aspect of the problem as well as
numerical process.

Human errors can occur at any stage of the numerical processing cycle, some
common types of errors are:

1. Lack of understanding of the problem.


2. Wrong assumption.
3. Overlooking of some basic assumption required for formulating the model.
4. Errors in deriving the mathematical equation or using model that does not
describe adequately the physical system under study.
11
5. Selecting the wrong numerical method for solving the mathematical model.
6. Selecting a wrong algorithm for implementing the numerical method.
7. Making mistakes in the computer program, such as testing real number of
zero, using <symbol in place of >.
8. Mistakes in date input such as misprints, giving values column wise instead
of row wise to a matrix.
9. Wrong guessing of initial values.

Absolute and Relative Errors:


Some of the fundamental definition of errors analysis regardless of its source, an
error is usually quantified in two different but related ways but are related in some
ways, known as absolute error and relative error.

Let us suppose that true value of a date item is denoted by 𝑥𝑡 and its approximated
value is denoted by𝑥𝑎 , then they are related as True value, (𝑥𝑡 )=Approximate
value(𝑥𝑎 )+error.

Error is given by error=𝑥𝑡 -𝑥𝑎

The error may be negative or positive depending on the values of 𝑥𝑡 and 𝑥𝑎 . In


error analysis what is important is magnitude of the error and not the sign and
therefore we normally consider its absolute value, known as absolute error
denoted by

𝑒𝑟𝑟𝑜𝑟 = |𝑥𝑡 − 𝑥𝑎 |

In many case absolute error may not reflect its influence correctly as it does not
take into account the order of magnitude of the value under study. For example
an error of 1gm is much more significant in the weight of 10gm of gold than in
weight of a bag of sugar of 1 kg. In view of this we introduce the concept of
relative error which is nothing but the normalized value of absolute error. The
relative error is defined as follows:
𝑎𝑏𝑠𝑜𝑙𝑢𝑡𝑒 𝑒𝑟𝑟𝑜𝑟
𝑒𝑟 =
|𝑡𝑟𝑢𝑒 𝑣𝑎𝑙𝑢𝑒|
|𝑥𝑡 − 𝑥𝑎 |
=
|𝑥𝑡 |
𝑥𝑎
= |1 − |
𝑥𝑡

12
Minimizing the total error

1. Increasing the significant figures of the computer.


2. Minimizing the number of arithmetic operations.
3. Avoiding subtractive cancellations
4. Choosing proper initial parameters.

Significant digits

We all know that all computers operate with fixed length so that all the floating
point representation requires the mantissa to be specified number of digits. Some
numbers such as the value of 𝜋 = 3.141592 ….. we have to write as 3.14 or
3.14159 in all these cases we have omitted some digits. Now 2⁄7 =
0.285714 𝑜𝑟 𝜋 = 3.14159 is said to have number containing 6 significant digits.

The concept of significant digit has been introduced primarily to indicate the
accuracy if a numerical value. For example if the number y=23.40657 has correct
value of only 23.406 then we may say that y has 5 significant digits and is correct
up to 3 decimal places. The omission of certain digits from a number of results in
roundoff error. The following statements describe the notion of significant digits.

1. All non zero digits are significant.


2. All zero occurring between non zero digit are significant digits.
3. Trailing zero following a decimal point are significant .e.g. 3.50, 65.0&
0.230 have three significant digits each.
4. Zeros between the decimal point and preceding non-zero digit are not
significant e.g. following numbers have 4 significant digits.

0.0001234(1234𝑥10−7 )

0.001234(1234𝑥10−6 )

5. When the decimal point is not written trailing zeros are not considered to
be significant. E.g. 4500 may be written as 45𝑥102 contains only two
significant digits however.
4500.0 4 𝑠𝑖𝑔𝑛𝑖𝑓𝑖𝑐𝑎𝑛𝑡 𝑑𝑖𝑔𝑖𝑡𝑠
4
7.56𝑥10 3 𝑠𝑖𝑔𝑛𝑖𝑓𝑖𝑐𝑎𝑛𝑡 𝑑𝑖𝑔𝑖𝑡𝑠
4
7.560𝑥10 4 𝑠𝑖𝑔𝑛𝑖𝑓𝑖𝑐𝑎𝑛𝑡 𝑑𝑖𝑔𝑖𝑡𝑠
7.5600𝑥104 5 𝑠𝑖𝑔𝑛𝑖𝑓𝑖𝑐𝑎𝑛𝑡 𝑑𝑖𝑔𝑖𝑡𝑠

13
The concept of accuracy and precision are closely related to significant digits.
They are related as follows:
1. Accuracy refers to the number of significant digits in a value e.g. 57.396 is
accurate to five significant digits.
2. Precision refers to the number of decimal position i.e. the order of
magnitude if the last digit value. the number 57.396 has a precision of
0.001 or 10−3

Iterative methods
There are number of iterative methods that have been tried and used successfully
in various problem situations. All these methods typically generate a sequence of
estimates of the solution which is expected to converge to the true solution. All
iterative methods begin their process of solution with one or more guess of the
solution and then using those guesses to find another better approximation and so
on to get to required solution with desired accuracy. Iterative method can be
grouped as:

1. Bracketing methods
2. Open end methods

Before we start to go further into the methods first we need to know about the
starting and stopping criteria in an iterative process.

Starting criterion

Before an iterative process is initiated, we have to determine an interval that


contains the roots of the equation. One method is to plot the curve and find the
interval where the curve cuts the x-axis. Such that the interval that contains such
point will contain roots. This gives us rough estimate of the roots, also helps to
understand the properties of the function.
14
Stopping criterion
An iterative process must be terminated at some stage; we must have a criterion
for deciding when to stop the process. We may use one or combination of
following tests depending in the behavior of the function to terminate the process:
1. |𝑥𝑖+1 − 𝑥𝑖 | ≤ 𝐸𝑎 (𝑎𝑏𝑠𝑜𝑙𝑢𝑡𝑒 𝑒𝑟𝑟𝑜𝑟 𝑖𝑛 𝑥)
𝑥𝑖+1 −𝑥𝑖
2. | | ≤ 𝐸𝑟 (𝑟𝑒𝑙𝑎𝑡𝑖𝑣𝑒 𝑒𝑟𝑟𝑜𝑟 𝑖𝑛 𝑥 )𝑥 ≠ 0
𝑥𝑖+1
3. |𝑓(𝑥𝑖+1 )| ≤ 𝐸 (𝑣𝑎𝑙𝑢𝑒 𝑜𝑓 𝑓𝑢𝑛𝑐𝑡𝑖𝑜𝑛 𝑎𝑡 𝑟𝑜𝑜𝑡 )
4. |𝑓(𝑥𝑖+1 ) − 𝑓(𝑥𝑖 )| ≤ 𝐸 (𝑑𝑖𝑓𝑓𝑒𝑟𝑒𝑛𝑐𝑒 𝑖𝑛 𝑓𝑢𝑛𝑐𝑡𝑖𝑜𝑛 𝑣𝑎𝑙𝑢𝑒 )

𝑥𝑖 Represents the estimate of the root at 𝑖 𝑡ℎ iteration and f (𝑥𝑖 ) is the value of the
function at𝑥𝑖 . There may be situations where these tests may fail when used alone
so we use combination of many.

Bracketing method
This method starts with two initial guess that bracket the root and then
systematically reduce the width of the bracket until the solution is reached. Two
popular methods are:

1. Bisection method
2. False position method

Bisection method
The Bisection method is one of the simplest and most reliable method for solution
of non-linear equations. This method relies on the fact that if 𝑓(𝑥) is real and
continuous in the interval 𝑎 < 𝑥 < 𝑏 and 𝑓(𝑎)&𝑓(𝑏) have opposite signs i.e
𝑓(𝑎) ∗ 𝑓 (𝑏) < 0 then there is at least one real root in the interval between a & b.
let 𝑥1 = 𝑎 𝑎𝑛𝑑 𝑥2 = 𝑏 . now determine another point 𝑥3 to be mid point between
𝑥1 +𝑥2
a and b i.e 𝑥3 = now there exists the following three conditions;
2

1. 𝑓 (𝑥3 ) = 0, 𝑡ℎ𝑒𝑛 𝑤𝑒 ℎ𝑎𝑣𝑒 𝑎 𝑟𝑜𝑜𝑡 𝑎𝑡 𝑥3


2. 𝑖𝑓 𝑓 (𝑥3 ) ∗ 𝑓(𝑥1 ) < 0, 𝑡ℎ𝑒𝑛 𝑡ℎ𝑒𝑟𝑒 𝑖𝑠 𝑟𝑜𝑜𝑡 𝑖𝑛 𝑡ℎ𝑒 𝑖𝑛𝑡𝑒𝑟𝑣𝑎𝑙 𝑥1 & 𝑥3
3. 𝑖𝑓 𝑓 (𝑥3 ) ∗ 𝑓(𝑥2 ) < 0, 𝑡ℎ𝑒𝑛 𝑡ℎ𝑒𝑟𝑒 𝑖𝑠 𝑟𝑜𝑜𝑡 𝑖𝑛 𝑡ℎ𝑒 𝑖𝑛𝑡𝑒𝑟𝑣𝑎𝑙 𝑥2 & 𝑥3

15
Figure 1.2: Illustration of Bisection method

Example 1: find a root of the equation 𝑥 3 − 𝑥 − 11 = 0, correct up to 4 decimal


place using bisection method.

Solution:(𝑥 ) = 𝑥 3 − 𝑥 − 11 = 0, now we select the initial approximation, by


selecting those values of x where their functional values have opposite sign.

S.N x f(x)
1 1 -11
2 2 -5
sign
3 3 13 changed
4 4 49
5 5 109
6 6 199
7 7 325
8 8 493

16
From above table we can that the values of f(x) changes at x=2 & x=3, we can
randomly test for the values without creating the table but it will be easy to find
out if we use table.

Now the initial approximation be𝑥1 = 2,𝑥2 = 3 then 𝑓(2) = −5 &𝑓(3) =


13, where root lies in between 2 & 3, hence next approximation will be 𝑥3 =
𝑥1 +𝑥2
2

2+3
e 𝑥3 = = 2.5, 𝑓(2.5) = 2.125. since 𝑓(2)𝑓(2.5) < 0, a root lies in between
2

2 & 2.5, now proceeding further in tabular form we get.

Itr x1 f(x1) x2 f(x2) xm f(xm) error


1 2.0000 -5.0000 3.0000 13.0000 2.5000 2.1250 1.0000
2 2.0000 -5.0000 2.5000 2.1250 2.2500 -1.8594 0.5000
3 2.2500 -1.8594 2.5000 2.1250 2.3750 0.0215 0.2500
4 2.2500 -1.8594 2.3750 0.0215 2.3125 -0.9460 0.1250
5 2.3125 -0.9460 2.3750 0.0215 2.3438 -0.4691 0.0625
6 2.3438 -0.4691 2.3750 0.0215 2.3594 -0.2256 0.0313
7 2.3594 -0.2256 2.3750 0.0215 2.3672 -0.1025 0.0156
8 2.3672 -0.1025 2.3750 0.0215 2.3711 -0.0406 0.0078
9 2.3711 -0.0406 2.3750 0.0215 2.3730 -0.0096 0.0039
10 2.3730 -0.0096 2.3750 0.0215 2.3740 0.0059 0.0020
11 2.3730 -0.0096 2.3740 0.0059 2.3735 -0.0018 0.0010
12 2.3735 -0.0018 2.3740 0.0059 2.3738 0.0021 0.0005
13 2.3735 -0.0018 2.3738 0.0021 2.3737 0.0001 0.0002
14 2.3735 -0.0018 2.3737 0.0001 2.3736 -0.0009 0.0001
15 2.3736 -0.0009 2.3737 0.0001 2.3736 -0.0004 0.0001
16 2.3736 -0.0004 2.3737 0.0001 2.3736 -0.0001 0.0000

Therefore, the root of the equation is 2.3737, since the value of error is 0.0000 or
we can also say that the new root is same as old so this is the required roots for
given stopping criteria.

Example 2: Find the root of the equation of 𝑥 2 − 4𝑥 − 10 = 0, correct upto 5


decimal places.

17
Solution:𝑓(𝑥 ) = 𝑥 2 − 4𝑥 − 10 = 0, let the initial approximation be -2& -1,
chosen from table below .

S.N x f(x)
1 -3 11
2 -2 2
3 -1 -5
4 0 -10
5 1 -13
6 2 -14
7 3 -13
now the initial approximation be 𝑥1 = −2, 𝑥2 = −1, then 𝑓(−2) = 2 &𝑓(−1) =
−5, where root lies in between 2 & 3, hence next approximation will be 𝑥3 =
𝑥1 +𝑥2
2

−1−2
e 𝑥3 = = −1.5, 𝑓(−1.5) = −1.7500, since 𝑓(−2)𝑓(−1.5) < 0, a root lies
2

in between -2 &-1.5, now proceeding further in tabular form we get.

Itr x1 f(x1) x2 f(x2) xm f(xm) error


- - -
1 -2 2.0000 1.0000 -5.0000 1.5000 1.7500 1.0000
- -
2 -2 2.0000 1.5000 -1.7500 1.7500 0.0625 0.5000
- - -
3 -1.75 0.0625 1.5000 -1.7500 1.6250 0.8594 0.2500
- - -
4 -1.75 0.0625 1.6250 -0.8594 1.6875 0.4023 0.1250
- - -
5 -1.75 0.0625 1.6875 -0.4023 1.7188 0.1709 0.0625
- - -
6 -1.75 0.0625 1.7188 -0.1709 1.7344 0.0544 0.0313
- -
7 -1.75 0.0625 1.7344 -0.0544 1.7422 0.0040 0.0156
- - - -
8 1.74219 0.0040 1.7344 -0.0544 1.7383 0.0253 0.0078
- - - -
9 1.74219 0.0040 1.7383 -0.0253 1.7402 0.0106 0.0039
18
- - - -
10 1.74219 0.0040 1.7402 -0.0106 1.7412 0.0033 0.0020
- - -
11 1.74219 0.0040 1.7412 -0.0033 1.7417 0.0003 0.0010
- - -
12 -1.7417 0.0003 1.7412 -0.0033 1.7415 0.0015 0.0005
- - -
13 -1.7417 0.0003 1.7415 -0.0015 1.7416 0.0006 0.0002
- - -
14 -1.7417 0.0003 1.7416 -0.0006 1.7416 0.0001 0.0001
- -
15 -1.7417 0.0003 1.7416 -0.0001 1.7417 0.0001 0.0001
- - -
16 1.74167 0.0001 1.7416 -0.0001 1.7417 0.0000 0.0000

Therefore, the root of the equation is -1.7417, since the value of error is 0.0000.

Practice: find the roots of the equation for following equations, correct up to
5 decimal places.

1. 𝟑𝒙 + 𝐬𝐢𝐧 (𝒙) − 𝒆𝒙 = 𝟎
2. 𝐬𝐢 𝐧(𝒙) − 𝟐𝒙 + 𝟏 = 𝟎
3. 𝒆𝒙 − 𝒙 − 𝟐 = 𝟎
4. 𝒙𝟑 − 𝒙 − 𝟑 = 𝟎
5. 𝟒𝒙𝟑 − 𝟐𝒙 − 𝟔 = 𝟎

NOTE: When there are trigonometric functions, use radian measure in calculator.

False Position Method


In Bisection method, the interval between 𝑥1 &𝑥2 is divided into two equal halves,
irrespective of the location of the root. It may be possible that the root is closer to
one as in figure 1.3, note that the root is closer to 𝑥1 .let us join the point 𝑥1 &𝑥2
by a straight line. The point of intersection of this line with x-axis gives and
improved estimate root and is called false position of the root. Let this point is
called 𝑥3 . This point then replaces one of initial guess. The process is then
repeated with new values of 𝑥1 &𝑥2 , since this method uses the false position of
19
the root repeatedly it is called false position method. It is also called linear
interpolation method.

F(x)
X2, f(x2)
X3, f(x3)

X1

X3 X2 X

X1, f(x1)

Figure1.3 : Illustration of False position method

The equation of the line joining (𝑥1 , 𝑓(𝑥1 ))& (𝑥2 , 𝑓(𝑥2 )) is

𝑦 − 𝑦1 = 𝑚(𝑥 − 𝑥1 )
𝑦2 − 𝑦1
𝑦 − 𝑦1 = (𝑥 − 𝑥1 )
𝑥2 − 𝑥1
𝑓(𝑥2 ) − 𝑓(𝑥1 )
𝑦 − 𝑓(𝑥1 ) = (𝑥 − 𝑥1 )
𝑥2 − 𝑥1

Let the line joining the points (𝑥1 , 𝑓(𝑥1 ))& (𝑥2 , 𝑓 (𝑥2 )) cuts x-axis at (𝑥3 , 0), then
the point lies in the line, putting the value in the equation we get
𝑓(𝑥2 ) − 𝑓(𝑥1 )
0 − 𝑓(𝑥1 ) = (𝑥3 − 𝑥1 )
𝑥2 − 𝑥1

On solving the above equation, we get,


𝑓(𝑥1 )(𝑥2 − 𝑥1 )
𝑥3 = 𝑥1 −
𝑓(𝑥2 ) − 𝑓(𝑥1 )

This is the formula for calculating the new approximation in false position
method.

20
Example 1: find the real root of the equation 𝑥 3 − 2𝑥 − 5 = 0 by the method of
false position correct up to 4 decimal places.

Solution: Let 𝑓(𝑥 ) = 𝑥 3 − 2𝑥 − 5 = 0, Now we select the initial approximation,


by selecting those values of x where their functional values have opposite sign.

S.N x f(x)
1 1 -6
2 2 -1
Sign
3 3 16 changed
4 4 51
5 5 110
6 6 199
7 7 324
8 8 491
From above table we can that the values of f(x) changes at x=2 & x=3, we can
randomly test for the values without creating the table but it will be easy to find
out if we use table.

now the initial approximation be 𝑥1 = 2, 𝑥2 = 3, then 𝑓 (2) = −1 &𝑓(3) =


16, where root lies in between 2 & 3, hence next approximation will be

𝑓(𝑥1 )(𝑥2 − 𝑥1 )
𝑥3 = 𝑥1 −
𝑓(𝑥2 ) − 𝑓(𝑥1 )
(−1)(3 − 2)
𝑥3 = 2 −
(16 − (−1))

𝑥3 = 2.0588

𝑓(2.0588) = −0.3908. since 𝑓(2.0588) ∗ 𝑓(3) < 0, a root lies in between


2.0588&3 now proceeding further in tabular form we get.

Itr x1 f(x1) x2 f(x2) x3 f(x3) error


1 2.0000 -1.0000 3.0000 16.0000 2.0588 -0.3908 1.0000
2 2.0588 -0.3908 3.0000 16.0000 2.0813 -0.1472 0.9412
3 2.0813 -0.1472 3.0000 16.0000 2.0896 -0.0547 0.9187

21
4 2.0896 -0.0547 3.0000 16.0000 2.0927 -0.0202 0.9104
5 2.0927 -0.0202 3.0000 16.0000 2.0939 -0.0075 0.9073
6 2.0939 -0.0075 3.0000 16.0000 2.0943 -0.0027 0.9061
7 2.0943 -0.0027 3.0000 16.0000 2.0945 -0.0010 0.9057
8 2.0945 -0.0010 3.0000 16.0000 2.0945 -0.0004 0.9055
9 2.0945 -0.0004 3.0000 16.0000 2.0945 -0.0001 0.9055
10 2.0945 -0.0001 3.0000 16.0000 2.0945 -0.0001 0.9055
11 2.0945 -0.0001 3.0000 16.0000 2.0945 0.0000 0.9055
12 2.0945 0.0000 3.0000 16.0000 2.0946 0.0000 0.9055

Therefore, the root of the equation is 2.0946, since the value of f(x3) = 0.0000.

Example 2: find the real root of the equation 𝑥 2 − 4𝑥 − 10 = 0 by the method of


false position correct up to 6 decimal places.

Solution

Let 𝑓(𝑥 ) = 𝑥 2 − 4𝑥 − 10 = 0, Now we select the initial approximation, by


selecting those values of x where their functional values have opposite sign.

S.N x f(x)
1 -3 11
2 -2 2
3 -1 -5
4 0 -10
5 1 -13
6 2 -14
7 3 -13

From above table we can that the values of f(x) changes at x=-2 & x=-1, we can
randomly test for the values without creating the table but it will be easy to find
out if we use table.

now the initial approximation be 𝑥1 = −2, 𝑥2 = −1, then 𝑓(−2) = 2 &𝑓(−1) =


−5, where root lies in between -2 &-1, hence next approximation will be

𝑓(𝑥1 )(𝑥2 − 𝑥1 )
𝑥3 = 𝑥1 −
𝑓(𝑥2 ) − 𝑓(𝑥1 )

22
(2)(−1 − (−2))
𝑥3 = −2 −
(−5 − 2)

𝑥3 = −1.714286

𝑓(−1.714286) = −0.204082. since 𝑓(2) ∗ 𝑓(−1.714286) < 0, a root lies in


between 2 &−1.714286 now proceeding further in tabular form we get.

Itr x1 f(x1) x2 f(x2) x3 f(x3) error


- - - - -
1 2.000000 2.000000 1.000000 5.000000 1.714286 0.204082 1.000000
- - - - -
2 2.000000 2.000000 1.714286 0.204082 1.740741 0.006859 0.285714
- - - - -
3 2.000000 2.000000 1.740741 0.006859 1.741627 0.000229 0.259259
- - - - -
4 2.000000 2.000000 1.741627 0.000229 1.741656 0.000008 0.258373
- - - -
5 2.000000 2.000000 1.741656 0.000008 1.741657 0.000000 0.258344

Therefore, the root of the equation is -1.741657, since the value of f(x3) =
0.000000.

Practice: Find the real roots for the following equations , correct up to 5
decimal places.

1. 𝟑𝒙 + 𝐬𝐢𝐧 (𝒙) − 𝒆𝒙 = 𝟎
2. 𝒙 − 𝒆−𝒙 = 𝟎
3. 𝒙𝟑 − 𝟒𝒙𝟐 + 𝒙 + 𝟔 = 𝟎
4. 𝟑𝒙𝟐 + 𝟔𝒙 − 𝟒𝟓 = 𝟎
5. 𝟒𝒙𝟑 − 𝟐𝒙 − 𝟔 = 𝟎

23
Open end methods:
This method uses single starting value or two values that do not necessarily
bracket the root. The following methods fall under open end method:

1. Secant method
2. Newton method
3. Fixed point method

Secant Method
The secant method begins by finding two points on the curve of f(x), hopefully
near to root. We draw a line through these two points and find the point where it
intersects the x -axis. The two points may both be on one side of the root as seen
in figure, but they can also be on opposite side.

If f(x) were truly linear, the straight line would intersect x-axis at the roots, but
f(x) will never be linear because we would never use a root finding method on a
linear function. That means the intersection of the line with x-axis in not at root,
but that should be close to it. From the obvious similar triangles we can write

F(X1)

F(X2)

X3 X2 X1

Figure 1.4: Illustration of Secant method


(𝑥2 − 𝑥3 ) (𝑥1 − 𝑥2 )
=
𝑓(𝑥2 ) (𝑓(𝑥1 ) − 𝑓(𝑥2 ))

Now solving this for 𝑥3 we get

24
𝑓(𝑥2 )(𝑥1 − 𝑥2 )
𝑥3 = 𝑥2 −
𝑓(𝑥1 ) − 𝑓(𝑥2 )

Because f(x) is not exactly linear, 𝑥3 is not equal to root, but it should be closer
than either of the two points.

Example 1: Find the real root of the equation 𝑥 2 − 4𝑥 − 10 = 0 by the method


of secant method correct up to 6 decimal places.

Solution

Let 𝑓(𝑥 ) = 𝑥 2 − 4𝑥 − 10 = 0, let the initial approximation be 𝑥1 = 4, 𝑥2 = 6,


hence next approximation will be

𝑓(𝑥2 )(𝑥1 − 𝑥2 )
𝑥3 = 𝑥2 −
𝑓(𝑥1 ) − 𝑓(𝑥2 )
(2)(4 − 6)
𝑥3 = 6 −
(−10 − 2)

𝑥3 = 5.666667

Proceeding further in tabular form we get.

Itr. x1 f(x1) x2 f(x2) x3 f(x3) error


- -
1 4.000000 10.000000 6.000000 2.000000 5.666667 0.555556 2.000000
- -
2 6.000000 2.000000 5.666667 0.555556 5.739130 0.018904 0.333333
-
3 5.666667 -0.555556 5.739130 0.018904 5.741683 0.000191 0.072464
4 5.739130 -0.018904 5.741683 0.000191 5.741657 0.000000 0.002553
5 5.741683 0.000191 5.741657 0.000000 5.741657 0.000000 0.000026
Therefore, the root of the equation is 5.741657, since the value of f(x3) =
0.000000.

Practice: Find the real roots following equations, correct up to 5 decimal


places.

1. 𝟑𝒙 + 𝐬𝐢𝐧 (𝒙) − 𝒆𝒙 = 𝟎
25
2. 𝟒𝒙𝟑 − 𝟐𝒙 − 𝟔 = 𝟎
3. 𝒙𝟐 − 𝟓𝒙 + 𝟔 = 𝟎
4. 𝒙 𝐬𝐢𝐧 𝒙 − 𝟏 = 𝟎
5. 𝒆𝒙 − 𝟑𝒙 = 𝟎

Newton’s method
One of the most widely used methods of solving non-linear equations is Newton’s
method (also called Newton Raphson Method). This method is also based on the
linear approximation of the function, but does so using a tangent line to the curve.
Figure gives the graphical description starting from a single initial estimate 𝑥0 ,
that is not too far from a root. We move along the tangent to its intersection with
x-axis and take the next approximation. This is continued until either the
successive x-value are sufficiently close or the value of the function is sufficiently
near to zero.

The calculation scheme follows immediately from the right triangle shown in
figure, which has the angle of inclination of the tangent line to the curve at𝑥 = 𝑥0 .

ᶿ
X1 X1

Figure 1.5: Illustration of Newton’s Method

26
𝑓(𝑥0 )
tan 𝜃 = 𝑓 ′ (𝑥0 ) =
𝑥0 − 𝑥1
𝑓(𝑥0 )
𝑥1 = 𝑥0 −
𝑓 ′ (𝑥0 )

In general,
𝑓(𝑥𝑛 )
𝑥𝑛+1 = 𝑥𝑛 − 𝑤ℎ𝑒𝑟𝑒 𝑛 = 0,1,2,3 ….
𝑓 ′ (𝑥𝑛 )

Newton’s method is widely used because it is more rapidly convergent then any
of the methods. Some important things that should be kept in mind while using
Newton method:

1. When 𝑓 ′ (𝑥0 ) is very large, i.e. when the slope is large the root can be
calculated in even less time.
2. If we choose the initial approximation𝑥0 close to the root then we get the
root of the equation very quickly.
3. The process will evidently fail if 𝑓 ′ (𝑥 ) = 0, in that case use other methods
4. If the initial approximation to the root is not given choose two values of x
such that its functional values are opposite, as this will ensure that the
chosen point in near the root.

Example 1: Find the root of 𝑥 3 − 3𝑥 2 + 2𝑥 − 10 = 0, using NR method


Solution: Let 𝑥0 = 2 be an approximate of the root, then
𝑓(𝑥 ) = 𝑥 3 − 3𝑥 2 + 2𝑥 − 10
𝑓 ′ (𝑥 ) = 3𝑥 2 − 6𝑥 + 2
At 𝑥0 = 2
𝑓(2) = 23 − 322 + 2 ∗ 2 − 10 = −10
𝑓 ′ (2) = 322 − 6 ∗ 2 + 2 = 2

Then the new approximate is :

𝑓(𝑥0 )
𝑥1 = 𝑥0 −
𝑓 ′ (𝑥0 )
−10
𝑥1 = 2 −
2

27
=7
Now
𝑥0 = 𝑥1 = 7
Then doing further calculation, we get required root of the equation. In tabular
form we get

Itr x0 f(x0) f'(x0) x1 error


1 2.00000 -10.00000 2.00000 7.00000 5.00000
2 7.00000 200.00000 107.00000 7.00000 5.00000
3 5.13084 56.35721 50.19155 5.13084 1.86916
4 4.00800 14.20854 26.14417 4.00800 1.12284
5 3.46453 2.50479 17.22172 3.46453 0.54347
6 3.31909 0.15333 15.13448 3.31909 0.14544
7 3.30895 0.00071 14.99382 3.30895 0.01013
8 3.30891 0.00000 14.99316 3.30891 0.00005
Therefore, the root of the equation is 3.30891, since the value error=0.00005
correct up to 4 decimal place.

Practice :

1. 𝐬𝐢𝐧(𝒙) = 𝟏 + 𝒙𝟑
2. 𝒇(𝒙) = 𝒙𝟐 − 𝟐𝒙 − 𝟏
3. 𝒇(𝒙) = 𝒙𝟑 − 𝒙 − 𝟑
4. 𝒇(𝒙) = 𝒙𝟑 − 𝟑𝒙 − 𝟐
5. 𝒇(𝒙) = 𝐜𝐨𝐬 𝒙

Fixed point Iteration method


Any function in the form of 𝑓(𝑥) = 0 can be manipulated such that x is on the
left hand side of the equation as shown∶ 𝑥 = 𝑔(𝑥). Both equations are equivalent.
Observe that if 𝑓(𝑟) = 0, where r is the root of f(x), it follows that r= 𝑔(𝑟),
whenever we have r= 𝑔(𝑟)r is said to be fixed point for the function g.

If 𝑥𝑖 is an approximate solution then 𝑥𝑖+1 = 𝑔(𝑥𝑖 ). The above transformation can


be obtained either by algebraic manipulation of the given equation or by simply
adding x to both sides of equation.

Example 1: locate the root of the equation 𝑓(𝑥 ) = 𝑥 2 − 2𝑥 − 3.

28
Suppose we arrange to given the equivalent form 𝑥 = 𝑔1 (𝑥) = √2𝑥 + 3, if we
start with x=4 and iterate. Successive values of x are

𝑥0 = 4

𝑥1 = √11 = 3.31662

𝑥2 = 3.10375

𝑥3 = 3.03439

𝑥4 = 3.01144

𝑥5 = 3.00381

𝑥6 = 3.00127

Therefore, it appears that the values are converging on the root at 𝑥 = 3

Now if we re-arrange the terms then we get another equation


3
𝑔2 (𝑥 ) = =𝑥
(𝑥 − 2)

Let us start the integration again with 𝑥0 = 4, successive values then

𝑥0 = 4

𝑥1 = 1.5

𝑥2 = −6

𝑥3 = −0.375

𝑥4 = −1.26316

𝑥5 = −0.91935

𝑥6 = −1.02763

𝑥7 = −0.99087

𝑥8 = −1.00305

𝑥9 = −0.99898

𝑥10 = −1.00034

29
𝑥11 = −0.99989

𝑥12 = −1.0004

𝑥13 = −1.00000

It seems that we now converge to another root at 𝑥 = −1, we also see that the
converge is oscillatory rather than monotonic.

Consider another re-arrangement

𝑥2 − 3
𝑥 = 𝑔2 (𝑥 ) =
2
Starting with
𝑥0 = 4

𝑥1 = 6.5

𝑥2 = 19.625

𝑥3 = 191.070

From these results we see that the iterates are diverging.

NOTE: the g(x) formed must be such that |𝑔′ (𝑥)| around the real root should be
less than 1, if this is not case change g(x).

Practice

Use the Fixed point iteration method to evaluate a root of the equation 𝒙𝟐 −
𝒙 − 𝟏 = 𝟎, using the following forma of g(x)

a. 𝒙 = 𝒙𝟐 − 𝟏
b. 𝒙 = 𝟏 + 𝟐𝒙 − 𝒙𝟐
𝟏+𝟑𝒙−𝒙𝟐
c. 𝒙 =
𝟐
Starting with 𝒙𝟎 = 𝟏 𝒂𝒏𝒅 𝒙𝟎 = 𝟐 and discuss the results

30
Convergence:

Convergence of Bisection method


In the bisection method, we choose a midpoint 𝑥3 in the interval between 𝑥1 &𝑥3 .
Depending on the sign of the function 𝑓(𝑥0 ), 𝑓(𝑥1 ) &𝑓(𝑥2 ). 𝑥1 &𝑥2 is set to equal
to 𝑥0 , such that the new interval contains the root. In either case the interval
containing the root is reduced by a factor 2. The same procedure is repeated n
𝑥2 −𝑥1 ∆𝑥
times, then the interval containing the root is reduced to the size =
2𝑛 2𝑛

∆𝑥
After n iterations the root must lie within ± of our estimate. This means that
2𝑛
∆𝑥
error bounds at 𝑛𝑡ℎ iteration is 𝐸𝑛 = | 𝑛 |
2

∆𝑥 ∆𝑥 𝐸𝑛
Similarly𝐸𝑛+1 = | 𝑛+1
|=| |=
2 2𝑛 .2 2

that is the error decreases linearly with each step by a factor of 0.5. the bisection
method is therefore linearly convergent. Since the convergence is slow to achieve
a high degree of accuracy. Large number of iterations may be needed; however
the bisection algorithm is guaranteed to converge.

Convergence of secant method and false position


Both of the secant method and false position uses iterations that can be written as
𝑓(𝑥𝑛 )(𝑥𝑛 − 𝑥𝑛−1 )
𝑥𝑛+1 =
𝑓 (𝑥𝑛 ) − 𝑓(𝑥𝑛−1 )

Which is similar to𝑥 = 𝑔(𝑥), except 𝑥 = 𝑔(𝑥𝑛 , 𝑥𝑛−1 ) when we apply Taylor
series the derivatives are pretty complicated, so we omit the details it turns out
that the error relation is
𝑔(𝜉1 , 𝜉2 )
𝑒𝑛+1 = ∗ 𝑒𝑛 𝑒𝑛+1
2
Showing that the error is proportional to the product of the two pervious errors,
we can conclude that the convergence is better than linear but poorer than
quadratic

𝑒𝑛+1 ∝ 𝑒𝑛 ∗ 𝑒𝑛−1

Convergence of Fixed point iteration:


The demonstration in example earlier shows that fixed point iterations seems to
converge linearly. We now show when this is true.
31
We have 𝑥𝑛+1 = 𝑔(𝑥𝑛 ) now writing above relation for the error after iteration
n+1, where R is the true value of the root.

𝑅 − 𝑥𝑛+1 = 𝑅 − 𝑔(𝑥𝑛 ) = 𝑔(𝑅) − 𝑔(𝑥𝑛 )

Because where 𝑥 = 𝑅, 𝑅 = 𝑔(𝑅), multiplying and dividing by (R-𝑥𝑛 ), we get


(𝑔(𝑅)−𝑔(𝑥𝑛 ))
𝑅 − 𝑥𝑛+1 = (R-𝑥𝑛 )
(𝑅−𝑥𝑛 )

Now we can use the mean value theorem, if 𝑔(𝑥) and 𝑔′ (𝑥) are continuous, to
say that

𝑅 − 𝑥𝑛+1 = 𝑔′ (𝜉𝑛 ) ∗ (𝑅 − 𝑥𝑛 ) where 𝜉𝑛 lies between 𝑥𝑛 𝑎𝑛𝑑 𝑅, writing 𝑒𝑛 for


the error of the 𝑛𝑡ℎ iterate, we have |𝑒𝑛+1 | = |𝑔′ (𝜉𝑛 ) ∗ 𝑒𝑛 |

Because 𝑒𝑛 the error in 𝑥𝑛 is 𝑅 − 𝑥𝑛 (we take absolute values because the


successive iterates may oscillate around the root). Now from above equation we
can say that the fixed point iteration will converge linearly, in the limit as 𝑥𝑛
approaches R, provided that we start within the interval |𝑔′ (𝜉𝑛 )| < 𝐾 < 1

Convergence of Newton’s method


Newton’s method uses iteration that resembles fixed point
𝑓(𝑥𝑛 )
𝑥𝑛+1 = 𝑥𝑛 − = 𝑔(𝑥𝑛 ) , successively iterates will converge if |𝑔′ (𝑥)| < 1
𝑓′ (𝑥𝑛 )
and doing the differentiation, we see that the method converge, if


𝑓(𝑥 ) ∗ 𝑓 ′′ (𝑥)
|𝑔 (𝑥)| = | | < 1………………1
(𝑓 ′ (𝑥))2

Which requires that f(x) and its derivatives exits and be continuous. Newton
method is shown to be quadratically convergent by the following as before

𝑅 − 𝑥𝑛+1 = 𝑔(𝑅) − 𝑔(𝑥𝑛 )

Now we expand 𝑔(𝑥𝑛 ) as Taylor series in terms of (𝑅 − 𝑥𝑛 ) with the second


derivative term as the remainder getting

′(
𝑔′′ (𝜉 )
𝑔(𝑥𝑛 ) = 𝑔(𝑅) + 𝑔 𝑅) ∗ (𝑅 − 𝑥𝑛 ) + ( ) ∗ (𝑅 − 𝑥𝑛 )2 … … … … .2
2

Where 𝜉 lies within (𝑥𝑛 , 𝑅), however from equation 1

32

𝑓(𝑅) ∗ 𝑓 ′′ (𝑅)
|𝑔 (𝑅)| = | |=0
(𝑓 ′ (𝑅))2

Because 𝑓(𝑅) = 0 at the root and equation 2 reduces to

𝑔 ′ (𝜉 )
𝑔(𝑥𝑛 ) = 𝑔(𝑅) + ( ) ∗ (𝑅 − 𝑥𝑛 )2 … … … … . .3
2

Using 𝑒𝑛 = 𝑅 − 𝑥𝑛 for the error on the 𝑛𝑡ℎ iterate equation 3 becomes

𝑒𝑛+1 = 𝑅 − 𝑥𝑛+1 = 𝑔(𝑅) − 𝑔(𝑥𝑛 ) = −(𝑔′′ (𝜉)/2)(𝑒𝑛 2 )

Providing that Newtons method is quadratically convergent

𝑒𝑛+1 ∝ 𝑒𝑛 2

Chapter 2: Interpolation and approximation


The statement 𝑦 = 𝑓(𝑥 ), 𝑥0 ≤ 𝑥 ≤ 𝑥𝑛 means for every corresponding value of x
in the range 𝑥0 ≤ 𝑥 ≤ 𝑥𝑛 , there exists one or more values of y. assuming that
𝑓(𝑥) is single valued and continuous and that it is known explicitly then the
values of 𝑓(𝑥) corresponding to certain given values of x, say 𝑥0 , 𝑥1, 𝑥2 … . . 𝑥𝑛
can easily be computed and tabulated. The central problem of numerical analysis
is the converse one,given the set of tabular values of
(𝑥0 , 𝑦0 ), (𝑥1 , 𝑦1 ), (𝑥2 , 𝑦2 ) … … (𝑥𝑛 , 𝑦𝑛 ) satisfying the relation 𝑦 = 𝑓(𝑥) where the
explicit nature of f(x) is not known, it is required to find a simpler function say
𝜙(𝑥) such that 𝑓(𝑥 )𝑎𝑛𝑑 𝜙(𝑥)agree at the set of tabulated points. Such a process
is called interpolation. If 𝜙(𝑥) is polynomial then the process is called polynomial
interpolation and 𝜙(𝑥 ) is called interpolating polynomial. Similarly different
types of interpolation arise depending on 𝜙(𝑥).

An application of interpolation can be seen everyday in weather forcasting. The


weather service people collect information on temperatures, wind speed and
direction, humidity, pressure from hundreds of weather stations around the world.
All these data items are entered into a massive computer program that models the
weather.

Interpolation
𝑒 𝑥 = 𝑎0 + 𝑎1 𝑥 + 𝑎2 𝑥 2 + 𝑎3 𝑥 3 + ⋯ … … . +𝑎𝑛 𝑥 𝑛

33
Taylor series expansion of 𝑒 𝑥 about x=0, 𝑎0 , 𝑎1 , 𝑎2 … ..are coefficient to be
determined

𝑥 0 0.5 1 1.5 2 2.5 3


𝑒𝑥 1 1.8487 2.7183 4.4817 7.3891 12.1825 20.085

If we have to find the value of 𝑒 2.2 𝑜𝑟 𝑒 0.75 then interpolation inside the given
range.

If we have to find the value of 𝑒 3.2 then extrapolation outside the given range.

Various method of interpolation

1. Lagrange interpolation
2. Newton’s interpolation
3. Newton’s Gregory forward interpolation
4. Spline interpolation

Polynomial form

The most common form of an nth order polynomial is

𝑝(𝑥 ) = 𝑎0 + 𝑎1 𝑥 + 𝑎2 𝑥 2 + 𝑎3 𝑥 3 + ⋯ … … . +𝑎𝑛 𝑥 𝑛 known as power form.

Linear interpolation
The simplest form of interpolation is to approximate two data points by straight
line, suppose we have two points (𝑥1 𝑓(𝑥1 )) &(𝑥2 𝑓(𝑥2 )). These two points can
be connected linearly as shown in figure, using the concept of similar triangles
we show that :

𝑓(𝑥 ) − 𝑓(𝑥1 ) 𝑓(𝑥2 ) − 𝑓(𝑥1 )


=
𝑥 − 𝑥1 𝑥2 − 𝑥1

34
Figure: Graphical representation of Linear interpolation

On solving for f(x) we get


𝑓(𝑥2 ) − 𝑓(𝑥1 )
𝑓(𝑥 ) = 𝑓(𝑥1 ) + (𝑥 − 𝑥1 )
𝑥2 − 𝑥1
𝑓(𝑥2 )−𝑓(𝑥1 )
Above equation is known as linear interpolation formula, note that
𝑥2 −𝑥1
represents the slope of line.

Example : The table below shows square root for the integers, determine the
square root of 2.5

x 1 2 3 4 5
F(x) 1 1.4142 1.7321 2 2.2361

The given value of 2.5 lies in between 2 and 3. Therefore 𝑥1 = 2, 𝑓(𝑥1 ) =


1.4142, 𝑥2 = 3, 𝑓 (𝑥2 ) = 1.7321,

𝑓 (𝑥2 ) − 𝑓(𝑥1 )
𝑓(2.5) = 𝑓(𝑥1 ) + (𝑥 − 𝑥1 )
𝑥2 − 𝑥1
𝑓 (3) − 𝑓(2)
= 𝑓(2) + (2.5 − 2)
3−2

35
1.7321 − 1.4142
= 1.4142 + (2.5 − 2)
3−2
= 1.5732

Now if the two points taken are 𝑥1 = 2, 𝑥2 = 4

𝑓 (4) − 𝑓(2)
𝑓(2.5) = 𝑓(1) + (2.5 − 2)
4−2
(2 − 1.4142)
𝑓(2.5) = 1.4142 + 0.5
2
=1.5607

The correct answer is 1.5811, so from above values we can say that closer the
points the more accurate results.

Lagrange Interpolation polynomial


Let (𝑥0 , 𝑦0 ), (𝑥1 , 𝑦1 ), (𝑥2 , 𝑦2 ), (𝑥3 , 𝑦3 ) are given set of data points.Let 𝑦 = 𝑓(𝑥)
be a function which takes the (n+1) values 𝑦0 , 𝑦1 , 𝑦2 , … … 𝑦𝑛 corresponding to
𝑥 = 𝑥0 , 𝑥1 , 𝑥2 … … 𝑥𝑛 . Now 𝑓(𝑥) can be represented as polynomial of 𝑛𝑡ℎ degree
in x.

Let the polynomial be of the form

𝑦 = 𝑓(𝑥 ) = 𝑎0 (𝑥 − 𝑥1 )(𝑥 − 𝑥2 ) … … (𝑥 − 𝑥𝑛 )

+𝑎1 (𝑥 − 𝑥0 )(𝑥 − 𝑥2 ) … … (𝑥 − 𝑥𝑛 )

+𝑎2 (𝑥 − 𝑥0 )(𝑥 − 𝑥1 ) … … (𝑥 − 𝑥𝑛 ) … ….

+𝑎𝑛 (𝑥 − 𝑥0 )(𝑥 − 𝑥1 ) … … (𝑥 − 𝑥𝑛−1 ) … … . . (1)

Putting 𝑥 = 𝑥0 , 𝑦 = 𝑦0 in the equation 1 we get,

𝑦0 = 𝑎0 (𝑥0 − 𝑥1 )(𝑥0 − 𝑥2 ) … … (𝑥0 − 𝑥𝑛 )


𝑦0
𝑎0 =
(𝑥0 − 𝑥1 )(𝑥0 − 𝑥2 ) … … (𝑥0 − 𝑥𝑛 )

Again putting 𝑥 = 𝑥1 , 𝑦 = 𝑦1 in the equation 1 we get,

36
𝑦1 = 𝑎1 (𝑥1 − 𝑥0 )(𝑥1 − 𝑥2 ) … … (𝑥1 − 𝑥𝑛 )
𝑦1
𝑎1 =
(𝑥1 − 𝑥0 )(𝑥1 − 𝑥2 ) … … (𝑥1 − 𝑥𝑛 )

On preceding
𝑦𝑛
𝑎𝑛 =
(𝑥𝑛 − 𝑥0 )(𝑥𝑛 − 𝑥1 ) … … (𝑥𝑛 − 𝑥𝑛−1 )

Substituting the values of 𝑎0 , 𝑎1, 𝑎2 … … 𝑎𝑛 in equation 1 we get.

(𝑥 − 𝑥1 )(𝑥 − 𝑥2 ) … … (𝑥 − 𝑥𝑛 )
𝑦 = 𝑓 (𝑥 ) = 𝑦
(𝑥0 − 𝑥1 )(𝑥0 − 𝑥2 ) … … (𝑥0 − 𝑥𝑛 ) 0
(𝑥 − 𝑥0 )(𝑥 − 𝑥2 ) … … (𝑥 − 𝑥𝑛 )
+ 𝑦
(𝑥1 − 𝑥0 )(𝑥1 − 𝑥2 ) … … (𝑥1 − 𝑥𝑛 ) 1

+ … ….
(𝑥 − 𝑥0 )(𝑥 − 𝑥1 ) … … (𝑥 − 𝑥𝑛−1 )
𝑦
(𝑥𝑛 − 𝑥0 )(𝑥𝑛 − 𝑥1 ) … … (𝑥𝑛 − 𝑥𝑛−1 ) 𝑛

this is known as Lagrange’s interpolation formula

in general

𝑛 𝑦𝑗 ∏𝑛𝑖=0(𝑥 − 𝑥𝑖 )
𝑖≠𝑗
𝑓 (𝑥 ) = ∑ 𝑛
∏𝑖=0(𝑥𝑗 − 𝑥𝑖 )
𝑗=0 𝑖≠𝑗

This is Lagrange basic polynomial

Note:

1. This formula can be used irrespective of whether the values 𝑥0, 𝑥1, 𝑥2,…. 𝑥𝑛,
are equally spaced or not.
2. It is simple and easy to remember but its application is not speedy.
3. The main drawback of it is that if another interpolation value is inserted,
then the interpolation coefficients are required to be recalculated.

Example 1: Consider the problem to find the square root of 2.5 using the
second order Lagrange interpolation polynomial.

37
Consider the following three points

x0 = 2 x1 = 3 x2 = 4
f0 = 1.4142 f1 = 1.7321 f2 = 2

We know that
2

𝑓(𝑥 ) = ∑ 𝑦𝑖 𝑙𝑖
𝑖=0

Where
∏2𝑗=0(𝑥 − 𝑥𝑗 )
𝑗≠𝑖
𝑙𝑖 =
∏2𝑗=0(𝑥𝑖 − 𝑥𝑗 )
𝑗≠𝑖

so
(𝑥 − 𝑥1 )(𝑥 − 𝑥2 )
𝑙0 (𝑥 ) =
(𝑥0 − 𝑥1 )(𝑥0 − 𝑥2 )
(𝑥−3)(𝑥−4)
= (2−3)(2−4)

𝑥 2 − 7𝑥 + 12
=
2

(𝑥 − 𝑥0 )(𝑥 − 𝑥2 )
𝑙1 (𝑥 ) =
(𝑥1 − 𝑥0 )(𝑥1 − 𝑥2 )
(𝑥−2)(𝑥−4)
= (3−2)(3−4)

𝑥 2 − 6𝑥 + 8
=
−1
(𝑥 − 𝑥0 )(𝑥 − 𝑥1 )
𝑙2 (𝑥 ) =
(𝑥2 − 𝑥0 )(𝑥2 − 𝑥1 )
(𝑥−2)(𝑥−3)
= (4−2)(4−3)

38
𝑥 2 − 5𝑥 + 6
=
2
We know, 𝑓(𝑥 ) = 𝑦0 𝑙0 (𝑥 ) + 𝑦1 𝑙1 (𝑥 ) + 𝑦2 𝑙2 (𝑥 )

𝑥 2 − 7𝑥 + 12 𝑥 2 − 6𝑥 + 8 𝑥 2 − 5𝑥 + 6
= 1.4142 ∗ + 1.7321 ∗ +2∗
2 −1 2
= 0.7071 ∗ (𝑥 2 − 7𝑥 + 12) − 1.7321 ∗ (𝑥 2 − 6𝑥 + 8) + (𝑥 2 − 5𝑥 + 6)

𝑓(2.5) = 0.7071 ∗ (2.52 − 7 ∗ 2.5 + 12) − 1.7321 ∗ (2.52 − 6 ∗ 2.5 + 8)


+ (2.52 − 5 ∗ 2.5 + 6)

= 0.5303 + 1.2991 − 0.25

= 1.5794

The square root of 2.5 is 1.5794 with some error.

Practice :

1. Find the Lagrange interpolation polynomial to fit the following data.


𝑖 0 1 2 3
𝑥𝑖 0 1 2 3
𝑥𝑖 0 1.7183 6.3891 19.0855
𝑒 −1
1.5
Use the polynomial to estimate the value of 𝑒

2. Find the Lagrange interpolation polynomial to fit the following data.


𝑥 1.0 1.1 1.2
cos 𝑥 0.5403 0.4536 0.3624
Use the polynomial to estimate the value of cos 1.15

Newtons Interpolation formula


Given the set of data points (𝑥0 , 𝑦0 ), (𝑥1 , 𝑦1 ), (𝑥2 , 𝑦2 ) … … (𝑥𝑛−1 , 𝑦𝑛−1 ). Let us
consider a polynomial function of the form known as newton form as

𝑝𝑛 (𝑥 ) = 𝑎0 + 𝑎1 (𝑥 − 𝑥0 ) + 𝑎2 (𝑥 − 𝑥0 )(𝑥 − 𝑥1 )
+ 𝑎3 (𝑥 − 𝑥0 )(𝑥 − 𝑥1 )(𝑥 − 𝑥2 ) + ⋯ + 𝑎𝑛 (𝑥 − 𝑥1 ) … (𝑥 − 𝑥𝑛−1 )

Of the order n which passes through all the given data points

At 𝑥 = 𝑥0 , 𝑝𝑛 (𝑥0 ) = 𝑎0 = 𝑦0

39
𝐴𝑡 , 𝑥 = 𝑥1 , 𝑝𝑛 (𝑥1 ) = 𝑎0 + 𝑎1 (𝑥1 − 𝑥0 ) = 𝑦1
𝑦1 − 𝑎0
𝑎1 =
𝑥1 − 𝑥0
𝑦1 − 𝑦0
=
𝑥1 − 𝑥0

𝐴𝑡 , 𝑥 = 𝑥2 , 𝑝𝑛 (𝑥2 ) = 𝑎0 + 𝑎1 (𝑥2 − 𝑥0 ) + 𝑎2 (𝑥2 − 𝑥0 )(𝑥2 − 𝑥1 ) = 𝑦2


𝑦2 − 𝑦0 − 𝑎1 (𝑥2 − 𝑥0 )
𝑎2 =
(𝑥2 − 𝑥0 )(𝑥2 − 𝑥1 )

Substituting of the value of 𝑎1


𝑦1 −𝑦0
𝑦2 − 𝑦0 − (𝑥2 − 𝑥0 )
𝑥1 −𝑥0
𝑎2 =
(𝑥2 − 𝑥0 )(𝑥2 − 𝑥1 )

On further calculation we get the final result as

𝑦2 −𝑦1 𝑦1 −𝑦0

𝑥2 −𝑥1 𝑥1 −𝑥0
𝑎2 =
(𝑥2 − 𝑥0 )

Now let us define new notation as


𝑦1 − 𝑦0
𝑎1 = = 𝑓[𝑥0 , 𝑥1 ] 𝑑𝑖𝑣𝑖𝑑𝑒𝑑 𝑑𝑖𝑓𝑓𝑒𝑟𝑒𝑛𝑐𝑒
𝑥1 − 𝑥0
𝑦2 −𝑦1 𝑦1 −𝑦0

𝑥2 −𝑥1 𝑥1 −𝑥0
𝑎2 = = 𝑓[𝑥0 , 𝑥1 , 𝑥2 ]
(𝑥2 − 𝑥0 )

𝑎2 = 𝑓[𝑥0 , 𝑥1 , 𝑥2 , 𝑥3 ] … …

𝑎𝑛 = 𝑓[𝑥0 , 𝑥1 , 𝑥2 , 𝑥3 , … … 𝑥𝑛 ]

The polynomial 𝑝𝑛 (𝑥 ) which passes through the given points is

𝑝𝑛 (𝑥 ) = 𝑓[𝑥0 ] + 𝑓[𝑥0 , 𝑥1 ](𝑥 − 𝑥0 ) + 𝑓[𝑥0 , 𝑥1 , 𝑥2 ](𝑥 − 𝑥0 )(𝑥 − 𝑥1 )


+ 𝑓[𝑥0 , 𝑥1 , 𝑥2 , 𝑥3 ](𝑥 − 𝑥0 )(𝑥 − 𝑥1 )(𝑥
− 𝑥2 ) … … . 𝑓[𝑥0 , 𝑥1 , 𝑥2 , 𝑥3 … 𝑥𝑛 ](𝑥 − 𝑥0 )(𝑥 − 𝑥1 )(𝑥 − 𝑥2 ) … (𝑥
− 𝑥𝑛−1 )
40
This polynomial is called Newtons divided difference interpolation

Example : Given below is a table of data for log 𝑥, estimate log 2.5using second
order newton

𝑖 0 1 2 3
𝑥𝑖 1 2 3 4
log 𝑥𝑖 0 0.3010 0.4771 0.6021

Solution

𝑎0 = 𝑓 [𝑥0 ] = 𝑦0 = 0
𝑦1 − 𝑦0 0.3010 − 0
𝑎1 = 𝑓[𝑥0 , 𝑥1 ] = = = 0.3010
𝑥1 − 𝑥0 2−1
𝑦2 −𝑦1 𝑦1 −𝑦0 0.4771−0.3010 0.3010−0
− −
𝑥2 −𝑥1 𝑥1 −𝑥0 3−2 2−1
𝑎2 = 𝑓[𝑥0 , 𝑥1 , 𝑥2 ] = = = −0.0625use
(𝑥2 −𝑥0 ) (3−1)

Now,

𝑝𝑛 (𝑥 ) = 𝑓[𝑥0 ] + 𝑓 [𝑥0 , 𝑥1 ](𝑥 − 𝑥0 ) + 𝑓 [𝑥0 , 𝑥1 , 𝑥2 ](𝑥 − 𝑥0 )(𝑥 − 𝑥1 )

= 0 + 0.3010 ∗ (𝑥 − 1) + (−0.0625)(𝑥 − 1)(𝑥 − 2)

= 0.3010 ∗ (𝑥 − 1) − 0.0625(𝑥 − 1)(𝑥 − 2)

𝑝𝑛 (2.5) = 0.3010 ∗ (2.5 − 1) − 0.0625(2.5 − 1)(2.5 − 2)

= 0.3010 ∗ 1.5 − 0.0469

= 0.4046

Newtons divided difference table:


The alternative way of finding the coefficients(𝑎0 ,𝑎1 , 𝑎2 𝑎𝑛𝑑 𝑠𝑜 𝑜𝑛) values to
use Newton divided difference table, for given (𝑥0, 𝑓0 ),(𝑥1, 𝑓1 ),(𝑥2, 𝑓2 ),(𝑥3 𝑓3 ) and
(𝑥4, 𝑓4 ) is called Newton’s divided difference table.

Example : find the functional value for 𝑥 = 7 using newton interpolation


polynomial

x 5 6 9 11
f(x) 12 13 14 16

41
Since there are four data points the required polynomial will be of the order 3

𝑝3 (𝑥 ) = 𝑎0 + 𝑎1 (𝑥 − 𝑥0 ) + 𝑎2 (𝑥 − 𝑥0 )(𝑥 − 𝑥1 )
+ 𝑎3 (𝑥 − 𝑥0 )(𝑥 − 𝑥1 )(𝑥 − 𝑥2 )

To get the value of 𝑎0 , 𝑎1 , 𝑎2 , 𝑎3 we are going to use newton divided difference


table

x f 1st Order 2nd Order Difference


Difference
5 12
13 − 12
6−5
=1
6 13 1⁄ − 1
3
9−5
= − 1⁄6
14 − 13 2⁄ −(−1⁄ )
15 6 1
= ⁄20
9−6 11−5
= 1⁄3
9 14 1 − 1⁄3
= 2⁄5
11 − 6
16 − 14
11 − 9
=1
11 16

From table 𝑎0 = 12, 𝑎1 = 1, 𝑎2 = − 1⁄6 , 𝑎3 = 1⁄20

Now 𝑝3 (𝑥 ) = 12 + 1(𝑥 − 5) − 1⁄6 (𝑥 − 5)(𝑥 − 6) + 1⁄20 (𝑥 − 5)(𝑥 −


6)(𝑥 − 9)

Now substitute x=7 in above expression and we get

𝑝3 (𝑥 ) = 12 + 1(7 − 5) − 1⁄6 (7 − 5)(7 − 6) + 1⁄20 (7 − 5)(7 − 6)(7 − 9)


= 13.47

42
Evenly spaced data

If x-value are evenly spaced getting an interpolating polynomial is considerably


simplified. Most of the engineering and scientific table are available in this form.

Newton’s forward difference interpolation/ Gregory Newton forward


interpolation formula

let 𝑦 = 𝑓(𝑥) be a function which takes the values 𝑦0 , 𝑦1 … . . 𝑦𝑛 for values (n+1),
at 𝑥0 , 𝑥1 , 𝑥2 … . 𝑥𝑛 of the independent variables x. let these values of x be
equidistance i.e𝑥𝑖 = 𝑥0 + 𝑖ℎ, 𝑖. 𝑒 𝑖 = 0,1,2 … 𝑛. Let y(x) be the polynomial in x
of the nth degree such that 𝑦𝑖 = 𝑓(𝑥𝑖 ), 𝑖 = 0,1,2 … 𝑛.

𝑦(𝑥 ) = 𝐴0 + 𝐴1 (𝑥 − 𝑥0 ) + 𝐴2 (𝑥 − 𝑥0 )(𝑥 − 𝑥1 )
+ 𝐴3 (𝑥 − 𝑥0 )(𝑥 − 𝑥1 )(𝑥 − 𝑥2 ) … … . . (𝑎)

Putting 𝑥 = 𝑥0 , 𝑥1 … … . 𝑥𝑛 𝑠𝑢𝑐𝑐𝑒𝑠𝑠𝑖𝑣𝑒𝑙𝑦

We get, putting 𝑥 = 𝑥0

𝑦0 = 𝐴0

𝐴0 = 𝑦0

putting 𝑥 = 𝑥1 and putting 𝐴0 = 𝑦0

𝑦1 = 𝐴0 + 𝐴1 (𝑥1 − 𝑥0 )
𝑦1 − 𝐴0 𝑦1 − 𝑦0 ∆𝑦0
𝐴1 = = =
𝑥1 − 𝑥0 𝑥1 − 𝑥0 ℎ

Where h =equidistant gap.

putting 𝑥 = 𝑥2 and putting values of 𝐴0 , 𝐴1

𝑦2 = 𝐴0 + 𝐴1 (𝑥1 − 𝑥0 )+𝐴2 (𝑥2 − 𝑥0 )(𝑥2 − 𝑥1 )

𝑦2 − 𝐴0 − 𝐴1 (𝑥2 − 𝑥0 )
𝐴2 =
(𝑥2 − 𝑥0 )(𝑥2 − 𝑥1 )

43
𝑦1 −𝑦0
𝑦2 − 𝑦0 − (𝑥2 − 𝑥0 )
𝑥1 −𝑥0
=
(𝑥2 − 𝑥0 )(𝑥2 − 𝑥1 )

𝑥2 − 𝑥0 = (𝑥2 − 𝑥1 ) + (𝑥1 − 𝑥0 ) = ℎ + ℎ = 2ℎ

𝑦1 −𝑦0
𝑦2 − 𝑦0 − 2ℎ

=
(2ℎ)(ℎ)
𝑦2 − 𝑦0 −2𝑦1 + 2𝑦0
=
2ℎ2
𝑦2 −2𝑦1 + 𝑦0
=
2ℎ2
∆2 𝑦0
=
2! ℎ2
Similarly

∆3 𝑦0
𝐴3 =
3! ℎ3

Similarly, and so on putting these values in equation (a), we get

∆𝑦0 (𝑥 − 𝑥0 ) ∆2 𝑦0 (𝑥 − 𝑥0 )(𝑥 − 𝑥1 )
𝑦(𝑥 ) = 𝑦0 + +
ℎ 2! ℎ2
∆3 𝑦0 (𝑥 − 𝑥0 )(𝑥 − 𝑥1 )(𝑥 − 𝑥2 )
+ … … . . (𝑏)
3! ℎ3
(𝑥−𝑥0 )
Putting = 𝑝, 𝑖. 𝑒 𝑥 = 𝑥0 + 𝑝ℎ where p is a real number

Finally we get

𝑝(𝑝 − 1)∆2 𝑦0 𝑝(𝑝 − 1)(𝑝 − 2)∆3 𝑦0


𝑦𝑝 = 𝑦0 + 𝑝∆𝑦0 + + +⋯
2! 3!
𝑝(𝑝 − 1) … [𝑝 − (𝑛 − 1)]∆𝑛 𝑦0
+
𝑛!
Where 𝑦𝑝 = 𝑦(𝑥0 + 𝑝ℎ) is known as Gregory Newton forward interpolation
formula.

44
Gregory Newton Backward Interpolation Formula

let 𝑦 = 𝑓(𝑥) be a function which takes the values 𝑦0 , 𝑦1 … . . 𝑦𝑛 for values (n+1),
at 𝑥0 , 𝑥1 , 𝑥2 … . 𝑥𝑛 of the independent variables x. let these values of x be
equidistance i.e𝑥𝑖 = 𝑥0 + 𝑖ℎ, 𝑖. 𝑒 𝑖 = 0,1,2 … 𝑛. Let y(x) be the polynomial in x
of the nth degree such that 𝑦𝑖 = 𝑓(𝑥𝑖 ), 𝑖 = 0,1,2 … 𝑛. Suppose it is required to
evaluate y(x) near the end of the table value, then we can assume that,

𝑦(𝑥 ) = 𝐴0 + 𝐴1 (𝑥 − 𝑥𝑛 ) + 𝐴2 (𝑥 − 𝑥𝑛 )(𝑥 − 𝑥𝑛−1 )


+ 𝐴3 (𝑥 − 𝑥𝑛 )(𝑥 − 𝑥𝑛−1 )(𝑥 − 𝑥𝑛−2 ) + ⋯
+ ⋯ 𝐴𝑛 (𝑥 − 𝑥𝑛 )(𝑥 − 𝑥𝑛−1 ) … (𝑥 − 𝑥1 ) … … (𝑎)

Putting 𝑥 = 𝑥𝑛 , 𝑥𝑛−1 … … . 𝑥0 𝑠𝑢𝑐𝑐𝑒𝑠𝑠𝑖𝑣𝑒𝑙𝑦 𝑖𝑛 𝑒𝑞𝑢𝑎𝑡𝑖𝑜𝑛 𝑎

We get, putting 𝑥 = 𝑥𝑛

𝐴0 = 𝑦(𝑥𝑛 ) = 𝑦𝑛

putting 𝑥 = 𝑥𝑛−1 and putting 𝐴0 = 𝑦𝑛

𝑦(𝑥𝑛−1 ) = 𝑦𝑛−1 = 𝐴0 + 𝐴1 (𝑥𝑛−1 − 𝑥𝑛 )

putting 𝑥 = 𝑥𝑛−2

𝑦(𝑥𝑛−2 ) = 𝑦𝑛−2 = 𝐴0 + 𝐴1 (𝑥𝑛−2 − 𝑥𝑛 )+𝐴2 (𝑥𝑛−2 − 𝑥𝑛 )(𝑥𝑛−2 − 𝑥𝑛−1 )

Solving above equation for values of A, we get

45
𝑦𝑛−1 − 𝐴0 𝑦𝑛−1 − 𝑦𝑛 𝑦𝑛 − 𝑦𝑛−1 ∇𝑦𝑛
𝐴1 = = = =
𝑥𝑛−1 − 𝑥𝑛 𝑥𝑛−1 − 𝑥𝑛 𝑥𝑛 − 𝑥𝑛−1 ℎ

Where h =equidistant gap.


𝑦𝑛−2 − 𝐴0 − 𝐴1 (𝑥𝑛−2 − 𝑥𝑛 )
𝐴2 =
(𝑥𝑛−2 − 𝑥𝑛 )(𝑥𝑛−2 − 𝑥𝑛−1 )

𝑦𝑛−2 − 𝑦𝑛 − (𝑦𝑛 − 𝑦𝑛−1 )(−2) 1


= 𝑥
(−2ℎ)(−ℎ) ℎ
𝑦𝑛 −2𝑦𝑛−1 + 2𝑦𝑛−2
=
2ℎ2
∇2 𝑦𝑛
=
2! ℎ2
Similarly

∇3 𝑦𝑛
𝐴3 =
3! ℎ3
And so on

Putting these values in equation a we get

∇𝑦𝑛 (𝑥 − 𝑥𝑛 ) ∇2 𝑦𝑛 (𝑥 − 𝑥𝑛 )(𝑥 − 𝑥𝑛−1 )


𝑦(𝑥 ) = 𝑦𝑛 + +
ℎ 2! ℎ2
∇3 𝑦𝑛 (𝑥 − 𝑥𝑛 )(𝑥 − 𝑥𝑛−1 )(𝑥 − 𝑥𝑛−2 )
+ … … . . (𝑏)
3! ℎ3
(𝑥−𝑥𝑛 )
Putting = 𝑝, 𝑖. 𝑒 𝑥 = 𝑥𝑛 + 𝑝ℎ where p is a real number

Finally we get

𝑝(𝑝 + 1)∇2 𝑦𝑛 𝑝(𝑝 + 1)(𝑝 + 2)∇3 𝑦𝑛


𝑦𝑝 = 𝑦𝑛 + 𝑝∆𝑦𝑛 + + +⋯
2! 3!
𝑝(𝑝 + 1)(𝑝 + 2) … [𝑝 + (𝑛 − 1)]∇𝑛 𝑦𝑛
+
𝑛!
Where 𝑦𝑝 = 𝑦(𝑥𝑛 + 𝑝ℎ) is known as Gregory Newton Backward interpolation
formula.

46
Example 1: Estimate the value of sin 𝜃 𝑎𝑡 𝜃 = 25° , using Newton Gregory
Forward difference formula with the help of following table

𝜃 10 20 30 40 50
sin 𝜃 0.1736 0.3420 0.5 0.6428 0.7660

Solution

In order to use newtons Gregory difference formula we need the values of ∆𝑛 .


These coefficients can be obtained from the difference table given below

𝜃 sin 𝜃 ∆𝑦𝑛 ∆2 𝑦𝑛 ∆3 𝑦𝑛 ∆4 𝑦𝑛
10 0.1736
0.1684
20 0.3420 -0.0104
0.1580 -0.0048
30 0.5 -0.0152 0.0004
0.1428 -0.0041
40 0.6428 -0.0196
0.1232
50 0.7660

The Newton’s Forward Difference Interpolation Formula

𝑝(𝑝 − 1)∆2 𝑦0 𝑝(𝑝 − 1)(𝑝 − 2)∆3 𝑦0


𝑦𝑝 = 𝑦0 + 𝑝∆𝑦0 + +
2! 3!
𝑝(𝑝 − 1)(𝑝 − 2)(𝑝 − 3)∆4 𝑦0
+
4!

𝑥−𝑥0 25−10
Where 𝑝 = for 𝜃 = 25, 𝑝 = = 1.5
ℎ 10

1.6(1.5 − 1)(−0.0104)
𝑦𝑝 = 0.1736 + 1.5 × 0.1684 +
2!
1.5(1.5 − 1)(1.5 − 2)(−0.0048)
+
3!
1.5(1.5 − 1)(1.5 − 2)(1.5 − 3)0.004
+
4!
= 0.1736 + 0.2526 − 0.0039 + 0.0003 + 0.0000

47
= 0.4226

Extra solving using backward formula

𝑝(𝑝 + 1)∇2 𝑦𝑛 𝑝(𝑝 + 1)(𝑝 + 2)∇3 𝑦𝑛


𝑦𝑝 = 𝑦𝑛 + 𝑝∆𝑦𝑛 + +
2! 3!
𝑝(𝑝 + 1)(𝑝 + 2)(𝑃 + 3)∇4 𝑦𝑛
+
4!
25 − 50
𝑝= = −2.5
10
(−2.5)(−2.5 + 1)(−0.0196)
𝑦(25) = 0.7660 + (−2.5)(0.1232) +
2!
(−2.5)(−2.5 + 1)(−2.5 + 2)(−0.0044)
+
3!
(−2.5)(−2.5 + 1)(−2.5 + 2)(−2.5 + 3)(0.0004)
+
4!
= 0.7660 − 0.3080 − 0.0368 + 0.0014 + 0
= 0.4226
Example 2 : Find the values of y for x=0.8 for the given set of values using
Newton’s Backward Difference Interpolation Formula

X 0.5 1 1.5 2 2.5 3


Y 2.1990 2.5 2.6761 2.8010 2.8979 2.9771

Now the difference table is

X y ∇𝑦𝑛 ∇2 𝑦𝑛 ∇3 𝑦𝑛 ∇4 𝑦𝑛 ∇5 𝑦𝑛
0.5 2.1990
1 2.5 0.3010
1.5 2.6761 0.1761 -0.1249
2 2.8010 0.1249 -0.0512 0.0737
2.5 2.8979 0.0969 -0.0280 0.0232 -0.0505
3 2.9771 0.0792 -0.0177 0.0103 -0.0129 0.0376

48
Now, Newton’s Backward Interpolation Formula

𝑝(𝑝 + 1)∇2 𝑦𝑛 𝑝(𝑝 + 1)(𝑝 + 2)∇3 𝑦𝑛


𝑦𝑝 = 𝑦𝑛 + 𝑝∆𝑦𝑛 + +
2! 3!
𝑝(𝑝 + 1)(𝑝 + 2)(𝑃 + 3)∇4 𝑦𝑛
+
4!
𝑝(𝑝 + 1)(𝑝 + 2)(𝑃 + 3)(𝑃 + 4)∇5 𝑦𝑛
+
5!
Where
𝑥 − 𝑥𝑛 0.8 − 3
𝑝= = = −4.4
ℎ 0.5
Now
(−4.4)(−4.4 + 1)(−0.0177)
𝑦𝑝 = 𝑦(0.8) = 2.9771 + (−4.4)(0.0792) +
2!
(−4.4)(−4.4 + 1)(−4.4 + 2)(0.0103)
+
3!
(−4.4)(−4.4 + 1)(−4.4 + 2)(−4.4 + 3)(−0.0129)
+
4!
(−4.4)(−4.4 + 1)(−4.4 + 2)(−4.4 + 3)(−4.4 + 4)(0.0376)
+
5!
= 2.9771 − 0.3485 − 0.1324 − 0.0616 − 0.0270 − 0.0063

= 2.4013

49
Spline curves
There are many times when fitting an interpolating polynomial to data points is
very difficult. Here is an example where we try to fit to data pairs from known
functions.

None of the polynomial is a good representation of the function. In particular we


observe that eight-degree polynomial derivatives widely near x=2.

One approach to overcome this problem is to divide the entire range of points into
sub intervals and use local low order polynomials to interpolate each sub
intervals, such polynomials are called piecewise polynomials.

50
Figure piecewise polynomial interpolation

Such piecewise polynomials are called splines functions. So, the splines functions
look smooth at the connecting points, the connecting points are called knots or
nodes.

The formula for obtaining cubic spline function:

(1) We write the formula for a cubic polynomial 𝑠𝑖 (𝑥) as,

si(x) = (ai-1/6hi) (hi2 ui-ui3) +(ai/6hi) (ui-13 – hi2 ui-1) +1/hi (fi ui-1 -fi-1 ui)

where, ui = x-xi

(2) Formula for obtaining “ai” values:


(I) For 3 data points:

51
𝑓𝑖+1 −𝑓𝑖 𝑓𝑖 −𝑓𝑖−1
ℎ𝑖 𝑎𝑖−1 + 2(ℎ𝑖 + ℎ𝑖+1 )𝑎𝑖 + ℎ𝑖+1 𝑎𝑖+1 = 6 ( − )
ℎ𝑖+1 ℎ𝑖

(II) For 4 data points:


2(ℎ1 + ℎ2 ) ℎ2 𝑎1 𝐷
[ ] [𝑎 ] = [ 1 ]
ℎ2 2(ℎ2 + ℎ3 ) 2 𝐷2
𝑓𝑖+1 −𝑓𝑖 𝑓𝑖 −𝑓𝑖−1
Where, Di = 6 ( − )
ℎ𝑖+1 ℎ𝑖

Q.N. (1) Given the data points as below:

i 0 1 2
xi 4 (x0) 9 (x1) 16 (x2)
f(xi) 2 (f0) 3 (f1) 4 (f2)
Estimate the functional value at x=7 using cubic spline technique.

Solution : h1 =5, h2 =7 Now, using the formula,


𝑓𝑖+1 −𝑓𝑖 𝑓𝑖 −𝑓𝑖−1
ℎ𝑖 𝑎𝑖−1 + 2(ℎ𝑖 + ℎ𝑖+1 )𝑎𝑖 + ℎ𝑖+1 𝑎𝑖+1 = 6 ( − )…(A)
ℎ𝑖+1 ℎ𝑖

Put i=1 since x=7 lies in the domain of s1(x). i.e.


𝑓 −𝑓1 𝑓1 −𝑓0
ℎ1 𝑎0 + 2(ℎ1 + ℎ2 )𝑎1 + ℎ2 𝑎2 = 6 ( 2 − )……(B)
ℎ2 ℎ1

Now, we know from the cubic spline technique, a0= an=0 i.e. a0= a2=0

So, from (B) we get, 2(5+7) a1=6[1/7-1/5].Therefore, a1 = -0.0143

Now the cubic spline function,

si(x) = (ai-1/6hi) (hi2 ui-ui3) +(ai/6hi) (ui-13 – hi2 ui-1) +1/hi (fi ui-1 -fi-1 ui)…(C)

where, ui = x-xi

put i=1 in (C) we get,

s1(x) = (a0/6h1) (h12 u1-u13) +(a1/6h1) (u03 – h12 u0) +1/h1 (f1u0 -f0 u1)

where, u0 =x-x0 and u1 =x-x1

So, s1(7) = 2.6229 i.e. f(7) = 2.6229Ans.


52
Q.N. ( 2): Given the data points as below:

i 0 1 2 3
xi 1(x0) 2(x1) 3(x2) 4(x3)
f(xi) 0.5(f0) 0.3333(f1) 0.25(f2) 0.20(f3)
Estimate the functional value at x=2.5 using cubic spline technique.

Solution: h1 =1, h2 =1, h3 =1 and a0= 0, a1, a2, a3=0 (from cubic spline technique)
2(1 + 1) 1 𝑎1 𝐷
[ ] [𝑎 ] = [ 1 ]
1 2(1 + 1) 2 𝐷2
𝑓 −𝑓1 𝑓1 −𝑓0
Now D1 (i=1) = 6 ( 2 − ) = 0.5004
ℎ2 ℎ1

𝑓 −𝑓2 𝑓2 −𝑓1
and D2(i=2) = 6 ( 3 − ) =0.1995
ℎ3 ℎ2

Now, a1 = 0.120 and a2 =0.0199

Since x=2.5 lies on the domain of s2(x) i.e. i=2

Now, the cubic spline function,

s2(x) = (a1/6h2) (h22 u2-u23) +(a2/6h2) (u13 – h22 u1) +1/h2 (f2 u1 -f1 u2)

where, u2 = x-x2 , u1 = x-x1

So, s2(2.5) = 0.2829 i.e. f(2.5) = 0.2829

Practice questions:

1. Estimate the value of ln(3.5) using Newton-Gregory Forward Difference


Formula using given data
x 1.0 2.0 3.0 4.0
ln 𝑥 0.0 0.6931 1.0986 1.3863
° °
2. Estimate the value of sin 𝜃 𝑎𝑡 𝜃 = 45 &15 , using Newton Gregory
Forward and Backward difference formula with the help of following table
and compare the results

𝜃 10 20 30 40 50
sin 𝜃 0.1736 0.3420 0.5 0.6428 0.7660

53
Curve Fitting:
In many applications it is often necessary to establish a mathematical relationship
between experimental values, this relationship may be used for either testing
existing mathematical model or establishing new ones. The mathematical
equation can also be used to predict or forecast values of the dependent variables.

Suppose the value of y for the different values of x are given, if we want to know
the effect of x and y then we may write a functional relationship 𝑦 = 𝑓(𝑥)

The variable y is called dependent variables and x is the independent variable.


The relationship mat be either linear or non linear. We shall discuss the technique
known as least squares regression to fit data under following situation.

Relationship is linear
Fitting a straight line is the simplest approach of regression analysis. Let us
consider the mathematical equation of a straight line

𝑦 = 𝑎 + 𝑏𝑥 = 𝑓(𝑥)

We know that a is the intercept of the line and b is the slope. Consider the
points(𝑥𝑖 , 𝑦𝑖 ), then the vertical distance of this point from the line 𝑓(𝑥 ) = 𝑎 +
𝑏𝑥 is 𝑞𝑖 , then

𝑞𝑖 = 𝑦𝑖 − 𝑓(𝑥𝑖 )

= 𝑦𝑖 − (𝑎 + 𝑏𝑥𝑖 )

There are various approaches that would be tries for fitting the best line through
the data:

1. Minimize the sum of errors


2. Minimize the sum of absolute value of errors
3. Minimize the sum of squares of errors

54
Least Square regression:

Let the sum squares of individual errors be expressed as


𝑛 𝑛

𝑄 = ∑ 𝑞𝑖 = ∑[𝑦𝑖 − 𝑓 (𝑥𝑖 )]2


2

𝑖=1 𝑖=1
𝑛

= ∑[𝑦𝑖 − 𝑎 − 𝑏𝑥𝑖 ]2
𝑖=1

In this method of least squares we choose a & b such that Q is minimum, since Q
depends on a & b, a necessary condition for Q to be minimum is
𝜕𝑄 𝜕𝑄
= 0, =0
𝜕𝑎 𝜕𝑏
Then
𝑛
𝜕𝑄
= −2 ∑(𝑦𝑖 − 𝑎 − 𝑏𝑥𝑖 ) = 0
𝜕𝑎
𝑖=1
𝑛
𝜕𝑄
= −2 ∑ 𝑥𝑖 (𝑦𝑖 − 𝑎 − 𝑏𝑥𝑖 ) = 0
𝜕𝑏
𝑖=1

Thus we can write as:


𝑛

∑(𝑦𝑖 − 𝑎 − 𝑏𝑥𝑖 ) = 0
𝑖=1

∑ 𝑦𝑖 = 𝑛𝑎 + 𝑏 ∑ 𝑥𝑖 … … … … … 𝑎

∑ 𝑥𝑖 𝑦𝑖 = 𝑎 ∑ 𝑥𝑖 + 𝑏 ∑ 𝑥𝑖 2 … … … … … 𝑏

These are called normal equations solving for a & b we get


𝑛 ∑ 𝑥𝑖 𝑦𝑖 − ∑ 𝑥𝑖 ∑ 𝑦𝑖
𝑏=
𝑛 ∑ 𝑥𝑖 2 − (∑ 𝑥𝑖 )2
∑ 𝑦𝑖 ∑ 𝑥𝑖
𝑎= −𝑏 = 𝑦̅ − 𝑏𝑥̅
𝑛 𝑛

55
Where 𝑥̅ 𝑎𝑛𝑑 𝑦̅ are the average of x and y values.

Example: Fit a straight line to the following set of data

X 1 2 3 4 5
Y 3 4 5 6 8

Solution

The various summations are given below

𝒙𝒊 𝒚𝒊 𝒙𝒊 𝟐 𝒙𝒊 𝒚𝒊
1 3 1 3
2 4 4 8
3 5 9 15
4 6 16 24
5 8 25 40
𝚺 15 26 55 90

now
𝑛 ∑ 𝑥𝑖 𝑦𝑖 − ∑ 𝑥𝑖 ∑ 𝑦𝑖
𝑏=
𝑛 ∑ 𝑥𝑖 2 − (∑ 𝑥𝑖 )2
5 ∗ 90 − 15 ∗ 26
𝑏=
5 ∗ 55 − 152
= 1.20

∑ 𝑦𝑖 ∑ 𝑥𝑖
𝑎= −𝑏
𝑛 𝑛
26 15
= − 1.2
5 5
= 1.6

Therefore, the linear equation is 𝑦 = 1.6 + 1.2𝑥

56
Practice :

1. Fit a linear curve through the following data points

X 1 2 3 4 5 6 7
Y 0.5 2.5 2.0 4.0 3.5 6.0 5.5
Answer :𝑦 = 0.0714 + 0.839𝑥

2. In an organization , systematic efforts were introduces to reduce the


employee absenteeism and result for the first 10 months are shown below,
fit a linear least square lines to the data.
Months 1 2 3 4 5 6 7 8 9 10
Absentees(%) 10 9 9 8.5 9 8 8.5 7 8 7.5

3. The following table shows heights(h) and weights, find the regression line
and estimate the weights of the person with the following heights.
a) 140cm
b) 163 cm
c) 172.5 cm

h(cm) 175 165 160 180 150 170 155 185


w(kg) 68 58 59 71 51 62 53 68

Fitting Transcendental equations


In many cases of course data from experimental test are non linear, so we need to
fit them some functions other than first degree polynomial some popular forms
are

𝑦 = 𝑎𝑥 𝑏 𝑜𝑟 𝑦 = 𝑎𝑒 𝑏𝑥

Now for 𝑦 = 𝑎𝑥 𝑏 if we take logarithms on both sides we get

ln 𝑦 = ln 𝑎 + bln 𝑥

now let is write as

𝑧 = 𝐴 + 𝑏𝑥

𝑧 = ln 𝑦, 𝐴 = ln 𝑎 , 𝑋 = ln 𝑥

This equation is similar in form to linear equation and therefore using the same
procedure we can evaluate the parameters A & B.

57
𝑛 ∑ ln 𝑥𝑖 ln 𝑦𝑖 − ∑ ln 𝑥𝑖 ∑ ln 𝑦𝑖
𝑏=
𝑛 ∑ (ln 𝑥𝑖 )2 − (∑ ln 𝑥𝑖 )2
(∑ ln 𝑦𝑖 − 𝑏 ∑ ln 𝑥𝑖 )
ln 𝑎 = 𝐴 =
𝑛
𝑎 = 𝑒𝐴

Example : given the data table below , fit a power function model of the form 𝑦 =
𝑎𝑥 𝑏

𝑥 1 2 3 4 5
𝑦 0.5 2 4.5 8 12.5

The various quantities requires are

𝑥𝑖 𝑦𝑖 ln 𝑥𝑖 ln 𝑦𝑖 (ln 𝑥𝑖 )2 (ln 𝑥𝑖 )(ln 𝑦𝑖 )


1 0.5 0 -0.6931 0 0
2 2 0.6931 0.6931 0.4804 0.4804
3 4.5 1.0986 1.5041 1.2069 1.6524
4 8 1.3863 2.0794 1.9218 2.8827
5 12.5 1.6094 2.5257 2.5902 4.0649
∑ 4.7874 6.1092 6.1993 9.0804

𝑛 ∑ ln 𝑥𝑖 ln 𝑦𝑖 − ∑ ln 𝑥𝑖 ∑ ln 𝑦𝑖
𝑏=
𝑛 ∑ (ln 𝑥𝑖 )2 − (∑ ln 𝑥𝑖 )2
5 ∗ 9.0804 − 4.7874 ∗ 6.1092
=
5 ∗ 6.1993 − 4.78742
=2

(∑ ln 𝑦𝑖 − 𝑏 ∑ ln 𝑥𝑖 )
𝐴=
𝑛
6.1092 − 2 ∗ 4.7874
=
5
58
= −0.6981

𝑎 = 𝑒 𝐴 = 𝑒 −0.6931 = 0.5

𝑦 = 𝑎𝑥 𝑏 = 0.5𝑥 2

𝑦 = 0.5𝑥 2

Practice:

1. The temperature of a metal strip was measured at various time intervals


during heating and the values are given in the table
Time,t(min) 1 2 3 4
∘ 70 83 150 124
Temp,𝑇 (𝑐)

If the relationship between the temperature T and time t is of the form 𝑇 =


𝑡⁄
𝑏𝑒 4 + 𝑎, estimate temp at t=6min.

2. Use the exponential model 𝑦 = 𝑎𝑒 𝑏𝑥 to fit the data


X 0.4 0.8 1.2 1.6 2.0 2.4
Y 75 100 140 200 270 375

Fitting a polynomial function

When a given set of data does not appear to satisfy a linear equation, we can try
a suitable polynomial as regression curve to fit the data. The least squares
technique can be readily used to fit the data to a polynomial

Consider a polynomial of degree m-1.

𝑓(𝑥 ) = 𝑦 = 𝑎1 + 𝑎1 𝑥 + 𝑎3 𝑥 2 + 𝑎4 𝑥 3 + ⋯ … + 𝑎𝑚 𝑥 𝑚−1

If the data contains n set of x any y values, then the sum squares of the errors is
given by
𝑛

𝑄 = ∑[𝑦𝑖 − 𝑓(𝑥𝑖 )]2


𝑖=1

59
Since f(x) is a polynomial and contains coefficient 𝑎1 , 𝑎2 , 𝑎3…. we have to
estimate all m coefficients as before we have the following m equations that can
be solved for these coefficients i.e
𝜕𝑄 𝜕𝑄 𝜕𝑄
= 0, = 0…. =0
𝜕𝑎1 𝜕𝑎2 𝜕𝑎𝑚

Consider a general term


𝑛
𝜕𝑄 𝜕𝑓 (𝑥𝑖 )
= −2 ∑[𝑦𝑖 − 𝑓(𝑥𝑖 )] =0
𝜕𝑎𝑗 𝜕𝑎𝑗
𝑖=1

𝜕𝑓(𝑥𝑖 )
= 𝑥𝑖 𝑗−1
𝜕𝑎𝑗

Thus, we have
𝑛

∑[𝑦𝑖 − 𝑓(𝑥𝑖 )]𝑥𝑖 𝑗−1 = 0 𝑗 = 1,2,3 … . . 𝑚


𝑖=1
𝑛

∑[𝑦𝑖 𝑥𝑖 𝑗−1 − 𝑥𝑖 𝑗−1 𝑓(𝑥𝑖 )] = 0


𝑖=1

Substituting for 𝑓(𝑥𝑖 )


𝑛 𝑛

∑ 𝑥𝑖 𝑗−1 (𝑎1 + 𝑎1 𝑥𝑖 + 𝑎3 𝑥𝑖 2 + 𝑎4 𝑥𝑖 3 + ⋯ … + 𝑎𝑚 𝑥𝑖 𝑚−1 ) = ∑ 𝑦𝑖 𝑥𝑖 𝑗−1


𝑖=1 𝑖=1

These are m equations and each summation is for i=1 to n

𝑎1 𝑛 + 𝑎2 ∑𝑥𝑖 + 𝑎3 ∑𝑥𝑖 2 + 𝑎4 ∑𝑥𝑖 3 + ⋯ … + 𝑎𝑚 ∑𝑥𝑖 𝑚−1 = ∑𝑦𝑖

𝑎1 ∑𝑥𝑖 + 𝑎2 ∑𝑥𝑖 2 + 𝑎3 ∑𝑥𝑖 3 + 𝑎4 ∑𝑥𝑖 4 + ⋯ … + 𝑎𝑚 ∑𝑥𝑖 𝑚 = ∑𝑦𝑖 𝑥𝑖 …

𝑎1 ∑𝑥𝑖 𝑚−1 + 𝑎2 ∑𝑥𝑖 𝑚 + 𝑎3 ∑𝑥𝑖 𝑚+1 + 𝑎4 ∑𝑥𝑖 𝑚+2 + ⋯ … + 𝑎𝑚 ∑𝑥𝑖 2𝑚−2


= ∑𝑦𝑖 𝑥𝑖 𝑚−1

60
The set of m equation can be represented in matrix as CA=B

𝑛 ∑𝑥𝑖 ∑𝑥𝑖 2 … ∑𝑥𝑖 𝑚−1


𝐶 = ∑𝑥𝑖 ∑𝑥𝑖 2 ∑𝑥𝑖 3 … ∑𝑥𝑖 𝑚
⋮ ⋮ ⋮ … ⋮
[∑𝑥𝑖 𝑚−1 ∑𝑥𝑖 𝑚 ∑𝑥𝑖 𝑚+1 …
∑𝑥𝑖 2𝑚−2
]

𝑎1 ∑𝑦𝑖
𝑎2 ∑𝑦𝑖 𝑥𝑖
𝑎
𝐴 = 3 𝐵 = ∑𝑦𝑖 𝑥𝑖 2
⋮ ⋮
[𝑎𝑚 ] [∑𝑦𝑖 𝑥𝑖 𝑚−1 ]

Example : Fit a second order polynomial to the data in the table

x 1.0 2 3 4
y 6 11 18 27

The order of the polynomial is 2 and therefore we will have 3 simultaneous


equations as shown below:

𝑎1 𝑛 + 𝑎2 ∑𝑥𝑖 + 𝑎3 ∑𝑥𝑖 2 = ∑𝑦𝑖

𝑎1 ∑𝑥𝑖 + 𝑎2 ∑𝑥𝑖 2 + 𝑎3 ∑𝑥𝑖 3 = ∑𝑦𝑖 𝑥𝑖

𝑎1 ∑𝑥𝑖 2 + 𝑎2 ∑𝑥𝑖 3 + 𝑎3 ∑𝑥𝑖 4 = ∑𝑦𝑖 𝑥𝑖 2

𝒙 𝒚 𝒙𝟐 𝒙𝟑 𝒙𝟒 𝒚𝒙 𝒚𝒙𝟐
1 6 1 1 1 6 6
2 11 4 8 16 22 44
3 18 9 27 81 54 162
4 27 16 64 256 108 432
∑ 10 62 30 100 354 190 644

61
Substituting these values, we get,

4𝑎1 + 10𝑎2 + 30𝑎3 = 62

10𝑎1 + 30𝑎2 + 100𝑎3 = 190

30𝑎1 + 100𝑎2 + 354𝑎3 = 644

On solving these equations gives,

𝑎1 = 3, 𝑎2 = 2, 𝑎3 = 1

Therefore, the least square quadratic polynomial is 𝑦 = 3 + 2𝑥 + 𝑥 2

62
Chapter 3: Numerical Differentiation and Integration
Let us consider a set of values (𝑥𝑖 , 𝑦𝑖 ) of a function. The process of computing
the derivative or derivatives of that function at some values of x from the given
set of values is called Numerical Differentiation. This may be done by first
approximating the function by suitable interpolation formula and then
differentiating.

Derivatives using Newton’s Forward Difference formula


Newton’s forward interpolation formula
𝑝(𝑝−1)∆2 𝑦0 𝑝(𝑝−1)(𝑝−2)∆3 𝑦0 𝑝(𝑝−1)(𝑝−2)(𝑝−3)∆4 𝑦0
𝑦𝑝 = 𝑦0 + 𝑝∆𝑦0 + + + ... (1)
2! 3! 4!
𝑥 − 𝑥0
𝑝=

Differentiating both sides of above equation with respect to p, we have

𝑑𝑦 (2𝑝 − 1)∆2 𝑦0 (3𝑝2 − 6𝑝 + 2 )∆3 𝑦0


= ∆𝑦0 + + +⋯ (2)
𝑑𝑝 2! 3!

Now
𝑑𝑦 𝑑𝑦 𝑑𝑝 𝑑𝑦 1
= =
𝑑𝑥 𝑑𝑝 𝑑𝑥 𝑑𝑝 ℎ
𝑑𝑝 1
∵ =
𝑑𝑥 ℎ
𝑑𝑦 1 (2𝑝 − 1)∆2 𝑦0 (3𝑝2 − 6𝑝 + 2 )∆3 𝑦0
= [∆𝑦0 + +
𝑑𝑥 ℎ 2! 3!
(4𝑝 − 18𝑝 + 22𝑝 − 6 )∆4 𝑦0
3 2
+ ] … (3)
4!

63
At 𝑥 = 𝑥0 , 𝑝 = 0, hence putting p=0 in equation 3 we get

𝑑𝑦 1 ∆2 𝑦0 ∆3 𝑦0 ∆4 𝑦0
| = [∆𝑦0 − + − ] … (4)
𝑑𝑥 𝑥=𝑥0 ℎ 2 3 4

Differentiating equation 3 again with respect to x we get

𝑑2 𝑦 𝑑 𝑑𝑦 𝑑𝑝 1 𝑑 𝑑𝑦
= ( ) = ( )
𝑑𝑥 2 𝑑𝑝 𝑑𝑥 𝑑𝑥 ℎ 𝑑𝑝 𝑑𝑥

1 2 (𝑝 − 1)∆3 𝑦0 (6𝑝2 − 18𝑝 + 11 )∆4 𝑦0


= 2 [∆ 𝑦0 + + + ⋯ ] (5)
ℎ 1! 12

Putting 𝑝 = 0 in equation 5

𝑑2 𝑦 1 2 3
11 4
| = [∆ 𝑦0 − ∆ 𝑦0 + ∆ 𝑦0 ]
𝑑𝑥 2 𝑥=𝑥 ℎ2 12
0

Similarly

𝑑3 𝑦 1 3 3 4
| = [∆ 𝑦0 − ∆ 𝑦0 … ]
𝑑𝑥 3 𝑥=𝑥 ℎ3 2
0

Derivates using Newton’s Backward Difference Formula

Newton’s backward interpolation formula is


𝑝(𝑝+1)∇2 𝑦𝑛 𝑝(𝑝+1)(𝑝+2)∇3 𝑦𝑛 𝑝(𝑝+1)(𝑝+2)(𝑃+3)∇4 𝑦𝑛
𝑦 = 𝑦𝑛 + 𝑝∇𝑦𝑛 + + + ... (8)
2! 3! 4!
𝑥 − 𝑥𝑛
𝑝= … … (9)

𝑑𝑦 𝑑𝑦 𝑑𝑝 𝑑𝑦 1
= =
𝑑𝑥 𝑑𝑝 𝑑𝑥 𝑑𝑝 ℎ

𝑑𝑦 1 2𝑝 + 1 2 3𝑝2 + 6𝑝 + 2 3
= [∇𝑦𝑛 + ∇ 𝑦𝑛 + ∇ 𝑦0 + ⋯ ] … (10)
𝑑𝑝 ℎ 2! 3!
64
At 𝑥 = 𝑥𝑛 , 𝑝 = 0, hence putting p=0 in equation 10 we get

𝑑𝑦 1 ∇2 𝑦𝑛 ∇3 𝑦𝑛 ∇4 𝑦𝑛
| = [∇𝑦𝑛 + + + ] … (11)
𝑑𝑥 𝑥=𝑥𝑛 ℎ 2 3 4

Again, differentiating equation 10 with respect to x

𝑑2 𝑦 𝑑 𝑑𝑦 𝑑𝑝 1 𝑑 𝑑𝑦
= ( ) = ( )
𝑑𝑥 2 𝑑𝑝 𝑑𝑥 𝑑𝑥 ℎ 𝑑𝑝 𝑑𝑥

1 2 6𝑝 + 6 3 6𝑝2 + 18𝑝 + 11 4
= 2 [∇ 𝑦𝑛 + ∇ 𝑦𝑛 + ∇ 𝑦𝑛 + ⋯ ] … (12)
ℎ 3! 4!

Putting 𝑝 = 0

𝑑2 𝑦 1 2 3
11 4
| = [∇ 𝑦𝑛 + ∇ 𝑦𝑛 + ∇ 𝑦𝑛 + ⋯ ] … (13)
𝑑𝑥 2 𝑥=𝑥 ℎ2 12
𝑛

Similarly

𝑑3 𝑦 1 3 3 4
| = [∇ 𝑦𝑛 + ∇ 𝑦𝑛 + ⋯ ] … (14)
𝑑𝑥 3 𝑥=𝑥 ℎ3 2
𝑛

Note: first derivative is also as rate of change, so it can also be asked to find
the velocity, second derivative to find acceleration etc.

Example: Find the first, second and third derivate of 𝑓(𝑥 )𝑎𝑡 𝑥 = 1.5 if

𝑥 1.5 2.0 2.5 3.0 3.5 4.0


𝑓(𝑥) 3.375 7.0 13.625 24 38.875 59.0

65
Solution

We have to find the derivate at the points 𝑥 = 1.5, which is at the beginning of
the given data. Therefore, we use the derivate of Newton’s Forward Interpolation
formula.

Forward difference table is

𝑥 𝑦 = 𝑓(𝑥) ∆𝑦 ∆2 𝑦 ∆3 𝑦 ∆4 𝑦 ∆5 𝑦
1.5 3.375
3.625
2.0 7.0 3
6.6250 0.75
2.5 13.625 3.750 0
10.3750 0.75 0
3.0 24.0 4.5 0
14.8750 0.75
3.5 38.875 5.25
20.1250
4.0 59.0

Here 𝑥0 = 1.5, 𝑦0 = 3.375, ∆𝑦0 = 3.625, ∆2 𝑦0 = 3, ∆3 𝑦0 = 0.75, ∆4 𝑦0 =


0, ℎ = 0.5

Now using equation for finding the derivate

𝑑𝑦 ′( )
1 ∆2 𝑦0 ∆3 𝑦0 ∆4 𝑦0
| = 𝑓 𝑥0 = [∆𝑦0 − + − + ⋯]
𝑑𝑥 𝑥=𝑥0 ℎ 2 3 4

1 3 0.75 0
𝑓 ′ (1.5) = [3.625 − + − + ⋯]
0.5 2 3 4
= 4.75

Now

𝑑2 𝑦 ′′ (
1 2 3
11
| = 𝑓 1.5) = [∆ 𝑦0 − ∆ 𝑦0 + ∗ 0]
𝑑𝑥 2 𝑥=𝑥 ℎ2 12
0

1 11
= [3 − 0.75 + ∗ 0]
1.52 12
=9
66
Again
𝑑3 𝑦 1 3 3 4
| = [∆ 𝑦0 − ∆ 𝑦0 … ]
𝑑𝑥 3 𝑥=𝑥 ℎ3 2
0

1
= [0.75]
1.53
=6

Example:

The population of a certain town (as obtained from central data) is shown in the
following table

Year 1951 1961 1971 1981 1991


population 19.36 36.65 58.81 77.21 94.61
(thousand)

Find the rate of growth of the population in the year 1981

Solution

Here we have to find the derivate at 1981 which is near the end of the table, hence
we use the derivative of Newtons Backward difference formula. The table if
difference is as follows:

𝑥(year) 𝑦 = ∇𝑦 ∇2 𝑦 ∇3 𝑦 ∇4 𝑦
𝑓(𝑥)(population)
1951 19.96
16.69
1961 36.65 5.47
22.16 -9.23
1971 58.81 -3.76 11.99
18.40 2.76
1981 77.21 -1
17.40
1991 94.61

67
Here ℎ = 10, 𝑥𝑛 = 1991, ∇𝑦𝑛 = 17.4, ∇2 𝑦𝑛 = −1, ∇3 𝑦𝑛 = 2.76, ∇4 𝑦𝑛 = 11.99

We know derivative for backward difference is:

𝑑𝑦 1 2𝑝 + 1 2 3𝑝2 + 6𝑝 + 2 3
= [∇𝑦𝑛 + ∇ 𝑦𝑛 + ∇ 𝑦0
𝑑𝑝 ℎ 2! 3!
2𝑝3 + 9𝑝2 + 11𝑝 + 3 4
+ ∇ 𝑦0 ]
4!

Now we have to find out the rate of growth of the population in year 1981, so
𝑥 − 𝑥𝑛 1981 − 1991
𝑝= = = −1
ℎ 10
∴ 𝑝 = −1, ℎ = 10

′(
1 2(−1) + 1 3(−1)2 + 6(−1) + 2
𝑦 1981) = [17.4 + ∗ (−1) + 2.76
10 2 6
2(−1)3 + 9(−1)2 + 11(−1) + 3
+ 11.99 ]
12

1
= [17.4 + 0.5 − 0.46 − 0.992]
10
= 1.6441

Therefore, the rate of growth of the population in the year is 1981 is 1.6441

Maxima and minima of tabulated function


We know Newton’s forward interpolation formula as :

𝑑𝑦 1 (2𝑝 − 1)∆2 𝑦0 (3𝑝2 − 6𝑝 + 2 )∆3 𝑦0


= [∆𝑦0 + +
𝑑𝑥 ℎ 2! 3!
(4𝑝3 − 18𝑝2 + 22𝑝 − 6 )∆4 𝑦0
+ …]
4!

We know that maximum and minimum values of a function 𝑦 = 𝑓(𝑥) can be


found by equating 𝑑𝑦/𝑑𝑥 to zero and solution for x

68
(2𝑝 − 1)∆2 𝑦0 (3𝑝2 − 6𝑝 + 2 )∆3 𝑦0
[∆𝑦0 + +
2! 3!
(4𝑝3 − 18𝑝2 + 22𝑝 − 6 )∆4 𝑦0
+ + ⋯]
4!

Now for keeping only up to third difference we have

(2𝑝 − 1)∆2 𝑦0 (3𝑝2 − 6𝑝 + 2 )∆3 𝑦0


∆𝑦0 + + =0
2! 3!
Solving this for p, by substituting ∆𝑦0 , ∆2 𝑦0 , ∆3 𝑦0 , we get 𝑥 as 𝑥0 + 𝑝ℎ at which
y is a maximum or minimum

Example: Given the following data, find the maximum value of y

𝑥 -1 1 2 3
𝑦 -21 15 12 3

Since the arguments (x -points) aren’t equally spaced we use Newton’s Divided
Difference formula

𝑦(𝑥 ) = 𝑎0 + 𝑎1 (𝑥 − 𝑥0 ) + 𝑎2 (𝑥 − 𝑥0 )(𝑥 − 𝑥1 )
+ 𝑎3 (𝑥 − 𝑥0 )(𝑥 − 𝑥1 )(𝑥 − 𝑥2 ) …

𝑥 𝑓(𝑥)
-1 -21
18∗
1 15 −7∗∗
-3 1
2 12 -3
-9
3 3

Note :
15 − (−21)
∗ 18 =
1 − (−1)

69
−3 − 18
∗∗ −7 =
2 − (−1)

From above table,

𝑎0 = −21, 𝑎1 = 18, 𝑎2 = −7, 𝑎3 = 1,

𝑓(𝑥 ) = −21 + 18(𝑥 + 1) + (𝑥 + 1)(𝑥 − 1)(−7) + (𝑥 + 1)(𝑥 − 1)(𝑥 − 2)(1)

𝑓(𝑥 ) = 𝑥 3 − 9𝑥 2 + 17𝑥 + 6
𝑑𝑦
For maxima and minima =0
𝑑𝑥

3𝑥 2 − 18𝑥 + 17 = 0

On solving, we get,

𝑥 = 4. .8257 𝑜𝑟 1.1743

Since x=4.8257 is out of range [-1 to 3] , we take x=1.1743

∴ 𝑦𝑚𝑎𝑥 = 𝑥 3 − 9𝑥 2 + 17𝑥 + 6

= 1.17433 − 9 ∗ 1.17342 + 17 ∗ 1.1743 + 6

= 15.171612

Differentiating continuous functions:


If the process of approximating the derivative 𝑓 ′ (𝑥) of the function f(x), when
the function itself is available

Forward Difference Quotient


consider a small increment ∆𝑥 = ℎ in x, according to Taylor’s theorem, we have
ℎ2
𝑓(𝑥 + ℎ) = 𝑓 (𝑥 ) + ℎ𝑓 ′ (𝑥 ) + 𝑓 ′′ (𝜃) … (1) 𝑓𝑜𝑟 𝑥 + 𝜃 ≤ 𝑥 + ℎ
2

by re-arranging the terms, we get

70
𝑓(𝑥+ℎ)−𝑓(𝑥) ℎ2
𝑓 ′ (𝑥 ) = − 𝑓 ′′ (𝜃) … . (2)
ℎ 2

Thus if h is chosen to be sufficiently small , 𝑓 ′ (𝑥) can be approximated by


𝑓(𝑥+ℎ)−𝑓(𝑥)
𝑓 ′ (𝑥 ) = ….(3)

With a truncation error of

ℎ2 ′′
𝐸𝑡 (ℎ) = − 𝑓 (𝜃) … . (4)
2
Equation 3 is called first order forward difference quotient. This is also known as
two-point formula. The truncation error is in the order of h and can be decreased
by decreasing h.

Similarly, we can show that the first order backward difference quotient is

𝑓 (𝑥 ) − 𝑓 (𝑥 − ℎ )
𝑓 ′ (𝑥 ) = … (5)

Central Difference Quotient

𝑓 (𝑥 + ℎ ) − 𝑓 (𝑥 − ℎ )
𝑓 ′ (𝑥 ) =
2ℎ
This equation is called second order difference quotient. Note that this is the
average of the forward difference quotient and backward difference equation.
This is also called as three-point formula.

Example: Estimate approximate derivative of 𝑓(𝑥 ) = 𝑥 2 𝑎𝑡 𝑥 = 1, for


h=0.2,0.1,0.05 and 0.01, using first order forward difference formula

We know that
𝑓 (𝑥 + ℎ ) − 𝑓 (𝑥 )
𝑓 ′ (𝑥 ) =

𝑓 (1 + ℎ ) − 𝑓 (𝑥 )
𝑓 ′ (𝑥 ) =

71
Derivative approximation is tabulated below as:

h 𝑓 ′ (1)
0.2 2.2
0.1 2.1
0.05 2.05
0.01 2.01

Note that the correct answer is 2. The derivative approximation approaches the
exact value as h decreases.

Now for central difference quotient

𝑓 (𝑥 + ℎ ) − 𝑓 (𝑥 − ℎ )
𝑓 ′ (𝑥 ) =
2ℎ
𝑓 (1 + ℎ ) − 𝑓 (1 − ℎ )
𝑓 ′ (𝑥 ) =
2ℎ
h 𝑓 ′ (1)
0.2 2
0.1 2
0.05 2

Example Practice:

1. Find the first and second derivates of the function tabulated below at point
x=19
x 1.0 1.2 1.4 1.6 1.8 2.0
f(x) 0 0.128 0.544 1.296 2.432 4.00

Result :0.63,6.6

2. The following data gives corresponding values of pressure and specific


volume of super-heated steam.

v 2 4 6 8 10
P 105 42.07 25.3 16.7 13
a. Find the rate of change of pressure with respect to volume when v=2

72
b. Find the rate of change of volume with respect to pressure when p=105

Numerical Integration:
𝑏
The process of computing ∫𝑎 𝑦 𝑑𝑥, 𝑤ℎ𝑒𝑟𝑒 𝑦 = 𝑓(𝑥) is given by a set of tabulated
values [𝑥𝑖 , 𝑦𝑖 ], i=0,1,2 ….n ,𝑎 = 𝑥0 , 𝑏 = 𝑥𝑛 is called numerical integration since
𝑦 = 𝑓(𝑥) is a single variable function, the process in general is known as
quadrature, like that of numerical differentiation here also we replace f(X) by an
interpolation formula and integrate it in between given limits.

Newtons Cotes Formula:


This is the most popular and widely used in numerical integration. Numerical
integration method uses an interpolating polynomial 𝑝𝑛 (𝑥) in place of f(x)
𝑏 𝑏
Thus 𝐼 = ∫𝑎 𝑓(𝑥 )𝑑𝑥 = ∫𝑎 𝑝𝑛 (𝑥 )𝑑𝑥 … … (1)

We know, Newton’s interpolation formula as:

73
𝑝(𝑝 − 1) 2 𝑝(𝑝 − 1)(𝑝 − 2) 3
𝑓 (𝑥 ) = 𝑓0 + 𝑝∆𝑓0 + ∆ 𝑓0 + ∆ 𝑓0 + ⋯
2! 3!
Integrating term by term, since 𝑥 = 𝑥0 + 𝑝ℎ

𝑑𝑥 = ℎ𝑑𝑝
𝑛
𝑝(𝑝 − 1) 2 𝑝(𝑝 − 1)(𝑝 − 2) 3
𝐼 = ∫ [𝑓0 + 𝑝∆𝑓0 + ∆ 𝑓0 + ∆ 𝑓0 + ⋯ ] ℎ𝑑𝑝
0 2! 3!

𝑛2 1 𝑛3 𝑛2 2 1 𝑛4
𝐼 = ℎ [𝑛𝑓0 + ∆𝑓0 + ( − ) ∆ 𝑓0 + ( − 𝑛3 + 𝑛2 ) ∆3 𝑓0
2 2! 3 2 3! 4

+ ⋯ ] … . (1)

Above equation is known as Newton’s Cote’s quadrature formula, used for


numerical integration.

If the limits of integration a and b are in the set of interpolating points


xi=0,1,2,3…..n, then the formula is referred as closed form. If the points a and b
lie beyond the set of interpolating points, then the formula is termed as open form.
Since the open form formula is not used for definite integration, we consider here
only the closed form methods. They include:

1. Trapezoidal rule
2. Simpson’s 1/3 rule
3. Simpson’s 3/8 rule

Trapezoidal rule (2 Point Formula)


Putting n=1 in equation 1 and neglecting second and higher order differences we
get
𝑥𝑛
∆𝑓0
∫ 𝑓(𝑥 )𝑑𝑥 = ℎ [𝑓0 + ]
𝑥0 2

1
𝐼 = ℎ [𝑓0 + (𝑓1 − 𝑓0 )]
2

𝐼= [𝑓 + 𝑓1 ]
2 0

74
Composite Trapezoidal Rule:
If the range to be integrated is large, the trapezoidal rule can be improved by
dividing the interval (a,b) into a number of small intervals. The sum of areas of
all the sub-intervals is the integral of the intervals (a,b) or (x0,xn). this is known
as composite trapezoidal rule.

As seen in the figure, there are n+1 equally spaced sampling point that create n
segments of equal width h given by
𝑏−𝑎
ℎ=
𝑛
𝑥𝑖 = 𝑎 + 𝑖ℎ 𝑖 = 0,1,2, … 𝑛

From the equation of trapezoidal rule,


𝑥𝑖
𝐼𝑖 = ∫ 𝑝1 (𝑥 )𝑑𝑥
𝑥𝑖−1

= [𝑓(𝑥𝑖−1 ) − 𝑓(𝑥𝑖 )]
2
The total area of all the n segments is
𝑛

𝐼 = ∑ [𝑓(𝑥𝑖−1 ) + 𝑓 (𝑥𝑖 )]
2
𝑖=1

ℎ ℎ ℎ
𝐼= [𝑓(𝑥0 ) + 𝑓(𝑥1 )] + [𝑓(𝑥1 ) + 𝑓(𝑥2 )] + ⋯ + [𝑓(𝑥𝑛−1 ) + 𝑓(𝑥𝑛 )]
2 2 2
Now let us denote 𝑓𝑖 = 𝑓(𝑥𝑖 ) then
𝑛−1

𝐼 = [𝑓0 + 2 ∑ 𝑓𝑖 + 𝑓𝑛 ]
2
𝑖=1

Above equation is known as composite trapezoidal rule

75
Simpson’s 𝟏⁄𝟑 rule ( 3 Point Formula)

Another popular method is Simpson’s 1/3 rule. Here the function f(x) is
approximated by second order polynomial 𝑝2 (𝑥) which passes through three
sampling points as shown in figure. The three points include the end point a & b
and midpoint between 𝑥1 = (𝑎 + 𝑏)/2. The width of the segment h is given by
(𝑏 − 𝑎)⁄
ℎ= 𝑛. Take n=2 and neglecting the third and higher order differences
we get (in newton’s cote formula)
22 1 23 22
𝐼 = ℎ [2𝑓0 + ∆𝑓0 + ( − ) ∆2 𝑓0 ]
2 2! 3 2

𝑏
1 8
∫ 𝑓(𝑥 )𝑑𝑥 = ℎ [2𝑓0 + 2(𝑓1 − 𝑓0 ) + ( − 2)(𝑓1 − 𝑓0 )2 ]
𝑎 2 3
1
= ℎ [2𝑓0 + 2𝑓1 − 2𝑓0 + (∆𝑓2 − ∆𝑓1 )]
3
ℎ 1
= [2𝑓0 + 2𝑓1 − 2𝑓0 + (𝑓2 − 𝑓1 − (𝑓1 −𝑓0 ))]
3 3

= [𝑓 + 4𝑓1 + 𝑓2 ]
3 0
Composite Simpson’s 1/3 rule:
𝑏

∫ 𝑓(𝑥 )𝑑𝑥 = [(𝑓0 + 𝑓𝑛 ) + 4(𝑓1 + 𝑓3 + 𝑓5 + ⋯ ) + 2(𝑓2 + 𝑓4 + 𝑓6 + ⋯ )]
𝑎 3

76
Simpson’s 3/8 rule ( 4 Point Rule)
We have Newton’s cotes formula

𝑛2 1 𝑛3 𝑛2 2 1 𝑛4
𝐼 = ℎ [𝑛𝑓0 + ∆𝑓0 + ( − ) ∆ 𝑓0 + ( − 𝑛3 + 𝑛2 ) ∆3 𝑓0 + ⋯ ]
2 2! 3 2 3! 4

Putting n=3 and neglecting 4th terms in above formula

32 1 33 32 2 1 34
𝐼 = ℎ [3𝑓0 + ∆𝑓0 + ( − ) ∆ 𝑓0 + ( − 33 + 32 ) ∆3 𝑓0 + ⋯ ]
2 2 3 2 6 4

On solving we get
3ℎ
𝐼= [(𝑓0 + 𝑓3 ) + 3𝑓1 + 3𝑓2 ]
8

Adding all these integrals where n is a multiple of 3 we get


3ℎ
∫ 𝑓(𝑥 )𝑑𝑥 = [(𝑓0 + 𝑓𝑛 ) + 3(𝑓1 + 𝑓2 + 𝑓4 + 𝑓5 + 𝑓7 + ⋯ ) + 2(𝑓3 + 𝑓6 + 𝑓9
8
+ ⋯ )]

This is composite Simpson’s 3/8 rule.

Example:
10 𝑑𝑥
1. Evaluate ∫0 using
1+𝑥 2
a. Trapezoidal rule
b. Simpson’s 1/3 rule
c. Simpson’s 3/8 rule

77
Solution:

Taking h=1, divide the whole range of the integration [0,10] into ten equal parts.
The value of the integrand for each point of sub division.

𝑥𝑖 𝑥0 1 2 3 4 5 6 7 8 9 10
=𝑥 =0
𝑓𝑖 1 0. 0. 0. 0.058 0.038 0.027 0.02 0.015 0.012 0.009
=𝑦 5 2 1 8 5 0 0 4 2 9

a. By Trapezoidal rule
10
𝑑𝑥 ℎ
∫ = [𝑓 + 𝑓1 ]
0 1 + 𝑥2 2 0
1
= [1 + 0.5]
2
= 0.75

b. By Simpson’s 1/3 rule


10
𝑑𝑥 ℎ
∫ = [𝑓 + 4𝑓1 + 𝑓2 ]
0 1 + 𝑥2 3 0
1
= [1 + 4 × 0.5 + 0.2]
3
= 1.0667

c. By Simpson’s 3/8 rule


10
𝑑𝑥 3ℎ
∫ 2
= [(𝑓0 + 𝑓3 ) + 3𝑓1 + 3𝑓2 ]
0 1 + 𝑥 8
3×1
= [(1 + 0.1) + 3 × 0.5 + 3 × 0.2]
8
= 1.2

Composite methods:

a. Trapezoidal rule
10 𝑛−1
𝑑𝑥 ℎ
∫ = [𝑓 + 2 ∑ 𝑓𝑖 + 𝑓𝑛 ]
0 1+𝑥
2 2 0
𝑖=1

78
9

= [𝑓0 + 2 ∑ 𝑓𝑖 + 𝑓10 ]
2
𝑖=1
1
= [1 + 2(0.5 + 0.2 + 0.1 + 0.0588 + 0.0385 + 0.0270 + 0.020
2
+ 0.0154 + 0.0122) + 0.0099]
= 1.4769

b. By Simpson’s 1/3 rule


10
𝑑𝑥 ℎ
∫ 2
= [(𝑓0 + 𝑓10 ) + 4(𝑓1 + 𝑓3 + 𝑓5 + 𝑓7 + 𝑓9 ) + 2(𝑓2 + 𝑓4
0 1+𝑥 3
+ 𝑓6 + 𝑓8 )]
1
= [(1 + 0.0099)
3
+ 4(0.5 + 0.1 + 0.0385 + 0.020 + 0.0122)
+ 2(0.2 + 0.0588 + 0.0270 + 0.0154)]
1
= [1.0099 + 2.6828 + 0.6024]
3
= 1.4317

c. Simpson’s 3/8 rule


10
𝑑𝑥 3ℎ
∫ 2
= [(𝑓0 + 𝑓10 ) + 3(𝑓1 + 𝑓2 + 𝑓4 + 𝑓5 + 𝑓7 + 𝑓8 ) + 2(𝑓3
0 1+𝑥 8
+ 𝑓6 + 𝑓9 )]
3
= [(1 + 0.0099)
8
+ 3(0.5 + 0.2 + 0.0588 + 0.0385 + 0.020 + 0.0154)
+ 2(0.1 + 0.0270 + 0.0270 + 0.0122)]
= 1.4199

79
Romberg integration formula/ Richardson’s deferred approach to the limit
or Romberg method
Take an arbitrary value of h and calculate
𝑏

𝐼1 = ∫ 𝑓(𝑥)𝑑𝑥 = [(𝑓 + 𝑓𝑛 ) + 2(𝑓1 + 𝑓2 + 𝑓3 + 𝑓𝑛−1 )]
𝑎 2 0
𝑏

𝐼2 = ∫ 𝑓(𝑥)𝑑𝑥 = [(𝑓 + 𝑓𝑛 ) + 2(𝑓1 + 𝑓2 + 𝑓3 + 𝑓𝑛−1 )]
𝑎 4 0
𝑏

𝐼3 = ∫ 𝑓(𝑥)𝑑𝑥 = [(𝑓 + 𝑓𝑛 ) + 2(𝑓1 + 𝑓2 + 𝑓3 + 𝑓𝑛−1 )]
𝑎 8 0

Now better estimate of 𝐼1 & 𝐼2 can be found as


1
𝐼1 ∗ = 𝐼2 + (𝐼2 − 𝐼1 )
3
1
𝐼2 ∗ = 𝐼3 + (𝐼3 − 𝐼2 )
3
1
If 𝐼1 ∗ = 𝐼2 ∗ then stop else continue as 𝐼1 ∗∗ = 𝐼2 ∗ + (𝐼2 ∗ − 𝐼1 ∗ ) and so on
3

1 𝑑𝑥
Example: Evaluate ∫0 using Romberg’s method correct up to four decimal
1+𝑥 2
places. Hence find approximate value of π.

Solution
𝑏−𝑎 1−0
By taking n=2, ℎ = = = 0.5
𝑛 2

a. When h=0.5

𝑥 0 0.5 1
𝑓𝑖 1 0.8 0.5

ℎ 0.5
𝐼1 = [(𝑓0 + 𝑓2 ) + 2(𝑓1 )] = [(1 + 0.5) + 2(0.8)] = 0.7750
2 2

80
b. When h=0.5/2=0.25
𝑥 0 0.25 0.5 0.75 1
𝑓𝑖 1 0.9412 0.8 0.64 0.5

𝐼2 = [(𝑓0 + 𝑓4 ) + 2(𝑓1 + 𝑓2 + 𝑓3 )]
2
0.25
= [(1 + 0.5) + 2(0.941 + 0.8 + 0.64)] = 0.7828
2
c. When h=0.25/2=0.125
𝑥 0 0.125 0.25 0.375 0.5 0.625 0.75 0.875 1
𝑓𝑖 1 0.9846 0.9412 0.8767 0.8 0.7191 0.64 0.5664 0.5


𝐼3 = [(𝑓 + 𝑓8 ) + 2(𝑓1 + 𝑓2 + 𝑓3 + 𝑓4 + 𝑓5 + 𝑓6 + 𝑓7 )]
2 0
0.125
= [(1 + 0.5) + 2(0.9846 + 0.9412 + 0.8767 + 0.8 + 0.7191 + 0.64
2
+ 0.5664)] = 0.78475
1 1
𝐼1 ∗ = 𝐼2 + (𝐼2 − 𝐼1 ) = 0.7828 + (0.7828 − 0.7750) = 0.7854
3 3
1 1
𝐼2 ∗ = 𝐼3 + (𝐼3 − 𝐼2 ) = 0.7848 + (0.7848 − 0.7828) = 0.7854
3 3
Since these two are the same value, we conclude that the value of the integral
=0.7854
1 𝑑𝑥
i.e ∫0 = 0.7854
1+𝑥 2

1
𝑑𝑥 −1 ]1 −1 −1
𝜋
∫ = [ tan 𝑥 0 = tan 1 − tan 0 = = 0.7854
0 1 + 𝑥2 4

∴ 𝜋 ≈ 3.1416

81
Gaussian integration:
Gaussian integration is based on the concept that the accuracy of numerical
integration can be improved by choosing sampling points wisely rather than on
the basis of equal sampling. The problem is to compute the values of 𝑥1 & 𝑥2 given
the value of a and b and to choose approximate weights w1 & w2 . The method of
implementing the strategy of finding approximate values of xi & wi and obtaining
the integral of f(x) is called Gaussian integration or quadrature.

Gaussian integration assumes an approximation of the form


1 𝑛

𝐼𝑔 = ∫ 𝑓 (𝑥 )𝑑𝑥 = ∑ 𝑤𝑖 𝑓(𝑥𝑖 ) … . (1)


−1 𝑖=1

The above equation 1 contains 2n unknowns to be determined. For example for


n=2, we need to find the values of w1,w2,x1,x2. We assume that the integral will
be exact up to cubic polynomial. This implies the function 1,x,x2&x3 can be
numerically integrated to obtain exact results.

Assume f(x)=1 (assume the integral is exact up to cubic polynomial)

1. f(x)=1
1
𝑤1 + 𝑤2 = ∫ 𝑑𝑥 = 2
−1
2. f(x)=x
1
w1 x1 + w2 x2 = ∫ f(x)dx = 0
−1
2
3. f(x)=x
1 1
2
w1 𝑥1 + w2 𝑥2 = ∫ f(x)dx = ∫ 𝑥 2 dx =
2 2
−1 −1 3
4. f(x)=x3
1 1
w1 𝑥1 + w2 𝑥2 = ∫ f(x)dx = ∫ 𝑥 3 dx = 0
3 3
−1 −1
Solving above equation we get
𝑤1 = 1, 𝑤2 = 1

82
𝑥1 = −1⁄ = −0.5773502
√3
𝑥2 = 1⁄ = 0.5773502
√3
Thus, we have the Gaussian Quadrature formula, for n=2
1
∫ 𝑓(𝑥)𝑑𝑥 = 𝑓(− 1⁄ ) + 𝑓(1⁄ )
−1 √3 √3
This formula will give correct value for the integral of f(x) in the range (-
1,1) for any function up to third order. The above equation is also called
Gauss Legendre formula.

1
Example : Compute ∫−1 𝑒 𝑥 using two point Gaussian integration formula
1
𝐼 = ∫ 𝑒 𝑥 𝑑𝑥 = 𝑤1 𝑓(𝑥1 ) + 𝑤2 𝑓(𝑥2 )
−1

Where x1 and x2 are Gaussian quadrature points and are given by

𝑥1 = −1⁄ = −0.5773502, 𝑤1 = 1
√3
𝑥2 = 1⁄ = 0.5773502, 𝑤2 = 1
√3
𝑓(𝑥) = 𝑒 𝑥

we know that,

𝐼 = 𝑤1 𝑓 (− 1⁄ ) + 𝑤2 𝑓 (1⁄ )
√3 √3
−1⁄ 1⁄
=𝑒 √3 +𝑒 √3

= 0.5614 + 1.7813

= 2.3427

83
Changing limits of Integration
Note that the Gaussian formula imposed a restriction on the limits of integration
to be from -1 to 1. The restriction can be overcome by using the techniques of the
“interval transformation” used in calculus, let
𝑏 1
∫ 𝑓(𝑥)𝑑𝑥 = 𝑐 ∫ 𝑔(𝑧) 𝑑𝑧
𝑎 −1

Assume the following transformation between x and new variable z. by following


relation.

i.e x=Az+B

this must satisfy the following conditions at x=a, z=-1 & x=b, z=1

i.e B-A=a, A+B=b


𝑏−𝑎 𝑎+𝑏
𝐴= ,𝐵 =
2 2
𝑏−𝑎 𝑎+𝑏
∴ x=( )z + ( )
2 2

𝑏−𝑎
𝑑𝑥 = ( )𝑑𝑧
2
𝑏−𝑎
here 𝐶 =
2

∴ the integral becomes

𝑏−𝑎 1
∫ 𝑔(𝑧)𝑑𝑧
2 −1

The Gaussian formula for this integration is


𝑛
𝑏−𝑎 1 𝑏−𝑎
∫ 𝑔(𝑧)𝑑𝑧 = ( ) ∑ 𝑤𝑖 𝑔(𝑧𝑖 )
2 −1 2
𝑖=1

84
Where wi and zi are the weights and quadrature points for the integration domain
(-1,1)

Example: Compute the integral


2 𝑥⁄
𝐼 = ∫−2 𝑒 − 2 by using Gaussian two points formula

Here n=2
𝑏−𝑎 1 𝑏−𝑎 𝑏−𝑎
𝐼= ∫−1 𝑔(𝑧)𝑑𝑧 = ∑𝑛𝑖=1 𝑤𝑖 𝑔(𝑧𝑖 ) = ( ) [𝑤1 𝑔(𝑧1 ) + 𝑤2 𝑔(𝑧2 )]
2 2 2

𝑏−𝑎 𝑏+𝑎
𝑥=( )𝑧 +
2 2
2 − (−2) 2 + (−2)
= 𝑧 +
2 2
= 2𝑧
𝑥⁄ 2𝑧⁄
∴ 𝑔(𝑧) = 𝑒 − 2 = 𝑒− 2 = 𝑒 −𝑧

For two point formula :

𝑤1 = 𝑤2 = 1

𝑧1 = − 1⁄ , 𝑧2 = 1⁄
√3 √3
𝑏−𝑎
𝐼= [𝑤1 𝑔(𝑧1 ) + 𝑤2 𝑔(𝑧2 )]
2
2 − (−2) −(−1⁄ ) −(1⁄ )
= [𝑒 √3 + 𝑒 √3 ]
2
= 2(0.5614 + 1.7813)

= 4.8654

85
Values for gaussian quadrature
Number of terms Values of x Weighting factor Valid to degree
2 -0.5773502 1 3
0.5773502 1

3 -0.77459667 0.55555555
0 0.88888889 5
0.77459667 0.55555555

4 -0.86113631 0.34785485
-0.33998104 0.65214515 7
0.33998104 0.65214515
0.86113631 0.34785485

4
Example: Use Gaussian integration 3 point formula to evaluate ∫2 (𝑥 4 + 1)𝑑𝑥

Given n=3, a=2, b=4


3
𝑏−𝑎
𝐼= ∑ 𝑤𝑖 𝑔(𝑧𝑖 )
2
𝑖=1

𝑏−𝑎
𝐼= [𝑤1 𝑔(𝑧1 ) + 𝑤2 𝑔(𝑧2 ) + 𝑤3 𝑔(𝑧3 )]
2
𝑏−𝑎 𝑎+𝑏
𝑥=( )𝑧 + ( )
2 2
4−2 4+2
=( )𝑧 + ( )
2 2
=𝑧+3

∴ 𝑔(𝑧) = (𝑧 + 3)4 + 1

For n=3

𝑤1 = 0.55556 𝑧1 = −0.77460

𝑤2 = 0.88889 𝑧2 =0

𝑤3 = 0.55556 𝑧3 = 0.77460

86
𝐼 = 0.55556[(−0.77460 + 3)4 + 1] + 0.88889[(0 + 3)4 + 1]
+ 0.55556[(0.77460 + 3)4 + 1]

= 14.1814 + 72.8890 + 113.3310

= 200.4014

87
Chapter 4: solution of Linear Algebraic Equations

Linear equations:

First mathematical models of many of the real world problems are either linear
or can be approximated reasonably well using linear relationships. Analysis of
linear relationship of variables is generally easier than that of non-linear
relationships.

A linear equation involving two variables x and y has the standard form 𝑎𝑥 +
𝑏𝑦 = 𝑐, where a, b& c are real numbers and a and b both cannot be equal to zero.

The equation becomes non-linear if any of the variables has the exponent other
than one, example

4𝑥 + 5𝑦 = 15 𝑙𝑖𝑛𝑒𝑎𝑟

4𝑥 − 𝑥𝑦 + 5𝑦 = 15 𝑛𝑜𝑛 − 𝑙𝑖𝑛𝑒𝑎𝑟

𝑥 2 + 5𝑦 2 = 15 𝑛𝑜𝑛 − 𝑙𝑖𝑛𝑒𝑎𝑟

Linear equation occurs in more than two variables as𝑎1 𝑥1 + 𝑎2 𝑥2 + 𝑎3 𝑥3 +


⋯ 𝑎𝑛 𝑥𝑛 = 𝑏. The set of equations is known as system of simultaneous equations,
in matrix form it can be represented as 𝐴𝑥 = 𝐵

3𝑥1 + 2𝑥2 + 4𝑥3 = 14

𝑥1 − 2𝑥2 = −7

−𝑥1 + 3𝑥2 + 2𝑥3 = 2


3 2 4 𝑥1 14
[ 1 −2 𝑥
0] [ 2 ] = [−7]
−1 3 2 𝑥3 2

88
Existence of solution
In solving system of equations, we find values of variables that satisfy all
equations in the system simultaneously. There may be 4 possibilities in solving
the equations.

1. System with unique solution


here the lines or equations intersect in one and only one point.

2. System with no solution


Here the lines or equation never intersect or parallel lines.

3. System with infinite solution


Here two equation or lines overlap, so that there is infinite
Solutions

4. ILL conditioned system:


There may be situation where the system has a solution but it is very close
to being singular, i.e, any equation have solution but is very difficult to
89
identify the exact point at which the lines intersect. If there is any slight
changes in the value in the equation then we will see huge change in the
solution, this type of equation is called ILL condition system, we should
be careful in solving these kind of solutions. Example
1.01 0.99 𝑥 2.00
[ ] [𝑦 ] = [ ]
0.99 1.01 2.00
1.01𝑥 + 0.99𝑦 = 2
0.99𝑥 + 1.01𝑦 = 2
On solving these equations, we get the solution at x=1 & y=1, however if
we make small changes in b i.e.
1.01 0.99 𝑥 2.02
[ ] [𝑦 ] = [ ]
0.99 1.01 1.98

1.01𝑥 + 0.99𝑦 = 2.02


0.99𝑥 + 1.01𝑦 = 1.98
On solving these equations, we get x=2 & y=0
So slight changes results in huge change in solution.

Methods of solutions (Direct Methods)

Elimination method
Elimination method is a method of solving simultaneous linear. This method
involves elimination of a term containing one of the unknowns in all but one
equation, one such step reduces the order of equations by one, repeated
elimination leads finally to one equation with one unknown.

Example: solve the following equation using elimination method

4𝑥1 − 2𝑥2 + 𝑥3 = 15 … … (1)

−3𝑥1 − 𝑥2 +4𝑥3 = 8 … … (2)

𝑥1 − 𝑥2 + 3𝑥3 = 13 … … (3)

Here multiply 𝑅1 𝑏𝑦 3 &𝑅2 𝑏𝑦 4 and add to eliminate 𝑥1 from 2. Multiply


𝑅1 𝑏𝑦 − 1&𝑅3 𝑏𝑦 4 and add to eliminate 𝑥1 from 3

4𝑥1 − 2𝑥2 + 𝑥3 = 15

−10𝑥2 +19𝑥3 = 77

90
−2𝑥2 + 11𝑥3 = 37

Now to eliminate 𝑥2 from third equation multiply second row by 2 and third row
by -10 and adding

4𝑥1 − 2𝑥2 + 𝑥3 = 15

−10𝑥2 +19𝑥3 = 77

−72𝑥3 = −216

Now we have a triangular system and solution is readily obtained from back-
substitution

𝑥3 = 3
77 − 19 ∗ 3
𝑥2 = = −2
−10
15 + 2 ∗ (−2) − 3
𝑥1 = =2
4
Gauss Elimination Method
The procedure in above example may not be satisfactory for large systems
because the transformed coefficients can become very large as we convert to a
triangular system. So, we use another method called Gaussian Elimination
𝑎𝑖1
method that avoid this by subtracting ⁄𝑎11 times the first equation from
𝑖 𝑡ℎ equation to make the transformed numbers in the first column equal to zero
and proceed on.

However, we must always be cautious against divide by zero, a useful strategy to


avoid divide by zero is to re-arrange the equations so as to put the coefficient of
large magnitude on the diagonal at each step, this is called pivoting. Complete
pivoting method require both row and column interchange but this is much
difficult and not frequently done. Changing only row called partial pivoting
which places a coefficient of larger magnitude on the diagonal by row interchange
only. This will be guaranteeing a non-zero divisors if there is a solution to set of
equations and will have the added advantage of giving improved arithmetic
precision. The diagonal elements that result are called pivot elements.

91
Example (without pivoting element)

0.143𝑥1 + 0.357𝑥2 + 2.01𝑥3 = −5.173

−1.31𝑥1 + 0.911𝑥2 + 1.99𝑥3 = −5.458

11.2𝑥1 − 4.30𝑥2 − 0.605𝑥3 = 4.415

Augmented matrix is
0.143 0.357 2.01 −5.173
[−1.31 0.911 1.99 −5.458]
11.2 −4.30 −0.605 4.415
𝑅 𝑅
𝑅2 → ( 1⁄0.143) 1.31 + 𝑅2 , 𝑅3 → ( 1⁄0.143) ∗ (−11.2) + 𝑅3

0.143 0.357 2.01 −5.173


[ 0 4.181 20.403 −52.847]
0 −32.261 −158.032 409.573
𝑅
𝑅3 → ( 2⁄4.181) 32.261 + 𝑅2

0.143 0.357 2.01 −5.173


[ 0 4.181 20.403 −52.847]
0 0 −0.6 1.8

𝑥3 = 1.8⁄−0.6 = −3.001

4.181𝑥2 + 20.403𝑥3 = −52.847


−52.847 − 20.403 ∗ −3.001
𝑥2 = = 2.005
4.181
0.143𝑥1 + 0.357𝑥2 + 2.01𝑥3 = −5.173
−5.173 − 0.357𝑥2 − 2.01𝑥3
𝑥1 =
0.143
−5.173 − 0.35 ∗ 2.005 − 2.01 − 3.001
𝑥1 =
0.143
𝑥1 = 0.749

92
Example (with pivoting element)

0.143𝑥1 + 0.357𝑥2 + 2.01𝑥3 = −5.173

−1.31𝑥1 + 0.911𝑥2 + 1.99𝑥3 = −5.458

11.2𝑥1 − 4.30𝑥2 − 0.605𝑥3 = 4.415

Augmented matrix is
0.143 0.357 2.01 −5.173
[−1.31 0.911 1.99 −5.458]
11.2 −4.30 −0.605 4.415
𝑅1 ↔ 𝑅3 (𝑃𝑖𝑣𝑜𝑡𝑖𝑛𝑔)
11.2 −4.30 −0.605 4.415
[−1.31 0.911 1.99 −5.458]
0.143 0.357 2.01 −5.173
𝑅 𝑅
𝑅2 → ( 1⁄11.2) 1.31 + 𝑅2 , 𝑅3 → ( 1⁄11.2) ∗ (−0.143) + 𝑅3

11.2 −4.30 −0.605 4.415


[ 0 0.408 1.919 −4.942]
0 0.412 2.018 −5.229
𝑅2 ↔ 𝑅3
11.2 −4.30 −0.605 4.415
[ 0 0.412 2.018 −5.229]
0 0.408 1.919 −4.942
𝑅
𝑅3 → ( 2⁄0.412) ∗ (−0.408) + 𝑅3

11.2 −4.30 −0.605 4.415


0 0.412 2.018 −5.229
0 0 −0.079 0.236

𝑥3 = 0.236⁄−0.079 = −2.990

0.412𝑥2 + 2.018𝑥3 = −5.229


−5.229 − 2.018 ∗ −2.990
𝑥2 = = 1.953
0.412
11.2𝑥1 − 4.30𝑥2 − 0.605𝑥3 = 4.415

93
4.415 + 4.30 ∗ 1.953 + 0.605 ∗ −2.990
𝑥1 =
11.2
𝑥1 = 0.982

Hence 𝑥1 = 2, 𝑥2 = 1.953, 𝑥3 = −2.990

Practice: Solve the following system of equations(without pivoting)

1. 3𝑥1 + 6𝑥2 + 𝑥3 = 16, 2𝑥1 + 4𝑥2 + 3𝑥3 = 13, 𝑥1 + 3𝑥2 + 2𝑥3 = 9


2. 2𝑥1 + 3𝑥2 + 4𝑥3 = 5, 3𝑥1 + 4𝑥2 + 5𝑥3 = 6, 4 𝑥1 + 5𝑥2 + 6𝑥3 = 7
3. Solve above equations again using pivoting techniques.

Gauss Jordan Method


Gauss Jordan method is another popular method used for solving a system of
linear equations. In this method the elements above the diagonal are made zero at
the same time that zero are created below the diagonal, usually the diagonal
elements are made ones at the same time the reduction is performed, this
transforms the coefficient matrix into identity matrix. When this has been
accomplished the column of right-hand side has been transformed into the
solution vector. Pivoting is normally employed to preserve arithmetic accuracy.

Example solution using Gauss-Jordan method

2𝑥1 + 4𝑥2 − 6𝑥3 = −8

𝑥1 + 3𝑥2 + 𝑥3 = 10

2𝑥1 − 4𝑥2 − 2𝑥3 = −12

Augmented matrix is
2 4 −6 −8
[1 3 1 10 ]
2 −4 −2 −12
𝑅
𝑅1 → ( 1⁄2)

1 2 −3 −4
[1 3 1 10 ]
2 −4 −2 −12
𝑅2 → 𝑅1 − 𝑅2 , 𝑅3 → −2𝑅1 + 𝑅3

94
1 2 −3 −4
[0 −1 −4 −14]
0 −8 4 −4
𝑅
𝑅2 → ( 2⁄−1)

1 2 −3 −4
0 1 4 14
0 −8 4 −4
𝑅1 → −2𝑅2 + 𝑅1 , 𝑅3 → 8𝑅2 + 𝑅3

1 0 −11 −32
0 1 4 14
0 0 36 108
𝑅
𝑅3 → ( 3⁄36)

1 0 −11 −32
0 1 4 14
0 0 1 3
𝑅1 → 11𝑅3 + 𝑅1 , 𝑅2 → −4𝑅3 + 𝑅2

1 0 0 1
0 1 0 2
0 0 1 3
Hence 𝑥1 = 1, 𝑥2 = 2, 𝑥3 = 3

Example Solution using Gauss-Jordan method (with pivoting)

2𝑥1 + 4𝑥2 − 6𝑥3 = −8

𝑥1 + 3𝑥2 + 𝑥3 = 10

2𝑥1 − 4𝑥2 − 2𝑥3 = −12

95
Augmented matrix is:
2 4 −6 −8
[1 3 1 10 ]
2 −4 −2 −12
𝑅
𝑅1 → ( 1⁄2)

1 2 −3 −4
[1 3 1 10 ]
2 −4 −2 −12
𝑅2 → 𝑅1 − 𝑅2 , 𝑅3 → −2𝑅1 + 𝑅3
1 2 −3 −4
[0 −1 −4 −14]
0 −8 4 −4

𝑅2 ↔ 𝑅3
1 2 −3 −4
0 −8 4 −4
0 1 4 −14

𝑅
𝑅2 → ( 2⁄−8)

1 2 −3 −4
0 1 −0.5 0.5
0 1 4 14
𝑅1 → −2𝑅2 + 𝑅1 , 𝑅3 → −𝑅2 + 𝑅3
1 0 −2 −5
0 1 −0.5 0.5
0 0 4.5 13.5
𝑅
𝑅3 → ( 3⁄4.5)

1 0 −2 −5
0 1 −0.5 0.5
0 0 1 3

96
𝑅1 → 2𝑅3 + 𝑅1 , 𝑅2 → 0.5𝑅3 + 𝑅2
1 0 0 1
0 1 0 2
0 0 1 3
Hence 𝑥1 = 1, 𝑥2 = 2, 𝑥3 = 3

Practice: Solve the following system of equations using GJ elimination


method.

1. 𝑥1 + 2𝑥2 − 3𝑥3 = 4, 2𝑥1 + 4𝑥2 − 6𝑥3 = 8, 𝑥1 − 2𝑥2 + 5𝑥3 = 4


2. 2𝑥1 + 𝑥2 + 𝑥3 = 7, 4𝑥1 + 2𝑥2 + 3𝑥3 = 4, 𝑥1 − 𝑥2 + 𝑥3 = 0

The inverse of a matrix


The division a matrix is not defined but the equivalent is obtained from the inverse
of the matrix. If the product of two square matrices A*B equals identity matrix I,
B is said to be inverse of A (also A is inverse of B). the usual notation of the
matrix is 𝐴−1 . we can say as 𝐴𝐵 = 𝐼, 𝐴 = 𝐵 −1 , 𝐵 = 𝐴−1 .

Example: Given matrix A, find the inverse of A using Gauss Jordan method.
1 −1 2
𝐴 = [3 0 1]
1 0 2
1 −1 2 1 0 0
The augmented matrix with identity matrix is [3 0 1 0 1 0]
1 0 2 0 0 1
𝑅2 → −3𝑅1 + 𝑅2 , 𝑅3 → −𝑅1 + 𝑅3
1 −1 2 1 0 0
[0 3 −5 −3 1 0]
0 1 0 −1 0 1
𝑅
𝑅2 → ( 2⁄3)

1 −1 2 1 0 0
[0 1 −1.6667 −1 0.333 0]
0 1 0 −1 0 1
𝑅1 → 𝑅1 + 𝑅2 , 𝑅3 → 𝑅2 − 𝑅3

97
1 0 0.3333 0 0.3333 0
[0 1 −1.6667 −1 0.3333 0]
0 0 −1.6667 0 0.3333 −1
𝑅
𝑅3 → ( 3⁄−1.6667)

1 0 0.3333 0 0.3333 0
[0 1 −1.6667 −1 0.333 0]
0 0 1 0 −0.2 0.6
𝑅1 → −0.3333𝑅3 + 𝑅1 , 𝑅2 → 1.6667𝑅3 + 𝑅2
1 0 0 0 0.4 −0.2
[0 1 0 −1 0 1 ]
0 0 1 0 −0.2 0.6
0 0.4 −0.2
−1
𝐴 = [−1 0 1 ]
0 −0.2 0.6

Practice: Find the inverse of the following matrix using Gauss Jordan
elimination method.
2 3 4
𝐴 = [4 2 3]
3 4 2

Method of factorization
Consider the following system of equations

𝑎11 𝑥1 + 𝑎12 𝑥2 + 𝑎13 𝑥3 = 𝑏1

𝑎21 𝑥1 + 𝑎22 𝑥2 + 𝑎23 𝑥3 = 𝑏2

𝑎31 𝑥1 + 𝑎32 𝑥2 + 𝑎33 𝑥3 = 𝑏3

These equations can be written in matrix form as:

𝐴𝑋 = 𝐵
𝑎11 𝑎12 𝑎13 𝑥1 𝑏1
𝐴 = [𝑎21 𝑎22 𝑎23 ] 𝑋 = [𝑥2 ] 𝐵 = [𝑏2 ]
𝑎31 𝑎32 𝑎33 𝑥3 𝑏3

98
In this method, we use the fact that the square matrix A can be factorized into the
form LU, where L is lower triangular matrix and U can be upper triangular matrix
such that 𝐴 = 𝐿𝑈
𝑙11 0 0 𝑢11 𝑢12 𝑢13
𝐿 = [𝑙21 𝑙22 0] 𝑈=[ 0 𝑢22 𝑢23 ]
𝑙31 𝑙32 𝑙33 0 0 𝑢33

𝐿𝑈𝑋 = 𝐵

Let us assume 𝑈𝑋 = 𝑍 , then 𝐿𝑍 = 𝐵

Now we can solve the system A𝑋 = 𝐵 in two stages

1. Solve the equation, 𝐿𝑍 = 𝐵 for Z by forward substitution


2. Solve the equation, 𝑈𝑋 = 𝑍 for X using Z by backward substitution.

The elements of L and U can be determined by comparing the elements of the


product of L and U with those of A. The decomposition with L having unit
diagonal values is called the Dolittle LU decomposition while the other one with
U having unit diagonal elements is called Crout’s LU decomposition.

Dolittle LU decomposition:
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
𝑢11 𝑢12 𝑢13 𝑎11 𝑎12 𝑎13
[𝑙21 𝑢11 𝑙21 𝑢12 + 𝑢22 𝑙21 𝑢13 + 𝑢23 ] = [𝑎21 𝑎22 𝑎23 ]
𝑙31 𝑢11 𝑙31 𝑢12 + 𝑙32 𝑢22 𝑙31 𝑢13 + 𝑙32 𝑢23 + 𝑢33 𝑎31 𝑎32 𝑎33

Equating the corresponding coefficients, we get the values of L and U

Example: Find L & U by using Doolittle algorithm.

2𝑥 − 3𝑦 + 10𝑧 = 3

−𝑥 + 4𝑦 + 2𝑧 = 20

5𝑥 + 2𝑦 + 𝑧 = −12

The given system is 𝐴𝑥 = 𝐵,

99
Where,
2 −3 10 𝑥 3
𝐴 = [−1 4 2 ] 𝑋 = [ 𝑦 ] 𝐵 = [ 20 ] here, A=LU
5 2 1 𝑧 −12
1 0 0 𝑢11 𝑢12 𝑢13 2 −3 10
[𝑙21 1 0] [ 0 𝑢22 𝑢23 ] = [−1 4 2]
𝑙31 𝑙32 1 0 0 𝑢33 5 2 1
𝑢11 𝑢12 𝑢13 2 −3 10
[𝑙21 𝑢11 𝑙21 𝑢12 + 𝑢22 𝑙21 𝑢13 + 𝑢23 ] = [−1 4 2]
𝑙31 𝑢11 𝑙31 𝑢12 + 𝑙32 𝑢22 𝑙31 𝑢13 + 𝑙32 𝑢23 + 𝑢33 5 2 1

Now comparing both sides we get,

𝑢11 = 2 , 𝑢12 = −3, 𝑢13 = 10

𝑙21 𝑢11 = −1

𝑙21 = − 1⁄2

𝑙21 𝑢12 + 𝑢22 = 4

𝑢22 = 5⁄2

𝑙21 𝑢13 + 𝑢23 = 2

𝑢23 = 7

𝑙31 𝑢11 = 5

𝑙31 = 5⁄2

𝑙31 𝑢12 + 𝑙32 𝑢22 = 2

𝑙32 = 19⁄5

𝑙31 𝑢13 + 𝑙32 𝑢23 + 𝑢33 = 1

𝑢33 = − 253⁄5

So, we have,

100
1 0 0 2 −3 10
1 5⁄
𝐿 = [− ⁄2 1 0] 𝑈 = [0 2 7 ]
5⁄ 19⁄ 1 0 0 − 253⁄5
2 5
Now 𝐿𝑍 = 𝐵 where Z is the matrix of order 3×3.
1 0 0 𝑍
1 1 3
[− ⁄2 1 0] [𝑍2] = [ 20 ]
5⁄ 19⁄ 1 𝑍3 −12
2 5
𝑍1 = 3

− 1⁄2 𝑍1 + 𝑍2 = 20

𝑍2 = 43⁄2

5⁄ 𝑍 + 19⁄ 𝑍 + 𝑍 = −12
2 1 5 2 3

𝑍3 = − 506⁄5

Now UX= 𝑍
2 −3 10 3
𝑥
5
[0 ⁄2 7 ] [𝑦] = [ 43⁄2 ]
0 0 − 254⁄5 𝑧 − 506⁄5

𝑧=2
5⁄ 𝑦 + 7𝑧 = 43⁄
2 2
𝑦=3

2𝑥 − 3𝑦 + 10𝑧 = 3

𝑥 = −4

Practice: Solve the following system of equations by factorization using Doolittle


method.

101
𝑥 + 3𝑦 + 8𝑧 = 4

𝑥 + 4𝑦 + 3𝑧 = −2

𝑥 + 3𝑦 + 4𝑧 = 1

Note: the process of solution by using method of factorization can be


repeatedly applied to solve the equation multiple times for different B. in this
case it is faster to do an LU decomposition of the matrix A once and then
solve the triangular matrices for different B, rather than using Gaussian
elimination each time.

Crout’s method
𝑙11 0 0 1 𝑢12 𝑢13 𝑎11 𝑎12 𝑎13
[𝑙21 𝑙22 0 ] [0 1 𝑢23 ] = [𝑎21 𝑎22 𝑎23 ]
𝑙31 𝑙32 𝑙33 0 0 1 𝑎31 𝑎32 𝑎33

𝑙11 𝑙11 𝑢12 𝑙11 𝑢13 𝑎11 𝑎12 𝑎13


[𝑙21 𝑙21 𝑢12 + 𝑙22 𝑙21 𝑢13 + 𝑙22 𝑢23 ] = [𝑎21 𝑎22 𝑎23 ]
𝑙31 𝑙31 𝑢12 + 𝑙32 𝑙31 𝑢13 + 𝑙32 𝑢23 + 𝑙33 𝑎31 𝑎32 𝑎33

Equating the corresponding coefficients, we get the values of l and u

Example Solve the following system by the method of Crout’s factorization


method.

2𝑥 − 3𝑦 + 10𝑧 = 3

−𝑥 + 4𝑦 + 2𝑧 = 20

5𝑥 + 2𝑦 + 𝑧 = −12

The given system is 𝐴𝑥 = 𝐵, where


2 −3 10 𝑥 3
𝐴 = [−1 4 2 ] 𝑋 = [𝑦] 𝐵 = [ 20 ] here A=LU
5 2 1 𝑧 −12
𝑙11 0 0 1 𝑢12 𝑢13 2 −3 10
[𝑙21 𝑙22 0 ] [0 1 𝑢23 ] = [−1 4 2]
𝑙31 𝑙32 𝑙33 0 0 1 5 2 1
Now comparing, we get,

𝑙11 = 2 , 𝑙21 = −1, 𝑙13 = 5

102
𝑙11 𝑢12 = −3

𝑢12 = − 3⁄2

𝑙11 𝑢13 = 10

𝑢13 = 10⁄2 = 5

𝑙21 𝑢12 + 𝑙22 = 4

𝑙22 = 5⁄2

𝑙21 𝑢13 + 𝑙22 𝑢23 = 2

𝑢23 = 14⁄5

𝑙31 𝑢12 + 𝑙32 = 2

𝑙32 = 19⁄2

𝑙31 𝑢13 + 𝑙32 𝑢23 + 𝑙33 = 1

𝑙33 = − 253⁄5

So, we have,
2 0 0 1 − 3⁄2 5
5⁄
𝐿 = [−1 2 0 ] 𝑈 = [0 1 14⁄ ]
5
5 19⁄5 − 253⁄5 0 0 1
Now 𝐿𝑧 = 𝐵
2 0 0 𝑧1
5⁄ 3
[−1 2 0 ] [𝑧2 ] = [ 20 ]
5 19⁄
5 − 253⁄5 𝑧3 −12

𝑍1 = 3⁄2

103
5
−𝑍1 + 𝑍2 = 20
2

𝑍2 = 43⁄2

253
5𝑍1 + 19⁄2 𝑍2 − 𝑍 = −12
5 3
𝑍3 = 2

Now UX= 𝑍

1 − 3⁄2 5 𝑥 3⁄
2
[0 1 14⁄ ] [𝑦] = [43⁄ ]
5 𝑧 5
0 0 1 2
𝑧=2
14
𝑦+ 𝑧 = 43⁄5
5
𝑦=3
3 3
𝑥 − 𝑦 + 5𝑧 =
2 2
𝑥 = −4

𝑥 = −4, 𝑦 = 3, 𝑧 = 2

Practice: Solve the following system using Doolittle and Crout’s


decomposition methods.

1. 𝑥1 + 2𝑥2 − 3𝑥3 = 4, 2𝑥1 + 4𝑥2 − 6𝑥3 = 8, 𝑥1 − 2𝑥2 + 5𝑥3 = 4


2. 2𝑥1 + 𝑥2 + 𝑥3 = 7, 4𝑥1 + 2𝑥2 + 3𝑥3 = 4, 𝑥1 − 𝑥2 + 𝑥3 = 0

Choleskys method:
In case of A is symmetric, the LU decomposition can be modified so that upper
factor in matrix is the transpose of the lower one (vice versa)

i.e.

104
𝐴 = 𝐿𝐿𝑇 = 𝑈 𝑇 𝑈
𝑙11 0 0 𝑙11 𝑙21 𝑙31 𝑎11 𝑎12 𝑎13
[𝑙21 𝑙22 0 ][ 0 𝑙22 𝑙32 ] = [𝑎21 𝑎22 𝑎23 ]
𝑙31 𝑙32 𝑙33 0 0 𝑙33 𝑎31 𝑎32 𝑎33

Just as other method, perform as before.

Symmetric matrix

A square matrix 𝑨 = [𝒂𝒊𝒋 ] is called symmetric if 𝒂𝒊𝒋 = 𝒂𝒋𝒊 for all i and j

Example: Factorize the matrix, using Cholesky algorithm


1 2 3
[2 8 22]
3 22 82
Now decomposition becomes,
𝑙11 0 0 𝑙11 𝑙21 𝑙31 1 2 3
[𝑙21 𝑙22 0 ][ 0 𝑙22 𝑙32 ] = [2 8 22]
𝑙31 𝑙32 𝑙33 0 0 𝑙33 3 22 82

Equating, we get:

𝑙11 2 = 1, 𝑙11 = 1

𝑙11 𝑙21 = 2, 𝑙21 = 2

𝑙11 𝑙31 = 3, 𝑙31 = 3

𝑙21 𝑙21 + 𝑙22 𝑙22 = 8 ,𝑙22 = 2

𝑙31 2 + 𝑙32 2 + 𝑙33 2 = 82 ,𝑙33 = 3


1 0 0
𝐿 = [2 2 0]
3 8 3

105
Practice: Find the Cholesky decomposition of the matrix
4 1 1
𝐴 = [1 5 2]
1 2 3

Iterative methods (Indirect Methods)


Gauss elimination and its derivatives are called direct method, an entirely
different way to solve many systems is through iteration. In this we start with an
initial estimate of the solution vector and proceed to refine this estimate.

When the system of equation can be ordered so that each diagonal entry of the
coefficient matrix is larger in magnitude that the sum of the magnitude of the
other coefficients in that row, then such system is called diagonally dominant and
the iteration will converge for any stating values. Formally we say that an nxn
matrix A is diagonally dominant if and only if for each i=1, 2, 3….n

|𝑎𝑖𝑖 | > ∑|𝑎𝑖𝑗 | 𝑓𝑜𝑟 𝑎𝑙𝑙 𝑖


𝑗≠𝑖

The iterative method depends on the arrangement of the equations in this manner

Let us consider a system of n equations in n unknowns

𝑎11 𝑥1 + 𝑎12 𝑥2 + ⋯ + 𝑎1𝑛 𝑥𝑛 = 𝑏1

𝑎21 𝑥1 + 𝑎22 𝑥2 + ⋯ + 𝑎2𝑛 𝑥𝑛 = 𝑏2

𝑎𝑛1 𝑥1 + 𝑎𝑛2 𝑥2 + ⋯ + 𝑎𝑛𝑛 𝑥𝑛 = 𝑏𝑛

We write the original system as


𝑏1 − (𝑎12 𝑥2 + 𝑎13 𝑥3 + ⋯ + 𝑎1𝑛 𝑥𝑛 )
𝑥1 =
𝑎11
𝑏2 − (𝑎21 𝑥1 + 𝑎23 𝑥3 + ⋯ + 𝑎2𝑛 𝑥𝑛 )
𝑥2 =
𝑎22

106
𝑏𝑛 − (𝑎𝑛1 𝑥1 + 𝑎𝑛2 𝑥2 + ⋯ + 𝑎𝑛𝑛−1 𝑥𝑛 )
𝑥𝑛 =
𝑎𝑛𝑛

Now we can computer 𝑥1 , 𝑥2 … 𝑥𝑛 by using initial guess for these values. The
new values area gain used to compute the next set of x values. The process can
continue till we obtain a desired level of accuracy in x values.

1.Gauss Jacobi Iteration method:

Example:

Solve the equation using Gauss Jacobi iteration method

6𝑥1 − 2𝑥2 + 𝑥3 = 11

𝑥1 + 2𝑥2 − 5𝑥3 = −1

−2𝑥1 + 7𝑥2 + 2𝑥3 = 5

Now, first we recorder the equation so that coefficient matrix is diagonally


dominant

6𝑥1 − 2𝑥2 + 𝑥3 = 11

−2𝑥1 + 7𝑥2 + 2𝑥3 = 5

𝑥1 + 2𝑥2 − 5𝑥3 = −1

Now,
11 − (−2𝑥2 + 𝑥3 )
𝑥1 =
6
5 − (−2𝑥1 + 2𝑥3 )
𝑥2 =
7
−1 − (𝑥1 + 2𝑥2 )
𝑥3 = −( )
5
We can simplify as:
11 2 1
𝑥1 = + 𝑥2 − 𝑥3
6 6 6
5 2 2
𝑥2 = + 𝑥1 − 𝑥3
7 7 7

107
1 1 2
𝑥3 = + 𝑥2 + 𝑥3
5 5 5
We begin with some initial approximation to the value of the variables, let’s take
as:

𝑥1 = 0, 𝑥2 = 0, 𝑥3 = 0,

Then new approximation using above formula will be as follows

𝑥1 =1.833333
𝑥2 =0.714286
𝑥3 =0.200000

2 Iteration
𝑥1 =2.038095
𝑥2 =1.180952
𝑥3 =0.852381

3 Iteration
𝑥1 =2.084921
𝑥2 =1.053061
𝑥3 =1.080000

4 Iteration
𝑥1 =2.004354
𝑥2 =1.001406
𝑥3 =1.038209

5 Iteration
𝑥1 =1.994100
𝑥2 =0.990327
𝑥3 =1.001433

6 Iteration
𝑥1 =1.996537
𝑥2 =0.997905
𝑥3 =0.994951

7 Iteration
𝑥1 =2.000143
𝑥2 =1.000453

108
𝑥3 =0.998469

8Iteration
𝑥1 =2.000406
𝑥2 =1.000478
𝑥3 =1.000210

9 Iteration
𝑥1 =2.000124
𝑥2 =1.000056
𝑥3 =1.000273

10 Iteration
𝑥1 =1.999973
𝑥2 =0.999958
𝑥3 =1.000047

11 Iteration
𝑥1 =1.999978
𝑥2 =0.999979
𝑥3 =0.999978

12 Iteration
𝑥1 =1.999997
𝑥2 =1.000000
𝑥3 =0.999987

12 Iteration
the final
result is :

𝑥1 =1.999997
𝑥2 =1.000000
𝑥3 =0.999987

Practice: Solve the equation using Gauss Jacobi Iteration method.

10𝑥1 − 2𝑥2 − 𝑥3 −𝑥4 = 11

−2𝑥1 + 10𝑥2 − 𝑥3 −𝑥4 = 15

109
−𝑥1 − 𝑥2 + 10𝑥3 − 2𝑥4 = 27

−𝑥1 − 𝑥2 − 2𝑥3 + 10𝑥4 = −9

result

𝑥1 = 1, 𝑥2 = 2, 𝑥3 = 3, 𝑥4 = 0,

2.Gauss Seidel Iteration method


This is simple modification of Gauss Jacobi method, as before

Let us consider a system of n equations in n unknowns

𝑎11 𝑥1 + 𝑎12 𝑥2 + ⋯ + 𝑎1𝑛 𝑥𝑛 = 𝑏1

𝑎21 𝑥1 + 𝑎22 𝑥2 + ⋯ + 𝑎2𝑛 𝑥𝑛 = 𝑏2

𝑎𝑛1 𝑥1 + 𝑎𝑛2 𝑥2 + ⋯ + 𝑎𝑛𝑛 𝑥𝑛 = 𝑏𝑛

We write the original system as:


𝑏1 − (𝑎12 𝑥2 + 𝑎13 𝑥3 + ⋯ + 𝑎1𝑛 𝑥𝑛 )
𝑥1 =
𝑎11
𝑏2 − (𝑎21 𝑥1 + 𝑎23 𝑥3 + ⋯ + 𝑎2𝑛 𝑥𝑛 )
𝑥2 =
𝑎22

𝑏𝑛 − (𝑎𝑛1 𝑥1 + 𝑎𝑛2 𝑥2 + ⋯ + 𝑎𝑛𝑛−1 𝑥𝑛 )


𝑥𝑛 =
𝑎𝑛𝑛

Now, we can compute: 𝑥1 , 𝑥2 … 𝑥𝑛 by using initial guess for these values. Here
we use the updated values of 𝑥1 , 𝑥2 … 𝑥𝑛 in calculating new values of x in each
iteration till we obtain a desired level of accuracy in x values. This method is

110
more rapid in convergence than gauss Jacobi method. The rate of convergence of
gauss seidel method is roughly twice that of gauss Jacobi.

Example

Solve the equation using Gauss Seidel iteration method .

8𝑥1 − 3𝑥2 + 2𝑥3 = 20

6𝑥1 + 3𝑥2 + 12𝑥3 = 35

4𝑥1 + 11𝑥2 − 𝑥3 = 33

Now, first we know the equation so that coefficient matrix is diagonally dominant

8𝑥1 − 3𝑥2 + 2𝑥3 = 20

4𝑥1 + 11𝑥2 − 𝑥3 = 33

6𝑥1 + 3𝑥2 + 12𝑥3 = 35

Now
20 + 3𝑥2 − 2𝑥3
𝑥1 =
8
33 − 4𝑥1 + 𝑥3
𝑥2 =
11
35 − 6𝑥1 − 3𝑥2
𝑥3 =
12
We begin with some initial approximation to the value of the variables, let’s take
as:

𝑥2 = 0, 𝑥3 = 0,

Then new approximation using above formula will be as follows


20 + 3 ∗ 0 − 2 ∗ 0
𝑥1 = = 2.5
8
33 − 4 ∗ 2.5 + 0
𝑥2 = = 2.0909
11

111
35 − 6 ∗ 2.5 − 3 ∗ 2.0909
𝑥3 = = 1.1439
12

2 iteration
20 + 3 ∗ 2.0909 − 2 ∗ 1.1439
𝑥1 = = 2.9981
8
33 − 4 ∗ 2.9981 + 1.1439
𝑥2 = = 2.0138
11
35 − 6 ∗ 2.9981 − 3 ∗ 1.7018
𝑥3 = = 0.9142
12

3 iteration
20 + 3 ∗ 2.0138 − 2 ∗ 0.9142
𝑥1 = = 3.0266
8
33 − 4 ∗ 3.0266 + 0.9142
𝑥2 = = 1.9825
11
35 − 6 ∗ 3.0266 − 3 ∗ 1.9825
𝑥3 = = 0.9077
12

4 iteration
20 + 3 ∗ 1.9825 − 2 ∗ 0.9077
𝑥1 = = 3.0165
8
33 − 4 ∗ 3.0165 + 0.9077
𝑥2 = = 1.9856
11
35 − 6 ∗ 3.0165 − 3 ∗ 1.9856
𝑥3 = = 0.9120
12

112
5 iteration
20 + 3 ∗ 1.9856 − 2 ∗ 0.9120
𝑥1 = = 3.0166
8
33 − 4 ∗ 3.0166 + 0.9120
𝑥2 = = 1.9860
11
35 − 6 ∗ 3.0166 − 3 ∗ 1.9860
𝑥3 = = 0.9119
12

6 iteration
20 + 3 ∗ 1.9860 − 2 ∗ 0.9119
𝑥1 = = 3.0168
8
33 − 4 ∗ 3.0168 + 0.9119
𝑥2 = = 1.9859
11
35 − 6 ∗ 3.0168 − 3 ∗ 1.9859
𝑥3 = = 0.9118
12

7 iteration
20 + 3 ∗ 1.9859 − 2 ∗ 0.9118
𝑥1 = = 3.0168
8
33 − 4 ∗ 3.0168 + 0.9118
𝑥2 = = 1.9859
11
35 − 6 ∗ 3.0168 − 3 ∗ 1.9859
𝑥3 = = 0.9118
12

Since the 6th and 7th approximate are almost same up to 4 decimal places, we can
say the solution vector is :

113
𝑥1 = 3.0168, 𝑥2 = 1.9859, 𝑥3 = 0.9118

Practice:

Solve the equation using Gauss Seidel iteration method

2𝑥1 + 𝑥2 + 𝑥3 = 5

3𝑥1 + 5𝑥2 + 2𝑥3 = 15

2𝑥1 + 𝑥2 + 4𝑥3 = 8

Practice: Solve the following systems using Jacobi and Gauss Seidel method

1. 3𝑥1 − 2𝑥2 = 5, − 𝑥1 + 2𝑥2 − 𝑥3 = 0, −2𝑥2 + 𝑥3 = −1


2. 2𝑥1 − 7𝑥2 − 10𝑥3 = −17, 5𝑥1 + 𝑥2 + 3𝑥3 = 14, 𝑥1 + 10𝑥2 + 9𝑥3 =
7

3.Relaxation Iterative method:


Solve the following system of equations by relaxation method:
10𝑥 − 2𝑦 + 𝑧 = 12

𝑥 + 9𝑦 − 𝑧 = 10

2𝑥 − 𝑦 + 11𝑧 = 20

Now obtaining residues:

12 − 10𝑥 + 2𝑦 − 𝑧 =R1

10 − 𝑥 − 9𝑦 + 𝑧 = R2

20 − 2𝑥 + 𝑦 − 11𝑧 =R3

114
Now, the increments in x, y, z are dx, dy, dz so, dx= -R1/-10 , dy = -R2/-9 and
dz = -R3/-11

Iterative Table:

i x y z R1 R2 R3 Incrmnts.
1 0 0 0 12 10 20 dz=-20/-11=1.8182
2 0 0 1.8182 10.1818 11.8182 -0.0002 dy=-11.8182/-9=1.3131
3 0 1.3131 1.8182 12.8080 0.0003 0.0003 dx=-12.8080/-10=1.2808
4 1.2808 1.3131 1.8182 0 -1.2805 -1.2487 dy=-(-1.2805)/-9=-0.142
5 1.2808 1.1708 1.8182 -0.2846 0.002 -1.3910 dz=-(-1.3910)/-11=-0.126
6 1.2808 1.1708 1.6917 -0.1581 -0.1263 0.0005 dx=-(-0.1581)/-10=
-0.158
7 1.2650 1.1708 1.6917 -0.0001 -0.1105 0.0321 dy=-(-0.1105)/-9= -
0.0123
𝑥 1.2650
Therefore, the solution vector, X =[𝑦] =[1.1708] Ans.
𝑧 1.6917
Power method:
Power method is a single value method used for determining the dominant eigen
value of a matrix. It as an iterative method implemented using an initial starting
vector x. the starting vector can be arbitrary if no suitable approximation is
available. Power method is implemented as follows

𝑌 = 𝐴𝑋 − − − − − (𝑎)
𝑌
𝑋= − − − − − (𝑏)
𝑘
The new value of X is obtained in b is the used in equation a to compute new
value of Y and the process is repeated until the desired level of accuracy is
obtained. The parameter k is called scaling factor is the element of Y with largest
magnitude.

115
Example: find the largest Eigen value 𝜆 and the corresponding vector v, of the
matrix using power method
1 2 0
𝐴 = [2 1 0]
0 0 −1
Solution assume X be column vector to be eigen vector of given matrix, now let
0
𝑋 = [1] be the eigen vector
0
Now iteration 1
1 2 0 0 2 𝑌 1 2 1
𝑌 = 𝐴𝑋 = [2 1 0 ] [1] = [1] 𝑋 = = [1] = [0.5]
𝑘 2
0 0 −1 0 0 0 0
iteration 2
1 2 0 1 2 𝑌 1 2 0.8
𝑌 = 𝐴𝑋 = [2 1 0 ] [0.5] = [2.5] 𝑋= = [2.5] = [ 1 ]
𝑘 2.5
0 0 −1 0 0 0 0
iteration 3
1 2 0 0.8 2.8 𝑌 1 2.8
𝑌 = 𝐴𝑋 = [2 1 0 ] [ 1 ] = [2.6] 𝑋= = [2.6]
𝑘 2.8
0 0 −1 0 0 0
1
= [0.929]
0
iteration 4
1 2 0 1 2.858 𝑌
𝑌 = 𝐴𝑋 = [2 1 0 ] [0.929] = [2.928] 𝑋=
𝑘
0 0 −1 0 0
1 2.858 0.976
= [2.928] = [ 1 ]
2.928
0 0
iteration 5

116
1 2 0 0.976 2.976 𝑌
𝑌 = 𝐴𝑋 = [2 1 0 ] [ 1 ] = [2.952] 𝑋=
𝑘
0 0 −1 0 0
1 2.976 1
= [2.952] = [0.992]
2.976
0 0
iteration 6
1 2 0 1 2.984 𝑌
𝑌 = 𝐴𝑋 = [2 1 0 ] [0.992] = [2.992] 𝑋=
𝑘
0 0 −1 0 0
1 2.984 0.997
= [2.992] = [ 1 ]
2.992
0 0
iteration 7
1 2 0 0.997 2.997 𝑌
𝑌 = 𝐴𝑋 = [2 1 0 ] [ 1 ] = [ 2.994] 𝑋=
𝑘
0 0 −1 0 0
1 2.997 1
= [2.994] = [0.999]
2.997
0 0
iteration 8
1 2 0 1 2.998 𝑌
𝑌 = 𝐴𝑋 = [2 1 0 ] [0.999] = [2.999] 𝑋=
𝑘
0 0 −1 0 0
1 2.998 1
= [2.999] = [1]
2.999
0 0
iteration 9
1 2 0 1 3 𝑌 1 3 1
𝑌 = 𝐴𝑋 = [2 1 0 ] [1] = [3] 𝑋 = = [3] = [1]
𝑘 3
0 0 −1 0 0 0 0

Since the value of X is same for 8th and 9th iteration so eigen value is 𝜆 = 3 and
1
eigen vector is 𝑋 = [1]
0

117
Practice: Determine the Numerically largest eigen value and the
corresponding eigen vector of the following matrix, using power method
𝟐𝟓 𝟏 𝟐
[𝟏 𝟑 𝟎]
𝟐 𝟎 −𝟒
𝟏
Eigen value is 25.18, eigen vector =[𝟎. 𝟎𝟒𝟓𝟎𝟖]
𝟎. 𝟎𝟔𝟖𝟓𝟒

Chapter 5 Solution of ordinary differential Equations


Many of the laws in physics, chemistry, engineering, economics are based on
empirical observations that describe changes in the state of the system.
Mathematical models that describe the state of such system are often expressed
in terms of not only certain system parameters but also their derivatives, such
mathematical model which uses differential calculus to express relationship
between variables are known as differential equations.

Examples:
𝑑𝑖
1. Kirchhoff’s law 𝐿 + 𝑖𝑅 = 𝑣
𝑑𝑡
𝑑𝑣
2. 𝑚 =𝐹
𝑑𝑡
𝑑2 𝑦 𝑑𝑦
3. 𝑚 +𝑎 + 𝑘𝑦 = 0
𝑑𝑡 2 𝑑𝑡

Here

• The quantity y that is being differentiated is called dependent variable.


• The quantity with respect to which the dependent variable is differentiated
is called independent variable.
• If there is only one independent variable then the equation is called an
ordinary differential equation.

118
• If the equation contains more than one independent variable then it is called
partial differential equation
𝜕2𝑢 𝜕2𝑢
+ = 𝑓(𝑥, 𝑦)
𝜕𝑥 2 𝜕𝑦 2
Order of equation:
The highest derivative that appears in the equation is called order. If there is only
first derivative then it called first order differential equation.

Degree of equation:
The degree of differential equation is the power of the highest order derivative
𝑥𝑦 " + 𝑥 2 𝑦 ′ = 2𝑦 + 3 𝑜𝑟𝑑𝑒𝑟 = 2, 𝑑𝑒𝑔𝑟𝑒𝑒 = 1
(𝑦 "′ )2 + 5𝑦 ′ = 2𝑦 + 3 𝑜𝑟𝑑𝑒𝑟 = 3, 𝑑𝑒𝑔𝑟𝑒𝑒 = 2

Initial value problem (IVP)


In order to obtain the values of the integration constant, we need additional
information for example consider the solution 𝑦 = 𝑎𝑒 𝑥 to the equation 𝑦 ′ = 𝑦. if
we are giving a value of y for some x, the constant a can be dertermined, suppose
y=1 when x=0, then 𝑦(0) = 𝑎𝑒 0 = 1,

∴ 𝑎 = 1 and particular solution is 𝑦 = 𝑒 𝑥

It is also possible to specify the condition at different values of the independent


variables such problems are called boundary value problem (BVP).

Example
𝑦 " = 𝑓(𝑥, 𝑦, 𝑦 ′ ) 𝑦(𝑎) = 𝐴, 𝑦(𝑏) =
𝐵 𝑤ℎ𝑒𝑟𝑒 𝑎 & 𝑏 𝑎𝑟𝑒 𝑡𝑤𝑜 𝑑𝑖𝑓𝑓𝑒𝑟𝑒𝑛𝑡 𝑝𝑜𝑖𝑛𝑡𝑠.

Solution of ordinary differential equations


1. Taylor’s series method
2. Euler’s method
3. Heun’s method
4. Runge’s method
5. Runge’s Kutta 4th order method
6. Shooting method
7. Picard’s method
8. R.K method for simultaneous equations
9. Solution of higher order differential equation
119
1. Taylor’s series
Taylor series is often used in determining the order of errors for methods and the
series itself is the basic for some numerical procedures.

Let 𝑦 ′ = 𝑓(𝑥, 𝑦), 𝑦(𝑥0 ) = 𝑦0


(7)

Be the differential equation to which the numerical solution is required.


Expanding 𝑦(𝑥) about 𝑥 = 𝑥0 by Taylor Series we get
(𝑥−𝑥0 )𝑦 ′ (𝑥0 ) (𝑥−𝑥0 )2 𝑦 ′′ (𝑥0 )
y(x) = 𝑦(𝑥0 ) + + +⋯
1! 2!
(8)
(𝑥−𝑥0 )𝑦0′ (𝑥−𝑥0 )2 𝑦0′′
= 𝑦0 + + +⋯ (9)
1! 2!

Putting 𝑥 = 𝑥0 + ℎ = 𝑥1 , h=difference we have


ℎ𝑦0′ ℎ2 𝑦0′′ ℎ3 𝑦0′′′
𝑦1 = 𝑦(𝑥1 ) = 𝑦0 + + + … (10)
1! 2! 3!

Here 𝑦0′ , 𝑦0′′ , 𝑦0′′′ … can be found using equation (1) and its successive
differentiation at 𝑥 = 𝑥0 . The series in (4) can be truncated at any stage if ‘h’ is
small. Now having obtained 𝑦1 we can calculate 𝑦1′ , 𝑦1′′ , 𝑦1′′′ from equation (1) at
𝑥 = 𝑥0 + h

Now expanding 𝑦(𝑥 ) by Taylor series about 𝑥 = 𝑥1 , we get


ℎ𝑦1′ ℎ2 𝑦1′′ ℎ3 𝑦1′′′
𝑦2 = 𝑦1 + + + … (11)
1! 2! 3!

Proceeding further we get



ℎ𝑦𝑛−1 ′′
ℎ2 𝑦𝑛−2 ′′′
ℎ3 𝑦𝑛−3
𝑦𝑛 = 𝑦𝑛−1 + + + … (12)
1! 2! 3!

By taking sufficient number of terms in above series the value of 𝑦𝑛 can be


obtained without much error

If a Taylor series is truncated while there are still non-zero derivatives of higher
order the truncated power series will not be exact. The error term for a truncated
Taylor Series can be written in several ways but the most useful form when the
series is truncated after 𝑛𝑡ℎ term is

120
Example:
𝑑𝑦
Using Taylor series method, solve = 𝑥 2 − 𝑦, 𝑦(0) = 1 at 𝑥=
𝑑𝑥
0.1,0.2,0.3 &0.4.

Solution

Given 𝑦 ′ = 𝑥 2 − 𝑦,𝑦(0) = 1,

𝑥0 = 0, 𝑦0 = 1, h = 0.1, 𝑥 = 0.1, 𝑥 = 0.2, 𝑥 = 0.3, 𝑥 = 0.4

Now

𝑦′ = 𝑥2 − 𝑦 𝑦0′ = 𝑥02 − 𝑦0 = 0 − 1 = −1

𝑦′′ = 2𝑥 − 𝑦 ′ 𝑦0′′ = 2𝑥0 − 𝑦0′ = 2 ∗ 0 − (−1) = 1

𝑦′′′ = 2 − 𝑦 ′′ 𝑦0′′′ = 2 − 𝑦0′′ = 1

𝑦 𝑖𝑣 = −𝑦 ′′′ 𝑦0𝑖𝑣 = −𝑦0′′′ = −1

By Taylor Series

ℎ𝑦0′ ℎ2 𝑦0′′ ℎ3 𝑦0′′′ ℎ4 𝑦0𝑖𝑣


𝑦1 = 𝑦0 + + + + …
1! 2! 3! 4!
𝑦1 = 𝑦(0.1)
0.1(−1) (0.1)2 ∗1 0.13 ∗1 0.14 ∗(−1)
= 1+ + + + …
1! 2! 3! 4!

= 1−0.1 + 0.005 + 0.0001667 − 0.00000417

=0.90516

Now

𝑦1′ = 𝑥12 − 𝑦1 = (0.1)2 − 0.90516=-0.89516

𝑦1′′ = 2𝑥1 − 𝑦1′ = 2 ∗ (0.1) − (−0.89516) = 1.09516

𝑦1′′′ = 2 − 𝑦1′′ = 2 − 1.0951 = 0.90484

𝑦1𝑖𝑣 = −𝑦1′′′ = −0.90484

121
By Taylor Series

ℎ𝑦1′ ℎ2 𝑦1′′ ℎ3 𝑦1′′′ ℎ4 𝑦1𝑖𝑣


𝑦2 = 𝑦1 + + + + …
1! 2! 3! 4!
𝑦2 = 𝑦(0.2)
0.1∗(−0.89516) (0.1)2 ∗1.09516 0.13 ∗0.90484 0.14 ∗(−)
= 0.90516 + + + + …
1! 2! 3! 4!

= 0.90516 − 0.089516 + 0.0054758 + 0.000150 − 0.00000377

=0.821266

Now

𝑦2′ = 𝑥22 − 𝑦2 = (0.2)2 − 0.8212352 = −0.7812352

𝑦2′′ = 2𝑥2 − 𝑦2′ = 2 ∗ (0.2) − (−0.7812352) = 1.1812352

𝑦2′′′ = 2 − 𝑦2′′ = 2 − 1.1812352 = 0.8187648

𝑦2𝑖𝑣 = −𝑦2′′′ = −0.8187648

By Taylor Series

ℎ𝑦2′ ℎ2 𝑦2′′ ℎ3 𝑦2′′′ ℎ4 𝑦2𝑖𝑣


𝑦3 = 𝑦2 + + + + …
1! 2! 3! 4!
𝑦3 = 𝑦(0.3)

0.1 ∗ (−0.7812352) (0.1)2 ∗ 1.1812352


= 0.8212352 + +
1! 2!
3 4
0.1 ∗ 0.8187648 0.1 ∗ (−0.8187648)
+ + …
3! 4!
= 0.7491509

Now

𝑦3′ = 𝑥32 − 𝑦3 = (0.3)2 − 0.7491509 = −0.6591509

𝑦3′′ = 2𝑥3 − 𝑦3′ = 2 ∗ (0.3) − (−0.6591509) = 1.2591509

𝑦3′′′ = 2 − 𝑦3′′ = 2 − 1.2591509 = 0.740849

122
𝑦3𝑖𝑣 = −𝑦3′′′ = −0.740849

By Taylor Series

ℎ𝑦3′ ℎ2 𝑦3′′ ℎ3 𝑦3′′′ ℎ4 𝑦3𝑖𝑣


𝑦4 = 𝑦3 + + + + …
1! 2! 3! 4!
𝑦4 = 𝑦(0.4)

0.1 ∗ (−0.6591509) (0.1)2 ∗ 1.2591509


= 0.7491509 + +
1! 2!
3
0.1 ∗ 0.740849
+ +⋯
3!
= 0.6896519

Similarly we can find the values of 𝑦𝑛 for n=5, 6, 7…..

2. Euler’s method:
Euler’s method is the simplest one step method. It has limited application because
of its low accuracy. From Taylor’s theorem we have

(𝑥 − 𝑥0 )𝑦 ′ (𝑥0 ) (𝑥 − 𝑥0 )2 𝑦 ′′ (𝑥0 )
y(x) = 𝑦(𝑥0 ) + + +⋯
1! 2!

Taking only first two terms only

𝑦(𝑥 ) = 𝑦(𝑥0 ) + 𝑦 ′ (𝑥0 )(𝑥 − 𝑥0 )

Now, we get,

𝑦(𝑥1 ) = 𝑦1 = 𝑦(𝑥0 ) + (𝑥1 − 𝑥0 )𝑓(𝑥0 , 𝑦0 )

where 𝑥 = 𝑥1 , 𝑓(𝑥0 , 𝑦0 ) = 𝑦 ′ (𝑥0 )

Now let ℎ = 𝑥1 − 𝑥0

𝑦1 = 𝑦0 + ℎ𝑓(𝑥0 , 𝑦0 )

Similarly

𝑦2 = 𝑦1 + ℎ𝑓(𝑥1 , 𝑦1 )

123
In general

𝑦𝑖+1 = 𝑦𝑖 + ℎ𝑓(𝑥𝑖 , 𝑦𝑖 )

This formula is known as Euler’s method and can be used recursively to evaluate
y1, y2 … starting from the initial condition 𝑦0 = 𝑦(𝑥0 )

• A new value of y is estimated using the previous value of y as initial


condition.
• The term hf(xi,yi) represents the incremental value of y and f(xi,yi) is the
slope of y(x) at (xi,yi), the new value is obtained by extrapolating linearly
over the step size h using the slope at its previous value.
i.e. new value =old value + slope x step size

Example : Given the equation 𝑦 ′ (𝑥) = 3𝑥 2 + 1, with y(1)=2, estimate y(2),


using Euler’s method using h=0.5 & h=0.25,
Solution

𝑦 ′ (𝑥 ) = 𝑓(𝑥, 𝑦) = 3𝑥 2 + 1
𝑦(1) = 2, 𝑦(𝑥0 ) = 𝑦0 , 𝑥0 = 1, 𝑦0 = 2
We know that

𝑦𝑖+1 = 𝑦𝑖 + ℎ𝑓(𝑥𝑖 , 𝑦𝑖 )

a. h=0.5
𝑦1 = 𝑦(1 + 0.5) = 𝑦(1.5) = 𝑦0 + ℎ𝑓(𝑥0 , 𝑦0 )
= 𝑦(1) + 0.5 × (3 × 12 + 1)
= 2 + 0.5 × 4
=4
𝑦1 = 𝑦(2.0) + 𝑦(1.5 + 0.5) = 𝑦1 + ℎ𝑓(𝑥1 , 𝑦1 ) = 𝑦(1.5) + 0.5 × 𝑓(𝑥1.5 , 𝑦1.5 )
= 4 + 0.5 × (3 × 1.52 + 1)
= 7.8750
∴ 𝑦(2) = 7.8750

b. h=0.25
𝑦(1) = 2
𝑦1 = 𝑦(1 + 0.25) = 𝑦(1.25) = 𝑦0 + ℎ𝑓 (𝑥0 , 𝑦0 ) = 2 + 0.25 × 𝑓(1,2)
= 2 + 0.25(3 × 12 + 1) = 3
𝑦2 = 𝑦(1.25 + 0.25) = 𝑦(1.5) = 𝑦1 + ℎ𝑓 (𝑥1 , 𝑦1 ) = 3 + 0.25 × 𝑓(1.25,3)

124
= 3 + 0.25(3 × 1.252 + 1) = 4.4218
𝑦3 = 𝑦(1.5 + 0.25) = 𝑦(1.75) = 𝑦2 + ℎ𝑓(𝑥2 , 𝑦2 )
= 4.4218 + 0.25 × 𝑓(1.5,4.4218)
= 4.4218 + 0.25(3 × 1.52 + 1) = 6.3593
𝑦4 = 𝑦(1.75 + 0.25) = 𝑦(2.0) = 𝑦3 + ℎ𝑓 (𝑥3 , 𝑦3 )
= 6.3593 + 0.25 × 𝑓(1.75,6.3593)
= 6.3593 + 0.25(3 × 1.752 + 1) = 8.9061
∴ 𝑦(2.0) = 8.9061

3. Heun’s method:
Euler’s method is the simplest of all one step methods. It is easy to implement on
computers. One of the major weakness is large truncation error in Euler’s method.
This is due to the fact that Euler’s method uses only the first two terms of Taylor’s
series. Now heun’s method also called improved Euler’s method.

In Euler’s method the slope at the beginning of the interval is used to extrapolate
yi to yi+1 over the entire interval, thus 𝑦𝑖+1 = 𝑦𝑖 + 𝑚1 ℎ. . . . . . . . 𝑎 where m1 is the
slope at(xi,yi).

Alternative is to use the line which is parallel to the tangent at the point
[𝑥𝑖+1 , 𝑦(𝑥𝑖+1 )] to extrapolate from 𝑦𝑖 𝑡𝑜 𝑦𝑖+1

𝑦𝑖+1 = 𝑦𝑖 + 𝑚2 ℎ. . . . . . . . 𝑏

Where, m2 is the slope at [𝑥𝑖+1 , 𝑦(𝑥𝑖+1 )]. Note that the estimate appears to be
overestimated.

Now a third approach is to use a line whose slope is the average of the slopes at
the end points of the interval, i.e
𝑚1 + 𝑚2
𝑦𝑖+1 = 𝑦𝑖 + ( )ℎ. . . . . . . . 𝑐
2

This gives the better approximation to 𝑦𝑖+1 , this approach is known as Heun’s
method.

The formula for implementing Heun’s method can be constructed easily as

𝑦 ′ (𝑥 ) = 𝑓(𝑥, 𝑦)

125
We can obtain:

𝑚1 = 𝑦 ′ (𝑥𝑖 ) = 𝑓(𝑥𝑖 , 𝑦𝑖 )

𝑚2 = 𝑦 ′ (𝑥𝑖+1 ) = 𝑓(𝑥𝑖+1 , 𝑦𝑖+1 )


𝑚1 + 𝑚2 𝑓(𝑥𝑖 , 𝑦𝑖 ) + 𝑓(𝑥𝑖+1 , 𝑦𝑖+1 )
∴𝑚= =
2 2
Now, the equation (c) becomes:

𝑦𝑖+1 = 𝑦𝑖 + [𝑓(𝑥𝑖 , 𝑦𝑖 ) + 𝑓(𝑥𝑖+1 , 𝑦𝑖+1 )]. . . . . . 𝑑
2
Note that the term yi+1 appears on both sides. The value yi+1 cannot be calculated
until the value of yi+1 inside the function f(xi+1,yi+1) is available. This value can be
predicted using Euler’s formula as

𝑦𝑖+1 = 𝑦𝑖 + ℎ𝑓(𝑥𝑖 , 𝑦𝑖 )

Then, the Heun’s formula can be written as:



𝑦𝑖+1 = 𝑦𝑖 + [𝑓(𝑥𝑖 , 𝑦𝑖 ) + 𝑓(𝑥𝑖+1 , 𝑦𝑒 𝑖+1 )]
2
Putting the value of Euler’s formula in above equation we get

𝑦𝑖+1 = 𝑦𝑖 + [𝑓(𝑥𝑖 , 𝑦𝑖 ) + 𝑦𝑖 + ℎ𝑓(𝑥𝑖 , 𝑦𝑖 )]
2

2𝑦
Example : Given the equation 𝑦 ′ (𝑥) = with y(1)=2, estimate y(2) using 1)
𝑥
Euler’s method 2) Heun’s method and compare the result. Take h=0.25
I. Euler’s method
h=0.25, y(1)=2

2×2
𝑦(1.25) = 𝑦1 = 𝑦0 + ℎ𝑓 (𝑥0 , 𝑦0 ) = 2 + 0.25𝑓 (1,2) = 2 + 0.25 × =3
1
2×3
𝑦(1.5) = 𝑦2 = 𝑦1 + ℎ𝑓 (𝑥1 , 𝑦1 ) = 3 + 0.25𝑓(1.25,3) = 3 + 0.25 ×
1.25
= 4.2

126
𝑦(1.75) = 𝑦3 = 𝑦2 + ℎ𝑓(𝑥2 , 𝑦2 ) = 4.2 + 0.25𝑓(1.5,4.2)
2 × 4.2
= 4.2 + 0.25 × = 5.6
1.5
𝑦(2) = 𝑦4 = 𝑦3 + ℎ𝑓 (𝑥3 , 𝑦3 ) = 5.6 + 0.25𝑓 (1.75,5.6)
2 × 5.6
= 5.6 + 0.25 × = 7.2
1.75

II. Heun’s method:


Iteration 1:
we know
𝑚1 + 𝑚2
𝑦𝑖+1 = 𝑦𝑖 + ( )ℎ
2
𝑚1 + 𝑚2
𝑦𝑖 = 𝑦0 + ( )ℎ
2
Given the initial condition 𝑦(𝑥0 ) = 𝑦0 = 𝑦(1) = 2
𝑚1 + 𝑚2
𝑦(1 + 0.25) = 𝑦(1.25) = 𝑦1 = 𝑦0 + ( )ℎ
2
2×2
𝑚1 = 𝑓(𝑥0, 𝑦0 ) = 𝑓(1,2) = =4
1
𝑚2 = 𝑓(𝑥0 + ℎ, 𝑦0 + 𝑚1 ℎ)

= 𝑓(1 + 0.25,2 + 4 × 0.25)

= 𝑓(1.25,3)
2×3
=
1.25
= 4.8
𝑚1 + 𝑚2 4 + 4.8
𝑦(1.25) = 𝑦0 + ( )ℎ = 2 + ( ) 0.25 = 3.1
2 2
Iteration 2:
𝑚1 + 𝑚2
𝑦(1.25 + 0.25) = 𝑦(1.5) = 𝑦2 = 𝑦1 + ( )ℎ
2
2 × 3.1
𝑚1 = 𝑓(𝑥1 𝑦1 ) = 𝑓 (1.25,3.1) = = 4.96
1.25

127
𝑚2 = 𝑓(𝑥1 + ℎ, 𝑦1 + 𝑚1 ℎ)

= 𝑓(1.25 + 0.25,3.1 + 4.96 × 0.25)

= 𝑓 (1.5,4.34)
2 × 4.34
=
1.5
= 5.7867
𝑚1 + 𝑚2 4.96 + 5.7867
𝑦(1.5) = 𝑦1 + ( ) ℎ = 3.1 + ( ) 0.25 = 4.44
2 2

Iteration 3:
𝑚1 + 𝑚2
𝑦(1.5 + 0.25) = 𝑦(1.75) = 𝑦3 = 𝑦2 + ( )ℎ
2
2 × 4.44
𝑚1 = 𝑓(𝑥2 𝑦2 ) = 𝑓(1.5,4.44) = = 5.92
1.5
𝑚2 = 𝑓(𝑥2 + ℎ, 𝑦2 + 𝑚1 ℎ)

= 𝑓(1.5 + 0.25, 4.44 + 5.92 × 0.25)

= 𝑓(1.75,5.92)
2 × 5.92
=
1.75
= 6.77
𝑚1 + 𝑚2 5.92 + 6.77
𝑦(1.75) = 𝑦3 = 𝑦2 + ( ) ℎ = 4.44 + ( ) 0.25 = 6.03
2 2

Iteration 4:
𝑚1 + 𝑚2
𝑦(1.75 + 0.25) = 𝑦(1.5) = 𝑦4 = 𝑦3 + ( )ℎ
2
2 × 6.03
𝑚1 = 𝑓(𝑥3 𝑦3 ) = 𝑓(1.75,6.03) = = 6.89
1.75
𝑚2 = 𝑓(𝑥3 + ℎ, 𝑦3 + 𝑚1 ℎ)

128
= 𝑓(1.75 + 0.25, 6.03 + 6.89 × 0.25)

= 𝑓(2,7.75)
2 × 7.75
=
2
= 7.75
𝑚1 + 𝑚2 6.89 + 7.75
𝑦(2) = 𝑦4 = 𝑦3 + ( ) ℎ = 6.03 + ( ) 0.25 = 7.86
2 2

The above equation can be done using the following formula, note this is
same problem but done using later formula, you can use any method which
ever you feel easy to use.

Iteration 1:

We know that


𝑦𝑖+1 = 𝑦𝑖 + [𝑓(𝑥𝑖 , 𝑦𝑖 ) + 𝑓(𝑥𝑖+1 , 𝑦𝑒 𝑖+1 )]
2
We know
2𝑦 2 × 2
𝑓(𝑥0 , 𝑦0 ) = 𝑓(1,2) = = =4
𝑥 1
𝑦𝑒 (1.25) = 𝑦(1) + ℎ × 𝑓(𝑥1 , 𝑦(1))
= 2 + 0.25𝑓 (1,2)
2×2
= 2 + 0.25 ×
1
=3

𝑦(1.25) = 𝑦(1) + [𝑓(𝑥1 , 𝑦1 ) + 𝑓(𝑥𝑖+1 , 𝑦𝑒 𝑖+1 )]
2
0.25
=2+ [𝑓(1,2) + 𝑓 (1.25,3)]
2

129
0.25 2 × 2 2 × 3
2+ [ + ]
2 1 1.25
= 3.1
Iteration 2:

𝑦(1.5) = 𝑦(1.25) + [𝑓(𝑥1.25 , 𝑦1.25 ) + 𝑓(𝑥1.5 , 𝑦𝑒 1.5 )]
2


𝑦(1.5) = 𝑦(1.25) + [𝑓(1.25,3.1) + 𝑓(𝑥1.5 , 𝑦𝑒 1.5 )]
2

𝑦𝑒 (1.25) = 𝑦(1.25) + ℎ × 𝑓 (𝑥1.25 , 𝑦1.25 )


= 3.1 + 0.25𝑓(1.25,3.1)
2 × 3.1
= 3.1 + 0.25 ×
1.25
= 4.34

𝑦(1.5) = 𝑦(1.25) + [𝑓(1.25,3.1) + 𝑓(𝑥1.5 , 𝑦𝑒 1.5 )]
2
0.25
𝑦(1.5) = 3.1 + [𝑓(1.25,3.1) + 𝑓(1.5,4.34)]
2
0.25 3.1 4.34
= 3.1 + [2 × +2× ]
2 1.25 1.5
= 4.4433
Iteration 3:

𝑦(1.75) = 𝑦(1.5) + [𝑓(𝑥1.5 , 𝑦1.5 ) + 𝑓(𝑥1.75 , 𝑦𝑒 1.75 )]
2

𝑦𝑒 (1.75) = 𝑦(1.5) + ℎ × 𝑓 (𝑥1.5 , 𝑦1.5 )


= 4.4433 + 0.25𝑓(1.5,4.4433)
2 × 4.4433
= 4.4433 + 0.25 ×
1.5
= 5.9244

𝑦(1.75) = 𝑦(1.5) + [𝑓(1.5,4.4433) + 𝑓(𝑥1.5 , 5.9244)]
2
0.25 4.4433 5.9244
= 4.4433 + [2 × +2× ]
2 1.5 1.75
= 6.0302
Iteration 4:

𝑦(2) = 𝑦(1.75) + [𝑓(𝑥1.75 , 𝑦1.75 ) + 𝑓(𝑥2 , 𝑦𝑒 2 )]
2
130
𝑦𝑒 (2) = 𝑦(1.75) + ℎ × 𝑓 (𝑥1.75 , 𝑦1.75 )
= 6.0302 + 0.25𝑓(1.75,6.0302)
2 × 6.0302
= 6.0302 + 0.25 ×
1.75
= 7.7531

𝑦(2) = 𝑦(1.75) + [𝑓(1.75,6.0302) + 𝑓(2,7.7531)]
2
0.25 6.0302 7.7531
= 6.0302 + [2 × +2× ]
2 1.75 2
= 7.8608
𝑦
The exact solution of the equation 𝑦 ′ (𝑥) = 2 with 𝑦(1) = 2 is obtained as
𝑥
2
𝑦(𝑥) = 2𝑥
𝑦(2) = 2 × 22 = 8
error =8-7.8608=0.1392

Runge Kutta method:


Runge Kutta method refers to a family of one step methods used for numerical
solution of initial value problems. They are all based on the general form of the
extrapolation equation:

𝑦𝑖+1 = 𝑦𝑖 + 𝑠𝑙𝑜𝑝𝑒 × 𝑖𝑛𝑡𝑒𝑟𝑣𝑎𝑙 𝑠𝑖𝑧𝑒

= 𝑦𝑖 + 𝑚ℎ

Where m represents the slope that is weighted averages of the slope at various
points in the interval h. Runge Kutta (RK) methods are known by their order. For
instance an RK method is called r-order Runge Kutta method when slope at r
points are used to construct the weighted average slope m.

Euler’s method is the first order RK method because it uses only one slope at
(xi,yi) to estimate 𝑦𝑖+1 .

Huen’s method is a second order RK method because it employs slope at two


ends points of the interval. It demonstrated that higher order would be better the
accuracy of estimates.

131
Fourth order Runge Kutta method (Classical fourth order Runge Kutta
method)
The classical fourth order Runge Kutta method is given as:
𝑚1 + 2𝑚2 + 2𝑚3 + 𝑚4
𝑦𝑖+1 = 𝑦𝑖 + ( )ℎ
6
Where

𝑚1 = 𝑓(𝑥𝑖 , 𝑦𝑖 )
ℎ 𝑚1 ℎ
𝑚2 = 𝑓(𝑥𝑖 + , 𝑦𝑖 + )
2 2
ℎ 𝑚2 ℎ
𝑚3 = 𝑓(𝑥𝑖 + , 𝑦𝑖 + )
2 2
𝑚4 = 𝑓(𝑥𝑖 + ℎ, 𝑦𝑖 + 𝑚3 ℎ)

Runge Kutta (3rd order RK method)


𝑚1 + 4𝑚4 + 𝑚3
𝑦𝑖+1 = 𝑦𝑖 + ( )ℎ
6
Where,

𝑚1 = 𝑓(𝑥𝑖 , 𝑦𝑖 )

𝑚2 = 𝑓(𝑥𝑖 + ℎ, 𝑦𝑖 + 𝑚1 ℎ)

𝑚3 = 𝑓(𝑥𝑖 + ℎ, 𝑦𝑖 + 𝑚2 ℎ)
ℎ ℎ
𝑚4 = 𝑓(𝑥𝑖 + , 𝑦𝑖 + 𝑚1 )
2 2
Example : Use the classical RK method to estimate y(0.4) when 𝑦 ′ (𝑥) = 𝑥 2 +
𝑦 2 with 𝑦(0) = 0, assume h=0.2.

Solution

Given condition

𝑦(0) = 0, 𝑓(𝑥, 𝑦) = 𝑥 2 + 𝑦 2

We know that,

132
𝑚1 + 2𝑚2 + 2𝑚3 + 𝑚4
𝑦𝑖+1 = 𝑦𝑖 + ( )ℎ
6
Where,

𝑚1 = 𝑓(𝑥𝑖 , 𝑦𝑖 )
ℎ 𝑚1 ℎ
𝑚2 = 𝑓(𝑥𝑖 + , 𝑦𝑖 + )
2 2
ℎ 𝑚2 ℎ
𝑚3 = 𝑓(𝑥𝑖 + , 𝑦𝑖 + )
2 2
𝑚4 = 𝑓(𝑥𝑖 + ℎ, 𝑦𝑖 + 𝑚3 ℎ)

iteration 1:
𝑚1 + 2𝑚1 + 2𝑚3 + 𝑚4
𝑦(0.2) = 𝑦0 + ( )ℎ
6
𝑚1 = 𝑓(𝑥0 , 𝑦0 ) = 𝑓(0,0) = 0
ℎ 𝑚1 ℎ 0.2 0 × 0.2
𝑚2 = 𝑓(𝑥0 + , 𝑦0 + ) = 𝑓(0 + ,0 + ) = 𝑓(0.1,0)
2 2 2 2
= 0.12 + 0.02 = 0.01
ℎ 𝑚2 ℎ 0.2 0.01 × 0.2
𝑚3 = 𝑓(𝑥0 + , 𝑦0 + ) = 𝑓(0 + ,0 + ) = 𝑓(0.1,0.001)
2 2 2 2
= 0.12 + 0.0012 = 0.01

𝑚4 = 𝑓(𝑥0 + ℎ, 𝑦0 + 𝑚3 ℎ) = 𝑓(0 + 0.2,0 + 0.01 × 0.2) = 𝑓(0.2,0.002)


= 0.12 + 0.0022 = 0.04
𝑚1 + 2𝑚1 + 2𝑚3 + 𝑚4
𝑦(0.2) = 𝑦0 + ( )ℎ
6
0 + 2 × 0.01 + 2 × 0.01 + 0.04
𝑦(0.2) = 0 + ( ) 0.2 = 0.00267
6
Iteration 2
𝑚1 + 2𝑚1 + 2𝑚3 + 𝑚4
𝑦(0.4) = 𝑦1 + ( )ℎ
6

133
𝑦1 = 𝑦(0.2)

𝑚1 = 𝑓(𝑥0.2 , 𝑦0.2 ) = 𝑓(0.2,0.00267) = 0.04


0.2 0.04 × 0.2
𝑚2 = 𝑓(0.2 + , 0.00267 + ) = 𝑓(0.3,0.0067)
2 2
= 0.32 + 0.00672 = 0.09004
0.2 0.09004 × 0.2
𝑚3 = 𝑓(0.2 + , 0.00267 + ) = 𝑓(0.3,0.01167)
2 2
= 0.32 + 0.011672 = 0.09014

𝑚4 = 𝑓(0.2 + 0.2,0.00267 + 0.9014 × 0.2) = 𝑓(0.4,0.02070)


= 0.42 + 0.020702 = 0.16043
𝑚1 + 2𝑚1 + 2𝑚3 + 𝑚4
𝑦(0.4) = 𝑦0 + ( )ℎ
6
0.04 + 2 × 0.09004 + 2 × 0.09014 + 0.16043
𝑦(0.4) = 0.00267 + ( ) 0.2
6
= 0.02136

Runge Kutta method for simultaneous first order equations:


Consider the simultaneous equation
𝑑𝑦 𝑑𝑥
= 𝑓1 (𝑥, 𝑦, 𝑧) & = 𝑓2 (𝑥, 𝑦, 𝑧)
𝑑𝑥 𝑑𝑧
With the initial conditions 𝑦(𝑥0 ) = 𝑦0 , 𝑧(𝑥0 ) = 𝑧0 now starting from (𝑥0 , 𝑦0 , 𝑧0 )
the increment k and l in y and z are given by the following formula

𝑘1 = ℎ𝑓1 (𝑥0 , 𝑦0 , 𝑧0 ) ; 𝑙1 = ℎ𝑓2 (𝑥0 , 𝑦0 , 𝑧0 )


ℎ 𝑘1 𝑙1 ℎ 𝑘1 𝑙1
𝑘2 = ℎ𝑓1 (𝑥0 + , 𝑦0 + , 𝑧0 + ) ; 𝑙2 = ℎ𝑓2 (𝑥0 + , 𝑦0 + , 𝑧0 + )
2 2 2 2 2 2
ℎ 𝑘2 𝑙2 ℎ 𝑘2 𝑙2
𝑘3 = ℎ𝑓1 (𝑥0 + , 𝑦0 + , 𝑧0 + ) ; 𝑙3 = ℎ𝑓2 (𝑥0 + , 𝑦0 + , 𝑧0 + )
2 2 2 2 2 2
𝑘4 = ℎ𝑓1 (𝑥0 + ℎ, 𝑦0 + 𝑘3 , 𝑧0 + 𝑙3 ) ; 𝑙4 = ℎ𝑓2 (𝑥0 + ℎ, 𝑦0 + 𝑘3 , 𝑧0 + 𝑙3 )

134
(𝑘1 + 2𝑘2 + 2𝑘3 + 𝑘4 )
𝑘=
6
(𝑙1 + 2𝑙2 + 2𝑙3 + 𝑙4 )
𝑙=
6
y1 = y0 + k, z1 = z0 + l

To compute y2,z2 we simply replace x0,y0,z0 by x1,y1,z1 in the above formulae

If we consider the second order R.K method

𝑘1 = ℎ𝑓1 (𝑥0 , 𝑦0 , 𝑧0 ) ; 𝑙1 = ℎ𝑓2 (𝑥0 , 𝑦0 , 𝑧0 )

𝑘2 = ℎ𝑓1 (𝑥0 + ℎ, 𝑦0 + 𝑘1 , 𝑧0 + 𝑙1 ) ; 𝑙2 = ℎ𝑓2 (𝑥0 + ℎ, 𝑦0 + 𝑘1 , 𝑧0 + 𝑙1 )


𝑘1 + 𝑘2 𝑙1 + 𝑙2
𝑘= ; 𝑙=
2 2
𝑦1 = 𝑦0 + 𝑘 ; 𝑧1 = 𝑧0 + 𝑘
𝑑𝑦 𝑑𝑧
Example: Solve = 𝑦𝑧 + 𝑥; = 𝑥𝑧 + 𝑦 given that y(0)=1,z(0)=-1 for
𝑑𝑥 𝑑𝑥
y(0.1),z(0.1)

Solution:

Here,

𝑓1 (𝑥, 𝑦, 𝑧) = 𝑦𝑧 + 𝑥 ; 𝑓2 (𝑥, 𝑦, 𝑧) = 𝑥𝑧 + 𝑦

let h=0.1 x0=0, y0=1, z0=-1

𝑘1 = ℎ𝑓1 (𝑥0 , 𝑦0 , 𝑧0 ) = 0.1𝑓1 (0,1, −1) = 0.1(1 × −1 + 0) = −0.1

𝑙1 = ℎ𝑓2 (𝑥0 , 𝑦0 , 𝑧0 ) = 0.1𝑓2 (0,1, −1) = 0.1(0 × −1 + 1) = 0.1


ℎ 𝑘1 𝑙1
𝑘2 = ℎ𝑓1 (𝑥0 + , 𝑦0 + , 𝑧0 + )
2 2 2
0.1 −0.1 0.1
= 0.1𝑓1 (0 + ,1 + , −1 + )
2 2 2
= 0.1𝑓1 (0.05,0.95, −0.95)

= 0.1(0.95 × −0.95 + 0.05)

= −0.08525
135
ℎ 𝑘1 𝑙1
𝑙2 = ℎ𝑓2 (𝑥0 + , 𝑦0 + , 𝑧0 + )
2 2 2
0.1 −0.1 0.1
= 0.1𝑓2 (0 + ,1 + , −1 + )
2 2 2
= 0.1(0.05 × −0.95 + 0.95)

= 0.09025

ℎ 𝑘2 𝑙2
𝑘3 = ℎ𝑓1 (𝑥0 + , 𝑦0 + , 𝑧0 + )
2 2 2
0.1 −0.08525 0.09025
= 0.1𝑓1 (0 + ,1 + , −1 + )
2 2 2
= 0.1𝑓1 (0.05,0.95738, −0.95738)

= 0.1(0.95738 × −0.95738 + 0.05) = −0.08666

ℎ 𝑘2 𝑙2
𝑙3 = ℎ𝑓2 (𝑥0 + , 𝑦0 + , 𝑧0 + )
2 2 2
0.1 −0.0891 0.0903
= 0.1𝑓2 (0 + ,1 + , −1 + )
2 2 2
= 0.1𝑓2 (0.05,0.95738, −0.95738)

= 0.1(0.05 × −0.95738, +0.95738)

= 0.09095

𝑘4 = ℎ𝑓1 (𝑥0 + ℎ, 𝑦0 + 𝑘3 , 𝑧0 + 𝑙3 )

= 0.1𝑓1 (0 + 0.1,1 + (−0.08666), −1 + 0.09095)

= 0.1𝑓1 (0.1,0.91334, −0.90905)

= 0.1(0.91334 × −0.90905 + 0.1)

= −0.07303

136
𝑙4 = ℎ𝑓2 (𝑥0 + ℎ, 𝑦0 + 𝑘3 , 𝑧0 + 𝑙3 )

= 0.1𝑓2 (0 + 0.1,1 + (−0.0862), −1 + 0.0907)

= 0.1𝑓2 (0.1,0.91334, −0.90905)

= 0.1(0.1 × −0.90905 + 0.91334)

= 0.08224

(𝑘1 + 2𝑘2 + 2𝑘3 + 𝑘4 )


𝑘=
6
(−0.1 + 2 × −0.8525 + 2 × −0.08666 − 0.07303)
=
6
= −0.08614
(𝑙1 + 2𝑙2 + 2𝑙3 + 𝑙4 )
𝑙=
6
(0.1 + 2 × 0.09025 + 2 × 0.09095 + 0.082224)
=
6
= 0.09077

𝑦1 = 𝑦(0.1) = 𝑦0 + 𝑘 = 1 + (−0.08614) = 0.91386

𝑧1 = 𝑧(0.1) = 𝑧0 + 𝑙 = −1 + 0.09077 = −0.90923

Practice: Compute y(0.2) & z(0.2) in the above solution.

Higher order equations:


A higher order differential equation is in the form

𝑑𝑚 𝑦 𝑑𝑦 𝑑2 𝑦
= 𝑓(𝑥, 𝑦, , 2 . . . . ). . . . . . 𝑎
𝑑𝑥 𝑚 𝑑𝑥 𝑑𝑥
With m initial conditions given as

𝑦(𝑥0 ) = 𝑎1 , 𝑦 ′ (𝑥0 ) = 𝑎2 . . . . . 𝑦 𝑚−1 (𝑥0 ) = 𝑎𝑚

137
we can replace equation a by a system of first order equation as follows. Let us
denote

𝑑𝑦 𝑑2 𝑦
𝑦 = 𝑦1 , = 𝑦2 , 2 = 𝑦3 . . . ..
𝑑𝑥 𝑑𝑥
then
𝑑𝑦1
= 𝑦2 𝑦1 (𝑥0 ) = 𝑦1,0 = 𝑎1
𝑑𝑥
𝑑𝑦2
= 𝑦3 𝑦2 (𝑥0 ) = 𝑦2,0 = 𝑎2
𝑑𝑥
….
𝑑𝑦𝑚−1
= 𝑦𝑚 𝑦𝑚−1 (𝑥0 ) = 𝑦𝑚−1,0 = 𝑎𝑚−1
𝑑𝑥
𝑑𝑦𝑚
= 𝑓(𝑥1 , 𝑦2 , 𝑦2 . . . 𝑦𝑚 ) 𝑦𝑚 (𝑥0 ) = 𝑦𝑚,0 = 𝑎𝑚
𝑑𝑥
This system is similar to the system of first order with the condition,

𝑓𝑖 = 𝑦𝑖+1 , 𝑖 = 1,2, . . . . 𝑚 − 1

𝑓𝑚 = 𝑓(𝑥, 𝑦1 , 𝑦2 . . . 𝑦𝑚 )

RK method for second order differential equations:


Consider the second order differential equation
𝑑2𝑦 𝑑𝑦
= 𝜙 [𝑥, 𝑦, ] 𝑦(𝑥0 ) = 𝑦0 , 𝑦 ′ (𝑥0 ) = 𝑦 ′ 0 , 𝑧(𝑥0 ) = 𝑧0 . . . . . . . . (𝑎)
𝑑𝑥 2 𝑑𝑥

𝑑𝑦 𝑑2𝑦 𝑑𝑧
Let = 𝑧, 𝑡ℎ𝑒𝑛 , =
𝑑𝑥 𝑑𝑥 2 𝑑𝑥

Substituting equation (a) we get


𝑑𝑧
= 𝑧 = ∅(𝑥, 𝑦, 𝑧), 𝑦(𝑥0 ) = 𝑦0 , 𝑧(𝑥0 ) = 𝑧0
𝑑𝑥

The problem reduces to


𝑑𝑦 𝑑𝑧
= 𝑧 = 𝑓1 (𝑥, 𝑦, 𝑧) & = 𝑧 ′ = 𝑓2 (𝑥, 𝑦, 𝑧) subjected to 𝑦(𝑥0 ) = 𝑦0 , 𝑧(𝑥0 ) =
𝑑𝑥 𝑑𝑥
𝑧0 and this can be solved as before.

138
Example : Solve 𝑦 " = 𝑥𝑦 ′ − 𝑦, 𝑦(0) = 3, 𝑦 ′ (0) = 0 to approximate y(0.1).

Given:

𝑦 " = 𝑥𝑦 ′ − 𝑦, 𝑦(0) = 3, 𝑦 ′ (0) = 0, ℎ = 0.1


𝑑𝑦
Let = 𝑦 ′ = 𝑧, then 𝑦 " = 𝑧 ′ , above equation reduces to
𝑑𝑥

𝑦 ′ = 𝑧 = 𝑓1 (𝑥, 𝑦, 𝑧)

𝑦 " = 𝑧 ′ = 𝑥𝑦 ′ − 𝑦 = 𝑥𝑧 − 𝑦 = 𝑓2 (𝑥, 𝑦, 𝑧)

Subjected to y(0)=3 & z(0) =0 .i.e 𝑥0 = 0, 𝑦0 = 3, 𝑧0 = 0

Now,

𝑘1 = ℎ𝑓1 (𝑥0 , 𝑦0 , 𝑧0 ) = ℎ(𝑧0 ) = 0.1 × 0 = 0

𝑙1 = ℎ𝑓2 (𝑥0 , 𝑦0 , 𝑧0 ) = ℎ𝑓2 (0,3,0) = 0.1 × (0 × 0 − 3) = −0.3


ℎ 𝑘1 𝑙1
𝑘2 = ℎ𝑓1 (𝑥0 + , 𝑦0 + , 𝑧0 + )
2 2 2
0.1 0 0.3
= ℎ𝑓1 (0 + , 3 + , 0 + (− ))
2 2 2

= ℎ𝑓1 (0.05,3, −0.15)

= 0.1(−0.15)

= −0.015

0.1 0 0.3
𝑙2 = 0.1𝑓2 (0 + ,3 + ,0 − )
2 2 2
= 0.1𝑓2 (0.05,3, −0.15)

= 0.1(0.05 × −0.0015 − 3) = −0.3001

0.1 −0.15 −0.3001


𝑘3 = ℎ𝑓1 (0 + ,3 + ,0 + )
2 2 2

139
= 0.1𝑓1 (0.05,2.925, −0.1501)

= 0.1 × −0.1501

= −0.0150

0.1 −0.15 −0.3001


𝑙3 = ℎ𝑓2 (0 + ,3 + ,0 + )
2 2 2
= 0.1𝑓2 (0.05,2.925, −0.1501)

= 0.1(0.05 × −0.1501 − 2.925)

= −0.2933

𝑘4 = ℎ𝑓1 (0 + 0.1,3 + (−0.0150),0 + (−0.2933))

= 0.1𝑓1 (0.1,2.9850, −2.933)

= 0.1 × −0.2933

= −0.0293

𝑙4 = ℎ𝑓2 (0 + 0.1,3 + (−0.0150),0 + (−0.2933))

= 0.1𝑓2 ((0.1,2.9850, −2.933))

= 0.1(0.1 × −0.293 − 2.9850)

= −0.3014

(𝑘1 + 2𝑘2 + 2𝑘3 + 𝑘4 )


𝑘=
6
(0 + 2 × −0.015 + 2 × −0.0150 − 0.0293)
=
6
= −0.0149

140
(𝑙1 + 2𝑙2 + 2𝑙3 + 𝑙4 )
𝑙=
6
(−0.3 + 2 × −0.3001 + 2 × −0.2933 − 0.3014)
=
6
= −0.2980

𝑦1 = 𝑦(0.1) = 𝑦0 + 𝑘 = 3 + (−0.3014) = 2.6986

𝑧1 = 𝑧(0.1) = 𝑧0 + 𝑙 = 0 − 0.2980 = −0.2980

Picard method of successive approximation


𝑑𝑦
Consider the first order differential equation = 𝑓(𝑥, 𝑦) subjected to 𝑦(𝑥0 ) =
𝑑𝑥
𝑦0 . We can integrate this to obtain the solution in the interval(x0,x).

The above equation can be written as dy = f(x, y)dx

Integrating between the limits , we get


𝑦 𝑥
∫ 𝑑𝑦 = ∫ 𝑓(𝑥, 𝑦)𝑑𝑥
𝑦0 𝑥0

𝑥
𝑦 − 𝑦0 = ∫ 𝑓(𝑥, 𝑦)𝑑𝑥
𝑥0

𝑥
𝑦 = 𝑦0 + ∫ 𝑓(𝑥, 𝑦)𝑑𝑥
𝑥0

𝑥
𝑦(𝑥) = 𝑦(𝑥0 ) + ∫ 𝑓(𝑥, 𝑦)𝑑𝑥
𝑥0

Since y appears under the integral sign on the right, the integration cannot be
formed. The dependent variable should be replaced by either a constant or a
function of x, since we know the initial value of y at x=x0 we may use this as a
first approximation to the solution and the result can be used on the right hand
side to obtain the next approximation.

Now by Picard’s methods first approximation we replace y by y0 in f(x,y) i.e

141
𝑥
𝑦1 = 𝑦0 + ∫ 𝑓(𝑥, 𝑦0 )𝑑𝑥
𝑥0

For second approximation y2 replace y by y1


𝑥
𝑦2 = 𝑦0 + ∫ 𝑓(𝑥, 𝑦1 )𝑑𝑥 … ..
𝑥0

𝑥
𝑦𝑛 = 𝑦0 + ∫ 𝑓(𝑥, 𝑦𝑛−1 )𝑑𝑥
𝑥0

The process is to be stopped when two values of y, are same to desired degree of
accuracy

Note:

1. This method is applicable only to a limited class of equations in which the


successive integration can be perform easily.
2. Sometimes it may not be possible to carry out the integration.
3. It is not convenient method for computer-based solution.

Example : Use Picard’s method to approximate the value of y when


x=0.1,0.2,0.3,0.4 & 0.5. given that y=1 at x=0, y’=1+xy, correct up to three
decimal places

Given
𝑑𝑦
= 1 + 𝑥𝑦 ; 𝑦(0) = 1
𝑑𝑥
𝑓(𝑥, 𝑦) = 1 + 𝑥𝑦, 𝑦0 = 1, 𝑥0 = 0

first approximation
𝑥 𝑥
𝑦1 = 𝑦0 + ∫ 𝑓(𝑥, 𝑦0 )𝑑𝑥 = 1 + ∫ (1 + 𝑥𝑦0 )𝑑𝑥
𝑥0 0

𝑥
= 1 + ∫ (1 + 𝑥 )𝑑𝑥
0

𝑥2
=1+𝑥+
2

142
Second approximation
𝑥
𝑦2 = 𝑦0 + ∫ 𝑓 (𝑥, 𝑦1 )𝑑𝑥
𝑥0

𝑥
= 1 + ∫ (1 + 𝑥𝑦1 )𝑑𝑥
0

𝑥
𝑥2
= 1 + ∫ (1 + 𝑥 (1 + 𝑥 + )) 𝑑𝑥
0 2

𝑥2 𝑥3 𝑥4
= 1+𝑥+ + +
2 3 8

Third approximation
𝑥
𝑦3 = 𝑦0 + ∫ 𝑓(𝑥, 𝑦2 )𝑑𝑥
𝑥0

𝑥
= 1 + ∫ (1 + 𝑥𝑦2 )𝑑𝑥
0

𝑥
𝑥2 𝑥3 𝑥4
= 1 + ∫ (1 + 𝑥 (1 + 𝑥 + + + )) 𝑑𝑥
0 2 3 8

𝑥2 𝑥3 𝑥4 𝑥5 𝑥6
= 1+𝑥+ + + + +
2 3 8 15 48

Fourth approximation
𝑥
𝑦4 = 𝑦0 + ∫ 𝑓(𝑥, 𝑦3 )𝑑𝑥
𝑥0

𝑥
= 1 + ∫ (1 + 𝑥𝑦3 )𝑑𝑥
0

𝑥
𝑥2 𝑥3 𝑥4 𝑥5 𝑥6
= 1 + ∫ (1 + 𝑥 ( 1 + 𝑥 + + + + + )) 𝑑𝑥
0 2 3 8 15 48

143
𝑥2 𝑥3 𝑥4 𝑥5 𝑥6 𝑥7 𝑥8
= 1+𝑥+ + + + + + +
2 3 8 15 48 105 348
Now at x=0.1

Y1=1.1050

Y2=1.1053

Y3=1.1053

Since the value is correct up to three decimal places y(0.1)=1.105

Shooting method
This method is called shooting method because it resembles an artillery problem.
In this method the given boundary value problem is first converted into an
equivalent initial value problem an then solved using any of the method discussed
in previous section.

Consider the equation

𝑦 " = 𝑓(𝑥, 𝑦, 𝑦 ′ ) 𝑦(𝑎) = 𝐴, 𝑦(𝑏) = 𝐵

Letting 𝑦 ′ = 𝑧, we obtain the following set of two equations 𝑦 ′ = 𝑧 , 𝑧 ′ =


𝑓(𝑥, 𝑦, 𝑧). In order to solve this set as initial value problem we need two
conditions at x=a, we have one condition y(a)=A and therefore require another
condition for z at x=a. let us assume that 𝑧(𝑎) = 𝑀1 , where M1 is a guess. Note
M1 represents the slope 𝑦 ′ (𝑥) 𝑎𝑡 𝑥 = 𝑎 thus the problem is reduced to as system
two first order equation with initial conditions

𝑦′ = 𝑧 𝑦 (𝑎 ) = 𝐴

𝑧 ′ = 𝑓(𝑥, 𝑦, 𝑧) 𝑧(𝑎) = 𝑀1 … … (𝑎)

Equation a can be solved for y and z, using any one step method, using steps of
h, until the solution at x=b is reached. Let the estimated value of y(x) at x=b be
B1, if B1=B then we have obtained the required solution. In practice it is very
unlikely that our initial guess z(a)=M1 is correct.

If 𝐵1 ≠ 𝐵 then we obtain the solution with another guess say z(a) =M2. Let new
estimate of y(x) be at x=b be B2. If B2 is not equal to B then process is continued
till we obtain the correct estimate of y(b). However the procedure can be

144
accelerated by suing an improves guess for z(a) after estimates of B1 & B2 are
obtained.

Let us assume that z(a)=M3 lead to the value of y(b)=B, if we assume that values
of M and B are linearly related then
𝑀3 − 𝑀2 𝑀2 − 𝑀1
=
𝐵 − 𝐵2 𝐵2 − 𝐵1
𝐵 − 𝐵2
𝑀3 = 𝑀2 + (𝑀 − 𝑀1 )
𝐵2 − 𝐵1 2
𝐵2 − 𝐵
𝑀3 = 𝑀2 − (𝑀 − 𝑀1 )
𝐵2 − 𝐵1 2

Now with z(a)=M3, we can again obtain the solution of y(x).


𝑑2 𝑦
Example : using shooting method solve the equation = 6𝑥, 𝑦(1) =
𝑑𝑥 2
2, 𝑦(2) = 9 in the interval (1,2)

Solution

By transformation
𝑑𝑦 𝑑𝑧
= 𝑧 = 𝑓1 (𝑥, 𝑦, 𝑧), 𝑦(1) = 2 , = 6𝑥 = 𝑓2 (𝑥, 𝑦, 𝑧)
𝑑𝑥 𝑑𝑥
145
Let us assume that 𝑧(1) = 𝑦 ′ (1) = 2(𝑀1 𝑠𝑎𝑦), applying Heun’s method we
obtain the solution as follows

Iteration 1:

h=0.5, x0=1, y(1)=y0=2, z(1)=z0=2


𝑚1 + 𝑚2
𝑦𝑖+1 = 𝑦𝑖 + ( )ℎ
2
𝑚1 (1) = 𝑓1 (𝑥0 , 𝑦0 , 𝑧0 ) = 𝑓1 (1,2,2) = 𝑧0 = 2

𝑚1 (2) = 𝑓2 (𝑥0 , 𝑦0 , 𝑧0 ) = 𝑓2 (1,2,2) = 6𝑥0 = 6 × 1 = 6

𝑚2 (1) = 𝑓1 (𝑥0 + ℎ, 𝑦0 + 𝑚1 (1)ℎ, 𝑧0 + hm1 (2))

= 𝑓1 (1 + 0.5,2 + 2 × 0.5,2 + 6 × 0.5)

= 𝑓1 (1.5,3,5)

=5

𝑚2 (2) = 𝑓2 (𝑥0 + ℎ, 𝑦0 + 𝑚1 (1)ℎ, 𝑧0 + hm1 (2))

= 𝑓2 (1 + 0.5,2 + 2 × 0.5,2 + 6 × 0.5)

= 𝑓1 (1.5,3,5)

=6×𝑥

= 6 × 1.5

=9

𝑚1 (1) + 𝑚2 (1) 2 + 5
𝑚(1) = = = 3.5
2 2
𝑚1 (2) + 𝑚2 (2) 6 + 9
𝑚(2) = = = 7.5
2 2

𝑦(𝑥1 ) = 𝑦(1.5) = 𝑦(1) + 𝑚(1)ℎ = 2 + 3.5 × 0.5 = 3.75

𝑧(𝑥1 ) = 𝑧(1.5) = 𝑧(1) + 𝑚(2)ℎ = 2 + 7.5 × 0.5 = 5.75

146
iteration 2 :

h=0.5, x1=1.5, y1=3.75, z1=5.75

𝑚1 (1) = 𝑓1 (𝑥1 , 𝑦1 , 𝑧1 ) = 𝑧1 = 5.75

𝑚1 (2) = 𝑓2 (𝑥1 , 𝑦1 , 𝑧1 ) = 6𝑥1 = 6 × 1.5 = 9

𝑚2 (1) = 𝑓1 (𝑥1 + ℎ, 𝑦1 + 𝑚1 (1)ℎ, 𝑧1 + hm1 (2))

= 𝑓1 (1.5 + 0.5,3.75 + 5.75 × 0.5,5.75 + 9 × 0.5)

= 𝑓1 (2,6.625,10.25)

= 10.25

𝑚2 (2) = 𝑓2 (𝑥1 + ℎ, 𝑦1 + 𝑚1 (1)ℎ, 𝑧1 + hm1 (2))

= 𝑓2 (1.5 + 0.5,3.75 + 5.75 × 0.5,5.75 + 9 × 0.5)

= 𝑓1 (2,6.625,10.25)

=6×𝑥

=6×2

= 12
𝑚1 (1) + 𝑚2 (1) 5.75 + 10.25
𝑚(1) = = =8
2 2
𝑚1 (2) + 𝑚2 (2) 9 + 12
𝑚(2) = = = 10.5
2 2
𝑦(𝑥2 ) = 𝑦(2) = 𝑦(1) + 𝑚(1)ℎ = 3.75 + 8 × 0.5 = 7.75

This gives B1=7.75 which is less than B=9

Now let us assume z (1) =y’ (1) =4(M2) and again estimate y (2)

Iteration 1:

h=0.5, x0=1, y(1)=y0=2, z(1)=z0=4

147
𝑚1 + 𝑚2
𝑦𝑖+1 = 𝑦𝑖 + ( )ℎ
2
𝑚1 (1) = 𝑓1 (𝑥0 , 𝑦0 , 𝑧0 ) = 𝑓1 (1,2,4) = 𝑧0 = 4

𝑚1 (2) = 𝑓2 (𝑥0 , 𝑦0 , 𝑧0 ) = 𝑓2 (1,2,4) = 6𝑥0 = 6 × 1 = 6

𝑚2 (1) = 𝑓1 (𝑥0 + ℎ, 𝑦0 + 𝑚1 (1)ℎ, 𝑧0 + hm1 (2))

= 𝑓1 (1 + 0.5,2 + 4 × 0.5,4 + 6 × 0.5)

= 𝑓1 (1.5,4,7)

=7

𝑚2 (2) = 𝑓2 (𝑥0 + ℎ, 𝑦0 + 𝑚1 (1)ℎ, 𝑧0 + hm1 (2))

= 𝑓2 (1 + 0.5,2 + 4 × 0.5,4 + 6 × 0.5)

= 𝑓1 (1.5,4,7)

=6×𝑥

= 6 × 1.5

=9

𝑚1 (1) + 𝑚2 (1) 4 + 7
𝑚(1) = = = 5.5
2 2
𝑚1 (2) + 𝑚2 (2) 6 + 9
𝑚(2) = = = 7.5
2 2

𝑦(𝑥1 ) = 𝑦(1.5) = 𝑦(1) + 𝑚(1)ℎ = 2 + 5.5 × 0.5 = 4.75

𝑧(𝑥1 ) = 𝑧(1.5) = 𝑧(1) + 𝑚(2)ℎ = 4 + 7.5 × 0.5 = 7.75

iteration 2 :

h=0.5, x1=1.5, y1=4.75, z1=7.75

148
𝑚1 (1) = 𝑓1 (𝑥1 , 𝑦1 , 𝑧1 ) = 𝑧1 = 7.75

𝑚1 (2) = 𝑓2 (𝑥1 , 𝑦1 , 𝑧1 ) = 6𝑥1 = 6 × 1.5 = 9

𝑚2 (1) = 𝑓1 (𝑥1 + ℎ, 𝑦1 + 𝑚1 (1)ℎ, 𝑧1 + hm1 (2))

= 𝑓1 (1.5 + 0.5,4.75 + 7.75 × 0.5,7.75 + 9 × 0.5)

= 𝑓1 (2,8.625,12.25)

= 12.25

𝑚2 (2) = 𝑓2 (𝑥1 + ℎ, 𝑦1 + 𝑚1 (1)ℎ, 𝑧1 + hm1 (2))

= 𝑓2 (1.5 + 0.5,4.75 + 7.75 × 0.5,7.75 + 9 × 0.5)

= 𝑓1 (2,8.625,12.25)

=6×𝑥

=6×2

= 12
𝑚1 (1) + 𝑚2 (1) 7.75 + 12.25
𝑚(1) = = = 10
2 2
𝑚1 (2) + 𝑚2 (2) 9 + 12
𝑚(2) = = = 10.5
2 2
𝑦(𝑥2 ) = 𝑦(2) = 𝑦(1) + 𝑚(1)ℎ = 4.75 + 10 × 0.5 = 9.75

Which is greater than B=9, now let us have the third estimate of z(1)=M 3 using
the relationship
𝐵2 − 𝐵
𝑀3 = 𝑀2 − (𝑀 − 𝑀1 )
𝐵2 − 𝐵1 2
9.75 − 9
𝑀3 = 4 − (4 − 2)
9.75 − 7.75
= 3.25

The new estimate for z(1)=y’(1)=3.25

149
Iteration 1:

h=0.5, x0=1, y(1)=y0=2, z(1)=z0=3.25

𝑚1 + 𝑚2
𝑦𝑖+1 = 𝑦𝑖 + ( )ℎ
2
𝑚1 (1) = 𝑓1 (𝑥0 , 𝑦0 , 𝑧0 ) = 𝑓1 (1,2,3.25) = 𝑧0 = 3.25

𝑚1 (2) = 𝑓2 (𝑥0 , 𝑦0 , 𝑧0 ) = 𝑓2 (1,2,3.25) = 6𝑥0 = 6 × 1 = 6

𝑚2 (1) = 𝑓1 (𝑥0 + ℎ, 𝑦0 + 𝑚1 (1)ℎ, 𝑧0 + hm1 (2))

= 𝑓1 (1 + 0.5,2 + 3.25 × 0.5,3.25 + 6 × 0.5)

= 𝑓1 (1.5,3.625,6.25)

= 6.25

𝑚2 (2) = 𝑓2 (𝑥0 + ℎ, 𝑦0 + 𝑚1 (1)ℎ, 𝑧0 + hm1 (2))

= 𝑓2 (1 + 0.5,2 + 3.25 × 0.5,3.25 + 6 × 0.5)

= 𝑓1 (1.5,3.625,6.25)

=6×𝑥

= 6 × 1.5

=9

𝑚1 (1) + 𝑚2 (1) 3.25 + 6.25


𝑚(1) = = = 4.75
2 2
𝑚1 (2) + 𝑚2 (2) 6 + 9
𝑚(2) = = = 7.5
2 2

𝑦(𝑥1 ) = 𝑦(1.5) = 𝑦(1) + 𝑚(1)ℎ = 2 + 4.75 × 0.5 = 4.375

150
𝑧(𝑥1 ) = 𝑧(1.5) = 𝑧(1) + 𝑚(2)ℎ = 3.25 + 7.5 × 0.5 = 7.

iteration 2 :

h=0.5, x1=1.5, y1=4.375, z1=7

𝑚1 (1) = 𝑓1 (𝑥1 , 𝑦1 , 𝑧1 ) = 𝑧1 = 7

𝑚1 (2) = 𝑓2 (𝑥1 , 𝑦1 , 𝑧1 ) = 6𝑥1 = 6 × 1.5 = 9

𝑚2 (1) = 𝑓1 (𝑥1 + ℎ, 𝑦1 + 𝑚1 (1)ℎ, 𝑧1 + hm1 (2))

= 𝑓1 (1.5 + 0.5,4.375 + 7 × 0.5,7 + 9 × 0.5)

= 𝑓1 (2,7.875,11.5)

= 11.5

𝑚2 (2) = 𝑓2 (𝑥1 + ℎ, 𝑦1 + 𝑚1 (1)ℎ, 𝑧1 + hm1 (2))

= 𝑓2 (1.5 + 0.5,4.375 + 7 × 0.5,7 + 9 × 0.5)

= 𝑓1 (2,7.875,11.5)

=6×𝑥

=6×2

= 12
𝑚1 (1) + 𝑚2 (1) 7 + 11.5
𝑚(1) = = = 9.25
2 2
𝑚1 (2) + 𝑚2 (2) 9 + 12
𝑚(2) = = = 10.5
2 2
𝑦(𝑥2 ) = 𝑦(2) = 𝑦(1) + 𝑚(1)ℎ = 4.375 + 9.25 × 0.5 = 9

The solution is y(1)=2, y(1.5)=4.375, y(2)=9 the exact solution is 𝑦(𝑥) = 𝑥 3 + 1


and therefore y(1.5)=4.375

151
Practice :
𝑑𝑦
1. Solve = 1 − 𝑦, 𝑦(0) = 0 𝑖𝑛 𝑡ℎ𝑒 𝑟𝑎𝑛𝑔𝑒 0 ≤ 𝑥 ≤ 0.3, using
𝑑𝑥
a. Euler’s method b. Heun’s method
𝑑𝑦 2𝑥
2. Solve =𝑦− , 𝑦(0) = 0 𝑖𝑛 𝑡ℎ𝑒 𝑟𝑎𝑛𝑔𝑒 0 ≤ 𝑥 ≤ 0.2, using
𝑑𝑥 𝑦
b. Euler’s method b. Heun’s method
3. Using Runge Kutta method of fourth order solve for y(0.1), y(0.2) & y(0.3)
given that 𝑦 ′ = 𝑥𝑦 + 𝑦 2 ,y(0)=1
4. Solve the following equation by Picard’s method 𝑦 ′ (𝑥) = 𝑥 2 + 𝑦 2 , 𝑦(0) =
0 estimate y(0.1),y(0.2)
5. Applying shooting method to solve the boundary value problem, solve
𝑦 " = 𝑦(𝑥), 𝑦(0) = 0 𝑎𝑛𝑑 𝑦(1) = 1, i.e find 𝑦 ′ (0)

152
Chapter 6: Solution of partial differential equations
Many physical phenomena in applied science and engineering when formulated
into mathematical models fall into a category of system known as partial
differential equations. A partial differential equation is a differential equation
involving more than one in independent variables.

We can write a second order equation involving two independent variables in


general form as :

𝑎𝜕 2 𝑓 𝑏𝜕 2 𝑓 𝑐𝜕 2 𝑓 𝜕𝑓 𝜕𝑓
+ + = 𝐹(𝑥, 𝑦, , ). . . . . . . . . . 1
𝜕𝑥 2 𝜕𝑥𝜕𝑦 𝜕𝑦 2 𝜕𝑥 𝜕𝑦

Where a,b,c may be constant or function of x & y

The equation 1 is classified as

i. Elliptical if 𝑏 2 − 4𝑎𝑐 < 0


ii. Parabolic if 𝑏 2 − 4𝑎𝑐 = 0
iii. Hyperbolic if 𝑏 2 − 4𝑎𝑐 > 0

Two approaches of solving PDEs are:

1. Finite difference method (where regions are regular).


2. Finite element method (where regions are irregular).

Finite difference method:


The finite difference method is based on the formula for approximating first and
second order derivatives of a function. In this method derivatives that occurs in
partial differential equation are replaced by their finite difference equivalents.
The difference equation is then written for each grid points using function values
at the surrounding grid points. Solving these equations simultaneously give the
values of the function of each grid points.

153
Figure: two-dimensional finite difference grid

𝑥𝑖+1 = 𝑥𝑖 + ℎ

𝑦𝑖+1 = 𝑦𝑖 + ℎ

We have already discussed that if the function f(x) has a continuous fourth
derivative, then it’s first and second derivatives are given by the following central
difference approximation.
𝑓(𝑥𝑖 + ℎ) − 𝑓(𝑥𝑖 − ℎ)
𝑓 ′ (𝑥𝑖 ) =
2ℎ

𝑓𝑖+1 − 𝑓𝑖−1
𝑓 ′𝑖 = . . . . . . . . . .2
2ℎ
𝑓(𝑥𝑖 + ℎ) − 2𝑓(𝑥𝑖 ) − 𝑓(𝑥𝑖 − ℎ)
𝑓 " (𝑥𝑖 ) =
ℎ2
𝑓𝑖+1 −2𝑓𝑖 − 𝑓𝑖−1
𝑓 "𝑖 = . . . . . . . . . .3
ℎ2
The subscripts on f indicate the x value at which the function is evaluated. When
f is a function of two variables x and y, the partial derivatives of f with respect x
or y are the ordinary derivatives of f with respect to x or y when y or x does not
change. We can use the equations 2 and 3 in the x direction to determine

154
derivatives with respect to x and in the y direction to determine derivatives with
respect to y. thus we have
𝜕𝑓(𝑥𝑖 , 𝑦𝑗 ) 𝑓(𝑥𝑖+1 , 𝑦𝑗 ) − 𝑓(𝑥𝑖−1 , 𝑦𝑗 )
= 𝑓𝑥 (𝑥𝑖 , 𝑦𝑗 ) =
𝜕𝑥 ℎ
𝜕𝑓(𝑥𝑖 , 𝑦𝑗 ) 𝑓(𝑥𝑖 , 𝑦𝑗+1 ) − 𝑓(𝑥𝑖 , 𝑦𝑗−1 )
= 𝑓𝑦 (𝑥𝑖 , 𝑦𝑗 ) =
𝜕𝑦 𝑘

𝜕 2 𝑓(𝑥𝑖 , 𝑦𝑗 ) 𝑓(𝑥𝑖+1 , 𝑦𝑗 ) − 2𝑓(𝑥𝑖 , 𝑦𝑗 ) + 𝑓(𝑥𝑖−1 , 𝑦𝑗 )


= 𝑓𝑥𝑥 (𝑥𝑖 , 𝑦𝑗 ) =
𝜕𝑥 2 ℎ2
𝜕 2 𝑓(𝑥𝑖 , 𝑦𝑗 ) 𝑓(𝑥𝑖 , 𝑦𝑗+1 ) − 2𝑓(𝑥𝑖 , 𝑦𝑗 ) + 𝑓(𝑥𝑖 , 𝑦𝑗−1 )
= 𝑓 (𝑥 ,
𝑦𝑦 𝑖 𝑗 𝑦 ) =
𝜕𝑦 2 𝑘2

𝜕 2 𝑓(𝑥𝑖 , 𝑦𝑗 ) 𝑓(𝑥𝑖+1 , 𝑦𝑗+1 ) − 𝑓(𝑥𝑖+1 , 𝑦𝑗−1 ) − 𝑓(𝑥𝑖−1 , 𝑦𝑗+1 ) + 𝑓(𝑥𝑖−1 , 𝑦𝑗−1 )


=
𝜕𝑥𝜕𝑦 4ℎ𝑘

It would be convenient to use double subscripts i,j on f to indicate x and y values.


Then above equation become
𝑓𝑖+1,𝑗 − 𝑓𝑖−1,𝑗
𝑓𝑥,𝑖,𝑗 =

𝑓𝑖,𝑗+1 − 𝑓𝑖,𝑗−1
𝑓𝑦,𝑖,𝑗 =
𝑘
𝑓𝑖+1,𝑗 − 2𝑓𝑖,𝑗 + 𝑓𝑖−1,𝑗
𝑓𝑥𝑥,𝑖,𝑗 =
ℎ2
𝑓𝑖,𝑗+1 − 2𝑓𝑖,𝑗 + 𝑓𝑖,𝑗−1
𝑓𝑦𝑦,𝑖,𝑗 =
𝑘2
𝑓𝑖+1,𝑗+1 − 𝑓𝑖+1,𝑗−1 − 𝑓𝑖−1,𝑗+1 + 𝑓𝑖−1,𝑗−1
𝑓𝑥𝑦,𝑖,𝑗 =
2ℎ𝑘
We will use these finite difference equivalents of the partial derivatives to
construct various types of differential equations.

Elliptical equations
Elliptical equations are governed by condition on the boundary of closed domain.
We consider here the two most commonly encountered elliptical equations.

a. Laplace’s equation

155
b. Poisson’s equation

Laplace’s equation
Any equation of the form ∇2 𝑓 = 0 is called laplace’s equation, where
2
𝜕2 𝜕2
∇ = 2 + 2 .....4
𝜕𝑥 𝜕𝑦
2 2
𝜕 𝑓 𝜕 𝑓
∴ 2
+ 2 = ∇2 𝑓 = 0. . . . . .5
𝜕𝑥 𝜕𝑦

𝜕𝑓 𝜕𝑓
Where a=1,b=0,c=1 and F(x,y, , )=0
𝜕𝑥 𝜕𝑦
Where ∇2 is called Laplacian operator, above equation can be written as
𝑈𝑥𝑥 + 𝑈𝑦𝑦 = 0
Replacing the second order derivatives by their finite difference equivalents, at
points (𝑥𝑖 , 𝑦𝑖 ) we get
𝑓𝑖+1,𝑗 − 2𝑓𝑖𝑗 + 𝑓𝑖−1,𝑗 𝑓𝑖,𝑗+1 − 2𝑓𝑖𝑗 + 𝑓𝑖,𝑗−1
∇2 𝑓𝑖𝑗 = + = 0. . . . . . 6
ℎ2 𝑘2
If we assume for simplicity, h=k, then we get

𝑓𝑖+1,𝑗 − 2𝑓𝑖𝑗 + 𝑓𝑖−1,𝑗 𝑓𝑖,𝑗+1 − 2𝑓𝑖𝑗 + 𝑓𝑖,𝑗−1


∇2 𝑓𝑖𝑗 = +
ℎ2 ℎ2
𝑓𝑖+1,𝑗 + 𝑓𝑖−1,𝑗 − 4𝑓𝑖𝑗 + 𝑓𝑖,𝑗+1 + 𝑓𝑖,𝑗−1
∇2 𝑓𝑖𝑗 = .......7
ℎ2
𝑓𝑖+1,𝑗 + 𝑓𝑖−1,𝑗 − 4𝑓𝑖𝑗 + 𝑓𝑖,𝑗+1 + 𝑓𝑖,𝑗−1 = 0
This is called Laplace’s equation

Above equation contains four neighboring points around central points (𝑥𝑖 , 𝑦𝑖 ) as
shown in figure, the above equation is known as five point difference formula for
Laplace’s equation.

156
figure: Grid for Laplace equation

we can also represent the relationship of pivotal values pictorially as below.

1 1
2
∇ 𝑓𝑖𝑗 = 2 {1 −4 1} 𝑓𝑖𝑗 = 0 . . . . . . . 8

1
From above equation we can show that the function value at grid point(𝑥𝑖 , 𝑦𝑖 ) is
the average of the values at the four adjoining points. i.e
1
𝑓𝑖𝑗 = (𝑓𝑖+1,𝑗 + 𝑓𝑖−1,𝑗 +𝑓𝑖,𝑗+1 + 𝑓𝑖,𝑗−1 ). . . . . . . . 9
4

To evaluate numerically the solution of Laplace equation at the grid points we


can apply equation 9 at the grid points where 𝑓𝑖𝑗 is required thus obtaining a
system of linear equations in the pivotal values of 𝑓𝑖𝑗 . The system of linear
equations may be solved using either direct or iterative methods.

Example: Consider a steel plate of size 15cm x 15cm, if two of the sides are held
at 100oc and other two sides are held at 0oc, what are the steady state temperatures
at interior points assuming a grid of size 5cm x 5cm.

Note: A problem with values known on each boundary is said to have Dirichlet
boundary condition. This problem is illustrated below.

157
The system of equation is as follows:

Point 1:

100 + 100 + 𝑓3 + 𝑓2 − 4𝑓1 = 0 … … . .1

Point 2:

𝑓1 + 100 + 𝑓4 + 0 − 4𝑓2 = 0. . . . . . . .2

Point 3:

100 + 𝑓1 + 0 + 𝑓4 − 4𝑓3 = 0. . . . . . . .3

Point 4:

𝑓3 + 𝑓2 + 0 + 0 − 4𝑓4 = 0. . . . . . . .4

On solving above four equations we get the values as:

𝑓1 = 75, 𝑓2 = 50, 𝑓3 = 50, 𝑓4 = 25

So we can see the interior temperature points as above.

Note: for solving use any iterative methods that you have learned in chapter 4.

158
Poisson’s equation
If we put a=1, b=0, c=1 in the equation and F(x,y,f,𝑓𝑥 , 𝑓𝑦 )=g(x,y) then

𝑎𝜕 2 𝑓 𝑏𝜕 2 𝑓 𝑐𝜕 2 𝑓 𝜕𝑓 𝜕𝑓
+ + = 𝐹 (𝑥, 𝑦, , )
𝜕𝑥 2 𝜕𝑥𝜕𝑦 𝜕𝑦 2 𝜕𝑥 𝜕𝑦

We get

𝜕 2 𝑓 𝑐𝜕 2 𝑓
+ = 𝑔(𝑥, 𝑦)
𝜕𝑥 2 𝜕𝑦 2

∇2 𝑓 = 𝑔(𝑥, 𝑦) … … . . 𝑎

The above equation a is called poisson’s equation using the notation 𝑔𝑖𝑗 =
𝑔(𝑥𝑖 , 𝑦𝑖 ) and laplace equation may be modified to solve the equation a. the finite
difference formula for solving poisson’s equation then takes of the form

𝑓𝑖+1,𝑗 + 𝑓𝑖−1,𝑗 + 𝑓𝑖,𝑗+1 + 𝑓𝑖,𝑗−1 − 4𝑓𝑖𝑗 = ℎ2 𝑔𝑖𝑗 … … . . 𝑏

Example: Solve the poisson’s equation ∇2 𝑓 = 2𝑥 2 𝑦 2 over the square domain 0 ≤


𝑥 ≤ 3 & 0 ≤ 𝑦 ≤ 3 with f=0 on the boundary and h=1.

The domain is divided into squares of one unit size as in figure.

159
By applying equations b at each grid points

Point 1:

0 + 0 + 𝑓3 + 𝑓2 − 4𝑓1 = 12 𝑔(1,2)

𝑓2 +𝑓3 − 4𝑓1 = 2𝑥12 𝑥22

𝑓2 +𝑓3 − 4𝑓1 = 8 . . . . . . . . 1

Point 2:

𝑓1 + 0 + 0 + 𝑓4 − 4𝑓2 = 12 𝑔(2,2)

𝑓1 +𝑓4 − 4𝑓2 = 2𝑥22 𝑥22

𝑓1 − 4𝑓2 + 𝑓4 = 32 . . . . . . . . 2

Point 3:

0 + 𝑓1 + 0 + 𝑓4 − 4𝑓3 = 12 𝑔(1,1)

𝑓1 +𝑓4 − 4𝑓3 = 2𝑥12 𝑥12

𝑓1 − 4𝑓3 + 𝑓4 = 2 . . . . . . . . 3

Point 4:

𝑓3 + 𝑓2 + 0 + 0 − 4𝑓4 = 12 𝑔(2,1)

𝑓2 +𝑓3 − 4𝑓4 = 2𝑥22

𝑓2 + 𝑓3 − 4𝑓4 = 8 . . . . . . . . 4

On solving we get
22 43 13 22
𝑓1 = − , 𝑓2 = − , 𝑓3 = − , 𝑓4 = −
4 4 4 4
Therefore the interior points are as above.

160
Note: we can use any problem-solving methods already discussed for solving the
values of fi

Parabolic equations
Elliptical equations studies previously described problems that are time
independent, such problems are known as steady state problems, but we come
across problems that are not steady state. This means that the function is
dependent on both space and time. Parabolic equations for which 𝑏 2 − 4𝑎𝑐 = 0,
describes the problem that depend on space and time variables.

A popular case for parabolic type of equation is the study of heat flow in one-
dimensional direction in an insulated rod, such problems are governed by both
boundary and initial conditions.

Figure : heat flow in a rod

Let f represent the temperature at any points in rod, whose distance from left end
is x. Heat is flowing from left to right under the influence of temperature gradient.
The temperature f(x,t) in the at position x and time t governed by the heat
equation.
𝜕𝑓 𝜕𝑓
𝑘1 = 𝑘 2 𝑘 3 ……..𝑎
𝜕𝑥 2 𝜕𝑡
Where 𝑘1 is coefficient of thermal conductivity, 𝑘2 is the specific heat and 𝑘3 is
density of the material.

Equation a can be simplified as

𝑘𝑓𝑥𝑥 (𝑥, 𝑡) = 𝑓𝑡 (𝑥, 𝑡) … … . 𝑏

161
𝑘1
Where 𝑘 =
𝑘2 𝑘3

The initial condition will be the initial temperatures at all points along the rod .

𝑓(𝑥, 0) = 𝑓(𝑥) 0 ≤ 𝑥 ≤ 𝐿

The boundary conditions f(0,t) and f(L,t) describes the temperature at each end
of the rod as function of time, if they are held at constant then

𝑓 (0, 𝑡) = 𝑐1 0 ≤ 𝑡 ≤ ∞

𝑓(𝐿, 𝑡) = 𝑐2 0 ≤ 𝑡 ≤ ∞

solution of heat equation

we can solve the heat equation in equation using the finite difference formula
given below.
𝑓(𝑥, 𝑡 + 𝜏) − 𝑓 (𝑥, 𝑡)
𝑓𝑡 (𝑥, 𝑡) =
𝜏
1
= (𝑓𝑖,𝑗+1 − 𝑓𝑖,𝑗 ) … … . 𝑐
𝜏
𝑓(𝑥 − ℎ, 𝑡) − 2𝑓(𝑥, 𝑡) + 𝑓(𝑥 + ℎ, 𝑡)
𝑓𝑥𝑥 (𝑥, 𝑡) =
ℎ2
1
= (𝑓 − 2𝑓𝑖,𝑗 +𝑓𝑖+1,𝑗 ) … … 𝑑
ℎ2 𝑖−1,𝑗
Substituting c and d in equation b we can obtain
1 𝑘
(𝑓𝑖,𝑗+1 − 𝑓𝑖,𝑗 ) = 2 (𝑓𝑖−1,𝑗 − 2𝑓𝑖𝑗 + 2𝑓𝑖+1,𝑗 ) … … 𝑒
𝜏 ℎ
Solving for 𝑓𝑖,𝑗+1

2𝜏𝑘 𝜏𝑘
𝑓𝑖,𝑗+1 = (1 − ) 𝑓𝑖𝑗 + (𝑓 + 𝑓𝑖+1,𝑗 )
ℎ2 ℎ2 𝑖−1,𝑗
= (1 − 2𝛾)𝑓𝑖𝑗 + 𝛾(𝑓𝑖−1,𝑗 + 𝑓𝑖+1,𝑗 ) … . . 𝑓
𝜏𝑘
Where 𝛾 =
ℎ2

162
Bender Schmidt method
The recurrence of equation allows us to evaluate f at each point x and at any point
t. if we choose step size ∆𝑡 & ∆𝑥, such that
2𝜏𝑘
1 − 2𝛾 = 1 − = 0 ……𝑔
ℎ2
Equation f simplifies to
1
𝑓𝑖,𝑗+1 = (𝑓 + 𝑓𝑖−1,𝑗 ) … … . ℎ
2 𝑖+1,𝑗
Equation h is known as Bender Schmidt recurrence equation. This equation
determines the value of f at 𝑥 = 𝑥𝑖 , at time 𝑡 = 𝑡𝑖 + 𝜏 as the average of the values
right and left of 𝑥𝑖 at time 𝑡𝑗 .

Note that the step size in ∆𝑡 obtained from equation g.

ℎ2
𝜏=
2𝑘
Gives the equation h , equation f is stable if and only if the we step size 𝜏 satisfies
the condition

ℎ2
𝜏≤
2𝑘
Example : Solve the parabolic equation 2𝑓𝑥𝑥 (𝑥, 𝑡) = 𝑓𝑡 (𝑥, 𝑡) , given the initial
condition

𝑓(𝑥, 0) = 50(4 − 𝑥 ) 0 ≤ 𝑥 ≤ 4

And boundary conditions

𝑓(0, 𝑡) = 0

𝑓(4, 𝑡) = 0, 0 ≤ 𝑡 ≤ 1.5

Solution

If we assume ∆𝑥 = ℎ = 1, ∆𝑡 = 𝜏 (using Bender Schmidt method)

ℎ2 12
𝜏≤ = = 0.25
2𝑘 2𝑥2

163
Taking 𝜏 = 0.25, we have
1
𝑓𝑖,𝑗+1 = (𝑓 + 𝑓𝑖+1,𝑗 )
2 𝑖−1,𝑗
From the initial boundary condition : 𝑓(0, 𝑡) = 0 or, f(0,j) =0 for all values of j.
i.e. 𝑓(0,0) = 0

𝑓(0,1) = 0

𝑓(0,2) = 0

𝑓(0,3) = 0

𝑓(0,4) = 0

𝑓(0,5) = 0

𝑓(0,6) = 0

From the final boundary condition: 𝑓 (4, 𝑡) = 0 or 𝑓(4, 𝑗) = 0 for all values of j.

𝑓(4,0) = 0

𝑓(4,1) = 0

𝑓(4,2) = 0

𝑓(4,3) = 0

𝑓(4,4) = 0

Now, again from the given initial condition:

𝑓(𝑥, 0) = 50(4 − 𝑥 )

Or, 𝑓(𝑖, 0) = 50(4 − 𝑖 ) for all values of i.

𝑓(1,0) = 50(4 − 1)=150

𝑓(2,0) = 50(4 − 2)=100

𝑓(3,0) = 50(4 − 3)=50

164
Now, again from Bender Schmidt recursive formula,

1
𝑓𝑖,𝑗+1 = (𝑓𝑖−1,𝑗 + 𝑓𝑖+1,𝑗 ) ………(A)
2

Put j=0 in (A) we get,


1
𝑓𝑖,1 = (𝑓𝑖−1,0 + 𝑓𝑖+1,0 )………..(B)
2

Put i=1, 2, 3 respectively in (B) we get,


1 1
𝑓1,1 = (𝑓0,0 + 𝑓2,0 )= (0 + 100)=50
2 2

1 1
𝑓2,1 = (𝑓1,0 + 𝑓3,0 )= (150 + 50)=100
2 2

1 1
𝑓3,1 = (𝑓2,0 + 𝑓4,0 )= (100 + 0)=50
2 2

Again take j=1 and i= 1.2, 3 respectively to find 𝑓1,2 𝑓2,2 𝑓3,2 and take j=2, j=3,
j=4 and j=6 and find the corresponding values for i=1, i=2 and i=3 for each ‘j’ .

Using the formula we can generate successfully f(x,t). the estimated are recorded
in the following table at each interior point, the temperature at any single point is
just average of the values at the adjacent points of the previous points.

x 0 (i=0) 1(i=1) 2 (i=2) 3(i=3) 4(i=4)


t
0.00(j=0) 0 150 100 50 0
0.25 (j=1) 0 50(f1,1) 100(f2.1) 50(f3,1) 0
0.50(j=2) 0 50 50 50 0
0.75 (j=3) 0 25 50 25 0
1.00(j=4) 0 25 25 25 0
Hyperbolic equation
Hyperbolic equation models the vibration of structure such as building beams and
machines we here consider the case of a vibrating string that is fixed at both the
ends as figure.

165
The lateral displacement of string f varies with time t and distance x along the
string. The displacement f(x,t) is governed by the wave equation

𝜕2𝑓 𝜕2𝑓
𝑇 = 𝜌
𝜕𝑥 2 𝜕𝑡 2
Where T is the tension in the string and ρ is the mass per unit length.

Hyperbolic problems are governed by both boundary and initial conditions, if


time is one of the independent variables. Two boundary conditions are the
vibrating string problems under consideration are

𝑓(0, 𝑡) = 0, 0≤𝑡≤𝑏

𝑓 (𝐿, 𝑡) = 0, 0 ≤ 𝑡 ≤ 𝑏

Two initial conditions are:

𝑓(𝑥, 0) = 𝑓(𝑥 ), 0 ≤ 𝑡 ≤ 𝛼

𝑓𝑡 (𝑥, 0) = 𝑔(𝑥 ), 0 ≤ 𝑡 ≤ 𝑎

Solution hyperbolic equations

The domain of interest 0 ≤ 𝑡 ≤ 𝑎 𝑎𝑛𝑑 0 ≤ 𝑡 ≤ 𝑏 is partitioned as shown in


figure, the rectangle size is ∆𝑥 = ℎ, ∆𝑡 = 𝜏

166
Figure : Grid for solving hyperbolic equation

The difference equation for 𝑓𝑥𝑥 (𝑥, 𝑡) 𝑎𝑛𝑑 𝑓𝑡𝑡 (𝑥, 𝑡) are

𝑓(𝑥 − ℎ, 𝑡) − 2𝑓(𝑥, 𝑡) + 𝑓(𝑥 + ℎ, 𝑡)


𝑓𝑥𝑥 (𝑥, 𝑡) =
ℎ2
𝑓(𝑥, 𝑡 − 𝜏) − 2𝑓 (𝑥, 𝑡) + 𝑓(𝑥, 𝑡 + 𝜏)
𝑓𝑡𝑡 (𝑥, 𝑡) =
𝜏2
This implies that
𝑓𝑖−1,𝑗 − 2𝑓𝑖𝑗 + 𝑓𝑖+1,𝑗 𝑓𝑖,𝑗−1 − 2𝑓𝑖𝑗 + 𝑓𝑖,𝑗+1
𝑇 = 𝜌
ℎ2 𝜏2
Solving this for 𝑓𝑖,𝑗+1 , we obtain

𝑇𝜏 2 𝑇𝜏 2
𝑓𝑖,𝑗+1 = −𝑓𝑖,𝑗−1 + 2 (1 − 2 ) 𝑓𝑖𝑗 + 2 (𝑓𝑖+1,𝑗 + 𝑓𝑖−1,𝑗 )
𝜌ℎ 𝜌ℎ
𝑇𝜏2
If we make 1 − =0
𝜌ℎ2

Then we have

𝑓𝑖,𝑗+1 = −𝑓𝑖,𝑗−1 + 𝑓𝑖+1,𝑗 + 𝑓𝑖−1,𝑗 … … … 𝑑

167
The values of f at 𝑥 = 𝑥𝑖 and 𝑡 = 𝑡𝑗 + 𝜏 is equal to the um of the values of f, at
the point 𝑥 = 𝑥𝑖 − ℎ and 𝑥 = 𝑥𝑖 + ℎ at the time 𝑡 = 𝑡𝑗 (𝑝𝑟𝑒𝑣𝑖𝑜𝑢𝑠 𝑡𝑖𝑚𝑒) minus
the value of f at 𝑥 = 𝑥𝑖 at time 𝑡 = 𝑡𝑗 − 𝜏. From figure we can say 𝑓𝐴 = 𝑓𝐵 +
𝑓𝐷 − 𝑓𝐶

Starting values

We need two rows of starting values, corresponding to j=1 and j=2, in order to
computer the values of the third row. First row is obtained using the condition.

𝑓(𝑥, 0) = 𝑓(𝑥 )

The 2nd row can be obtained using the 2nd initial condition as 𝑓𝑡 (𝑥, 0) = 𝑔(𝑥 )

We know that
𝑓𝑖,0+1 − 𝑓𝑖,0−1
𝑓𝑡 (𝑥, 0) = = 𝑔𝑖
2𝜏
𝑓𝑖,−1 = 𝑓𝑖,1 − 2𝜏𝑔𝑖 𝑓𝑜𝑟 𝑡 = 0 𝑜𝑛𝑙𝑦

Substituting this in equation d, we get for 𝑡 = 𝑡1


1
𝑓𝑖,1 = (𝑓 + 𝑓𝑖−1,0 ) + 𝜏𝑔𝑖 … … . 𝑒
2 𝑖+1,0
In many cases 𝑔(𝑥𝑖 ) = 0 then we have
1
𝑓𝑖,1 = (𝑓𝑖+1,0 + 𝑓𝑖−1,0 )
2

Example: Solve numerically the wave equation

𝑓𝑡𝑡 (𝑥, 𝑡) = 4𝑓𝑥𝑥 (𝑥, 𝑡)0 ≤ 𝑥 ≤ 5 & 0 ≤ 𝑡 ≤ 2.5

With boundary condition

𝑓 (0, 𝑡) = 0 𝑎𝑛𝑑𝑓 (5, 𝑡) = 0

168
And initial values

𝑓 (𝑥, 0) = 𝑓(𝑥 ) = 𝑥 (5 − 𝑥 )

𝑓𝑡 (𝑥, 0) = 𝑔(𝑥 ) = 0

Solution

Let h=1
𝑇
Given =4
𝜌

𝜏2
Assuming 1 − 4 =0
12

We get
1
𝜏=
2
The values estimated using equations d and e

0 1 2 3 4 5
x
t
0.0 0 4 6 6 4 0
0.5 0 3* 5 ** 5 3 0
1.0 0 1 2 2 1 0
1.5 0 -1*** -2 -2 -1 0
2.0 0 -3 -5 -5 -3 0
2.5 0 -4 -6 -6 -4 0

0+6 4+6
∗= ∗∗= ∗∗∗= 2 + 0 − 3
2 2

169
Chapter 6: Solution of partial differential equations
Many physical phenomena in applied science and engineering when formulated
into mathematical models fall into a category of system known as partial
differential equations. A partial differential equation is a differential equation
involving more than one in independent variables.

We can write a second order equation involving two independent variables in


general form as :

𝑎𝜕 2 𝑓 𝑏𝜕 2 𝑓 𝑐𝜕 2 𝑓 𝜕𝑓 𝜕𝑓
+ + = 𝐹(𝑥, 𝑦, , ). . . . . . . . . . 1
𝜕𝑥 2 𝜕𝑥𝜕𝑦 𝜕𝑦 2 𝜕𝑥 𝜕𝑦

Where a,b,c may be constant or function of x & y

The equation 1 is classified as

iv. Elliptical if 𝑏 2 − 4𝑎𝑐 < 0


v. Parabolic if 𝑏 2 − 4𝑎𝑐 = 0
vi. Hyperbolic if 𝑏 2 − 4𝑎𝑐 > 0

Two approaches of solving are

3. Finite difference method (where regions are regular)


4. Finite element method (where regions are irregular)

Finite difference method


The finite difference method is based on the formula for approximating first and
second order derivatives of a function. In this method derivatives that occurs in
partial differential equation are replaced by their finite difference equivalents.
The difference equation is then written for each grid points using function values
at the surrounding grid points. Solving these equations simultaneously give the
values of the function of each grid points.

170
Figure: two-dimensional finite difference grid

𝑥𝑖+1 = 𝑥𝑖 + ℎ

𝑦𝑖+1 = 𝑦𝑖 + ℎ

We have already discussed that if the function f(x) has a continuous fourth
derivative, then it’s first and second derivatives are given by the following central
difference approximation.
𝑓(𝑥𝑖 + ℎ) − 𝑓(𝑥𝑖 − ℎ)
𝑓 ′ (𝑥𝑖 ) =
2ℎ

𝑓𝑖+1 − 𝑓𝑖−1
𝑓 ′𝑖 = . . . . . . . . . .2
2ℎ
𝑓(𝑥𝑖 + ℎ) − 2𝑓(𝑥𝑖 ) − 𝑓(𝑥𝑖 − ℎ)
𝑓 " (𝑥𝑖 ) =
ℎ2
𝑓𝑖+1 −2𝑓𝑖 − 𝑓𝑖−1
𝑓 "𝑖 = . . . . . . . . . .3
ℎ2
The subscripts on f indicate the x value at which the function is evaluated. When
f is a function of two variables x and y, the partial derivatives of f with respect x
or y are the ordinary derivatives of f with respect to x or y when y or x does not
change. We can use the equations 2 and 3 in the x direction to determine

171
derivatives with respect to x and in the y direction to determine derivatives with
respect to y. thus we have
𝜕𝑓(𝑥𝑖 , 𝑦𝑗 ) 𝑓(𝑥𝑖+1 , 𝑦𝑗 ) − 𝑓(𝑥𝑖−1 , 𝑦𝑗 )
= 𝑓𝑥 (𝑥𝑖 , 𝑦𝑗 ) =
𝜕𝑥 2ℎ
𝜕𝑓(𝑥𝑖 , 𝑦𝑗 ) 𝑓(𝑥𝑖 , 𝑦𝑗+1 ) − 𝑓(𝑥𝑖 , 𝑦𝑗−1 )
= 𝑓𝑦 (𝑥𝑖 , 𝑦𝑗 ) =
𝜕𝑦 2𝑘

𝜕 2 𝑓(𝑥𝑖 , 𝑦𝑗 ) 𝑓(𝑥𝑖+1 , 𝑦𝑗 ) − 2𝑓(𝑥𝑖 , 𝑦𝑗 ) + 𝑓(𝑥𝑖−1 , 𝑦𝑗 )


= 𝑓𝑥𝑥 (𝑥𝑖 , 𝑦𝑗 ) =
𝜕𝑥 2 ℎ2
𝜕 2 𝑓(𝑥𝑖 , 𝑦𝑗 ) 𝑓(𝑥𝑖 , 𝑦𝑗+1 ) − 2𝑓(𝑥𝑖 , 𝑦𝑗 ) + 𝑓(𝑥𝑖 , 𝑦𝑗−1 )
= 𝑓 (𝑥 ,
𝑦𝑦 𝑖 𝑗 𝑦 ) =
𝜕𝑦 2 𝑘2

𝜕 2 𝑓(𝑥𝑖 , 𝑦𝑗 ) 𝑓(𝑥𝑖+1 , 𝑦𝑗+1 ) − 𝑓(𝑥𝑖+1 , 𝑦𝑗−1 ) − 𝑓(𝑥𝑖−1 , 𝑦𝑗+1 ) + 𝑓(𝑥𝑖−1 , 𝑦𝑗−1 )


=
𝜕𝑥𝜕𝑦 4ℎ𝑘

It would be convenient to use double subscripts i,j on f to indicate x and y values.


Then above equation become
𝑓𝑖+1,𝑗 − 𝑓𝑖−1,𝑗
𝑓𝑥,𝑖,𝑗 =

𝑓𝑖,𝑗+1 − 𝑓𝑖,𝑗−1
𝑓𝑦,𝑖,𝑗 =
𝑘
𝑓𝑖+1,𝑗 − 2𝑓𝑖,𝑗 + 𝑓𝑖−1,𝑗
𝑓𝑥𝑥,𝑖,𝑗 =
ℎ2
𝑓𝑖,𝑗+1 − 2𝑓𝑖,𝑗 + 𝑓𝑖,𝑗−1
𝑓𝑦𝑦,𝑖,𝑗 =
𝑘2
𝑓𝑖+1,𝑗+1 − 𝑓𝑖+1,𝑗−1 − 𝑓𝑖−1,𝑗+1 + 𝑓𝑖−1,𝑗−1
𝑓𝑥𝑦,𝑖,𝑗 =
2ℎ𝑘
We will use these finite difference equivalents of the partial derivatives to
construct various types of differential equations.

Elliptical equations
Elliptical equations are governed by condition on the boundary of closed domain.
We consider here the two most commonly encountered elliptical equations.

c. Laplace’s equation

172
d. Poisson’s equation

Laplace’s equation
Any equation of the form ∇2 𝑓 = 0 is called laplace’s equation, where
2
𝜕2 𝜕2
∇ = 2 + 2 .....4
𝜕𝑥 𝜕𝑦
2 2
𝜕 𝑓 𝜕 𝑓
∴ 2
+ 2 = ∇2 𝑓 = 0. . . . . .5
𝜕𝑥 𝜕𝑦

𝜕𝑓 𝜕𝑓
Where a=1,b=0,c=1 and F(x,y, , )=0
𝜕𝑥 𝜕𝑦
Where ∇2 is called Laplacian operator, above equation can be written as
𝑈𝑥𝑥 + 𝑈𝑦𝑦 = 0
Replacing the second order derivatives by their finite difference equivalents, at
points (𝑥𝑖 , 𝑦𝑖 ) we get
𝑓𝑖+1,𝑗 − 2𝑓𝑖𝑗 + 𝑓𝑖−1,𝑗 𝑓𝑖,𝑗+1 − 2𝑓𝑖𝑗 + 𝑓𝑖,𝑗−1
∇2 𝑓𝑖𝑗 = + = 0. . . . . . 6
ℎ2 𝑘2
If we assume for simplicity, h=k, then we get

𝑓𝑖+1,𝑗 − 2𝑓𝑖𝑗 + 𝑓𝑖−1,𝑗 𝑓𝑖,𝑗+1 − 2𝑓𝑖𝑗 + 𝑓𝑖,𝑗−1


∇2 𝑓𝑖𝑗 = +
ℎ2 ℎ2
𝑓𝑖+1,𝑗 + 𝑓𝑖−1,𝑗 − 4𝑓𝑖𝑗 + 𝑓𝑖,𝑗+1 + 𝑓𝑖,𝑗−1
∇2 𝑓𝑖𝑗 = .......7
ℎ2
𝑓𝑖+1,𝑗 + 𝑓𝑖−1,𝑗 − 4𝑓𝑖𝑗 + 𝑓𝑖,𝑗+1 + 𝑓𝑖,𝑗−1 = 0
This is called Laplace’s equation

Above equation contains four neighboring points around central points (𝑥𝑖 , 𝑦𝑖 ) as
shown in figure, the above equation is known as five point difference formula for
Laplace’s equation.

173
figure: Grid for Laplace equation

we can also represent the relationship of pivotal values as,

1 1
2
∇ 𝑓𝑖𝑗 = 2 {1 −4 1} 𝑓𝑖𝑗 = 0 . . . . . . . 8

1
From above equation we can show that the function value at grid point(𝑥𝑖 , 𝑦𝑖 ) is
the average of the values at the four adjoining points. i.e
1
𝑓𝑖𝑗 = (𝑓𝑖+1,𝑗 + 𝑓𝑖−1,𝑗 +𝑓𝑖,𝑗+1 + 𝑓𝑖,𝑗−1 ). . . . . . . . 9
4

To evaluate numerically the solution of Laplace equation at the grid points we


can apply equation 9 at the grid points where 𝑓𝑖𝑗 is required thus obtaining a
system of linear equations in the pivotal values of 𝑓𝑖𝑗 . The system of linear
equations may be solved using either direct or iterative methods.

Example: Consider a steel plate of size 15cm x 15cm, if two of the sides are held
at 100oc and the other two sides are held at 0oc. What are the steady state
temperatures at interior points(nodes) assuming a grid of 5cm x 5cm.

Note: a problem with values known on each boundary is said to have Dirichlet
boundary condition. This problem is illustrated below.

174
The system of equation is as follows

Point 1:

100 + 100 + 𝑓3 + 𝑓2 − 4𝑓1 = 0 … … . .1

Point 2:

𝑓1 + 100 + 𝑓4 + 0 − 4𝑓2 = 0. . . . . . . .2

Point 3:

100 + 𝑓1 + 0 + 𝑓4 − 4𝑓3 = 0. . . . . . . .3

Point 4:

𝑓3 + 𝑓2 + 0 + 0 − 4𝑓4 = 0. . . . . . . .4

On solving above four equations we get the values as:

𝑓1 = 75, 𝑓2 = 50, 𝑓3 = 50, 𝑓4 = 25

So we can see the interior temperature points as above.

Note: for solving use any methods that have learned in before chapters.

175
Poisson’s equation
If we put a=1, b=0, c=1 in the equation and F(x,y,f,𝑓𝑥 , 𝑓𝑦 )=g(x,y) then

𝑎𝜕 2 𝑓 𝑏𝜕 2 𝑓 𝑐𝜕 2 𝑓 𝜕𝑓 𝜕𝑓
+ + = 𝐹 (𝑥, 𝑦, , )
𝜕𝑥 2 𝜕𝑥𝜕𝑦 𝜕𝑦 2 𝜕𝑥 𝜕𝑦

We get

𝜕 2 𝑓 𝑐𝜕 2 𝑓
+ = 𝑔(𝑥, 𝑦)
𝜕𝑥 2 𝜕𝑦 2

∇2 𝑓 = 𝑔(𝑥, 𝑦) … … . . 𝑎

The above equation a is called poisson’s equation using the notation 𝑔𝑖𝑗 =
𝑔(𝑥𝑖 , 𝑦𝑖 ) and laplace equation may be modified to solve the equation a. the finite
difference formula for solving poisson’s equation then takes of the form

𝑓𝑖+1,𝑗 + 𝑓𝑖−1,𝑗 + 𝑓𝑖,𝑗+1 + 𝑓𝑖,𝑗−1 − 4𝑓𝑖𝑗 = ℎ2 𝑔𝑖𝑗 … … . . 𝑏

Example: Solve the poisson’s equation ∇2 𝑓 = 2𝑥 2 𝑦 2 over the square domain 0 ≤


𝑥 ≤ 3 & 0 ≤ 𝑦 ≤ 3 with f=0 on the boundary and h=1.

The domain is divided into squares of one unit size as in figure.

176
By applying equations b at each grid points

Point 1:

0 + 0 + 𝑓3 + 𝑓2 − 4𝑓1 = 12 𝑔(1,2)

𝑓2 +𝑓3 − 4𝑓1 = 2𝑥12 𝑥22

𝑓2 +𝑓3 − 4𝑓1 = 8 . . . . . . . . 1

Point 2:

𝑓1 + 0 + 0 + 𝑓4 − 4𝑓2 = 12 𝑔(2,2)

𝑓1 +𝑓4 − 4𝑓2 = 2𝑥22 𝑥22

𝑓1 − 4𝑓2 + 𝑓4 = 32 . . . . . . . . 2

Point 3:

0 + 𝑓1 + 0 + 𝑓4 − 4𝑓3 = 12 𝑔(1,1)

𝑓1 +𝑓4 − 4𝑓3 = 2𝑥12 𝑥12

𝑓1 − 4𝑓3 + 𝑓4 = 2 . . . . . . . . 3

Point 4:

𝑓3 + 𝑓2 + 0 + 0 − 4𝑓4 = 12 𝑔(2,1)

𝑓2 +𝑓3 − 4𝑓4 = 2𝑥22

𝑓2 + 𝑓3 − 4𝑓4 = 8 . . . . . . . . 4

On solving we get
22 43 13 22
𝑓1 = − , 𝑓2 = − , 𝑓3 = − , 𝑓4 = −
4 4 4 4
Therefore the interior points are as above.

177
Note: we can use any problem-solving methods already discussed for solving the
values of fi

Parabolic equations
Elliptical equations studies previously described problems that are time
independent, such problems are known as steady state problems, but we come
across problems that are not steady state. This means that the function is
dependent on both space and time. Parabolic equations for which 𝑏 2 − 4𝑎𝑐 = 0,
describes the problem that depend on space and time variables.

A popular case for parabolic type of equation is the study of heat flow in one-
dimensional direction in an insulated rod, such problems are governed by both
boundary and initial conditions.

Figure : heat flow in a rod

Let f represent the temperature at any points in rod, whose distance from left end
is x. Heat is flowing from left to right under the influence of temperature gradient.
The temperature f(x,t) in the at position x and time t governed by the heat
equation.
𝜕𝑓 𝜕𝑓
𝑘1 = 𝑘 2 𝑘 3 ……..𝑎
𝜕𝑥 2 𝜕𝑡
Where 𝑘1 is coefficient of thermal conductivity, 𝑘2 is the specific heat and 𝑘3 is
density of the material.

Equation a can be simplified as

𝑘𝑓𝑥𝑥 (𝑥, 𝑡) = 𝑓𝑡 (𝑥, 𝑡) … … . 𝑏

178
𝑘1
Where 𝑘 =
𝑘2 𝑘3

The initial condition will be the initial temperatures at all points along the rod .

𝑓(𝑥, 0) = 𝑓(𝑥) 0 ≤ 𝑥 ≤ 𝐿

The boundary conditions f(0,t) and f(L,t) describes the temperature at each end
of the rod as function of time, if they are held at constant then

𝑓 (0, 𝑡) = 𝑐1 0 ≤ 𝑡 ≤ ∞

𝑓(𝐿, 𝑡) = 𝑐2 0 ≤ 𝑡 ≤ ∞

solution of heat equation

we can solve the heat equation in equation using the finite difference formula
given below.
𝑓(𝑥, 𝑡 + 𝜏) − 𝑓 (𝑥, 𝑡)
𝑓𝑡 (𝑥, 𝑡) =
𝜏
1
= (𝑓𝑖,𝑗+1 − 𝑓𝑖,𝑗 ) … … . 𝑐
𝜏
𝑓(𝑥 − ℎ, 𝑡) − 2𝑓(𝑥, 𝑡) + 𝑓(𝑥 + ℎ, 𝑡)
𝑓𝑥𝑥 (𝑥, 𝑡) =
ℎ2
1
= (𝑓 − 2𝑓𝑖,𝑗 +𝑓𝑖+1,𝑗 ) … … 𝑑
ℎ2 𝑖−1,𝑗
Substituting c and d in equation b we can obtain
1 𝑘
(𝑓𝑖,𝑗+1 − 𝑓𝑖,𝑗 ) = 2 (𝑓𝑖−1,𝑗 − 2𝑓𝑖𝑗 + 2𝑓𝑖+1,𝑗 ) … … 𝑒
𝜏 ℎ
Solving for 𝑓𝑖,𝑗+1

2𝜏𝑘 𝜏𝑘
𝑓𝑖,𝑗+1 = (1 − ) 𝑓𝑖𝑗 + (𝑓 + 𝑓𝑖+1,𝑗 )
ℎ2 ℎ2 𝑖−1,𝑗
= (1 − 2𝛾)𝑓𝑖𝑗 + 𝛾(𝑓𝑖−1,𝑗 + 𝑓𝑖+1,𝑗 ) … . . 𝑓
𝜏𝑘
Where 𝛾 =
ℎ2

179
Bender Schmidt method
The recurrence of equation allows us to evaluate f at each point x and at any point
t. if we choose step size ∆𝑡 & ∆𝑥, such that
2𝜏𝑘
1 − 2𝛾 = 1 − = 0 ……𝑔
ℎ2
Equation f simplifies to
1
𝑓𝑖,𝑗+1 = (𝑓 + 𝑓𝑖−1,𝑗 ) … … . ℎ
2 𝑖+1,𝑗
Equation h is known as Bender Schmidt recurrence equation. This equation
determines the value of f at 𝑥 = 𝑥𝑖 , at time 𝑡 = 𝑡𝑖 + 𝜏 as the average of the values
right and left of 𝑥𝑖 at time 𝑡𝑗 .

Note that the step size in ∆𝑡 obtained from equation g.

ℎ2
𝜏=
2𝑘
Gives the equation h , equation f is stable if and only if the we step size 𝜏 satisfies
the condition

ℎ2
𝜏≤
2𝑘
Example: Solve the equation 2𝑓𝑥𝑥 (𝑥, 𝑡) = 𝑓𝑡 (𝑥, 𝑡) 𝑎𝑛𝑑 given the initial
condition:

𝑓(𝑥, 0) = 50(4 − 𝑥 ) 0 ≤ 𝑥 ≤ 4

And boundary conditions:

𝑓(0, 𝑡) = 0,

𝑓(4, 𝑡) = 𝑡 + 1, 0 ≤ 𝑡 ≤ 1.5

Solution

If we assume ∆𝑥 = ℎ = 1, ∆𝑡 = 𝜏 (using Bender Schmidt method)

ℎ2 12
𝜏≤ = = 0.25
2𝑘 2𝑥2

180
Taking 𝜏 = 0.25, we have
1
𝑓𝑖,𝑗+1 = (𝑓 + 𝑓𝑖+1,𝑗 )
2 𝑖−1,𝑗
Using the formula we can generate successfully f(x,t). the estimated are recorded
in the following table at each interior point, the temperature at any single point is
just average of the values at the adjacent points of the previous points.

X(i) 0 1 2 3 4
t (j)
0.00(0) 0 150 100 50 0
0.25(1) 0 50(f1,1) 100 50 0
0.50(2) 0 50 50 50 0
0.75 0 25 25 25 0
1.00 0 12.5 25 12.5 0
1.25 0 12.5 12.5 12.5 0
1.50 0 6.25 12.5 6.25 0
f(0,t) =0 , f(0,j)=0 for all values of j.

Again from the given final boundary condition: f(4,t) =0 , f(4,j)=0 for all values
of j.

Also from the given initial condition:𝑓(𝑖, 0) = 50(4 − 𝑖 ) for all values of i.

Hyperbolic equation
Hyperbolic equation models the vibration of structure such as building beams and
machines we here consider the case of a vibrating string that is fixed at both the
ends as figure.

181
The lateral displacement of string f varies with time t and distance x along the
string. The displacement f(x,t) is governed by the wave equation

𝜕2𝑓 𝜕2𝑓
𝑇 = 𝜌
𝜕𝑥 2 𝜕𝑡 2
Where T is the tension in the string and ρ is the mass per unit length.

Hyperbolic problems are governed by both boundary and initial conditions, if


time is one of the independent variables. Two boundary conditions are the
vibrating string problems under consideration are

𝑓(0, 𝑡) = 0, 0≤𝑡≤𝑏

𝑓 (𝐿, 𝑡) = 0, 0 ≤ 𝑡 ≤ 𝑏

Two initial condition are

𝑓(𝑥, 0) = 𝑓(𝑥 ), 0 ≤ 𝑡 ≤ 𝛼

𝑓𝑡 (𝑥, 0) = 𝑔(𝑥 ), 0 ≤ 𝑡 ≤ 𝑎

Solution hyperbolic equations

The domain of interest 0 ≤ 𝑡 ≤ 𝑎 𝑎𝑛𝑑 0 ≤ 𝑡 ≤ 𝑏 is partitioned as shown in


figure, the rectangle size is ∆𝑥 = ℎ, ∆𝑡 = 𝜏

182
Figure : Grid for solving hyperbolic equation

The difference equation for 𝑓𝑥𝑥 (𝑥, 𝑡) 𝑎𝑛𝑑 𝑓𝑡𝑡 (𝑥, 𝑡) are

𝑓(𝑥 − ℎ, 𝑡) − 2𝑓(𝑥, 𝑡) + 𝑓(𝑥 + ℎ, 𝑡)


𝑓𝑥𝑥 (𝑥, 𝑡) =
ℎ2
𝑓(𝑥, 𝑡 − 𝜏) − 2𝑓 (𝑥, 𝑡) + 𝑓(𝑥, 𝑡 + 𝜏)
𝑓𝑡𝑡 (𝑥, 𝑡) =
𝜏2
This implies that
𝑓𝑖−1,𝑗 − 2𝑓𝑖𝑗 + 𝑓𝑖+1,𝑗 𝑓𝑖,𝑗−1 − 2𝑓𝑖𝑗 + 𝑓𝑖,𝑗+1
𝑇 = 𝜌
ℎ2 𝜏2
Solving this for 𝑓𝑖,𝑗+1 , we obtain

𝑇𝜏 2 𝑇𝜏 2
𝑓𝑖,𝑗+1 = −𝑓𝑖,𝑗−1 + 2 (1 − 2 ) 𝑓𝑖𝑗 + 2 (𝑓𝑖+1,𝑗 + 𝑓𝑖−1,𝑗 )
𝜌ℎ 𝜌ℎ
𝑇𝜏2
If we make 1 − =0
𝜌ℎ2

Then we have

𝑓𝑖,𝑗+1 = −𝑓𝑖,𝑗−1 + 𝑓𝑖+1,𝑗 + 𝑓𝑖−1,𝑗 … … … 𝑑

183
The values of f at 𝑥 = 𝑥𝑖 and 𝑡 = 𝑡𝑗 + 𝜏 is equal to the um of the values of f, at
the point 𝑥 = 𝑥𝑖 − ℎ and 𝑥 = 𝑥𝑖 + ℎ at the time 𝑡 = 𝑡𝑗 (𝑝𝑟𝑒𝑣𝑖𝑜𝑢𝑠 𝑡𝑖𝑚𝑒) minus
the value of f at 𝑥 = 𝑥𝑖 at time 𝑡 = 𝑡𝑗 − 𝜏. From figure we can say 𝑓𝐴 = 𝑓𝐵 +
𝑓𝐷 − 𝑓𝐶

Starting values

We need two rows of starting values, corresponding to j=1 and j=2, in order to
computer the values of the third row. First row is obtained using the condition.

𝑓(𝑥, 0) = 𝑓(𝑥 )

The 2nd row can be obtained using the 2nd initial condition as 𝑓𝑡 (𝑥, 0) = 𝑔(𝑥 )

We know that
𝑓𝑖,0+1 − 𝑓𝑖,0−1
𝑓𝑡 (𝑥, 0) = = 𝑔𝑖
2𝜏
𝑓𝑖,−1 = 𝑓𝑖,1 − 2𝜏𝑔𝑖 𝑓𝑜𝑟 𝑡 = 0 𝑜𝑛𝑙𝑦

Substituting this in equation d, we get for 𝑡 = 𝑡1


1
𝑓𝑖,1 = (𝑓 + 𝑓𝑖−1,0 ) + 𝜏𝑔𝑖 … … . 𝑒
2 𝑖+1,0
In many cases 𝑔(𝑥𝑖 ) = 0 then we have
1
𝑓𝑖,1 = (𝑓𝑖+1,0 + 𝑓𝑖−1,0 )
2

Example: solve numerically the wave equation

𝑓𝑡𝑡 (𝑥, 𝑡) = 4𝑓𝑥𝑥 (𝑥, 𝑡)0 ≤ 𝑥 ≤ 5 & 0 ≤ 𝑡 ≤ 2.5

With boundary condition

𝑓 (0, 𝑡) = 0 𝑎𝑛𝑑𝑓 (5, 𝑡) = 0

184
And initial values

𝑓 (𝑥, 0) = 𝑓(𝑥 ) = 𝑥 (5 − 𝑥 )

𝑓𝑡 (𝑥, 0) = 𝑔(𝑥 ) = 0

Solution

Let h=1
𝑇
Given =4
𝜌

𝜏2
Assuming 1 − 4 =0
12

We get
1
𝜏=
2
The values estimated using equations d and e

0 1 2 3 4 5
x
t
0.0 0 4 6 6 4 0
0.5 0 3* 5 ** 5 3 0
1.0 0 1 2 2 1 0
1.5 0 -1*** -2 -2 -1 0
2.0 0 -3 -5 -5 -3 0
2.5 0 -4 -6 -6 -4 0

0+6 4+6
∗= ∗∗= ∗∗∗= 2 + 0 − 3
2 2

185

You might also like