# solving first order nonhomogenous ode where the nonhomogenous part is $f(y)$

solve the ode $x^2y^\prime-1=\cos 2y$

First I wrote $y=y_h+y_p$. $y_h$ can be found easily i think: $$x^2y^\prime-1=0 \\y^\prime=\frac 1 x^2 \\ y=-\frac 1 x +c_1$$ but about finding the private solution i dont know from where to begin. suppose it was $\cos 2x$ i could have guessed $$y_p=a\cos 2x+ b\sin 2x$$ but here I can't do so. how can I find $y_p$?

• try solving $$\int\frac{\mathrm{dy}}{1+\cos(2y)} = \int\frac{1}{x^{2}}\mathrm{dx}$$. With also using some trig identities. – Chinny84 Jan 22 '14 at 18:16
• This is a nonlinear equation (because of the $\cos(2\,y)$ term.) The method you are trying to use is for linear equations. – Julián Aguirre Jan 22 '14 at 18:20
• @JuliánAguirre yes the $\cos(2y)$ term is non-linear but the equation is a first order separable ode so I can split out the y terms and x terms and integrate without a problem. If the rhs was $x\cos(2y)$ for example, then I would not be able to separate. – Chinny84 Jan 22 '14 at 18:26
• @Chinny84 Of course. Since you explained that in your first comment, I did not see the need to repeat it. I just wanted to make sure the OP understands that the ansatz $y=y_h+y_p$ does not work in this case. – Julián Aguirre Jan 22 '14 at 18:30
• @JuliánAguirre Oh ok. Sorry, I misread your comment. – Chinny84 Jan 22 '14 at 19:33

$$x^2y^\prime-1=\cos 2y\longrightarrow x^2dy=\big(1+\cos(2y)\big)dx=2\cos^2(y)dx$$ so we get $$\frac{dy}{2\cos^2(y)}=\frac{dx}{x^2}\longrightarrow 0.5\tan(y)=-\frac{1}x+C, x\neq 0$$