# Modified Euler Method for second order differential equations

The question I am doing is asking me to carry out the Modified Euler method for a second order differential equation:

Consider the following initial value problem: $$y''=\frac{2}{x}y'-\frac{2}{x^2} y - \frac{1}{x^2},\quad y(1)=0, \quad y'(1)=1$$ Calculate the numerical solution at $x=1.2$ using the modified Euler's method. Take the step length $h=0.2$ and work to $6$ decimal digit accuracy.

So far whilst studying ODEs I have only come across numerical methods for first order differential equations. How do I go about solving this?

Usually, $f(x,y) = y'$ but what does $f(x,y)$ equal this time?

• Were you able to use the answer to resolve your problem? Aug 18, 2013 at 23:39
• Not quite - it was useful but it didn't resolve my problem. Hence why I haven't accepted it as an answer just yet. Aug 19, 2013 at 4:42
• I added an answer to add more details, see if that helps. Regards Aug 19, 2013 at 5:15

As lhf mentioned, we need to write this as a system of first order equations and then we can use Euler's Modified Method (EMM) on the system.

We can follow this procedure to write the second order equation as a first order system. Let $w_1(x) = y(x)$, $w_2(x) = y'(x)$, giving us:

• $w'_1 = y' = w_2$
• $w'_2 = y'' = \left(\dfrac{2}{x}\right)w_2 -\left(\dfrac{2}{x^2}\right)w_1 - \dfrac{1}{x^2}$

Our initial conditions become:

$$w_1(1) = 0, w_2(1) = 1$$

Now, you can apply EMM and you can see how you step through that (only Euler method, but it will give you the approach) at The Euler Method for Higher Order Differential Equations

From the given conditions, we are only doing one step of the algorithm, since we are starting at $x=1$ and want to find the result at $x=1.2$, where $h=0.2$.

Also note, we can compare the numerical solution to the exact result, which is:

$$y(x) = \dfrac{1}{2}\left(x^2-1\right)$$

That should be enough to guide you.

• Needs another TU! $\small{+1}$ Aug 19, 2013 at 12:35
• Hey, you capped for the day. Congrats! (As Asaf commented to me when I was approaching the 20k threshold: "I feel I can almost trust you!") Aug 19, 2013 at 12:54
• Yes, indeed, in fact, you can still earn a few more points that count. Capping is officially when you've received 200 points from upvotes alone, within a Math.SE day, such that no more reputation points can be earned from additional upvotes, (but the votes themselves "stand"). For example, I've "capped", and will not earn any more points today (until 5 pm your time), unless those points come from "accepts". Aug 19, 2013 at 13:00

Since this is a second-order equation, you need to pack $u=(y,y')$ and then write $u'=(y',y'')=(y',f(x,y))=g(x,u)$.

use y'=z and y''=z' and then solve both equation simultaneously