Using matlab symbolic processor, I can get the homogenous and particular solution to a harmonic oscillator with periodic forcing. I'm trying to write the particular solution in a compact form, with limited success. Does anyone have the general solution to a harmonic oscillator under periodic forcing?
Here's the equation I want to solve
$$ \frac{d^2}{dt^2} h(t) + 2 \zeta \omega_n \frac{d}{dt} h(t) + \omega_n^2 h(t) = \frac{C_i}{m} \sin(\omega_f t + \phi) . $$
Here's one approach
syms h(t) zeta omega_n h0 dh0 Cfi wfi phif m
Dh(t)=diff(h(t),t);
eqs = diff(h(t), t, t) == -2*zeta*omega_n*Dh-omega_n*omega_n*h(t)+Cfi/m*sin(wfi*t+phif);
disp('equation')
pretty(eqs)
sol=dsolve(eqs, h(0)==h0, Dh(0)==dh0);
pretty(sol)
chk=simplify(diff(sol,t,t)+2*zeta*omega_n*diff(sol,t)+omega_n*omega_n*sol-Cfi/m*sin(wfi*t+phif));
disp('check solution, should be zero');
disp(chk)
If you have $h(t)$ and want to find the forcing function, you can Fourrier analyze it. For each term $a \sin (\psi t)$ in the expansion, the left side becomes $a (\omega^2 -\psi^2)\sin (\psi t) +2a \zeta \omega \cos(\psi t)$ That matches the right side.