TITLE: Differential Equation Question $y'=\frac{1}{\cos y-x}$
QUESTION [5 upvotes]: I want to find the solution for the first order differential equation
$$y'=\frac{1}{\cos y-x}$$
I have no clue what to do, what I tried is:

$$(\cos y-x)dy=dx$$
$$\frac{dy}{dx}=\frac{1}{\cos y-x}$$

hints will be welcomed,thanks.

REPLY [5 votes]: Rewriting the equation as
$$
(x-\cos y)y'+1=0
$$
and putting $M(x,y)=1$ and $N(x,y)=x-\cos y$,
$$
M(x,y)dx+N(x,y)dy=0
$$
We see that the equation is not exact because 
$$\frac{\partial M(x,y)}{\partial y}=0\neq 1=\frac{\partial N(x,y)}{\partial x}.$$
We have to find an integrating factor $\mu(y)$ such that
$$
\mu(y)M(x,y)dx+\mu(y)N(x,y)dy=0
$$
is exact, that is $$ \frac{\partial \mu(y)M(x,y)}{\partial y}=\frac{\partial \mu(y)N(x,y)}{\partial x}. $$
We find that $\mu$ must satisfy $\mu'(y)=y$ so that $\mu(y)=e^{y}$.
Multiplying $(x-\cos y)y'+1=0$ by $\mu(y)$ one has
$$
e^{y}(x-\cos y)y'+e^{y}=0
$$
Let $A(x,y)=e^{y}$ and $B(x,y)=e^{y}(x-\cos y)$; this is an exact equation because 
$$
\frac{\partial A(x,y)}{\partial y}=\frac{\partial B(x,y)}{\partial x}=e^{y}.
$$
Let $F(x,y)$ such that $\frac{\partial F(x,y)}{\partial x}=A(x,y)$ and $\frac{\partial F(x,y)}{\partial y}=B(x,y)$; so the solution of the equation is given by
$$
F(x,y)=C
$$
with $C$ an arbitrary constant.
Integrating $\frac{\partial F(x,y)}{\partial x}$ with respect to $x$ one has
$$
F(x,y)=e^yx+\psi(y)
$$
where $\psi(y)$ is an arbitrary function of $y$. Differentiating $F(x,y)$ with respect to $y$, we find
$$
\frac{\partial F(x,y)}{\partial y}=e^yx+\psi'(y)=B(x,y)=e^{y}(x-\cos y)
$$
so that 
$$
\psi'(y)=-e^{y}\cos y
$$
and solving
$$
\psi(y)=-\frac{1}{2}e^{y}(\cos y+\sin y)
$$
Finally
$$
F(x,y)=e^yx-\frac{1}{2}e^{y}(\cos y+\sin y)
$$
so the solution is $F(x,y)=C$:
$$
e^yx-\frac{1}{2}e^{y}(\cos y+\sin y)=C
$$
or
$$
x=\frac{1}{2}(\cos y+\sin y)+Ce^{-y}.
$$