What would be a suitable finite-difference approximation of the boundary value problem
$$y^{\prime \prime} + 3y^{\prime} + 2y = 0, \quad y(0) = y^{\prime}(0) = 1 \quad ? $$
What would be a suitable finite-difference approximation of the boundary value problem
$$y^{\prime \prime} + 3y^{\prime} + 2y = 0, \quad y(0) = y^{\prime}(0) = 1 \quad ? $$
On
Calling $u = y$ we have the first order equivalent DE
$$ \cases{ \dot u = v\\ \dot v = -3v-2u } $$
the Euler difference to this DE is
$$ \cases{ u_k = u_{k-1}+h v_{k-1}\\ v_k = v_{k-1}-3hv_{k-1}-2h u_{k-1} } $$
or
$$ X_k = M X_{k-1} $$
with $X_0 = (1,\ 1)^{\dagger}$ and $M = \left(\begin{array} {cc}1 & h \\-2h & 1-3h\\\end{array}\right)$. This difference equation is stable as long as $0 < h < 1$
After solving we have
$$ u_k = 3 (1-h)^k-2 (1-2 h)^k\\ v_k = 4 (1-2 h)^k-3 (1-h)^k $$
Attached the solution for $h= 0.1$ and the coarser $h = 0.3$
The general form of a second-order inhomogeneous linear differential equation is: \begin{equation} \text{c}_\text{2}\cdot\frac{\text{d}^2\text{f}\left(t\right)}{\text{d}t^2}+\text{c}_\text{1}\cdot\frac{\text{d}\text{f}\left(t\right)}{\text{d}t}+\text{c}_\text{0}\cdot\text{f}\left(t\right)=\text{g}\left(t\right) \tag1\end{equation}
If the Laplace transformation is taken from both sides, one obtains on the left: \begin{align} \mathcal{L}_t\left[\text{c}_\text{2}\cdot\frac{\text{d}^2\text{f}\left(t\right)}{\text{d}t^2}+\text{c}_\text{1}\cdot\frac{\text{d}\text{f}\left(t\right)}{\text{d}t}+\text{c}_\text{0}\cdot\text{f}\left(t\right)\right]_{\left(\text{s}\right)} &= \\ \mathcal{L}_t\left[\text{c}_\text{2}\cdot\frac{\text{d}^2\text{f}\left(t\right)}{\text{d}t^2}\right]_{\left(\text{s}\right)}+\mathcal{L}_t\left[\text{c}_\text{1}\cdot\frac{\text{d}\text{f}\left(t\right)}{\text{d}t}\right]_{\left(\text{s}\right)}+\mathcal{L}_t\left[\text{c}_\text{0}\cdot\text{f}\left(t\right)\right]_{\left(\text{s}\right)} &= \notag\\ \text{c}_\text{2}\cdot\mathcal{L}_t\left[\frac{\text{d}^2\text{f}\left(t\right)}{\text{d}t^2}\right]_{\left(\text{s}\right)}+\text{c}_\text{1}\cdot\mathcal{L}_t\left[\frac{\text{d}\text{f}\left(t\right)}{\text{d}t}\right]_{\left(\text{s}\right)}+\text{c}_\text{0}\cdot\mathcal{L}_t\left[\text{f}\left(t\right)\right]_{\left(\text{s}\right)} &= \notag\\ \text{c}_\text{2}\cdot\left(\text{s}^2\cdot\text{F}\left(\text{s}\right)-\text{s}\cdot\text{f}\left(0\right)-\text{f}'\left(0\right)\right)+\text{c}_\text{1}\cdot\left(\text{s}\cdot\text{F}\left(\text{s}\right)-\text{f}\left(0\right)\right)+\text{c}_\text{0}\cdot\text{F}\left(\text{s}\right) \tag2 \end{align}
And on the right: \begin{equation} \mathcal{L}_t\left[\text{g}\left(t\right)\right]_{\left(\text{s}\right)}=\text{G}\left(\text{s}\right) \tag3\end{equation}
Now the left and right sides can be set equal: \begin{equation} \text{c}_\text{2}\cdot\left(\text{s}^2\cdot\text{F}\left(\text{s}\right)-\text{s}\cdot\text{f}\left(0\right)-\text{f}'\left(0\right)\right)+\text{c}_\text{1}\cdot\left(\text{s}\cdot\text{F}\left(\text{s}\right)-\text{f}\left(0\right)\right)+\text{c}_\text{0}\cdot\text{F}\left(\text{s}\right)=\text{G}\left(\text{s}\right) \tag4\end{equation} From the equivalent equations, $\text{F}\left(\text{s}\right)$ can be solved: \begin{align} \text{F}\left(\text{s}\right) & = \frac{\text{G}\left(\text{s}\right)+\text{f}\left(0\right)\cdot\left(\text{s}\cdot\text{c}_\text{2}+\text{c}_\text{1}\right)+\text{c}_\text{2}\cdot\text{f}'\left(0\right)}{\text{s}\cdot\left(\text{s}\cdot\text{c}_\text{2}+\text{c}_\text{1}\right)+\text{c}_\text{0}} \\ \notag & = \frac{\text{G}\left(\text{s}\right)}{\text{s}\cdot\left(\text{s}\cdot\text{c}_\text{2}+\text{c}_\text{1}\right)+\text{c}_\text{0}}+\frac{\text{f}\left(0\right)\cdot\left(\text{s}\cdot\text{c}_\text{2}+\text{c}_\text{1}\right)}{\text{s}\cdot\left(\text{s}\cdot\text{c}_\text{2}+\text{c}_\text{1}\right)+\text{c}_\text{0}}+\frac{\text{c}_\text{2}\cdot\text{f}'\left(0\right)}{\text{s}\cdot\left(\text{s}\cdot\text{c}_\text{2}+\text{c}_\text{1}\right)+\text{c}_\text{0}} \\ \notag & = \frac{\text{G}\left(\text{s}\right)}{\text{c}_\text{2}\cdot\text{s}^2+\text{c}_\text{1}\cdot\text{s}+\text{c}_\text{0}}+\frac{\text{f}\left(0\right)\cdot\left(\text{s}\cdot\text{c}_\text{2}+\text{c}_\text{1}\right)}{\text{c}_\text{2}\cdot\text{s}^2+\text{c}_\text{1}\cdot\text{s}+\text{c}_\text{0}}+\frac{\text{c}_\text{2}\cdot\text{f}'\left(0\right)}{\text{c}_\text{2}\cdot\text{s}^2+\text{c}_\text{1}\cdot\text{s}+\text{c}_\text{0}} \\ \notag & = \frac{1}{\text{c}_\text{2}}\cdot\frac{\text{G}\left(\text{s}\right)}{\text{s}^2+\frac{\text{c}_\text{1}}{\text{c}_\text{2}}\cdot\text{s}+\frac{\text{c}_\text{0}}{\text{c}_\text{2}}}+\frac{1}{\text{c}_\text{2}}\cdot\frac{\text{f}\left(0\right)\cdot\left(\text{s}\cdot\text{c}_\text{2}+\text{c}_\text{1}\right)}{\text{s}^2+\frac{\text{c}_\text{1}}{\text{c}_\text{2}}\cdot\text{s}+\frac{\text{c}_\text{0}}{\text{c}_\text{2}}}+\frac{1}{\text{c}_\text{2}}\cdot\frac{\text{c}_\text{2}\cdot\text{f}'\left(0\right)}{\text{s}^2+\frac{\text{c}_\text{1}}{\text{c}_\text{2}}\cdot\text{s}+\frac{\text{c}_\text{0}}{\text{c}_\text{2}}} \\ \notag & = \frac{1}{\text{c}_\text{2}}\cdot\frac{\text{G}\left(\text{s}\right)}{\text{s}^2+\frac{\text{c}_\text{1}}{\text{c}_\text{2}}\cdot\text{s}+\frac{\text{c}_\text{0}}{\text{c}_\text{2}}}+\frac{\text{f}\left(0\right)}{\text{c}_\text{2}}\cdot\frac{\text{s}\cdot\text{c}_\text{2}+\text{c}_\text{1}}{\text{s}^2+\frac{\text{c}_\text{1}}{\text{c}_\text{2}}\cdot\text{s}+\frac{\text{c}_\text{0}}{\text{c}_\text{2}}}+\text{f}'\left(0\right)\cdot\frac{1}{\text{s}^2+\frac{\text{c}_\text{1}}{\text{c}_\text{2}}\cdot\text{s}+\frac{\text{c}_\text{0}}{\text{c}_\text{2}}} \tag5 \end{align} The denominator formula above are all the same and can be written via sperating the squares as follows: \begin{equation} \text{s}^2+\frac{\text{c}_\text{1}}{\text{c}_\text{2}}\cdot\text{s}+\frac{\text{c}_\text{0}}{\text{c}_\text{2}}=\left(\text{s}-\left(-\frac{1}{2}\cdot\frac{\text{c}_\text{1}}{\text{c}_\text{2}}\right)\right)^2-\left(\sqrt{\frac{1}{4}\cdot\left(\frac{\text{c}_\text{1}}{\text{c}_\text{2}}\right)^2-\frac{\text{c}_\text{0}}{\text{c}_\text{2}}}\right)^2 \tag6\end{equation}
To write it in a clearer way, the following applies: \begin{equation} \alpha:=-\frac{1}{2}\cdot\frac{\text{c}_\text{1}}{\text{c}_\text{2}}\;\;\;\wedge\;\;\;\beta:=\sqrt{\frac{1}{4}\cdot\left(\frac{\text{c}_\text{1}}{\text{c}_\text{2}}\right)^2-\frac{\text{c}_\text{0}}{\text{c}_\text{2}}} \tag7\end{equation}
This also applies to: \begin{equation} \text{s}^2+\frac{\text{c}_\text{1}}{\text{c}_\text{2}}\cdot\text{s}+\frac{\text{c}_\text{0}}{\text{c}_\text{2}}=\left(\text{s}-\alpha\right)^2-\beta^2 \tag8\end{equation}
It can therefore be rewritten as follows: \begin{align} \text{f}\left(t\right) & = \frac{1}{\text{c}_\text{2}}\cdot\frac{\text{G}\left(\text{s}\right)}{\left(\text{s}-\alpha\right)^2-\beta^2}+\frac{\text{f}\left(0\right)}{\text{c}_\text{2}}\cdot\frac{\text{s}\cdot\text{c}_\text{2}+\text{c}_\text{1}}{\left(\text{s}-\alpha\right)^2-\beta^2}+\frac{\text{f}'\left(0\right)}{\left(\text{s}-\alpha\right)^2-\beta^2} \\ \notag & = \frac{1}{\text{c}_\text{2}\cdot\beta}\cdot\frac{\text{G}\left(\text{s}\right)\cdot\beta}{\left(\text{s}-\alpha\right)^2-\beta^2}+\frac{\text{f}\left(0\right)}{\text{c}_\text{2}}\cdot\frac{\text{s}\cdot\text{c}_\text{2}+\text{c}_\text{1}}{\left(\text{s}-\alpha\right)^2-\beta^2}+\frac{\text{f}'\left(0\right)}{\beta}\cdot\frac{\beta}{\left(\text{s}-\alpha\right)^2-\beta^2} \tag9 \end{align}
In order to finally solve the differential equation, the inverse Laplace transformation must be looked at. Using well-known Laplace transformation tables, it can be said that: \begin{equation} \text{f}_\text{1}\left(t\right):=\mathcal{L}_\text{s}^{-1}\left[\frac{\beta}{\left(\text{s}-\alpha\right)^2-\beta^2}\right]_{\left(t\right)}=\exp\left(\alpha\cdot t\right)\cdot\sinh\left(\beta\cdot t\right) \tag{10}\end{equation}
And with the help of convolution theory also applies: \begin{align} \text{f}_\text{2}\left(t\right) & := \mathcal{L}_\text{s}^{-1}\left[\frac{\text{G}\left(\text{s}\right)\cdot\beta}{\left(\text{s}-\alpha\right)^2-\beta^2}\right]_{\left(t\right)} \\ \notag & = \int_0^t\mathcal{L}_\text{s}^{-1}\left[\text{G}\left(\text{s}\right)\right]_{\left(x\right)}\cdot\mathcal{L}_\text{s}^{-1}\left[\frac{\beta}{\left(\text{s}-\alpha\right)^2-\beta^2}\right]_{\left(t-x\right)}\;\text{d}x \\ \notag & = \int_0^t\text{g}\left(x\right)\cdot\exp\left(\alpha\cdot\left(t-x\right)\right)\cdot\sinh\left(\beta\cdot\left(t-x\right)\right)\;\text{d}x \tag{11} \end{align}
Now the inverse Laplace transformation can be taken, so that one obtains the following: \begin{align} \text{f}\left(t\right) & = \mathcal{L}_\text{s}^{-1}\left[\text{F}\left(\text{s}\right)\right]_{\left(t\right)} \\ \notag & = \frac{\text{f}_\text{2}\left(t\right)}{\text{c}_\text{2}\cdot\beta}+\frac{\text{f}\left(0\right)}{\text{c}_\text{2}}\cdot\left(\text{c}_\text{2}\cdot\frac{\text{s}}{\left(\text{s}-\alpha\right)^2-\beta^2}+\frac{\text{c}_\text{1}}{\beta}\cdot\text{f}_\text{1}\left(t\right)\right)+\frac{\text{f}'\left(0\right)}{\beta}\cdot\text{f}_\text{1}\left(t\right) \\ \notag & = \frac{\text{f}_\text{2}\left(t\right)}{\text{c}_\text{2}\cdot\beta}+\frac{\text{f}\left(0\right)}{\text{c}_\text{2}}\cdot\left(\frac{\text{c}_\text{2}}{\beta}\cdot\frac{\text{s}\cdot\beta}{\left(\text{s}-\alpha\right)^2-\beta^2}+\frac{\text{c}_\text{1}}{\beta}\cdot\text{f}_\text{1}\left(t\right)\right)+\frac{\text{f}'\left(0\right)}{\beta}\cdot\text{f}_\text{1}\left(t\right) \\ \notag & = \frac{\text{f}_\text{2}\left(t\right)}{\text{c}_\text{2}\cdot\beta}+\frac{\text{f}\left(0\right)}{\text{c}_\text{2}}\cdot\left(\frac{\text{c}_\text{2}}{\beta}\cdot\text{f}_\text{1}'\left(t\right)+\frac{\text{c}_\text{1}}{\beta}\cdot\text{f}_\text{1}\left(t\right)\right)+\frac{\text{f}'\left(0\right)}{\beta}\cdot\text{f}_\text{1}\left(t\right) \\ \notag & = \frac{1}{\beta}\cdot\left\{\frac{\text{f}_\text{2}\left(t\right)+\text{f}\left(0\right)\cdot\left(\text{c}_\text{2}\cdot\text{f}_\text{1}'\left(t\right)+\text{c}_\text{1}\cdot\text{f}_\text{1}\left(t\right)\right)}{\text{c}_\text{2}}+\text{f}'\left(0\right)\cdot\text{f}_\text{1}\left(t\right)\right\} \tag{12} \end{align}
This provides the solution of the differential equation: \begin{equation} \text{f}\left(t\right)=\frac{1}{\beta}\cdot\left\{\frac{\text{f}_\text{2}\left(t\right)+\text{f}\left(0\right)\cdot\left(\text{c}_\text{2}\cdot\text{f}_\text{1}'\left(t\right)+\text{c}_\text{1}\cdot\text{f}_\text{1}\left(t\right)\right)}{\text{c}_\text{2}}+\text{f}'\left(0\right)\cdot\text{f}_\text{1}\left(t\right)\right\} \tag{13}\end{equation}