Holooly Plus Logo

Question 10.4: Solving by hand a first-order ODE using the second-order Run......

Solving by hand a first-order ODE using the second-order RungeKutta method.

Use the second-order Runge-Kutta method (modified Euler version) to solve the ODE \frac{d y}{d x}=-1.2 y+7 e^{-0.3 x} from x=0 to x=2.0 with the initial condition y=3 at x=0.

Solve by hand using h=0.5.

Step-by-Step
The 'Blue Check Mark' means that this solution was answered by an expert.
Learn more on how do we answer questions.

The equation is solved with the modified Euler method in Example 10-3, where the solution is obtained by writing a MATLAB program in a script file. Here, in order to illustrate how the RungeKutta method is applied, the calculations are carried out by hand.

The first point of the solution is (0,3), which is the point where the initial condition is given. The values of x and y at the first point are x_{1}=0 and y_{1}=3.

The rest of the solution is done by steps. In each step the next value of the independent variable is given by:

x_{i+1}=x_{i}+h=x_{i}+0.5      (10.77)

The value of the dependent variable y_{i+1} is calculated by first calculating K_{1} and K_{2} using Eq. (10.64):

\begin{gathered} K_{1}=f\left(x_{i}, y_{i}\right) \\ K_{2}=f\left(x_{i}+h, y_{i}+K_{1} h\right) \end{gathered}       (10.78)

and then substituting the Ks in Eq. (10.63):

y_{i+1}=y_{i}+\frac{1}{2}\left(K_{1}+K_{2}\right) h       (10.79)

First step: In the first step i=1. Equations (10.77)-(10.79) give:

x_{2}=x_{1}+0.5=0+0.5=0.5

 

K_{1}=-1.2 y_{1}+7 e^{-0.3 x_{1}}=-1.2 \cdot 3+7 e^{-0.3 \cdot 0}=3.4

 

y_{1}+K_{1} h=3+3.4 \cdot 0.5=4.7

 

K_{2}=-1.2\left(y_{1}+K_{1} h\right)+7 e^{-0.3\left(x_{1}+0.5\right)}=-1.2 \cdot 4.7+7 e^{-0.3 \cdot 0.5}=0.385

 

y_{2}=y_{1}+\frac{1}{2}\left(K_{1}+K_{2}\right) h=3+\frac{1}{2}(3.4+0.385) \cdot 0.5=3.946

At the end of the first step: x_{2}=0.5, y_{2}=3.946

Second step: In the second step i=2. Equations (10.77)-(10.79) give:

x_{3}=x_{2}+0.5=0.5+0.5=1.0

 

K_{1}=-1.2 y_{2}+7 e^{-0.3 x_{2}}=-1.2 \cdot 3.946+7 e^{-0.3 \cdot 0.5}=1.290

 

y_{2}+K_{1} h=3.946+1.290 \cdot 0.5=4.591

 

K_{2}=-1.2\left(y_{2}+K_{1} h\right)+7 e^{-0.3\left(x_{2}+0.5\right)}=-1.2 \cdot 4.591+7 e^{-0.3 \cdot 1.0}=-0.3223

y_{3}=y_{2}+\frac{1}{2}\left(K_{1}+K_{2}\right) h=3.946+\frac{1}{2}(1.290+(-0.3223)) \cdot 0.5=4.188

At the end of the second step: x_{3}=1.0, y_{3}=4.188

Third step: In the third step i=3. Equations (10.77)-(10.79) give: x_{4}=x_{3}+0.5=1.0+0.5=1.5

 

K_{1}=-1.2 y_{3}+7 e^{-0.3 x_{3}}=-1.2 \cdot 4.188+7 e^{-0.3 \cdot 1.0}=0.1601

 

y_{3}+K_{1} h=4.188+0.1601 \cdot 0.5=4.268

 

K_{2}=-1.2\left(y_{3}+K_{1} h\right)+7 e^{-0.3\left(x_{3}+0.5\right)}=-1.2 \cdot 4.268+7 e^{-0.3 \cdot 1.5}=-0.6582

y_{4}=y_{3}+\frac{1}{2}\left(K_{1}+K_{2}\right) h=4.188+\frac{1}{2}(0.1601+(-0.6582)) \cdot 0.5=4.063

At the end of the third step: x_{4}=1.5, y_{4}=4.063

Fourth step: In the third step i=4. Equations (10.77)-(10.79) give:

x_{5}=x_{4}+0.5=1.5+0.5=2.0

 

K_{1}=-1.2 y_{4}+7 e^{-0.3 x_{4}}=-1.2 \cdot 4.063+7 e^{-0.3 \cdot 1.5}=-0.4122

 

y_{4}+K_{1} h=4.063+(-0.4122) \cdot 0.5=3.857

 

K_{2}=-1.2\left(y_{4}+K_{1} h\right)+7 e^{-0.3\left(x_{4}+0.5\right)}=-1.2 \cdot 3.857+7 e^{-0.3 \cdot 2.0}=-0.7867

 

y_{5}=y_{4}+\frac{1}{2}\left(K_{1}+K_{2}\right) h=4.063+\frac{1}{2}(-0.4122+(-0.7867)) \cdot 0.5=3.763

At the end of the fourth step: x_{5}=2.0, y_{5}=3.763

The solution obtained is obviously identical (except for rounding errors) to the solution in Example 10-3.

Related Answered Questions