huen's method Archives - OnlineEngineeringNotes https://onlineengineeringnotes.com/tag/huens-method/ A Complete Guide to future Engineers Wed, 09 Jun 2021 16:19:08 +0000 en-US hourly 1 https://wordpress.org/?v=6.5.3 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