We are given:
$$y'=\dfrac{3x-2y}{x}\quad y(1)=0$$
Interval is $x \in[1,2]$, and a given step size $h=0.1$
We have:
- $h = \dfrac{b-a}{N} = .1 = \dfrac{2-1}{N} \rightarrow N = 10$
- $x = a = 1$
- $y(a) = y(1) = \alpha = 0 \rightarrow a = 1, \alpha = 0$
Set:
- $x_0 = 1, x_i = 1 + 0.1 i, y_0 = 0$
- Using Euler's, we have: $y_i = y_{i-1} + hf(x, y) = y_{i-1} + .1\left(\dfrac{3 x_{i-1} - 2 y_{i-1}}{x_{i-1}}\right)$
For $i= 1$, we have:
$x_0 = 1, y_0 = 0, y_1 = y_{0} + .1\left(\dfrac{3 x_{0} - 2 y_{0}}{x_{0}}\right) = 0 + .1 \dfrac{3 (1) - 2(0)}{1.1} = 0.3$
For $i= 2$, we have:
$x_1 = 1.1, y_1 = 0.3, y_2 = y_{1} + .1\left(\dfrac{3 x_{1} - 2 y_{1}}{x_{1}}\right) = 0.3 + .1 \dfrac{3 (1.1) - 2(.3)}{1.1} = 0.5454$
Continuing this way, we generate the table:
$~~~~~\text{Step} ~~|~~ x ~~~|~~ y $
- $~~00 ~~| 1.0~~ | 0. $
- $~~01 ~~| 1.1 ~~| 0.3 $
- $~~02 ~~| 1.2 ~~| 0.545455 $
- $~~03 ~~| 1.3 ~~| 0.754545 $
- $~~04 ~~| 1.4 ~~| 0.938462 $
- $~~05 ~~| 1.5 ~~| 1.1044 $
- $~~06 ~~| 1.6 ~~| 1.25714 $
- $~~07 ~~| 1.7~~ | 1.4 $
- $~~08 ~~| 1.8~~ | 1.53529 $
- $~~09 ~~| 1.9 ~~| 1.66471$
- $~~10~~| 2.0~~ | 1.78947 $
The exact solution is given by:
$$y(x) = \dfrac{x^3-1}{x^2}$$
At $x=2$, we have: $y(2) = \dfrac{7}{4} = 1.75$
Compare that to Euler's method, which has $1.78947$.
We are given:
$$y'=\dfrac{3x-2y}{x}\quad y(1)=0$$
Interval is $x \in[1,2]$, and a given step size $h=0.1$
For Heun's (Improved Euler's), we have:
- $h = \dfrac{b-a}{N} = .1 = \dfrac{2-1}{N} \rightarrow N = 10$
- $x = a = 1, y(a) = y(1) = \alpha = 0 \rightarrow a = 1, \alpha = 0$
- Set: $x_0 = 1, x_i = 1 + 0.1 i, y_0 = 0$
- Using Heun's (Improved Euler's), we have:
$y_{i+1} = y_{i} + \dfrac{h}{4}\left[f(x_i, y_i)+3f(x_i + \dfrac{2}{3}h, y_i+\dfrac{2}{3}hf(x_i,y_i))\right]$, so
$y_{i+1} = y_{i} + \dfrac{1}{40}\left[\dfrac{3 x_{i-1} - 2 y_{i-1}}{x_{i-1}} + 3\left(\dfrac{3 (x_i + \dfrac{2}{3}(.1)) - 2 (y_i+\dfrac{2}{3}(.1)\dfrac{3 x_{i-1} - 2 y_{i-1}}{x_{i-1}}}{x_i + \dfrac{2}{3}(.1)}\right) \right]$
$x_0 = 1, y_0 = 0, y_1 = 0 + \dfrac{1}{40}\left[3 + 3\dfrac{3(1+(2/3)(.1)) - 2(2(.1))}{1 + (2/3)(.1)} \right] = 0.271875$
Continuing this way, we generate the table:
$~~~~~\text{Step} ~~|~~ x ~~~|~~ y $
- $~~00 ~~| 1.0 ~~| ~~ 0.00000 $
- $~~01 ~~| 1.1 ~~| ~~ 0.271875 $
- $~~02 ~~| 1.2 ~~| ~~ 0.503084 $
- $~~03 ~~| 1.3 ~~| ~~ 0.705482 $
- $~~04 ~~| 1.4 ~~| ~~ 0.886908 $
- $~~05 ~~| 1.5 ~~| ~~ 1.05271 $
- $~~06 ~~| 1.6 ~~| ~~ 1.20664 $
- $~~07 ~~| 1.7 ~~| ~~ 1.35138 $
- $~~08 ~~| 1.8 ~~| ~~ 1.48891 $
- $~~09 ~~| 1.9 ~~| ~~ 1.6207 $
- $~~10 ~~| 2.0 ~~| ~~ 1.74786$
The exact solution is given by:
$$y(x) = \dfrac{x^3-1}{x^2}$$
At $x=2$, we have: $y(2) = \dfrac{7}{4} = 1.75$
Compare that to Heun's (Improved Euler's) method, which has $1.74786$.
Look at how much better this estimate is over regular Euler's from earlier.
Best Answer
To be complete, it is worth noting that there are many variants of Runge-Kutta (RK), including some new ones. These include, but are not limited to:
For this problem, I will assume you want to typical fourth order RK (RK4).
Initialization
Iteration using RK4
Results
Continuing with this itearation, we generate the following table.
$~~~~~\text{Step} ~~|~~~~ x ~~~|~~ y $
The exact solution is given by:
$$y(x) = \dfrac{x^3-1}{x^2}$$
At $x=2$, we have: $y(2) = \dfrac{7}{4} = 1.75$
Compare that to Runge-Kutta's-4 method, which has $1.75$.