TITLE: Differential equation trouble
QUESTION [5 upvotes]: I am trying to solve the following differential equation:

$$\frac{\mathrm{d}y}{\mathrm{d}x}=2(2x+y)^2$$

If we make the substitution $z=2x+y$, then we get: $$\frac{\mathrm{d}z}{\mathrm{d}x}=2+\frac{\mathrm{d}y}{\mathrm{d}x}=2+2z^{2}$$
This is a separable ODE, and so we get
$$\frac{\mathrm{d}z}{2+2z^{2}}=\mathrm{d}x \implies \int\frac{\mathrm{d}z}{2+2z^{2}}=\int\mathrm{d}x \implies \frac{1}{2}\tan^{-1}(z)=x+C$$
Rearranging we get:
$$z=\tan(2x+C) \implies y=\tan(2x+C)-2x$$
However plugging the ODE into Mathematica gives:
$$y(x)=\frac{2}{4Ce^{4ix}-i}-2x-i$$
And I can't see any way to reconcile these two results? Have I made an assumption that I'm unaware of at some point throughout my solution, or have I done something completely wrong?
P.S: Code for Mathematica:
FullSimplify[DSolve[y'[x] == 2 (2 x + y[x])^2, y[x], x]]

REPLY [2 votes]: \begin{align}
y(x)&=\frac{2}{4Ce^{4ix}-i}-2x-i\\
&=\frac{2e^{-2ix}}{4Ce^{2ix}-ie^{-2ix}}-i-2x\\
&=\frac{2e^{-2ix}-4Cie^{2ix}-e^{-2ix}}{4Ce^{2ix}-ie^{-2ix}}-2x\\
&=\frac{e^{-2ix}-4Cie^{2ix}}{4Ce^{2ix}-ie^{-2ix}}-2x
\end{align}
Now,
\begin{align}
\tan(2x+K) &= \frac{\sin(2x+K)}{\cos(2x+K)}\\
&=\frac{e^{2ix+Ki}-e^{-2ix-Ki}}{i(e^{2ix+Ki}+e^{-2ix-Ki})}\\
&=\frac{e^{-2ix}-e^{2ix+2Ki}}{-ie^{2ix+2Ki}-ie^{-2ix}}
\end{align}
And so, if we let $4Ci=-e^{2Ki}$, we have
$$
y(x)=\tan(2x+K)-2x
$$