Difference equation corresponds to $y''=-y$

209 Views Asked by At

Convert the differential equation $y''=-y$ into a difference equation using the leapfrog method.

My reference says: $$ \begin{bmatrix}1&0\\\Delta t&1\end{bmatrix}\begin{bmatrix}Y_{n+1}\\Y_{n+1}^{'}\end{bmatrix}=\begin{bmatrix}1&\Delta t\\0&1\end{bmatrix}\begin{bmatrix}Y_{n}\\Y_{n}^{'}\end{bmatrix}\implies \begin{bmatrix}Y_{n+1}\\Y_{n+1}^{'}\end{bmatrix}=\begin{bmatrix}1&\Delta t\\-\Delta t&1-(\Delta t)^2\end{bmatrix}\begin{bmatrix}Y_{n}\\Y_{n}^{'}\end{bmatrix}\\ Y_{n+1}=Y_n+\Delta t.Y_n^{'}\implies Y_{n+1}-Y_n=\Delta t.Y_n^{'} \\ \Delta t.Y_{n+1}+Y_{n+1}^{'}=Y_n^{'} \implies Y_n^{'}-Y_{n+1}^{'}=\Delta t.Y_{n+1} $$ Looks like the first equation is obtained by taking forward difference and later by backward. How do I justify such a choice ?

My Attempt

$$ Y_n^{'}=\frac{Y_{n+1}-Y_{n-1}}{2\Delta t}\\ Y_{n}^{''}=\frac{Y_{n+1}^{'}-Y_{n-1}^{'}}{2\Delta t}=\frac{\frac{Y_{n+2}-Y_{n}}{2\Delta t}-\frac{Y_{n}-Y_{n-2}}{2\Delta t}}{2\Delta t}=\frac{Y_{n+2}-2Y_{n}+Y_{n-2}}{(2\Delta t)^2}=\frac{Y_{n+1}-2Y_{n}+Y_{n-1}}{(\Delta t)^2}=-Y_{n}\\ \boxed{Y_{n+1}=Y_{n-1}+2\Delta t.Y_{n}^{'}\\ Y_{n+1}^{'}=Y_{n-1}^{'}-2\Delta t.Y_{n}} $$ $$ Y_{n-1}=(2-(\Delta t)^2)Y_n-Y_{n+1}\implies Y_{n+1}=(2-(\Delta t)^2)Y_n-Y_{n+1}+2\Delta t.Y_{n}^{'}\\ \boxed{Y_{n+1}=\frac{(2-(\Delta t)^2)}{2}Y_n+\Delta t.Y_n^{'}} $$

How do I approach this and obtain the matrix difference equation corresponds to $y''+y=0$ using midpoint differences ?

Reference: Example 3-Difference Equations (Page 323) and Q.28 Problem Set 6.3 (Page 335), Chapter 6 : Eigenvalues and Eigenvectors , Introduction to Linear Algebra, Gilbert Strang, Fifth Edition (2016)

1

There are 1 best solutions below

0
On

The equation you get for $Y_{n+1}$ is the same as what Wikipedia says for the Leapfrog Scheme:

$$Y_{n+1} = Y_n + Y_n' \Delta t + 0.5 (-Y_n) \Delta t^2$$ while the update equation for $Y'_{n+1}$ should be according to Wikipedia: \begin{align} Y'_{n+1} &= Y'_n + 0.5 (-Y_n -Y_{n+1}) \Delta t \\ &= Y'_{n-1} + 0.5 (-Y_{n-1} -Y_{n}) \Delta t + 0.5 (-Y_n -Y_{n+1}) \Delta t \\ &=Y_{n-1}' +0.5(-Y_{n-1} -2Y_{n} -Y_{n+1}) \Delta t \end{align}