Substitution in ordinary differential equation gone wrong Given
$$
y(t) = \left( \int u(t) \; \text{dt} \right)^2,
$$
the derivative of $y$ over $t$ is
$$
\dot{y} = 2 u(t) \int u(t) \; \text{dt}.
$$
Substituting $\int u$ in the above equation yields
$$
\dot{y} = 2u(t) \sqrt{y}.
$$
But integrating this differential equation with $y(0) = 0$ and $u(t) \equiv 1$ yields $y \equiv 0$ for all $t$, whereas $y(t) = t^2$ in the original equation.
Why is that?
 A: Your approach to the question is wrong, from the beginning itself. After integration, $y$ is no longer a function of $t$. Assuming that you mean $\int_0^x$ by the indefinite integral. We write
\begin{equation}
y(x) = \left(\int\limits_0^x u(t)dt\right)^2
\end{equation}
Differentiating using the Newton-Leibniz rule, we get,
\begin{equation}
y'(x) = 2u(x)\int\limits_0^x u(t)dt
\end{equation}
Assuming that $\int\limits_0^x u(t)dt>0$ and using the first equation in the above equation, we get,
\begin{equation}
\dfrac{dy}{dx} = 2u(x)\sqrt y
\end{equation}
Putting $u(x)\equiv1$, we get,
\begin{align}
&\dfrac{dy}{dx}=2\sqrt y\\
\implies &\dfrac{dy}{2\sqrt y} = dx\\
\implies &\sqrt y = x+C&&(\text{By integrating both sides})\\
\implies &y = x^2&&(\text{Using the initial condition})
\end{align}
This is what you desired. Also note that we can divide both sides by $\sqrt y$ only by assuming $\sqrt y\ne0$. $y\equiv0$ is a trivial solution to the differential equation.
A: I'm not sure what integration you used to obtain it, but  $y\equiv 0$ is indeed a solution to $y'=2\sqrt y$ with $y(0)=0$. Actually, so is $y(t)=t^2$. It seems then that you have stumbled upon the fact that that going from functions to ODE initial value problems (IVPs) solved by the function does not always allow you to reproduce the function again. This is called non-uniqueness of solutions for the IVP. It is not a simple problem and I'm quite sure there isn't a simple answer.
There is a more elementary example of non-uniqueness of solutions for IVPs: $y(t)=t^2$ also solves
\begin{cases}y''-2=0 \\ y(0)=0\end{cases}
and here there is no unique solution: $y=x^2+kx$ is a solution for all $k\in\mathbb R$. The IVP with the unique solution $y(t)=t^2$ is instead
\begin{cases}y''-2=0 \\ y(0)=0\\y'(0)=0\end{cases}
There is an argument to be made that it is "my fault" for not writing down a good IVP in the above, and it was easily fixed by using the "right" initial data. In the ODE you found however, the problem is more subtle, and it doesn't matter what other information you try to prescribe at $t=0$. In this case there is also an infinity of solutions: they are the two mentioned above, $y=0$, $y(t)=t^2$, and then weird families of solutions that switch from $0$ to $t^2$ at an arbitrary position. That is, for any $a\in(0,\infty)$, the following function is a solution:
$$  y(t)=\begin{cases} (t-a)^2 &\phantom{0\le{}}t\ge a \\ 0 &0\le t<a \end{cases} $$
Why this happens is not easy to explain, and the theory of ODEs is much more intricate than it might seem at first (and the theory of partial differential equations is more complex still!)
A basic explanation would be that $y'=2\sqrt y$ does not satisfy the assumptions of the Picard-Lindelöf theorem for ODEs. This says that $y'=f(y,t)$ with an initial condition has unique solutions if $f$ is Lipschitz, and  $\sqrt y$ is indeed not. But there are other ODEs that fail the assumptions of Picard-Lindelöf while still having unique solutions, so this is still far from a perfect explanation.
I'll end with mentioning however that there is a sense in which the "correct" solution to $y'=2\sqrt y$ is in fact $y(t)=t^2$. This is however quite technical; it is the theory of renormalized solutions developed by DiPerna and Lions.
