How to solve this first-order differential equation?

I have been trying to solve a differential equation as a practice question for my test, but I am just unable to get the correct answer. Please have a look at the D.E:
$dy/dx = 1/(3x+\sin(3y))$

My working is as follows:
$dx/dy = 3x+\sin(3y)$
$dx – 3x = \sin(3y) dy$
Integrating both sides:
$x-(3/2)x^2 = -(1/3)\cos(3y) + c$

But the correct answer is:
$x = ce^3y – 1/6(\cos(3y) + \sin(3y))$, which is quite different from what I have got. Could someone please help me solve this? Thanks 🙂

Solutions Collecting From Web of "How to solve this first-order differential equation?"

The step you tried to do would have to read $dx=3x dy + \sin(3y) dy$, which is a bad sign: you have a function of $x$ multiplied with $dy$ which means the variables have not been separated. You also tried to integrate a $3x$ that had no $dx$, which does not make proper sense.

Instead of trying to think about it like separation of variables, notice that your new equation (after changing variables to $x(y)$ instead of $y(x)$) is linear, so you should solve it by the method of integrating factors. That is, you should have $\frac{d}{dy} \left ( e^{-3y} x \right ) = e^{-3y} \sin(3y)$ and now you just have an integral and some algebra to do.

HINT…..You need to use the integrating factor method.

Starting with $$\frac{dx}{dy}-3x=\sin 3y$$

The integrating factor is $$I=e^{-3dy}=e^{-3y}$$

Therefore $$xe^{-3y}=\int e^{-3y}\sin 3y dy$$