# Solving differential equation with inhomogeneous part $\sin x \cos x$

How do you solve the following inhomogeneous differential equation:

$$y' + y\cos x = \sin x \cos x ?$$

I determined the homogeneous solution ($y_h=Ce^{-\sin x})$, but how do I find the particular solution? I tried using the ansatz $y_p = (P \sin x + Q\cos x)(S\sin x + Z\cos x)$, but this approach failed (I didn't succeed at least). What is the most bright approach? Thanks for any help!

• The ODE is linear in $y$. Have you attempted to find an integrating factor? – user170231 Jul 12 '15 at 22:56
• This should work. – Git Gud Jul 12 '15 at 22:56

$${ y }^{ \prime }+y\cos { x } =\sin { x } \cos { x }$$ $$\Downarrow$$ $${ y }\prime +y\cos { x } =0$$ $$\Downarrow$$ $$\frac { dy }{ dx } =-y\cos { x }$$ $$\Downarrow$$ $$\int { \frac { dy }{ y } } =-\int { \cos { x } dx }$$ $$\Downarrow$$ $$lny+{ C }_{ 1 }=-\sin { x } +C_{ 2 }$$ $$\Downarrow$$ $$y={ Ce }^{ -\sin { x } }$$ $$\Downarrow$$ $$y=C\left( x \right) { e }^{ -\sin { x } }$$ $$\Downarrow$$ $${ y }\prime =C\prime \left( x \right) { e }^{ -\sin { x } }-C\left( x \right) \cos { x } { e }^{ -\sin { x } }$$ $$\Downarrow$$ $$C\prime \left( x \right) { e }^{ -\sin { x } }-C\left( x \right) \cos { x } { e }^{ -\sin { x } }+C\left( x \right) \cos { x } { e }^{ -\sin { x } }=\sin { x } \cos { x }$$ $$\Downarrow$$ $$C\prime \left( x \right) { e }^{ -\sin { x } }=\sin { x } \cos { x }$$ $$\Downarrow$$ $$C\prime \left( x \right) ={ e }^{ \sin { x } }\sin { x } \cos { x }$$ $$\Downarrow$$
$$C\left( x \right) =\int { { e }^{ \sin { x } }\sin { x } \cos { x } dx } =\int { \sin { x } d } { e }^{ \sin { x } }={ e }^{ \sin { x } }\sin { x } -\int { { e }^{ \sin { x } }\cos { xdx } } ={ e }^{ \sin { x } }\sin { x } -\int { d{ e }^{ \sin { x } } } ={ e }^{ \sin { x } }\left( \sin { x } -1 \right) +C$$ finally $$y={ e }^{ -\sin { x } }\left[ { e }^{ \sin { x } }\left( \sin { x } -1 \right) +C \right] =\sin { x } -1+{ Ce }^{ -\sin { x } }$$
Use the integrating factor $$\mu(x) = \exp\left\{\int \cos(x)\ dx\right\} = e^{\sin(x)}.$$
make the ansatz $y_p=A\sin(x)+B\cos(x)+C_1$ where $A,B,C_1$ are real numbers
You could use $y_p=A\sin x+B$
this gives the equation $A\cos x+(A\sin x+B)\cos x=\sin x\cos x$.