# How to solve ODE with sine involved (comparison of coefficients)

I thought I grasped it thanks to an answer to a similar question I posed, but it seems a little trickier:

Given $$y' = y\,\sin(x)+\sin(2\,x)$$, trying to solve with the same approach:

$$y_p = a_0\,\sin(2\,x)+b_0\,\cos(2\,x)$$

so that:

\begin{align} {y_p}' &= 2\,a_0\cos(2\,x) -2\,b_0\,\sin(2\,x)\\ &= y\,\sin(x)+\sin(2\,x) \\ &= a_0\,\sin(2\,x)\,\sin(x)+b_0\,\cos(2\,x)\,\sin(x) + \sin(2\,x) \end{align}

Unlike the other inquiry no comparison of coefficients seems possible due to the multiplication.

Is there something to be done still?

## 1 Answer

The method of undetermined coefficients works for linear ODE with constant coefficients. The given ODE is a linear ODE with variable coefficients.

After multiplying both sides by the integral factor $$e^{\cos(x)}$$, the given linear ODE is equivalent to $$D(e^{\cos(x)}y(x))=e^{\cos(x)}\sin(2x).$$ Now integrate the RHS: \begin{align} \int e^{\cos(x)}\sin(2x)\,dx&=2\int e^{\cos(x)}\cos(x)\sin(x)\,dx\\ &=-2\int e^{t}t\,dt=-2e^t(t-1)+c\\ &=-2e^{\cos(x)}(\cos(x)-1)+c. \end{align} Hence the general solution is $$y(x)=ce^{-\cos(x)}+\underbrace{2(1-\cos(x))}_{\text{particular solution}}.$$ Note that the particular solution $$y_p(x)=2(1-\cos(x))$$ is not of the form: $$a_0\sin(2x)+b_0\cos(2x)$$. Indeed $$y_p(0)=0=b_0$$ and $$y_p(\pi)=4=b_0$$ which is a contradiction.

• wow, that's so shrewd, thank you!
– Leon
Commented Jan 3, 2021 at 12:12