First step is to expand the right side:

[math]\frac{dz}{dx} = z^2+8xz+16x^2[/math]

This is a Riccati equation: see Riccati equation – Wikipedia

if we let [math] u = z+4x, \frac{du}{dx} = \frac{dz}{dx} + 4[/math], we can write this equation as [math]\frac{du}{dx} – 4 = u^2[/math]

This equation is just separable, so we just have

[math]\frac{du}{u^2+4} = dx; \frac{1}{2}arctan(\frac{u}{2}) = x+C; \frac{1}{2}arctan\frac{z+4x}{2} = x+C[/math]

Now we plug in the condition:

[math]1/2*arctan(2/2) = 0+C; π/8 = C[/math]

So, your solution should be

[math]\frac{1}{2}arctan\frac{z+4x}{2} = x+\frac{π}{8}[/math]

in implicit form.

[math]z' = \left(z + 4x\right)^2[/math]

Set [math]y = z + 4x[/math], so [math]y' = z' + 4[/math], so [math]z' = y' – 4[/math].

[math]y' – 4 = y^2[/math]

[math]y' = y^2 + 4[/math]

[math]\frac{y'}{y^2+4} = 1[/math]

[math]\int \frac{y'}{y^2+4} dx = \int 1 dx[/math]

[math]\int \frac{\frac{dy}{dx}}{y^2+4} dx = x + C[/math]

[math]\int \frac{1}{y^2+4} dy = x + C[/math]

Setting [math]y = 2 \tan \left(\theta\right)[/math], which gives [math]dy = 2 \sec^2 \left(\theta\right) d\theta[/math]:

[math]\int \frac{2\sec^2\left(\theta\right)}{4\tan^2\left(\theta\right)+4} d\theta = x + C[/math]

[math]\int \frac{2\sec^2\left(\theta\right)}{4\sec^2\left(\theta\right)} d\theta = x + C[/math]

[math]\int \frac{1}{2} d\theta = x + C[/math]

[math]\frac{1}{2} \theta = x + C[/math]

(The constant of integration gets swallowed up by the [math]+C[/math].)

[math]\frac{1}{2} \tan^{-1}\left(\frac{y}{2}\right) = x + C[/math]

[math]\tan^{-1}\left(\frac{y}{2}\right) = 2x + C[/math]

[math]\frac{y}{2} = \tan\left(2x+C\right)[/math]

[math]y = 2\tan\left(2x+C\right)[/math]

[math]z = y – 4x[/math]

[math]z = 2\tan\left(2x+C\right) – 4x[/math]

It is a good idea to substitute this into the original equation to check if it is correct.

[math]z' = 4\sec^2\left(2x+C\right) – 4[/math]

[math]= 4\tan^2\left(2x+C\right)[/math]

[math]\left(z + 4x\right)^2 = \left(2\tan\left(2x+C\right)\right)^2[/math]

[math]= 4\tan^2\left(2x+C\right)[/math]

so this is the correct solution set.

What remains is to find [math]C[/math]. [math]z\left(0\right) = 2[/math], so:

[math]2 = 2\tan\left(2\left(0\right)+C\right) – 4\left(0\right)[/math]

[math]2 = 2\tan\left(C\right)[/math]

[math]\tan\left(C\right) = 1[/math]

[math]C = \frac{\pi}{4} + n\pi[/math], where [math]n[/math] is an integer

[math]z = 2\tan\left(2x+\frac{\pi}{4} + n\pi\right) – 4x[/math]

The choice of [math]n[/math] does not matter, because the tangent function is periodic with period [math]\pi[/math].

[math]z = 2\tan\left(2x+\frac{\pi}{4}\right) – 4x[/math]

This is the solution. For completeness, one might note that this has vertical asymptotes at [math]x = \frac{\pi}{8} + \frac{n\pi}{2}[/math] (where [math]n[/math] is an integer), so the domain of this solution is restricted to the open interval [math]\left(-\frac{3\pi}{8}, \frac{\pi}{8}\right)[/math]. What happens outside this interval (assuming we are looking for real solutions only)? [math]z = 2\tan\left(2x+C\right) – 4x[/math] is still true, but each interval between two vertical asymptotes is allowed to have its own [math]C[/math], as what happens at [math]x = 0[/math] cannot influence things beyond a break in the domain of applicability. (Change [math]C[/math] in any interval between asymptotes, and the differential equation still holds at every point in the domain of [math]y[/math].) If one wants to go around such breaks, a good way to do so is to ask for complex solutions rather than real ones.