I am trying to solve this differential equation:
$$x''(t)+4x(t)=t^2,x(0)=1,x'(0)=2$$
The answer should be:
$$x(t)=\frac{1}{4}t^2-\frac{1}{8}+\frac{9}{8}\cos{2t}+\sin{2t}$$
Which is also verified by WolframAlpha. But instead I got by calculating by hand:
$$x(t)=\frac{1}{4}t^2-\frac{1}{4}+\frac{9}{8}\cos{2t}+\sin{2t}$$
Here's how I got it. The Laplace transform of the differential equation is:
$$s^2X(s)-sx(0)-x'(0)+4X(s)=\frac{2}{s^3}$$
Since $x(0)=1$ and $x'(0)=2$:
$$s^2X(s)-s-2+4X(s)=\frac{2}{s^3}$$
Solving for $X(s)$:
$$X(s)=\frac{s^4+2s^3+2}{s^3(s^2+4)}=\frac{s^4+2s^3+2}{s^3(s+j2)(s-j2)}$$
Breaking it up into partial fractions:
$$X(s)=\frac{A}{s^3}+\frac{B}{s^2}+\frac{C}{s}+\frac{D}{s+j2}+\frac{E}{s-j2}$$
Solving for the coefficients:
$$ \begin{align} A &= s^3X(s)|_{s=0} = \frac{1}{2} \\ D &= (s+j2)X(s)|_{s=-j2} = \frac{9}{16}+j\frac{1}{2} \\ E &= (s-j2)X(s)|_{s=j2} = \frac{9}{16}-j\frac{1}{2} \\ \end{align} $$
But this part is where I think I calculated wrong but couldn't figure out why:
$$ \begin{align} B &= [\frac{d}{ds}s^3X(s)]_{s=0} = \frac{d}{ds}(\frac{s^4+2s^3+2}{s^2+4})|_{s=0}\\ &=\frac{(4s^3+6s^2)(s^2+4)-(s^4+2s^3+2)(2s)}{(s^2+4)^2}|_{s=0} \\ &=\frac{2s^5+2s^4+16s^3+24s^2-4s}{s^4+8s^2+16}|_{s=0} = 0 \end{align} $$ $$ \begin{align} C &= [\frac{d^2}{ds^2}s^3X(s)]_{s=0}=\frac{d}{ds}\frac{2s^5+2s^4+16s^3+24s^2-4s}{s^4+8s^2+16}|_{s=0} \\ &= \frac{(10s^4+8s^3+48s^2+48s-4)(s^4+8s^2+16)-(2s^5+2s^4+16s^3+24s^2-4s)(4s^3+16s)}{(s^4+8s^2+16)^2}|_{s=0} \\ &= \frac{(-4)(16)}{(16)^2} = \frac{-1}{4} \end{align} $$ Substituting in the coefficients: $$X(s)=\frac{1}{2}\cdot\frac{1}{s^3}-\frac{1}{4}\cdot\frac{1}{s}+(\frac{9}{16}+j\frac{1}{2})\cdot\frac{1}{s+j2}+(\frac{9}{16}-j\frac{1}{2})\cdot\frac{1}{s-j2}$$ Then do inverse Laplace transform: $$ \begin{align} x(t) &= \frac{1}{4}t^2-\frac{1}{4}+(\frac{9}{16}+j\frac{1}{2})e^{-j2t}+(\frac{9}{16}-j\frac{1}{2})e^{j2t}\\ &= \frac{1}{4}t^2-\frac{1}{4}+\frac{9}{8}(\frac{e^{j2t}+e^{-j2t}}{2})+(\frac{e^{j2t}-e^{-j2t}}{j2})\\ &=\frac{1}{4}t^2-\frac{1}{4}+\frac{9}{8}\cos{2t}+\sin{2t} \end{align} $$
I found out why I am wrong according to http://lpsa.swarthmore.edu/BackGround/PartialFraction/RootsRepeat.html
For any multiply repeated roots (n>2), the coefficient $A_k$ should be:
$$ A_k=\frac{1}{(k-1)!}\Big[\frac{d^{(k-1)}}{ds^{(k-1)}}(s+a)^nF(s)\Big]_{s=-a} $$
Therefore, $C$ should be:
$$ C=\frac{1}{2}\Big[\frac{d^2}{ds^2}s^3X(s)\Big]_{s=0} $$