Forward and Backward Euler method for a system of first-order differential equations

634 Views Asked by At

I was given the following second-order differential equation, \begin{equation}y^{\prime\prime}+2y^{\prime}+y=g(t),\end{equation} and that the solution is $y(t)=(1+t)(1+e^{-t})$. Using the solution I determined that \begin{equation}g(t)=t+3.\end{equation}

Following from this I transformed this second-order differential equation into a system of first-order differential equations, which is \begin{equation}\begin{pmatrix} x_{1} \\ x_{2}\end{pmatrix}=\begin{pmatrix}0&1\\-1&-2\end{pmatrix}\begin{pmatrix}y\\y^{\prime}\end{pmatrix}+\begin{pmatrix}0\\t+3\end{pmatrix}\end{equation} Now I want to perform a single step with $\Delta t=1$ starting from $t=0$ with the Forward Euler method and after that with the Backward Euler method. Firstly with the Forward Euler method I use: \begin{equation}w_{n+1}=w_{n}+\Delta tf(t_{n},w_{n})\end{equation} and I compute $w_{0}$ as \begin{equation}w_{0}=\begin{pmatrix}y(0)\\y^{\prime}(0)\end{pmatrix}=\begin{pmatrix}2\\1\end{pmatrix}\end{equation} so therefore \begin{equation}w_{1}=\begin{pmatrix}3\\0\end{pmatrix}\end{equation} Now I want to perform the Backward Euler method. \begin{equation}w_{n+1}=w_{n}+\Delta tf(t_{n+1},w_{n+1})\end{equation} so \begin{equation}w_{1}=\begin{pmatrix}2\\1\end{pmatrix}+\begin{pmatrix}0&1\\-1&-2\end{pmatrix}w_{1}+\begin{pmatrix}0\\4\end{pmatrix}\end{equation} From which I get \begin{equation}w_{1}=\frac{1}{4}\begin{pmatrix}11\\3\end{pmatrix}\end{equation} y two results seems to be quite differnt and that gets me to believe that I have made a mistake somewhere. Could someone let me know if they believe this to be correct, or why this could be wrong?

1

There are 1 best solutions below

0
On

Note that the second is $(2.75, 0.75)^T$. Your results are not that different for a step size of $Δt=1$ and a Lipschitz constant $L$ between $2$ and $3$. This setup is on the border between barely useful and chaotic, you want $LΔt$ smaller $1.5$ for results that are qualitatively valid, and smaller $0.1$ for results that begin to be quantitatively valid.

If you want to get a better intuition of that, repeat the calculation with smaller step sizes $0.5, 0.25, 0.1$ (and the correspondingly increased step number) and observe that the error shrinks roughly linearly in the step size.