Solve the first order ordinary differential equation $y'(x)=2x \cos^2 y(x)$ 
Solve $$y'(x) =2x \cos^2 y(x) .$$

\begin{align}
\frac{dy}{dx} &= \ 2x \cos^2 y(x) \\
\frac{dy}{\cos^2 y(x)} &=2x \, dx \\
\tan y(x) &=x^2+k, \qquad\qquad k \in \mathbb{R} \\
y(x) &=\arctan (x^2+k)
\end{align}
Is is correct?
Thanks!
 A: The basic procedure (separate, integrate, solve for $y(x)$) is correct, but the solution as written entails a few implicit assumptions, and as a result the it is not the general one. One way to see that something has gone awry is to notice that $y(0) = \arctan k \in \left(-\tfrac{\pi}{2}, \tfrac{\pi}{2}\right)$, so it does not include the specific solution that satisfies, e.g., $y(0) = \pi$.


*

*Dividing both sides by $\cos^2 y$ implicitly assumes that this quantity is not zero.

*Since $\arctan$ is not an inverse function for $\tan$ (it is the inverse of the restriction of $\tan$ to $\left(-\tfrac{\pi}{2}, \tfrac{\pi}{2}\right)$, $\tan y = x^2 + k$ does not imply that $y = \arctan (x^2 + k)$.
Here's how to resolve each of these issues:

(1) If $y$ is zero at some point $x_0$, so $\pi\left(n + \tfrac{1}{2}\right)$ for some integer $k$, then $y'(x_0) = 2x (0) = 0$. In particular, we see that the constant functions $$y(x) = \pi\left(n + \tfrac{1}{2}\right), \qquad n \in \Bbb Z$$ are all solutions. (2) The above characterization of $\arctan$ together with the fact that $\tan$ has period $\pi$ tells us that we can conclude that $y - \pi m = \arctan (x^2 + k)$ for some integer $m$. Rearranging gives the solutions $$y(x) = \arctan (x^2 + k) + \pi m, \qquad m \in \Bbb Z .$$

A: You can check if your proposed solution actually solves the equation. Let's calculate the derivative:
$$
y(x) = \arctan(x^2 + k)\\
y'(x) = \frac{2x}{(x^2+k)^2+1}
$$
This should equal $2x\cos^2(y(x))$ if $y(x)$ solved the original equation:
$$
2x\cos^2(y(x)) = 2x\cos^2(\arctan(x^2 + k)) = 2x\left(\frac{1}{\sqrt{(x^2+k)^2+1}}\right)^2 = \frac{2x}{(x^2+k)^2+1}
$$
Since those are the same quantity, you can say that what you derived solves the equation. Some comments and other answer underscore that that this may not be a unique solution since the inverse tangent of the tangent of an angle is not necessarily the original angle.
