2.3.3.2 second order linear constant coeff

\[\begin {aligned} x^{\prime \prime }+2 x^{\prime }+4 x&={\mathrm e}^{t} \cos \left (2 t \right )\\ x \left (0\right ) &= 0\\ x^{\prime }\left (0\right ) &= 1\\ \end {aligned}\]

Entering second order linear constant coefficient ode solverThis is second order non-homogeneous ODE. In standard form the ODE is

\[ A x''(t) + B x'(t) + C x(t) = f(t) \]

Where \(A=1, B=2, C=4, f(t)={\mathrm e}^{t} \cos \left (2 t \right )\). Let the solution be

\[ x = x_h + x_p \]

Where \(x_h\) is the solution to the homogeneous ODE

\begin{align*} A x''(t) + B x'(t) + C x(t) &= 0 \end{align*}

And \(x_p\) is a particular solution to the non-homogeneous ODE

\begin{align*} A x''(t) + B x'(t) + C x(t) &= f(t) \end{align*}

Where \(x_h\) is the solution to

\begin{align*} x^{\prime \prime }+2 x^{\prime }+4 x = 0 \end{align*}

This is second order with constant coefficients homogeneous ODE. In standard form the ODE is

\[ A x''(t) + B x'(t) + C x(t) = 0 \]

Where in the above \(A=1, B=2, C=4\). Let the solution be \(x=e^{\lambda t}\). Substituting this into the ODE gives

\[ \lambda ^{2} {\mathrm e}^{\lambda t}+2 \lambda \,{\mathrm e}^{\lambda t}+4 \,{\mathrm e}^{\lambda t} = 0 \tag {1} \]

Since exponential function is never zero, then dividing Eq(2) throughout by \(e^{\lambda t}\) gives

\[ \lambda ^{2}+2 \lambda +4 = 0 \tag {2} \]

Equation (2) is the characteristic equation of the ODE. Its roots determine the general solution form. Using the quadratic formula the roots are

\[ \lambda _{1,2} = \frac {-B}{2 A} \pm \frac {1}{2 A} \sqrt {B^2 - 4 A C} \]

Substituting \(A=1, B=2, C=4\) into the above gives

\begin{align*} \lambda _{1,2} &= \frac {-2}{(2) \left (1\right )} \pm \frac {1}{(2) \left (1\right )} \sqrt {2^2 - (4) \left (1\right )\left (4\right )}\\ &= -1 \pm i \sqrt {3} \end{align*}

Hence

\begin{align*} \lambda _1 &= -1 + i \sqrt {3}\\ \lambda _2 &= -1 - i \sqrt {3} \end{align*}

Which simplifies to

\begin{gather*} \begin {aligned} \lambda _1 &= i \sqrt {3}-1\\ \lambda _2 &= -1-i \sqrt {3} \end {aligned} \end{gather*}

Since the roots are complex conjugate of each others, then let the roots be

\begin{align*} \lambda _{1,2} &= \alpha \pm i \beta \end{align*}

Where \(\alpha =-1\) and \(\beta =\sqrt {3}\). Therefore the final solution using Euler relation can be written as

\begin{align*} x &= e^{\alpha t} \left ( c_1 \cos (\beta t) + c_2 \sin (\beta t) \right ) \end{align*}

Which becomes

\begin{align*} x &= e^{-t}\left (c_1 \cos \left (\sqrt {3}\, t \right )+c_2 \sin \left (\sqrt {3}\, t \right )\right ) \end{align*}

Therefore the homogeneous solution \(x_h\) is

\begin{align*} x_h &= {\mathrm e}^{-t} \left (c_1 \cos \left (\sqrt {3}\, t \right )+c_2 \sin \left (\sqrt {3}\, t \right )\right ) \end{align*}

The particular solution is found using the method of undetermined coefficients. Looking at the RHS of the ode, which is

\[ {\mathrm e}^{t} \cos \left (2 t \right ) \]

Shows that the corresponding undetermined set of the basis functions (UC_set) for the trial solution is

\[ [\{{\mathrm e}^{t} \cos \left (2 t \right ), {\mathrm e}^{t} \sin \left (2 t \right )\}] \]

While the set of the basis functions for the homogeneous solution found earlier is

\[ \left \{{\mathrm e}^{-t} \cos \left (\sqrt {3}\, t \right ), {\mathrm e}^{-t} \sin \left (\sqrt {3}\, t \right )\right \} \]

Since there is no duplication between the basis function in the UC_set and the basis functions of the homogeneous solution, the trial solution is a linear combination of all the basis in the UC_set.

\begin{align*} x_p &= A_{1} {\mathrm e}^{t} \cos \left (2 t \right )+A_{2} {\mathrm e}^{t} \sin \left (2 t \right ) \end{align*}

The unknowns \(\{A_{1}, A_{2}\}\) are found by substituting the above trial solution \(x_p\) into the ODE and comparing coefficients. Substituting the trial solution into the ODE and simplifying gives

\begin{align*} 3 A_{1} {\mathrm e}^{t} \cos \left (2 t \right )-8 A_{1} {\mathrm e}^{t} \sin \left (2 t \right )+3 A_{2} {\mathrm e}^{t} \sin \left (2 t \right )+8 A_{2} {\mathrm e}^{t} \cos \left (2 t \right ) = {\mathrm e}^{t} \cos \left (2 t \right ) \end{align*}

Solving for the unknowns by comparing coefficients results in

\[ \left [A_{1} = {\frac {3}{73}}, A_{2} = {\frac {8}{73}}\right ] \]

Substituting the above back in the above trial solution \(x_p\), gives the particular solution

\begin{align*} x_p &= \frac {3 \,{\mathrm e}^{t} \cos \left (2 t \right )}{73}+\frac {8 \,{\mathrm e}^{t} \sin \left (2 t \right )}{73} \end{align*}

Therefore the general solution is

\begin{gather*} \begin {aligned} x &= x_h + x_p \\ &= \left ({\mathrm e}^{-t} \left (c_1 \cos \left (\sqrt {3}\, t \right )+c_2 \sin \left (\sqrt {3}\, t \right )\right )\right ) + \left (\frac {3 \,{\mathrm e}^{t} \cos \left (2 t \right )}{73}+\frac {8 \,{\mathrm e}^{t} \sin \left (2 t \right )}{73}\right ) \end {aligned} \end{gather*}

Applying the initial conditions \([x \left (0\right ) = 0, x^{\prime }\left (0\right ) = 1]\), the solution becomes

\begin{align*} x &= -\frac {3 \,{\mathrm e}^{-t} \cos \left (\sqrt {3}\, t \right )}{73}+\frac {17 \,{\mathrm e}^{-t} \sin \left (\sqrt {3}\, t \right ) \sqrt {3}}{73}+\frac {3 \,{\mathrm e}^{t} \left (\cos \left (2 t \right )+\frac {8 \sin \left (2 t \right )}{3}\right )}{73} \\ \end{align*}
\(x = -\frac {3 \,{\mathrm e}^{-t} \cos \left (\sqrt {3}\, t \right )}{73}+\frac {17 \,{\mathrm e}^{-t} \sin \left (\sqrt {3}\, t \right ) \sqrt {3}}{73}+\frac {3 \,{\mathrm e}^{t} \left (\cos \left (2 t \right )+\frac {8 \sin \left (2 t \right )}{3}\right )}{73}\) Direction field