# Having trouble exact first-order differential equation.

I've been trying to solve the following differential equation:

$$3x+y(x)-2+\frac{dy(x)}{dx}(x-1)=0$$ And I found out it's an exact differential equation, since it can be rearranged as $(3x+y(x)-2)dx+(x-1)dy=0$

Assuming that a function $U(x,y)=\frac{\partial U}{\partial x}dx + \frac{\partial U}{\partial y}dy = k$, (where $k\equiv$ constant) exists, I calculated it as:

$$U(x,y)=\int (3x+y-2)dx + \int (x-1)dy=k$$

And I got $$y(x)=\frac{-3x^2}{2(2x-1)}+\frac{2x}{2x-1}+\frac{k}{2x-1}$$

But Mathematica says the solution is $$y(x)=\frac{-3x^2}{2(x-1)}+\frac{2x}{x-1}+\frac{k}{1-x}$$

So either I assumed something which isn't correct or I made a mistake along the process. Where did I go wrong?

• $3x+y(x)−2$ is different form $3x+y(x)−x$ – Andrei Nov 1 '17 at 16:55
• Sorry, that was a typo – Manuel Nov 1 '17 at 16:56
• Well, your solution is correct! You can also double check your solution on WolframAlpha – Shadi Nov 1 '17 at 17:21
• How is it correct? I see what you linked, but WolframAlpha also gives a different solution from the one I got. Is it because you can play with the coefficients since there is an arbitrary constant? – Manuel Nov 1 '17 at 17:26
• @Manuel Check your solution again. – Nosrati Nov 1 '17 at 17:32

It can be seen as a linear differential equation:

$y' +\dfrac{y}{x-1} = \dfrac{2-3x}{x-1}$

Using integration factor $x-1$

$y(1-x)=\int(2-3x)dx$

$y (1-x) = 2x - \frac{3x^2}{2} + k$

Hope it helps