Numerical Methods Archives - OnlineEngineeringNotes https://onlineengineeringnotes.com/category/numerical-methods/ A Complete Guide to future Engineers Thu, 10 Jun 2021 10:50:03 +0000 en-US hourly 1 https://wordpress.org/?v=6.5.2 Solution of Partial Differential, Elliptical, Parabolic, Hyperbolic Equations and their relevant examples https://onlineengineeringnotes.com/2021/06/10/solution-of-partial-differential-elliptical-parabolic-hyperbolic-equations-and-their-relevant-examples/ https://onlineengineeringnotes.com/2021/06/10/solution-of-partial-differential-elliptical-parabolic-hyperbolic-equations-and-their-relevant-examples/#respond Thu, 10 Jun 2021 10:49:59 +0000 https://onlineengineeringnotes.com/?p=885 Many physical phenomena in applied science and engineering when formulated intomathematical models fall into a category of system known as partial differential equations. Apartial differential equation is a differential equation involving more than one in independentvariables.We can write a second order equation involving two independent variables in general form as : Where a,b,c may be ... Read more

The post Solution of Partial Differential, Elliptical, Parabolic, Hyperbolic Equations and their relevant examples appeared first on OnlineEngineeringNotes.

]]>
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 :

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 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.

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.

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 derivatives with respect to x and in the y direction to determine
derivatives with respect to y. thus we have

It would be convenient to use double subscripts i,j on f to indicate x and y values.

Then above equation becomes;

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
b. Poisson’s equation

Laplace’s equation

Any equation of the form βˆ‡ 2𝑓 = 0 is called laplace’s equation, where

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

If we assume for simplicity, h=k, then we get

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.

figure: Grid for Laplace equation

we can also represent the relationship of pivotal values pictorially as below.

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

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 side are held at 100oc and other two side are held at 0oc, what are the steady state temperature at interior points 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.

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.

Poisson’s equation

If we put a=1, b=0, c=1 in the equation and F(x,y,f,𝑓π‘₯, 𝑓𝑦)=g(x,y) then

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

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.

By applying equations b at each grid points

 Point 1:

 0 + 0 + 𝑓3 + 𝑓2 βˆ’ 4𝑓1 = 1 2𝑔(1,2)

𝑓2+𝑓3 βˆ’ 4𝑓1 = 2π‘₯1 2π‘₯22

 π‘“2+𝑓3 βˆ’ 4𝑓1 = 8 . . . . . . . . 1

Point 2:

 π‘“1 + 0 + 0 + 𝑓4 βˆ’ 4𝑓2 = 1

 2𝑔(2,2) 𝑓1+𝑓4 βˆ’ 4𝑓2 = 2π‘₯2 2π‘₯2 2

𝑓1 βˆ’ 4𝑓2 + 𝑓4 = 32 . . . . . . . . 2

Point 3:

 0 + 𝑓1 + 0 + 𝑓4 βˆ’ 4𝑓3 = 1 2𝑔(1,1)

 π‘“1+𝑓4 βˆ’ 4𝑓3 = 2π‘₯1 2π‘₯1 2

𝑓1 βˆ’ 4𝑓3 + 𝑓4 = 2 . . . . . . . . 3

 Point 4:

𝑓3 + 𝑓2 + 0 + 0 βˆ’ 4𝑓4 = 1 2𝑔(2,1)

𝑓2+𝑓3 βˆ’ 4𝑓4 = 2π‘₯2 2 𝑓2 + 𝑓3 βˆ’ 4𝑓4 = 8 . . . . . . . . 4

On solving we get

Therefore the interior points are as above.
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.

Where π‘˜1is coefficient of thermal conductivity, π‘˜2 is the specific heat and π‘˜3 is density of the material.

Equation a can be simplified as

π‘˜π‘“π‘₯π‘₯(π‘₯,𝑑) = 𝑓𝑑 (π‘₯,𝑑) … … . b

Where π‘˜ = π‘˜1/ π‘˜2π‘˜

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,𝑑) = 𝑐10 ≀ 𝑑 ≀ ∞
𝑓(𝐿,𝑑) = 𝑐2 0 ≀ 𝑑 ≀ ∞

solution of heat equation
we can solve the heat equation in equation using the finite difference formula given below.

Bender Schmidt method

he recurrence of equation allows us to evaluate f at each point x and at any point t. if we choose
step size βˆ†π‘‘ & βˆ†π‘₯, such that

Equation f simplifies to

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 / 2k

Example : Solve the equation 2𝑓π‘₯π‘₯(π‘₯,𝑑) = 𝑓𝑑(π‘₯,𝑑) , 0 < 𝑑 < 1.5 π‘Žπ‘›π‘‘ 0 < π‘₯ < 4 given the initial condition

𝑓(π‘₯, 0) = 50(4 βˆ’ π‘₯)0 ≀ π‘₯ ≀ 4
And boundary condition
𝑓(0,𝑑) = 0, 0 ≀ 𝑑 ≀ 1.5
𝑓(4,𝑑) = 0, 0 ≀ 𝑑 ≀ 1.5
Solution
If we assume βˆ†π‘₯ = β„Ž = 1, βˆ†π‘‘ = 𝜏 (using Bender Schmidt method)

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.

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.

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

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 ≀ 𝑑 ≀ 𝛼
𝑓t(π‘₯, 0) = 𝑔(π‘₯), 0 ≀ 𝑑 ≀ π‘Ž

Solution hyperbolic equations
The domain of interest 0 ≀ 𝑑 ≀ π‘Ž π‘Žπ‘›π‘‘ 0 ≀ 𝑑 ≀ 𝑏 is partitioned as shown in figure, the rectangle
size is βˆ†π‘₯ = β„Ž, βˆ†π‘‘ = 𝜏

Figure : Grid for solving hyperbolic equation

The difference equation for 𝑓π‘₯π‘₯(π‘₯,𝑑) π‘Žπ‘›π‘‘ 𝑓𝑑𝑑(π‘₯,𝑑) are

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

𝑓𝐴 = 𝑓𝐡 + 𝑓𝐷 βˆ’ 𝑓C

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) = 𝑔(π‘₯)

Example: Solve numerically the wave equation

𝑓𝑑𝑑(π‘₯,𝑑) = 4𝑓π‘₯π‘₯(π‘₯,𝑑)0 ≀ π‘₯ ≀ 5 & 0 ≀ 𝑑 ≀ 2.5

With boundary condition

𝑓(0,𝑑) = 0 π‘Žπ‘›π‘‘π‘“(5,𝑑) = 0

And initial values

 π‘“(π‘₯, 0) = 𝑓(π‘₯) = π‘₯(5 βˆ’ π‘₯)

𝑓𝑑 (π‘₯, 0) = 𝑔(π‘₯) = 0

Solution
Let h=1
Given 𝑇/𝜌 = 4

Reference 1 : Numerical Methods , Dr. V.N. Vedamurthy & Dr. N. Ch. S. N. Iyengar, Vikas Publishing House.

The post Solution of Partial Differential, Elliptical, Parabolic, Hyperbolic Equations and their relevant examples appeared first on OnlineEngineeringNotes.

]]>
https://onlineengineeringnotes.com/2021/06/10/solution-of-partial-differential-elliptical-parabolic-hyperbolic-equations-and-their-relevant-examples/feed/ 0
Solution of Ordinary Differential and Higher Order Equations: Overview of initial and boundary value problems & Taylor series, Euler, Huen’s and Runge-Kutta methods https://onlineengineeringnotes.com/2021/06/09/solution-of-ordinary-differential-and-higher-order-equations-overview-of-initial-and-boundary-value-problems-taylor-series-euler-huens-and-runge-kutta-methods/ https://onlineengineeringnotes.com/2021/06/09/solution-of-ordinary-differential-and-higher-order-equations-overview-of-initial-and-boundary-value-problems-taylor-series-euler-huens-and-runge-kutta-methods/#respond Wed, 09 Jun 2021 16:19:00 +0000 https://onlineengineeringnotes.com/?p=827 Differential equations Many of the laws in physics, chemistry, engineering, economics are based on empiricalobservations that describe changes in the state of the system. Mathematical models thatdescribe the state of such system are often expressed in terms of not only certain systemparameters but also their derivatives, such mathematical model which uses differentialcalculus to express relationship ... Read more

The post Solution of Ordinary Differential and Higher Order Equations: Overview of initial and boundary value problems & Taylor series, Euler, Huen’s and Runge-Kutta methods appeared first on OnlineEngineeringNotes.

]]>

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:

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.
β€’ If the equation contains more than one independent variable then it is called partial
differential equation

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

Initial value problem

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 determined, 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.

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

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 (1)

Be the differential equation to which the numerical solution is required. Expanding 𝑦(π‘₯) about π‘₯ = π‘₯0 by Taylor Series we get

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 𝑦1we can calculate 𝑦1 β€² , 𝑦1 β€²β€² , 𝑦1 β€²β€²β€² from equation (1) at π‘₯ = π‘₯0 + h

Β Now expanding 𝑦(π‘₯) by Taylor series about π‘₯ = π‘₯1, we get

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

Where πœ‰ is a value between x and (x+a). the value of πœ‰ is ordinarily not known so there is
some uncertainty in the exact value of error still this term can give bounds for the errors.

Example:

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

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)

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 Γ— 1 2 + 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.5 2 + 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 Γ— 1 2 + 1) = 3

 π‘¦2 = 𝑦(1.25 + 0.25) = 𝑦(1.5) = 𝑦1 + β„Žπ‘“(π‘₯1, 𝑦1 ) = 3 + 0.25 Γ— 𝑓(1.25,3) = 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.5 2 + 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

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 is 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

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 𝑦 β€² (π‘₯) = 𝑓(π‘₯, 𝑦)

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 Eulers formula as

𝑦𝑖+1 = 𝑦𝑖 + β„Žπ‘“(π‘₯𝑖 , 𝑦𝑖)

Then the Heun’s formula can be written as:

Putting the value of euler’s formula in above equation we get

Example :

Given the equation 𝑦 β€² (π‘₯) = 2𝑦/ π‘₯ with y(1)=2, estimate y(2) using 1) Euler’s method 2) Heun’s method and compare the result. Take h=0.25

Solution

.

I. Euler’s method
h=0.25, y(1)=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.

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.

Fourth order Runge Kutta method(classical fourth order Runge Kutta method)

The classical fourth order Runge kutta method is given as

Runge Kutta (3rd order RK method)

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

Runge Kutta method for simultaneous first order equation

Consider the simultaneous equation

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)

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)

= 0.09077

𝑦1 = 𝑦(0.1) = 𝑦0 + π‘˜ = 1 + (βˆ’0.08614) = 0.91386

𝑧1 = 𝑧(0.1) = 𝑧0 + 𝑙 = βˆ’1 + 0.09077 = βˆ’0.90923

Higher order equation

A higher order differential equation is in the form

RK method for second order differential equations

Consider the second order differential equation

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

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

For second approximation y2 replace y by y1

The process is to be stopped when two values of y, are same to desired degree of accuracy
Note:

  • This method is applicable only to a limited class of equations in which the successive
    integration can be perform easily.
  • Sometimes it may not be possible to carry out the integration.
  • 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

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

𝑦 ” = 𝑓(π‘₯, 𝑦, 𝑦 β€² ) 𝑦(π‘Ž) = 𝐴, 𝑦(𝑏) = B

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 condtion 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 suing 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 accelerated by suing an improves guess for z(0) 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

Now with z(a)=M3, we can again obtain the solution of y(x).

Reference 1 : Numerical Methods , Dr. V.N. Vedamurthy & Dr. N. Ch. S. N. Iyengar, Vikas Publishing House.

The post Solution of Ordinary Differential and Higher Order Equations: Overview of initial and boundary value problems & Taylor series, Euler, Huen’s and Runge-Kutta methods appeared first on OnlineEngineeringNotes.

]]>
https://onlineengineeringnotes.com/2021/06/09/solution-of-ordinary-differential-and-higher-order-equations-overview-of-initial-and-boundary-value-problems-taylor-series-euler-huens-and-runge-kutta-methods/feed/ 0
Solution of Linear Algebraic Equations: Matrices and their properties, Elimination and Gauss Jordan methods, Method of factorization, power, iterative https://onlineengineeringnotes.com/2021/06/04/solution-of-linear-algebraic-equations-matrices-and-their-properties-elimination-and-gauss-jordan-methods-method-of-factorization-power-iterative/ https://onlineengineeringnotes.com/2021/06/04/solution-of-linear-algebraic-equations-matrices-and-their-properties-elimination-and-gauss-jordan-methods-method-of-factorization-power-iterative/#respond Fri, 04 Jun 2021 16:38:19 +0000 https://onlineengineeringnotes.com/?p=761 Matrices and properties Importance of linear equations First mathematical models of many of the real world problems are either linear or can beapproximated reasonably well using linear relationships. Analysis of linear relationship of variablesis generally easier than that of non-linear relationships.A linear equation involving two variables x and y has the standard form π‘Žπ‘₯ + ... Read more

The post Solution of Linear Algebraic Equations: Matrices and their properties, Elimination and Gauss Jordan methods, Method of factorization, power, iterative appeared first on OnlineEngineeringNotes.

]]>
Matrices and properties

Importance of 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 π‘›π‘œπ‘› βˆ’ π‘™π‘–π‘›π‘’π‘Žr

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

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 possibility 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 condition 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 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
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

On solving these equation we get x=2 & y=0
So slight changes results in huge change in solution.

Methods of solutions

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 π‘₯1from 2. Multiply 𝑅1 𝑏𝑦 βˆ’ 1&𝑅3 𝑏𝑦 4 and add to eliminate π‘₯1from 3

4π‘₯1 βˆ’ 2π‘₯2 + π‘₯3 = 15

βˆ’10π‘₯2+19π‘₯3 = 77

βˆ’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

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 method that avoid this by subtracting π‘Žπ‘–1/ π‘Ž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 guard 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.

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

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

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

Augmented matrix is

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.

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
𝐴𝑋 = B

n 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 𝐴 = πΏπ‘ˆ

πΏπ‘ˆπ‘‹ = 𝐡

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 LU
decomposition.

Dolittle LU decomposition

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

Example: Now find L & U either by using Dolittle algorithm

2π‘₯ βˆ’ 3𝑦 + 10𝑧 = 3
βˆ’π‘₯ + 4𝑦 + 2𝑧 = 20
5π‘₯ + 2𝑦 + 𝑧 = βˆ’12

The given system is 𝐴π‘₯ = 𝐡, where

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

2π‘₯ βˆ’ 3𝑦 + 10𝑧 = 3
π‘₯ = βˆ’4

Crout’s method

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

Example solve the following system by the method of crouts algorithms factorization
2π‘₯ βˆ’ 3𝑦 + 10𝑧 = 3
βˆ’π‘₯ + 4𝑦 + 2𝑧 = 20
5π‘₯ + 2𝑦 + 𝑧 = βˆ’12

The given system is 𝐴π‘₯ = 𝐡, where

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

𝑙33 = βˆ’ 253/ 5

So we have

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. 𝐴 = 𝐿𝐿 𝑇 = π‘ˆ 𝑇 π‘ˆ

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

Iterative 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

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.

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

We can simplify as

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 Iteration
π‘₯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
π‘₯3=0.998469
8 Iteration
 π‘₯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
Gauss Seidel Iteration method

This is a 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 + β‹― + π‘Žπ‘›π‘›π‘₯𝑛 = 𝑏3

We write the original system as

Now we can computer π‘₯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 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 recorder 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

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

Since the 6th and 7th approximate are almost same up to 4 decimal places, we can the result is

Β π‘₯1 = 3.0168, π‘₯2 = 1.9859, π‘₯3 = 0.9118

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.

Example: find the largest Eigen value πœ† and the corresponding vector v, of the matrix using power
method

Reference 1 : Numerical Methods , Dr. V.N. Vedamurthy & Dr. N. Ch. S. N. Iyengar, Vikas Publishing House.

The post Solution of Linear Algebraic Equations: Matrices and their properties, Elimination and Gauss Jordan methods, Method of factorization, power, iterative appeared first on OnlineEngineeringNotes.

]]>
https://onlineengineeringnotes.com/2021/06/04/solution-of-linear-algebraic-equations-matrices-and-their-properties-elimination-and-gauss-jordan-methods-method-of-factorization-power-iterative/feed/ 0
Numerical Differentiation and Integration https://onlineengineeringnotes.com/2021/06/02/numerical-differentiation-and-integration/ https://onlineengineeringnotes.com/2021/06/02/numerical-differentiation-and-integration/#respond Wed, 02 Jun 2021 16:52:53 +0000 https://onlineengineeringnotes.com/?p=704 Introduction Let us consider a set of values (π‘₯𝑖, 𝑦𝑖) of a function. The process of computing the derivative orderivatives of that function at some values of x from the given set of values is called NumericalDifferentiation. This may be done by first approximating the function by suitable interpolationformula and then differentiating. Derivatives using Newton’s ... Read more

The post Numerical Differentiation and Integration appeared first on OnlineEngineeringNotes.

]]>
Introduction

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

Derivate using Newton’s Backward Difference Formula

Newton’s backward interpolation formula is

At π‘₯ = π‘₯𝑛, 𝑝 = 0, hence putting p=0 in equation 10 we get

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

Example: find the first, second and third derivate of 𝑓(π‘₯)π‘Žπ‘‘ π‘₯ = 1.5 if

π‘₯1.52.02.53.03.54.0  
𝑓(π‘₯)3.3757.013.6252438.87559.0  

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

ere π‘₯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

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

Year19511961197119811991  
population (thousand)19.3636.6558.8177.2194.61

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:

Here β„Ž = 10, π‘₯𝑛 = 1991, βˆ‡π‘¦π‘› = 17.4, βˆ‡ 2𝑦𝑛 = βˆ’1, βˆ‡ 3𝑦𝑛 = 2.76, βˆ‡ 4𝑦𝑛= 11.99

We know derivate for backward difference is

Maxima and minima of tabulated function

We know Newton’s forward interpolation formula as :

We know that maximum and minimum values of a function 𝑦 = 𝑓(π‘₯) can be found by equating 𝑑𝑦/𝑑π‘₯ to zero and solution for x

Now for keeping only up to third difference we have

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

π‘₯-1123
𝑦-2115123  

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 )…

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 function

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

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

Central Difference Quotient

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

Derivative approximation is tabulated below as:

Note that the correct answer is 2. The derivative approximation approaches the exact value as h
decreases.
Now for central difference quotient

Numerical Integration

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)

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

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, … n

From the equation of trapezoidal rule,

The total area of all the n segments is

Above equation is known as composite trapezoidal rule

Simpson’s 1 ⁄ 3 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)

Simpson’s 3/8 rule( 4 point rule)

Example:

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

Romberg integration formula/ Richardson’s deferred approach to the limit or Romberg
method

Take an arbitrary value of h and calculate

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

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 x1,x2&x3 can be numerically integrated to obtain exact results.

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

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 called gauss Legrendre formula

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

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

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

Values for gaussian quadrature

Reference 1 : Numerical Methods , Dr. V.N. Vedamurthy & Dr. N. Ch. S. N. Iyengar, Vikas Publishing House.

The post Numerical Differentiation and Integration appeared first on OnlineEngineeringNotes.

]]>
https://onlineengineeringnotes.com/2021/06/02/numerical-differentiation-and-integration/feed/ 0
Interpolation and Approximation: Numerical Differentiation and Regression https://onlineengineeringnotes.com/2021/05/26/interpolation-and-approximation-numerical-differentiation-and-regression/ https://onlineengineeringnotes.com/2021/05/26/interpolation-and-approximation-numerical-differentiation-and-regression/#respond Wed, 26 May 2021 08:27:50 +0000 https://onlineengineeringnotes.com/?p=568 INTERPOLATION Introduction The process of estimating intermediate values between given data points is called Interpolation . The most common method used for this purpose is Polynomial Interpolation. Find the functional value for π‘₯ = 2.5 , i.e. 𝑓 2.5 = ? Is this a problem of Interpolation or extrapolation?? π‘₯ 1 3 4 6 9 ... Read more

The post Interpolation and Approximation: Numerical Differentiation and Regression appeared first on OnlineEngineeringNotes.

]]>

INTERPOLATION

Introduction

  • The process of estimating intermediate values between given data points is called Interpolation .
  • The most common method used for this purpose is Polynomial Interpolation.

Find the functional value for π‘₯ = 2.5 , i.e. 𝑓 2.5 = ? Is this a problem of Interpolation or extrapolation??

π‘₯13469
𝑓(π‘₯)416436723

Solution:
Step 1: Obtain the polynomial equation using tabular data points.
Suppose we got our polynomial as,
𝑓 π‘₯ = 4π‘₯
4 + 3π‘₯
2 + 2
Step 2 : Now, put π‘₯ = 2.5 in the above expression of 𝑓 π‘₯ which gives the desired answer

Note: The number of data points minus one defines the order of interpolation. If n number of data points are given, the order of the polynomial will be n-1.

Linear Interpolation

  • Connecting two data points with a straight line.
  • Suppose we are given two data points (π‘₯1, 𝑓 π‘₯1 ) and (π‘₯2, 𝑓 π‘₯2 ) .
  • We are going to derive the formula which helps to calculate 𝑓 π‘₯ for the given π‘₯ where π‘₯1 ≀ π‘₯ ≀ π‘₯2 .

Let us find the equation of straight line from the given two points (π‘₯1, 𝑓 π‘₯1 ) and (π‘₯2, 𝑓 π‘₯2 ) .

Demerits of Linear Interpolation

  • Linear Interpolation uses first order polynomial (i.e. straight line) to approximate the function.
  • To reduce this error, we need to use higher order polynomial.

Lagrange Interpolation Polynomial

  • Let π‘₯0, 𝑓0 , π‘₯1, 𝑓1 , and π‘₯2, 𝑓2 are the given data points.
xπ‘₯0π‘₯1π‘₯2
f𝑓0𝑓1𝑓2

Here, number of data points = 3 , so the polynomial will be of the order 2.

  • Let us consider a second order polynomial of the form 𝑝2 π‘₯ = 𝑏1 π‘₯ βˆ’ π‘₯0 π‘₯ βˆ’ π‘₯1 + 𝑏2 π‘₯ βˆ’ π‘₯1 π‘₯ βˆ’ π‘₯2 + 𝑏3 π‘₯ βˆ’ π‘₯2 π‘₯ βˆ’ π‘₯0 ………………..[1] where 𝑏1, 𝑏2 π‘Žπ‘›π‘‘ 𝑏3 π‘Žπ‘Ÿπ‘’ π‘‘β„Žπ‘’ π‘π‘œπ‘“π‘“π‘–π‘π‘–π‘’π‘›π‘‘π‘  π‘œπ‘“ π‘π‘œπ‘™π‘¦π‘›π‘œπ‘šπ‘–π‘Žπ‘™.
  • Given points π‘₯0, 𝑓0 , π‘₯1, 𝑓1 , and π‘₯2, 𝑓2 should satisfy the equation 1.
  • At π‘₯ = π‘₯π‘œ, 𝑝2 π‘₯0 = π‘“π‘œ,

Similarly, for π‘₯ = π‘₯1, 𝑝2 π‘₯1 = 𝑓1 Β 

Example 2.1
For the following data ,use Lagrange interpolation polynomial to find 𝑦 π‘Žπ‘‘ π‘₯ = 3.2.

x1245
y4961120

Solution: Here, π‘₯0 = 1, π‘₯1 = 2, π‘₯2 = 4, π‘₯3 = 5 , 𝑓0 = 4, 𝑓1 = 9, 𝑓2 = 61, 𝑓3 = 120

Now,

Newton Interpolation Polynomial

  • The Newton form of polynomial is 𝒑𝒏 (𝒙) = π’‚πŸŽ+ π’‚πŸπ’™ βˆ’ π’™πŸŽ + π’‚πŸ 𝒙 βˆ’ π’™πŸŽ 𝒙 βˆ’ π’™πŸ + π’‚πŸ‘ 𝒙 βˆ’ π’™πŸŽ 𝒙 βˆ’ π’™πŸ 𝒙 βˆ’ π’™πŸβ€¦ … … … … . . +𝒂𝒏 𝒙 βˆ’ π’™πŸŽ 𝒙 βˆ’ π’™πŸ … . . (𝒙 βˆ’ π’™π’βˆ’πŸ)
  • For given π‘₯0, 𝑓0 , π‘₯1, 𝑓1 , π‘₯2, 𝑓2 … … … (π‘₯𝑛, 𝑓𝑛), we need to find the value of coefficients π‘Ž0, π‘Ž1, π‘Ž2, π‘Ž3 … … … . . π‘Žπ‘›.
βœ“ If only two data points π‘₯0, 𝑓0 , π‘₯1, 𝑓1 are given, π’‘πŸ 𝒙 = π’‚πŸŽ+ π’‚πŸ 𝒙 βˆ’ π’™πŸŽ β†’ πŸπ’”π’• 𝒐𝒓𝒅𝒆𝒓 π’‘π’π’π’šπ’π’π’Žπ’Šπ’‚π’
βœ“ If three data points π‘₯0, 𝑓0 , π‘₯1, 𝑓1 , π‘₯2, 𝑓2 are given π’‘πŸ 𝒙 = π’‚πŸŽ + π’‚πŸ 𝒙 βˆ’ π’™πŸŽ + π’‚πŸ 𝒙 βˆ’ π’™πŸŽ 𝒙 βˆ’ π’™πŸ β†’ πŸπ’π’… 𝒐𝒓𝒅𝒆𝒓 π’‘π’π’π’šπ’π’π’Žπ’Šπ’‚π’
βœ“ Similarly, for four data points π‘₯0, 𝑓0 , π‘₯1, 𝑓1 , π‘₯2, 𝑓2 π‘₯3, 𝑓3 , π’‘πŸ‘ 𝒙 = π’‚πŸŽ + π’‚πŸ 𝒙 βˆ’ π’™πŸŽ + π’‚πŸ 𝒙 βˆ’ π’™πŸŽ 𝒙 βˆ’ π’™πŸ + π’‚πŸ‘(𝒙 βˆ’ π’™πŸŽ)(𝒙 βˆ’ π’™πŸ)(𝒙 βˆ’ π’™πŸ) β†’ πŸ‘π’“π’… 𝒐𝒓𝒅𝒆𝒓 π’‘π’π’π’šπ’π’π’Žπ’Šπ’‚π’
  • For π‘₯ = π‘₯0, 𝑝𝑛 (π‘₯0 )= 𝑓0 , we will get 𝑓0 = π‘Ž0 . π‘Ž0 = 𝑓0
  • For π‘₯ = π‘₯1, 𝑝𝑛 (π‘₯1 ) = 𝑓

or,  π‘“1 = π‘Ž0 + π‘Ž1 π‘₯1 βˆ’ π‘₯0

or, 𝑓1 = 𝑓0 + π‘Ž1 π‘₯1 βˆ’ π‘₯0 [since π‘Ž0 = 𝑓0]

𝑓2 = π‘Ž0 + π‘Ž1 π‘₯2 βˆ’ π‘₯0 + π‘Ž2(π‘₯2 βˆ’ π‘₯0)(π‘₯2 βˆ’ π‘₯1) which gives

Newton Divide Difference Table

The alternative way of finding the coefficients (π‘Ž0, π‘Ž1, π‘Ž2 π‘Žπ‘›π‘‘ π‘ π‘œ π‘œπ‘›) value is to use Newton divided difference table. For given π‘₯0, 𝑓0 , π‘₯1, 𝑓1 , π‘₯2, 𝑓2 , π‘₯3, 𝑓3 π‘Žπ‘›π‘‘ (π‘₯4, 𝑓4)

Example 2.2

Find the functional value for π‘₯ = 7 using Newton interpolation polynomial.

x56911
𝑓(π‘₯)12131416

Solution: Since 4 data points are given, the required polynomial will be of the order 3.

 π’‘πŸ‘ (𝒙) = π’‚πŸŽ + π’‚πŸ 𝒙 βˆ’ π’™πŸŽ + π’‚πŸ 𝒙 βˆ’ π’™πŸŽ 𝒙 βˆ’ π’™πŸ + π’‚πŸ‘ 𝒙 βˆ’ π’™πŸŽπ’™ βˆ’ π’™πŸ 𝒙 βˆ’ π’™πŸ

To get the value of π‘Ž0, π‘Ž1, π‘Ž2, π‘Ž3 π‘Žπ‘›π‘‘ π‘Ž4 , we are going to use Newton divided difference table.

Newton Forward Difference /Newton Backward Difference [Interpolation with equidistant points]

  • Particularly used when the functional values are given at a sequence of equally spaced points.
  • Also called as Newton Gregory technique.

Scenario 1:

x56911
𝑓(π‘₯)12131416

π»π‘’π‘Ÿπ‘’, π‘₯1 βˆ’ π‘₯0 = 6 βˆ’ 5 = 1 π‘€β„Žπ‘’π‘Ÿπ‘’π‘Žπ‘ , π‘₯2 βˆ’ π‘₯1 = 9 βˆ’ 6 = 3 Not equally spaced. We can’t use Newton Forward/Backward Difference. Rather, we need to rely on Lagrange or Newton Interpolation polynomial.

Scenario 2:

x1020304050
𝑓(π‘₯)072663124

Here, 𝒙 values are equally spaced. In this case we can use Newton forward difference or Newton backward difference.
𝑠𝑑𝑒𝑝 𝑠𝑖𝑧𝑒 β„Ž = 10

  • If required point is close to the start of the table, use Newton forward difference. 𝐴𝑑 π‘₯ = 15, 𝑓 (π‘₯) = ? π‘œπ‘Ÿ 𝐴𝑑 π‘₯ = 25, 𝑓 π‘₯ = ? [ First value of 𝒙 (𝐒. 𝐞. π‘₯0) acts as a reference point ]
  • If required point is close to the end of the table , use Newton backward difference. 𝐴𝑑 π‘₯ = 48, 𝑓 π‘₯ =? π‘œπ‘Ÿ 𝐴𝑑 π‘₯ = 35, π‘₯ = ? [ Last value of 𝒙 (𝐒. 𝐞. π‘₯𝑛) acts as a reference point ]
  • Simple difference is used here rather than divided difference which was used in Newton divided difference table. 𝑓1 βˆ’ 𝑓0 = 1𝑠𝑑 π‘œπ‘Ÿπ‘‘π‘’π‘Ÿ π‘ π‘–π‘šπ‘π‘™π‘’ π‘‘π‘–π‘“π‘“π‘’π‘Ÿπ‘’π‘›π‘π‘’

Newton Forward Difference

Let us create a forward difference table for given π‘₯0, 𝑓0 , π‘₯1, 𝑓1 , π‘₯2, 𝑓2 , π‘₯3, 𝑓3 π‘Žπ‘›π‘‘ (π‘₯4, 𝑓4)

Then, the Newton forward difference formula is given by,

Example 2.3:

Estimate the value of π‘ π‘–π‘›πœƒ π‘Žπ‘‘ πœƒ = 250 using Newton-Gregory forward difference formula.

πœƒ1020304050
sin(πœƒ)0.17360.34200.50000.64280.7660

Solution: Let us draw a Newton forward difference table to find the value of coefficients

π’‡πŸŽ = 𝟎. πŸπŸ•πŸ‘πŸ” , βˆ†π’‡πŸŽ = 𝟎. πŸπŸ”πŸ–πŸ’, βˆ† πŸπ’‡πŸŽ = βˆ’πŸŽ. πŸŽπŸπŸŽπŸ’ , βˆ† πŸ‘π’‡πŸŽ = βˆ’πŸŽ. πŸŽπŸŽπŸ’πŸ–, βˆ† πŸ’π’‡πŸŽ = 𝟎. 𝟎𝟎𝟎4

Newton forward difference formula is given by,

= 0.422665625

Newton Backward Difference

Let us create a forward difference table for given π‘₯0, 𝑓0 , π‘₯1, 𝑓1 , π‘₯2, 𝑓2 , π‘₯3, 𝑓3 π‘Žπ‘›π‘‘ (π‘₯4, 𝑓4)

Then, the Newton backward difference formula is given by,

Example 2.4
Estimate the value of π‘ π‘–π‘›πœƒ π‘Žπ‘‘ πœƒ = 45 0using Newton-Gregory backward difference formula.

πœƒ1020304050
sin(πœƒ)0.17360.34200.50000.64280.7660

Solution: Let us draw a Newton backward difference table to find the value of coefficients

From table, 𝑓4 = 0. 7660, 𝛻𝑓4 = 0.1232, 𝛻 2 𝑓4 = βˆ’0. 0196, 𝛻 3 𝑓4 = βˆ’0.0044, π‘Žπ‘›π‘‘ 𝛻 4 𝑓4 = 0.0004

Newton backward difference formula is given by

= 0.707509

NUMERICAL DIFFERENTIATION

Numerical Differentiation

  • Numerical differentiation is the process of computing the value of the derivative of an explicitly unknown function, with given discrete set of points(π‘₯𝑖 , 𝑓𝑖) .
  • To differentiate a function numerically, we first determine an interpolating polynomial and then compute the approximate derivative at the given point.
  • If π‘₯𝑖 ’s are equispaced use Newton’s forward/backward interpolation formula to find the derivative.
  • If π‘₯𝑖 ’s are not equispaced, we may find using Newton’s divided difference method or Lagrange’s interpolation formula and then differentiate it as many times as required.
Problem Scenario:
The following table gives the displacement, x (cm) of an object at various of time ,t(seconds). Find the velocity and acceleration of the object at t=1.2 sec. Use suitable interpolation method.
t 1.0 1.2 1.4 1.6 1.8
x 9.0 9.5 10.2 11.0 13.2

Numerical Derivatives using Newton Forward Interpolation

Newton forward interpolation formula is given by,

Numerical Derivatives using Newton Backward Interpolation

For given π‘₯0, 𝑓0 , π‘₯1, 𝑓1 , π‘₯2, 𝑓2 , π‘₯3, 𝑓3 π‘Žπ‘›π‘‘ (π‘₯4, 𝑓4) , Newton backward interpolation formula is given by

Example 2.5

x0123
y5638

Solution:

Newton difference table,

Formula for Newton forward interpolation is given by,

Example 2.6 Following table gives the census population of a state for the 1961 to 2001.

Year19611971198119912001
Population(million)19.9636.6558.8177.2194.61

Find the rate of growth of the population in the year 2001.
Solution: since given table is equi-spaced (h=10) and rate of growth is asked for 2001, we have to
use Newton backward interpolation.

𝑓4 = 94.61, βˆ‡ 𝑓4 = 17.40, βˆ‡ 2 𝑓4 = βˆ’1, βˆ‡ 3 𝑓4 = 2.76, βˆ‡ 4 𝑓4 = 11.99

Newton Backward Interpolation formula is give by,

Example 2.7 Compute f ’(3.5) and f ’’(4) given that f(0)=2, f(1)=3, f(2)=12, and f(5)=147

Solution:

x0125
y2312147

Since π‘₯𝑖 β€²s values are not equally spaced, we have to use either Lagrange or Newton divided difference formula.

Let us draw Newton divide difference table,

From table, π‘Ž0 = 2, π‘Ž1 = 1, π‘Ž2 = 4, π‘Ž3 = 1

Newton interpolation formula is given by,

 π‘“( π‘₯) = 𝑝3( π‘₯ )= π‘Ž0 + π‘Ž1 π‘₯ βˆ’ π‘₯0 + π‘Ž2 π‘₯ βˆ’ π‘₯0 π‘₯ βˆ’ π‘₯1 + π‘Ž3(π‘₯ βˆ’ π‘₯0)(π‘₯ βˆ’ π‘₯1)(π‘₯ βˆ’ π‘₯2)

Substituting the value of coefficients,

𝑓( π‘₯) = 2 + 1 π‘₯ βˆ’ 0 + 4 π‘₯ βˆ’ 0 π‘₯ βˆ’ 1 + 1(π‘₯ βˆ’ 0)(π‘₯ βˆ’ 1)(π‘₯ βˆ’ 2)

 𝑓 (π‘₯) = π‘₯ 3 + π‘₯ 2 βˆ’ π‘₯ + 2

REGRESSION

Regression : Introduction

β€’Interpolation: If we’re provided with various scattered data points then we try to find a curve
such that all the data points will exactly pass through it.(Perfect match)
β€’Regression: Here we try to fit a specific form of curve to the given data points. So, it may be
possible that all the points might not pass through the curve.(Generalizes the data)

Linear Regression

Fitting straight line to the given data points.

For given data points we need only one straight line (linear) which best fits the data.
The general form of equation:
π’š = 𝒂 + 𝒃𝒙
Value of coefficients a, b will be calculated with the help of given data points.

Linear Regression : Best Fitting Techniques

π‘’π‘Ÿπ‘Ÿπ‘œπ‘Ÿ = π‘‘π‘Ÿπ‘’π‘’ π‘£π‘Žπ‘™π‘’π‘’ βˆ’ π‘£π‘Žπ‘™π‘’π‘’ π‘œπ‘π‘‘π‘Žπ‘–π‘›π‘’π‘‘ π‘“π‘Ÿπ‘œπ‘š 𝑓𝑖𝑑𝑑𝑒𝑑 π‘’π‘žπ‘’π‘Žπ‘‘π‘–π‘œπ‘›

 π‘’0 = 𝑦0 βˆ’ (π‘Ž + 𝑏π‘₯0)

𝑒1 = 𝑦1 βˆ’ (π‘Ž + 𝑏π‘₯1)

𝑒2 = 𝑦2 βˆ’ (π‘Ž + 𝑏π‘₯2)

 π‘’3 = 𝑦3 βˆ’ (π‘Ž + 𝑏π‘₯3) 𝑦 = π‘Ž + 𝑏π‘₯

Β In General, 𝑒𝑖 = 𝑦𝑖 βˆ’ π‘Ž + 𝑏π‘₯𝑖 = 𝑦𝑖 βˆ’ π‘Ž βˆ’ 𝑏π‘₯i

Least Square Regression
I. Fitting Linear Equation of the form π’š = 𝒂 + 𝒃x

Error for each data point can be expressed as ,

𝑒𝑖 = 𝑦𝑖 βˆ’ π‘Ž + 𝑏π‘₯𝑖 = 𝑦𝑖 βˆ’ π‘Ž – 𝑏π‘₯𝑖

 In least squared approach, we use sum of square of errors, i.e

Total Error 𝑄 = 𝑒1 2 + 𝑒2 2 + 𝑒3 2 + 𝑒4 2 + … … … . . +𝑒𝑛 2

We have to choose π‘Ž π‘Žπ‘›π‘‘ 𝑏 such that total error 𝑄 is minimum. Since 𝑄 depends on π‘Ž π‘Žπ‘›π‘‘ 𝑏 , a necessary
condition for 𝑄 to be minimum is,

Example 2.8 Fit a straight line for the following data

x12345
y34568

Solution:

We have to fit straight line of the form
𝑦 = π‘Ž + 𝑏π‘₯
Normal equations for the above equation is,

n = 5 (number of data points given in table)
Now,
26 = 5π‘Ž + 15𝑏
90 = 15π‘Ž + 55𝑏
Upon solving these two equations, we get
π‘Ž = 1.60, 𝑏 = 1.20
Hence, the required straight line is, 𝑦 = π‘Ž + 𝑏π‘₯ = 𝟏. πŸ” + 𝟏. 𝟐x

Example 2.9: If P is pull required to lift a load W by means of a pulley, find a linear law of the form 𝑃 =
π‘šπ‘Š + 𝑐 using the following data. Also, find the value of P for W =30.
P 12 15 21 25
W 50 70 100 120

Hint: In 𝑃 = π‘šπ‘Š + 𝑐, π‘š π‘Žπ‘›π‘‘ 𝑐 are the coefficients whose value is to be determined with the help of given
data.

II. Fitting Power Equation of the form π’š = 𝒂𝒃 𝒙

 The power equation 𝑦 = π‘Žπ‘ π‘₯ is non linear in the form. First of all, we need to represent it into linear form.

 π‘¦ = π‘Žπ‘₯ 𝑏

 Taking 𝑙𝑛 on both sides,

ln 𝑦 = ln(π‘Žπ‘₯ 𝑏 )

ln 𝑦 = ln π‘Ž + 𝑏 ln(π‘₯)

Β Let us suppose, π‘Œ = ln 𝑦 , 𝐴 = ln 𝐴 , 𝑋 = ln π‘₯ . We get, π‘Œ = 𝐴 + 𝑏 𝑋 (Linear Form )

References :

  1. Balagurusamy, E. Numerical Methods. New Delhi: Tata McGraw-Hill Publishing Company Limited, 2008.
  2. Sastry, S.S. Introductory Methods of Numerical Analysis. New Delhi: PHI Learning Pvt. Ltd., 2012.
  3. Steven C. Chopra, Raymond P. Canale. Numerical Methods for Engineers. Newyork: MCGraw Hill Education,
    2015.

The post Interpolation and Approximation: Numerical Differentiation and Regression appeared first on OnlineEngineeringNotes.

]]>
https://onlineengineeringnotes.com/2021/05/26/interpolation-and-approximation-numerical-differentiation-and-regression/feed/ 0
Solution of Non- Linear Equation https://onlineengineeringnotes.com/2021/04/10/solution-of-non-linear-equation/ https://onlineengineeringnotes.com/2021/04/10/solution-of-non-linear-equation/#respond Sat, 10 Apr 2021 11:51:45 +0000 https://onlineengineeringnotes.com/?p=385 Bisection Method: This method is based on the repeated application of intermediate value property. Let, F(x) be continuous between a and b. Consider, F(a) be negative and F(b) be positive. Then, the first approximation of the root is x1= (a+b)/2 , if F(x1)= 0 then x1 is root of F(x)=0. Otherwise, the root lies between ... Read more

The post Solution of Non- Linear Equation appeared first on OnlineEngineeringNotes.

]]>

Bisection Method:

This method is based on the repeated application of intermediate value property. Let, F(x) be continuous between a and b.

Consider,

F(a) be negative and F(b) be positive.

Then, the first approximation of the root is x1= (a+b)/2 , if F(x1)= 0 then x1 is root of F(x)=0.

Otherwise, the root lies between a and x1 or x1 and b, according as F(x1) is positive or negative.

Then, we bisect the interval as before and continue the process until the root is found accuracy.

Problem: (By Bisection Method)

QNo.1 Find the real roots of the equation x3-2x-5=0

Solution:

Given,

Let,

F(x) = x3-2x-5

F(0) = -5

F(1) = -6

F(2) = -1

F(3) = 16

Also,

x1 = (a+b)/2

or, x1 = (2+3)/2 = 2.5

F(2.5) = (2.5)3 – 2*2.5-5 = 5.6250

Hence, the real root of the equation is 2.094.

False Position Method (Regula-Falsi Method)

Slope of AB = Slope of AC

Or, {F(b)-F(a) }/(b-a) = {0-F(a)}/(c-a)

Or, c-a = {-F(a) * (b-a)} / { F(b) – F(a)}

Or, c = a – {F(a) * (b-a)} / { F(b) – F(a)}

∴ c =  {a *F(a) – bF(a) } / {F(b) – F(a)}

Working Procedure (Method):-

1. Find the interval (a,b)

 Straight F(a) F(b) <0

2. Find c = {a* F(a) – bF(a) } / {F(b) – F(a)}

3. F(a) F(c) <0 roots lies in (a,c) & F(b) F(c)<0 roots lies in (c,b)

4. Repeat step (1.) and (2.)

Problem: ( By False Position Method)

Qno.1 Find a real root of x3-2x-5=0 using the method false position upto four iteration.

Solution:

Let, F(x) = x3-2x-5

        F(2) = -1

        F(3) = 16

Now,

I- interation

a=2, F(a)= -1

b=3,F(b)= 16

Using the formula, we get

 c = {a* F(a) – bF(a) } / {F(b) – F(a)}

or, c= (32+3)/(16+1) = 2.0588

F(c)= F(2.0588)= -0.3908<0

II-interation

a= 2.0588, F(a) = -0.3908

b= 3, F(b) = 16

c = {a* F(a) – bF(a) } / {F(b) – F(a)}

or, c= {16(2.0588)+3(0.3908)}/(16+0.3908) = 2.0812

F(c) = F(2.0812) = -0.1479

III-interation

a=2.0812, F(a) = -0.1479

b= 3 , F(b) = 16

c = {a* F(a) – bF(a) } / {F(b) – F(a)}

or, c = {16(2.08120)+3(0.1479)}/(16+0.1479)= 2.0896

F(c)=F(2.0896)=-0.0551<0

IV-interation

a=2.0896, F(a) = -0.0551

b= 3 , F(b) = 16

c = {a* F(a) – bF(a) } / {F(b) – F(a)}

or, c = {16(2.0896)+3(0.0551)}/(16+0.0551)= 2.0927

Hence, the required root is = 2.0927.

Fixed Point Iteration Method (Iteration Method)

Suppose we have equation F(x) = 0. The equation can be expressed as x = Ο•(x)

At x= x0

|Ο•| (x) |< 1

Then, iterative method applied. The suceesive approximation is

Given by xn= Ο•(xn-1)

                x1= Ο•(x0)

                x2= Ο•(x1)

Now,

xn = 1 / (1+ xn-1)1/2

Problem: (By Fixed Point Iteration Method)

Qno1. Find the roots of cosx = 3x -1, correct to four decimal places by iteration method.

Solution:

Let,

F(x) = cosx – 3x+1

F(0)= 2

F( Ο€/2) = 0 – (3 Ο€/2)+ 1 < 0

Now,

x =  Ο•(x) —————————-(i)

So, taking equation

Cosx = 3x-1

Or, 3x = 1 + cosx

Or, x = (1+ cosx)/3

Now,

Equation (i) is

Ο•(x) = (1+ cosx)/3

Differentiating on both side w.r.t x

|Ο•| (x) | = |sinx/3 |

At x0 = 0

|Ο•| (x) | = |sin0/3 | <1

Or, |Ο•| (x) | = 0 <1

Now,we  can apply equation

x= (1+cosx)/3

Now,

xn = (1+ cos xn-1)/3

Put, n=1

x1 = (1+cos x0)/3 = 0.066667

Put, n = 2

x2 = (1+ cos (0.066667) * 57.3)/3 = 0.595296

x3 = (1+cos(0.595296)* 57.3)/3 = 0.609328

x4 = (1+cos(0.609328)* 57.3)/3 = 0.606678

x5 = (1+cos(0.606678)* 57.3)/3 = 0.60782

x6 = (1+cos(0.60782)* 57.3)/3 = 0.607086

x7 = (1+cos(0.607086)* 57.3)/3 = 0.607105

x8 = (1+cos(0.607105)* 57.3)/3 = 0.607101

The correct root to four decimal places is 0.6071.

Secant Method ( Chord Method)

This method is quite similar to false position method except for the condition F(x1) F(x2) < 0.

Slope of AB = Slope of AC

Or, x-x0 = – {F(x0)(x1-x0)}/{ F(x1) – F(x0)}

Or, x = {x0F(x1) – x1F(x0)}/ { F(x1) – F(x0)}

Now,

xn+2 = {xnF(xn+1) – xn+1F(xn)}/{F(xn+1) – F(xn)}

This method fails when F(xn) = F(xn+1).

Problem:( By Secant Method)

Qno.1. Estimate the root of the equation cosx-xex= 0 . Using the secant method with initial estimate of x1 = 0.5 , x2=1.

Solution:

F(x) = cosx – xex

F(x1)=F(0.5)= cos(0.5) – (0.5) e(0.5) = 0.0532

F(x2)=F(1)= cos(1) – (1) e(1) = -2.17798

xn+1 = {xn=1 F(xn) – xnF(xn-1)}/ {F(xn)- F(xn-1)}

Put, n=2

x3 = {x1F(x2)-x2F(x1)} / {F(x2) – F(x1)} = 0.5119

F(x3) = F(0.5119)= cos(0.5119) – (0.5119) e(0.5119) = 0.01773

Put, n=3

x4 = { x2F(x3)-x3F(x2)} / {F(x3) – F(x2)} = 0.5158

F(x4) = F(0.5158)= cos(0.5158) – (0.5158) e(0.5158) = 0.00544

Put, n=4

x5 = { x3F(x4)-x4F(x3)} / {F(x4) – F(x3)} = 0.5178

F(x5) = F(0.5178)= cos(0.5178) – (0.5178) e(0.5178) = 0.00012

Put, n=5

x6 = { x4F(x5)-x5F(x4)} / {F(x5) – F(x4)} = 0.5178

F(x5) = F(0.5178)= cos(0.5178) – (0.5178) e(0.5178) = 0.00012

Hence, the root of the equation is 0.5178.

Newton Raphson Method

Equation of Tangent

y-F(x0) = F’(x0) (x1-x0)

or, 0-F(x0) = F’(x0) (x1-x0)

or, x1-x0= -F(x0) / F’(x0)

or, x1 = x0 -F(x0) / F’(x0)

Now,

xn+1 = xn -F(xn) / F’(xn) ,  F’(xn)  β‰  0

Problem: ( By Newton Raphson Method)

Qno1. Find by Newton Raphson Method a root of equation x3-3x- 5 = 0.

Solution:

F(x)= x3-3x- 5

F(2)= -3

F(3)= 16

Now,

F’(x) = 3 x2– 3

Using Formula,

xn+1 = xn -F(xn) / F’(xn)

or, xn+1 = xn – (xn3-3 xn – 5)/(3 xn 2– 3)

Put, n=0

x1 = x0 – (x03-3 x0 – 5)/(3 x0 2– 3) = 2.3333

Put, n=1

x2 = x1 – (x13-3 x1 – 5)/(3 x1 2– 3) = 2.2805

Put, n=2

x3 = x2 – (x23-3 x2 – 5)/(3 x2 2– 3) = 2.2790

Put, n=3

x4 = x3 – (x33-3 x3 – 5)/(3 x3 2– 3) = 2.2790

Hence, the required root is 2.2790.

Reference 1 : Numerical Methods , Dr. V.N. Vedamurthy & Dr. N. Ch. S. N. Iyengar, Vikas Publishing House.

The post Solution of Non- Linear Equation appeared first on OnlineEngineeringNotes.

]]>
https://onlineengineeringnotes.com/2021/04/10/solution-of-non-linear-equation/feed/ 0