Q:

Differential equation with $w$ and $w_0$

Given is the following differential equation
\begin{align}
y'' +w^2y = cos(w_0x), \\\\
w,w_0>0, w\neq w_0  \\\\
y(0)=1, y'(0)=0
\end{align}
So I procede solving the homogen part. Then the inhomogen with variation of constant
\begin{align}
y'' + w^2y=0 \\
y_h(x)=Acos(wx)+Bsin(wx)
\end{align}
Anyway solving like normal coefficient I get the $w$ and not w_0.
\begin{align}
\end{align}
I tried to continue with the wronski matrix, but the integral become really a mess and isn't the correct solution. Any hint?
\begin{align}
\\\\
\end{align}
The correct solution is:
\begin{align}
y(x)= cos(wx)+\frac{cos(w_0x) -cos(wx)}{w^2-w_0^2}
\end{align}

A:

Hint:  Try to solve first
$$y_1''+ w^2 y_1 =0$$
Then try to substitute $y_2(x)=A\cos(w_0 x)+B\sin(w_0 x)$ to the original equation, and try to find $A$ and $B$. Then the complete solution will be
$$y(x)=y_1(x)+y_2(x)$$
because the linearity:
$$y''+w^2y=(y_1''+w^2y_1)+(y_2''+w^2y_2)=(0)+(\cos(w_0 x))=\cos(w_0 x)$$
Substituting $y_2$ into the equation we get that
$$-Aw_0^2\cos(w_0 x)-Bw_0^2\sin(w_0 x)+w^2(A\cos(w_0 x)+B\sin(w_0 x))=\cos(wx)$$
$$(-Aw_0^2+Aw^2)\cos(w_0x)+(-Bw_0^2+Bw^2)\sin(w_0x)=\cos(w_0 x)$$
So we need that
$$-A w_0^2+Aw^2=1$$
And
$$-Bw_0^2+Bw^2=0$$
But of course, you can also use Laplace or Fourier transform, or maybe Green's method, but I think that would be an overkill.

