# differential equation of a harmonic oscillator

I have to find a general solution for the following differential equation with a constant f: $x''+\omega ^2x = f$

This is what I came up with so far:

$y_h = d^2(Ae^{\lambda t})/dy + \omega^2Ae^{\lambda t} = 0$

$\lambda^2-\omega^2 = 0$

$\lambda_1= + \omega$

$\lambda_2= -\omega$

Is this correct until now? And how do I have to solve it for the particular solution? Thank you very much for your time and help! Sorry for my bad English.

• Careful it's $\lambda^2=\omega^2$ ! So what are the solutions for $x''+\omega^2x=0$ so far ? – Atmos Jan 12 '18 at 21:06
• @Atmos It should be $\lambda = +/- \omega$, right? Thank you very much for your fast reply! – ina26 Jan 12 '18 at 21:10
• Yes, it means that $\displaystyle x \mapsto A \cos\left(\omega x\right)+B\sin\left(\omega x\right)$ is A solution of this equation. ( which traduces the oscillations of pulsation $\omega$ ). Now what's your idea to solve entirely this equation ? – Atmos Jan 12 '18 at 21:14
• Yes, you are on track to finding the solution to the homogeneous equation. – John Doe Jan 12 '18 at 21:16
• Note that you have a sign problem. It should be $\lambda^2+\omega^2=0$, with imaginary solutions $\lambda=\pm i\omega$. That's why you have sine and cosine solutions. – Andrei Jan 12 '18 at 22:57

$D$ annihilates $f$. So the specific solution is found among the solutions of $$(D^2+\omega^2)Dx=0$$ which has, for $\omega\ne 0$, the general solution $$x(t)=A\cos(\omega t)+B\sin(\omega t)+Ct.$$ Applying $D+\omega^2$ to this proposed solution gives $$\omega^2 C = 1 \implies C=1/\omega^2.$$ If $\omega^2=0$, then the solution of $D^2f=t$ is $$x(t)=A+Bt+\frac{t^3}{6}$$