# Integrating the Lambert-W function

I was attempting to integrate the Lambert-W Function and my answer differs from that given by Wikipedia and Wolfram Alpha so I figure I must be doing something wrong.

We have $f^{-1} = W(z)$, $f=ze^z$, and $F = e^z(z-1)$. Using the formula in this answer:

\begin{align*} \int W(z) \,dz &= zW(z) - \left[ \left( e^z(z-1) \right) \circ W(z) \right](z) + c \\ &= zW(z) - e^{W(z)} (W(z)-1) + c \end{align*}

However, the W|A and Wikipedia give:

$$\int W(z) \,dz = z\left( W(z) + \frac{1}{W(z)} - 1 \right) + c$$

Wikipedia gives the identity $\int_0^e W(z) \,dz = e-1$, which my antiderivative gives as a solution as well. So I figure the two primitives must just differ by a constant $c_0$? What is the difference between my solution and the other? or how do I show that they are the same?

That's easy: due to the definition of $W,$ we have $W(z)\,e^{W(z)}=z$, meaning $e^{W(z)}=\frac{z}{W(z)}.$ Substituting this in the fist expression for the antiderivative, we get the second one.
Integrating inverse functions can often be simplified using integration by parts: \begin{align} \int W(z)\,\mathrm{d}z &=\int x\,\mathrm{d}\!\left(xe^x\right)\\ &=x^2e^x-\int xe^x\,\mathrm{d}x\\ &=x^2e^x-xe^x+\int e^x\,\mathrm{d}x\\[3pt] &=x^2e^x-xe^x+e^x+C\\[6pt] &=\left(W(z)^2-W(z)+1\right)\frac{z}{W(z)}+C\\ &=z\left(W(z)-1+\frac1{W(z)}\right)+C \end{align}