# Solving the matrix ODE $M\ddot x + C\dot x + Kx = \sin(\omega t)e_i$

Consider the following ODE, where $$x$$ is a vector, $$M, C, K$$ real square matrices and $$e_i$$ a basis vector (for example $$[1\ 0\ \dots 0]^\top$$).:

$$M\ddot x + C\dot x + Kx = \sin(\omega t)e_i$$

with $$x(0)=x_0$$ and $$\dot x(0)=v_0$$, $$\omega>0$$.

It's a common linear second order (matrix) ODE. The one-dimensional case is very common (damped oscillator with harmonic excitation). Is it possible to find a simple solution in the matrix case?

It is easy to derive a particular solution: assume $$x(t) = Re\big[x_1 e^{i\omega t}\big]$$, then $$x_1 = (-\omega^2 M +i\omega C + K)^{-1} e_i.$$

For the homogeneous solution, as in the one-dimensional case: if $$x=e^{\lambda t}x_2$$, $$(\lambda^2 M + \lambda C + K)x_2 = 0$$ and there should be a discussion on the value of $$\lambda$$. But in the general case, $$M$$, $$C$$ and $$K$$ are not simultaneously diagonizable... So, is there a trick?

I managed to solve the ODE using the first-order form, but I am wondering if it is possible to take advantage of the less general form of the original problem to simplify the result:

$$\begin{bmatrix} \dot x \\ \ddot x \end{bmatrix} = \underbrace{\begin{bmatrix} 0 & I \\ -M^{-1}K & -M^{-1}C \end{bmatrix}}_{A} \underbrace{\begin{bmatrix} x \\ \dot x\end{bmatrix} }_{X(t)} + \underbrace{ \sin(\omega t)\begin{bmatrix} O \\ -M^{-1}e_i \end{bmatrix}}_{b(t)}:= \dot X(t) = A X(t) + b(t)$$

The solutions of $$X'(t) = AX(t) + b(t)$$ are $$X = X_h + X_p$$ with $$X_h = e^{tA}X_1$$ and $$X_p = e^{tA}\int e^{-sA}b(s) ds$$, or $$X(t) = e^{tA}\big( X_0 + \int_0^t e^{-sA}b(s)ds\big)$$.

$$b(t) =\sin(\omega t) \underbrace{\begin{bmatrix} O \\ M^{-1} e_i \end{bmatrix}}_{H} := \sin(\omega t)H$$ so $$\int_0^t e^{-sA}b(s)ds = Re\left\lbrace \int_0^t e^{-sA+i(\omega s-\pi/2)I}ds\right\rbrace H = Re\left\lbrace e^{-i\pi/2}\int_0^t e^{sA_2}ds \right\rbrace H = Re\left\lbrace e^{-i\pi/2}A_2^{-1}(e^{A_2 t} - I)H \right\rbrace\quad \text{with }A_2 = -A+i\omega I$$ In the end: $$X(t)=e^{tA}\Big(X_0 - Re\left\lbrace i A_2^{-1}(e^{tA_2}-I)\right\rbrace H \Big)\quad \text{with } A_2 = -A + i \omega I$$

and of course, $$X_0 = [x_0, \ v_0]^\top$$. It does not really look like the solutions of the linear second-order ODE in this form!