B Euler's method for second order DE

Karol
Messages
1,380
Reaction score
22
Can the Euler approximation method be used to solve higher order DE?
I have ##\ddot x=\omega^2 x## which i rewrite as ##y''=\omega^2y##. initial conditions y(0)=0, y'(0)=1.
The Euler method: ##y_{n+1}=y_n+h\cdot y'_n##. i use this to make:
$$y''_{n+1}=y'_n+h\cdot y''_n~~\rightarrow~~\omega^2y_{n+1}=y'_n+h\omega^2 y_n$$
$$\omega^2(y_n+hy'_n)=y'_n+h\omega^2 y_n$$
$$\rightarrow~y'_n=\left[ \frac{\omega^2(1-h)}{1-\omega^2h} \right]y_n$$
But this contradicts the initial condition y'(0)=1, after i substitute y(0)=0 in the formula i found.
 
Physics news on Phys.org
Wouldn't the Euler method dictate $$y'_{n+1} = y'_n + h\omega^2y_n$$ ?
 
Karol said:
Can the Euler approximation method be used to solve higher order DE?
Yes, every explicit first order method can be used to solve higher-order DE by writing the DE in vector form as a system of first-order DE, also see below.
Karol said:
I have ##\ddot x=\omega^2 x## which i rewrite as ##y''=\omega^2y##. initial conditions y(0)=0, y'(0)=1.
I do not quite understand the purpose of introducing ##y##, but it does no harm. Also, this equation looks like a free harmonic oscillator. Are you sure there should not be a minus in front of ##\omega^2##?
Karol said:
The Euler method: ##y_{n+1}=y_n+h\cdot y'_n##.
BvU said:
Wouldn't the Euler method dictate $$y'_{n+1} = y'_n + h\omega^2y_n$$ ?
I think that the OP and @BvU both have one half of the method for this problem :wink:.

As I alluded to at the start, you can solve higher order DE by converting them into a system of first order DE. Although not strictly necessary, this works best by introducing new symbols for the derivatives. For this example, set ##v := y'##, then the DE ##y''(t) = \omega^2y(t)## is equivalent to
$$
\left\{
\begin{align*}
y'(t) &= v(t)\\
v'(t) &= \omega^2y(t)
\end{align*}
\right.
$$
with the initial conditions ##y(0) = 0##, ##v(0) = 1##. Then Euler forward with stepsize ##h > 0## just reads
$$
\begin{align*}
\begin{bmatrix}
y_{n+1}\\
v_{n+1}
\end{bmatrix}
&\approx
\begin{bmatrix}
y_n\\
v_n
\end{bmatrix}
+
h
\begin{bmatrix}
y'(nh)\\
v'(nh)
\end{bmatrix}\\
&=
\begin{bmatrix}
y_n\\
v_n
\end{bmatrix}
+
h
\begin{bmatrix}
v_n\\
\omega^2y_n
\end{bmatrix}
\end{align*}
$$
where ##y_n := y(nh)## and ##v_n := v(nh)## for ##n = 0, 1,\ldots##. The first component is what the OP called the Euler method, while the second component appears in post #2.
 
Krylov said:
this equation looks like a free harmonic oscillator. Are you sure there should not be a minus in front of ##\omega^2## ?
It is taken from a mathematics book, teaching DE, not a physics book.
I thank you very much BvU and Krylov.
How do you quote exactly also the equations in the posts, since when i use the "+Quote" function that is given in this site, or i mark a part of a post and select "+Quote" from the context menu that appears, and then insert these quotes in the reply box the equations come out messed, while the text is good. i manually fix these equations, almost completely write them anew.
And also, how can you copy a poster's name, like Krylov did in the last post:
Snap1.jpg
 
Karol said:
It is taken from a mathematics book, teaching DE, not a physics book.
I thank you very much BvU and Krylov.
Ok. Whenever I see an ##\omega^2## somewhere, I start to think of ##\tfrac{k}{m}##.
You are welcome!
Karol said:
How do you quote exactly also the equations in the posts, since when i use the "+Quote" function that is given in this site, or i mark a part of a post and select "+Quote" from the context menu that appears, and then insert these quotes in the reply box the equations come out messed, while the text is good. i manually fix these equations, almost completely write them anew.
I recognize this and it is a bit uncomfortable. Probably there are better ways, but what usually do, is put the cursor where I want the quote (with formulas) to appear and then press "reply". This quotes the entire message with formulas correctly. Then I remove the excess text that I do not want quoted.

You can also right-click on an equation, then "Show Math As", then "TeX Commands". This opens a pop-up containing the ##\LaTeX## source. That context menu has some other options, too, it appears.
Karol said:
And also, how can you copy a poster's name, like Krylov did in the last post:
You write the member name with an "@" in front, like @Karol. When the member has enabled this, it will show him a message that he has been "mentioned" in a certain thread.
 
Thank you very much BvU and Krylov
 
Are there any good visualization tutorials, written or video, that show graphically how separation of variables works? I particularly have the time-independent Schrodinger Equation in mind. There are hundreds of demonstrations out there which essentially distill to copies of one another. However I am trying to visualize in my mind how this process looks graphically - for example plotting t on one axis and x on the other for f(x,t). I have seen other good visual representations of...
Back
Top