# Why is this differential equation an exact differential equation?

I'm looking at the following differential equation:

$\frac{dx}{dt} = \frac{\sin^2 x - t^2}{t \cdot \sin(2x)}$

I rewrote it as

$(t \cdot \sin(2x))dx = (\sin^2x - t^2)dt$

$\Leftrightarrow (\underbrace{\sin^2 x - t^2}_{J(x,t)})dt + (\underbrace{-t \cdot \sin(2x)}_{I(x,t)}) dx = 0$

where I put the minus sign inside the function because I think it is important that a plus stands between the two functions in order to check if a differential equation is exact or not. But then:

$\partial_x J(x,t) = 2 \sin x \cos x = \sin(2x)$

$\partial_t I(x,t) = -\sin(2x)$

Those functions don't seem to satisfy the condition for a differential equation to be exact. However my teacher wrote in his answer the following:

$\frac{-\partial_x (\sin^2 x - t^2) - \partial_t (t \cdot \sin (2x))}{t \sin(2x)} = \frac{-2}{t}$

$\implies c' = - \frac{2}{t} c$

$\implies x' = \frac{\frac{\sin^2 x}{t^2} - 1}{\frac{\sin (2x)}{t}}$

and he states that this equation is now exact. What happened there? I've never seen anything like that yet. I understand (more or less) what he is doing after $c' = -\frac{2}{t}c$ (separation of variables and integration), but how he came to the first line I have no idea. Is that a known technic to transform a differential equation that is $\textit{almost}$ exact?

So if the differential equation of the form $Mdt+Ndx=0$, for $C^1$ functions $M=M(x,t)$ and $N=N(x,t)$ on some rectangular region $R\subseteq\Bbb R^2$, satisfies $M_x=N_t$, then it is an exact equation. If it is not of that form, sometimes one can find an integrating factor $\mu$ (denoted in your problem by $c$) to multiply the equation, so that it becomes exact. There are methods for finding integrating factors in specific case. One specific case is if $\frac{M_x-N_t}{N}$ is a function of only $t$, then one can find an integrating factor $\mu=\mu(t)$ which is only a function of $t$, and satisfies the differential equation $\frac{d\mu}{dt}=\frac{M_x-N_t}{N}\mu$.
In this case, we see that $N(x,t)=-t\sin(2x)$ and $M(x,t)=\sin^2(x)-t^2$, so you can find that $\frac{M_x-N_t}{N}=\frac{-2}{t}$, which is only a function of $t$. So then you can find $\mu(t)$ as a solution of $\frac{d\mu}{dt}=\frac{-2}{t}\mu$ (note that it is easiest to take the solution which has an integration constant equal to zero). Then you simply multiply the equation to get $\mu Mdt+\mu Ndx=0$, and you can verify that this equation is exact by showing $\frac{\partial}{\partial x}(\mu M)=\frac{\partial}{\partial t}(\mu N)$.
His $c$ is an integrating factor which he's picking as a function of $t$ only. If you multiply everything through by $c(t)$ and compare your same partial derivatives, you'll get $$2c(t)\sin(2x) = -tc'(t)\sin(2x).$$