# How can I use the Heun's method to solve this first order Initial Value Problem?

My Problem is this given Initial Value Problem: $$y^{\prime}=\frac{3x-2y}{x}\quad y(1)=0$$ I am looking for a way to solve this problem using Heun's method. I have a given Interval of $[1,2]$ and a given step size of $h=0.1$

The example is already solved with a numerical solution. But i want to know more. See here. After discussing the solution by Eulers Method with a friend, he told me about Heun's method. But we failed to apply it to our example. How would Heun's method be applied to this problem?

-
I know you are not looking for this. But have you tried the integration factor method? To me it looks fine, although the solution is not explicit: it involves an integral. – awllower Jul 9 '13 at 6:22
When i am finished, i will try this method as well. Thanks! – Toralf Westström Jul 9 '13 at 8:35

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

• For $i= 1$, we have:

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

-
+1 very nice Amzoti. I don't know this method, but I think I need knowing it. :-) – Babak S. Jul 9 '13 at 8:08
@BabakS.: Thank you my friend, those take me too long to type up! :-) Have a great day! Regards – Amzoti Jul 9 '13 at 12:59
Nice work, and + too for all the typing! (+) – amWhy Jul 10 '13 at 0:04
@amWhy: Thanks, it is good to do some of those once in a while to stay in practice! :-) – Amzoti Jul 10 '13 at 0:07
Whoa, that's a long hike! Were you "off" of work today? Or on an extended vacation (a couple days off tacked on the the long weekend?) – amWhy Jul 10 '13 at 0:18