2.3.3.4 Maple. Time used: 0.045 (sec). Leaf size: 48
ode:=diff(diff(x(t),t),t)+2*diff(x(t),t)+4*x(t) = exp(t)*cos(2*t); 
ic:=[x(0) = 0, D(x)(0) = 1]; 
dsolve([ode,op(ic)],x(t), singsol=all);
 
\begin{align*} x = \frac {{\mathrm e}^{t} \left (3 \cos \left (2 t \right )+8 \sin \left (2 t \right )\right )}{73}+\frac {{\mathrm e}^{-t} \left (17 \sqrt {3}\, \sin \left (\sqrt {3}\, t \right )-3 \cos \left (\sqrt {3}\, t \right )\right )}{73} \end{align*}

Maple trace

Methods for second order ODEs: 
--- Trying classification methods --- 
trying a quadrature 
trying high order exact linear fully integrable 
trying differential order: 2; linear nonhomogeneous with symmetry [0,1] 
trying a double symmetry of the form [xi=0, eta=F(x)] 
-> Try solving first the homogeneous part of the ODE 
   checking if the LODE has constant coefficients 
   <- constant coefficients successful 
<- solving first the homogeneous part of the ODE successful
 

Maple step by step

\[ \begin {array}{lll} & {} & \textrm {Let's solve}\hspace {3pt} \\ {} & {} & \left [\frac {d^{2}}{d t^{2}}x \left (t \right )+2 \frac {d}{d t}x \left (t \right )+4 x \left (t \right )={\mathrm e}^{t} \cos \left (2 t \right ), x \left (0\right )=0, \left (\frac {d}{d t}x \left (t \right )\right )\bigg | {\mstack {}{_{\left \{t \hiderel {=}0\right \}}}}=1\right ] \\ \bullet & {} & \textrm {Highest derivative means the order of the ODE is}\hspace {3pt} 2 \\ {} & {} & \frac {d^{2}}{d t^{2}}x \left (t \right ) \\ \bullet & {} & \textrm {Characteristic polynomial of homogeneous ODE}\hspace {3pt} \\ {} & {} & r^{2}+2 r +4=0 \\ \bullet & {} & \textrm {Use quadratic formula to solve for}\hspace {3pt} r \\ {} & {} & r =\frac {\left (-2\right )\pm \left (\sqrt {-12}\right )}{2} \\ \bullet & {} & \textrm {Roots of the characteristic polynomial}\hspace {3pt} \\ {} & {} & r =\left (-1-\mathrm {I} \sqrt {3}, -1+\mathrm {I} \sqrt {3}\right ) \\ \bullet & {} & \textrm {1st solution of the homogeneous ODE}\hspace {3pt} \\ {} & {} & x_{1}\left (t \right )={\mathrm e}^{-t} \cos \left (\sqrt {3}\, t \right ) \\ \bullet & {} & \textrm {2nd solution of the homogeneous ODE}\hspace {3pt} \\ {} & {} & x_{2}\left (t \right )={\mathrm e}^{-t} \sin \left (\sqrt {3}\, t \right ) \\ \bullet & {} & \textrm {General solution of the ODE}\hspace {3pt} \\ {} & {} & x \left (t \right )=\mathit {C1} x_{1}\left (t \right )+\mathit {C2} x_{2}\left (t \right )+x_{p}\left (t \right ) \\ \bullet & {} & \textrm {Substitute in solutions of the homogeneous ODE}\hspace {3pt} \\ {} & {} & x \left (t \right )=\mathit {C1} \,{\mathrm e}^{-t} \cos \left (\sqrt {3}\, t \right )+\mathit {C2} \,{\mathrm e}^{-t} \sin \left (\sqrt {3}\, t \right )+x_{p}\left (t \right ) \\ \square & {} & \textrm {Find a particular solution}\hspace {3pt} x_{p}\left (t \right )\hspace {3pt}\textrm {of the ODE}\hspace {3pt} \\ {} & \circ & \textrm {Use variation of parameters to find}\hspace {3pt} x_{p}\hspace {3pt}\textrm {here}\hspace {3pt} f \left (t \right )\hspace {3pt}\textrm {is the forcing function}\hspace {3pt} \\ {} & {} & \left [x_{p}\left (t \right )=-x_{1}\left (t \right ) \int \frac {x_{2}\left (t \right ) f \left (t \right )}{W \left (x_{1}\left (t \right ), x_{2}\left (t \right )\right )}d t +x_{2}\left (t \right ) \int \frac {x_{1}\left (t \right ) f \left (t \right )}{W \left (x_{1}\left (t \right ), x_{2}\left (t \right )\right )}d t , f \left (t \right )={\mathrm e}^{t} \cos \left (2 t \right )\right ] \\ {} & \circ & \textrm {Wronskian of solutions of the homogeneous equation}\hspace {3pt} \\ {} & {} & W \left (x_{1}\left (t \right ), x_{2}\left (t \right )\right )=\left [\begin {array}{cc} {\mathrm e}^{-t} \cos \left (\sqrt {3}\, t \right ) & {\mathrm e}^{-t} \sin \left (\sqrt {3}\, t \right ) \\ -{\mathrm e}^{-t} \cos \left (\sqrt {3}\, t \right )-{\mathrm e}^{-t} \sqrt {3}\, \sin \left (\sqrt {3}\, t \right ) & -{\mathrm e}^{-t} \sin \left (\sqrt {3}\, t \right )+{\mathrm e}^{-t} \sqrt {3}\, \cos \left (\sqrt {3}\, t \right ) \end {array}\right ] \\ {} & \circ & \textrm {Compute Wronskian}\hspace {3pt} \\ {} & {} & W \left (x_{1}\left (t \right ), x_{2}\left (t \right )\right )=\sqrt {3}\, {\mathrm e}^{-2 t} \\ {} & \circ & \textrm {Substitute functions into equation for}\hspace {3pt} x_{p}\left (t \right ) \\ {} & {} & x_{p}\left (t \right )=-\frac {\sqrt {3}\, {\mathrm e}^{-t} \left (\int {\mathrm e}^{2 t} \cos \left (2 t \right ) \sin \left (\sqrt {3}\, t \right )d t \cos \left (\sqrt {3}\, t \right )-\int {\mathrm e}^{2 t} \cos \left (2 t \right ) \cos \left (\sqrt {3}\, t \right )d t \sin \left (\sqrt {3}\, t \right )\right )}{3} \\ {} & \circ & \textrm {Compute integrals}\hspace {3pt} \\ {} & {} & x_{p}\left (t \right )=\frac {{\mathrm e}^{t} \left (3 \cos \left (2 t \right )+8 \sin \left (2 t \right )\right )}{73} \\ \bullet & {} & \textrm {Substitute particular solution into general solution to ODE}\hspace {3pt} \\ {} & {} & x \left (t \right )=\mathit {C1} \,{\mathrm e}^{-t} \cos \left (\sqrt {3}\, t \right )+\mathit {C2} \,{\mathrm e}^{-t} \sin \left (\sqrt {3}\, t \right )+\frac {{\mathrm e}^{t} \left (3 \cos \left (2 t \right )+8 \sin \left (2 t \right )\right )}{73} \\ \square & {} & \textrm {Check validity of solution}\hspace {3pt} x \left (t \right )=\textit {\_C1} {\mathrm e}^{-t} \cos \left (\sqrt {3}\, t \right )+\textit {\_C2} {\mathrm e}^{-t} \sin \left (\sqrt {3}\, t \right )+\frac {{\mathrm e}^{t} \left (3 \cos \left (2 t \right )+8 \sin \left (2 t \right )\right )}{73} \\ {} & \circ & \textrm {Use initial condition}\hspace {3pt} x \left (0\right )=0 \\ {} & {} & 0=\textit {\_C1} +\frac {3}{73} \\ {} & \circ & \textrm {Compute derivative of the solution}\hspace {3pt} \\ {} & {} & \frac {d}{d t}x \left (t \right )=-\textit {\_C1} \,{\mathrm e}^{-t} \cos \left (\sqrt {3}\, t \right )-\textit {\_C1} \,{\mathrm e}^{-t} \sqrt {3}\, \sin \left (\sqrt {3}\, t \right )-\textit {\_C2} \,{\mathrm e}^{-t} \sin \left (\sqrt {3}\, t \right )+\textit {\_C2} \,{\mathrm e}^{-t} \sqrt {3}\, \cos \left (\sqrt {3}\, t \right )+\frac {{\mathrm e}^{t} \left (3 \cos \left (2 t \right )+8 \sin \left (2 t \right )\right )}{73}+\frac {{\mathrm e}^{t} \left (-6 \sin \left (2 t \right )+16 \cos \left (2 t \right )\right )}{73} \\ {} & \circ & \textrm {Use the initial condition}\hspace {3pt} \left (\frac {d}{d t}x \left (t \right )\right )\bigg | {\mstack {}{_{\left \{t \hiderel {=}0\right \}}}}=1 \\ {} & {} & 1=-\textit {\_C1} +\frac {19}{73}+\textit {\_C2} \sqrt {3} \\ {} & \circ & \textrm {Solve for}\hspace {3pt} \textit {\_C1} \hspace {3pt}\textrm {and}\hspace {3pt} \textit {\_C2} \\ {} & {} & \left \{\textit {\_C1} =-\frac {3}{73}, \textit {\_C2} =\frac {17 \sqrt {3}}{73}\right \} \\ {} & \circ & \textrm {Substitute constant values into general solution and simplify}\hspace {3pt} \\ {} & {} & x \left (t \right )=\frac {{\mathrm e}^{-t} \left (17 \sqrt {3}\, \sin \left (\sqrt {3}\, t \right )-3 \cos \left (\sqrt {3}\, t \right )\right )}{73}+\frac {{\mathrm e}^{t} \left (3 \cos \left (2 t \right )+8 \sin \left (2 t \right )\right )}{73} \\ \bullet & {} & \textrm {Solution to the}\hspace {3pt} \hspace {3pt}\textrm {IVP}\hspace {3pt} \\ {} & {} & x \left (t \right )=\frac {{\mathrm e}^{-t} \left (17 \sqrt {3}\, \sin \left (\sqrt {3}\, t \right )-3 \cos \left (\sqrt {3}\, t \right )\right )}{73}+\frac {{\mathrm e}^{t} \left (3 \cos \left (2 t \right )+8 \sin \left (2 t \right )\right )}{73} \end {array} \]