# Rearranging after solving first-order nonlinear differential equation

My friend posed to me an interesting physics problem that reduces to the differential equation $$\frac{dy}{dx} = \frac{a}{y} + b$$ where $a$ and $b$ are known, nonzero constants. After reading up on how to solve differential equations like this, I got it down to $$\frac{by - a\space \ln (a + by)}{b^2} = x + C$$ and this is where I hit a dead-end. Wolfram|Alpha tells me that $$y = \dfrac{a\left(-W\left(-\dfrac{e^{\dfrac{(x+C)b^2}{a}-1}}{a}\right)\right)-a}{b}$$ where $W(z)$ is the Lambert W-function, but this is incredibly complex and I have no idea how it got to that point.

How one would get to this solution, and is there possibly a simpler way of expressing this?

-
I think you got the sign of the logarithm wrong, and you should take the absolute value of its argument; but neither of those will help make the solution any nicer. – joriki Nov 3 '11 at 22:57
Thanks, fixed. W|A refuses to give an answer altogether if I use absolute values, though, so I'm not even sure how that would even be reflected in the solution. – algorithmshark Nov 3 '11 at 23:21

$$\frac{by - a \ln (a + by)}{b^2} = x + C$$

and do a few rearrangements:

$$\frac{b}{a}y - \ln (a + by) = \frac{b^2}{a}(x + C)$$

and complicate things a little:

\begin{align*}1+\frac{b}{a}y - \ln\left(1 + \frac{b}{a}y\right) &= 1 + \frac{b^2}{a}(x + C)+\ln\,a\\\frac{\exp\left(1+\frac{b}{a}y\right)}{1+\frac{b}{a}y}&=\exp\left(1 + \frac{b^2}{a}(x + C)+\ln\,a\right)\\\left(-1-\frac{b}{a}y\right)\exp\left(-1-\frac{b}{a}y\right)&=-\frac1{a}\exp\left(- \frac{b^2}{a}(x + C)-1\right)\end{align*}

which is the cue for Lambert to enter the fray:

$$-1-\frac{b}{a}y=W\left(-\frac1{a}\exp\left(- \frac{b^2}{a}(x + C)-1\right)\right)$$

and finally

$$y=-\frac{a}{b}\left(1+W\left(-\frac1{a}\exp\left(- \frac{b^2}{a}(x + C)-1\right)\right)\right)$$

Which branch of the Lambert function will be needed will depend on your application.

-