Question about problem 14-6 from Spivak's Calculus: Finding all continuous functions $f$ satisfying $\int_0^x f = (f(x))^2 + C$ for $C \neq 0$ Find all continuous functions $f$ satisfying $$F(x) = \int_0^x f = (f(x))^2 + C \quad\text{for } C \neq 0,$$ assuming $f$ has at most one zero.

Since $f$ is continuous on $\mathbb{R}$, by the FTC, $F$ is differentiable on $\mathbb{R}$ and $F'(x) = f(x) = 2f(x)f'(x)$. Now, Spivak states that $f$ is differentiable at $x$ whenever $f(x) \neq 0$, but I don't see how $f$ can ever not be differentiable, recalling that $F$ must be differentiable everywhere.
 A: This question is actually extremely nice. You have to work a little bit to get to an answer, though. So, we have that:
$$\forall x \in \mathbb{R}: f(x) = h'(x)$$
where $x \mapsto h(x) = (f(x))^2$. This implies that $h'$ is continuous. So, if $f(x) > 0$ at a given point $x$, $h'(x) > 0$. Since $h'$ is continuous, it follows that there is an open interval around $x$ on which $h'(x) > 0$.
Okay, let's also make another note; if $f$ is not zero at any point, then $f$ has to either be positive or it has to be negative. If there was a point $x$ where it was positive and a point $y$ where it was negative, then we could find a point $z$ where it would be zero by the Intermediate Value Theorem.
Let's suppose that $a \in \mathbb{R}$ is a zero of $f$. So, $f(a) = 0$. Then, $f$ is non-zero on the interval $(a,\infty)$. Let's assume that $f > 0$ on the interval $(a,\infty)$. This means that $h' > 0$ on this interval. So, $f^2$ is an increasing function. Moreover, since $f(a) = 0$, it follows that $f$ is strictly positive on $(a,\infty)$. Hence, we can write:
$$f = |f| = \sqrt{f^2}$$
This is a composition of differentiable functions on $(a,\infty)$. So, $f$ is differentiable on $(a,\infty)$. Then, we can write that:
$$h' = 2ff' = f$$
Since $f$ is strictly positive on $(a,\infty)$, it follows that $f' = \frac{1}{2}$
on this interval. So, $f(x) = \frac{1}{2}x + k$. Now, $f$ must be continuous at $a$. It follows that $k = -\frac{1}{2}a$. So:
$$f(x) = \frac{1}{2}(x-a)$$
Okay, that's cool. Observe that $F(0) = (f(0))^2+ C = 0$. If $f(0) = 0$, then $C = 0$ and that's impossible. So, $C < 0$. Now, the point here is that no matter which cases we consider, every case is just about proving that $f$ is differentiable in the set $(-\infty,a) \cup (a,\infty)$. In each case, the fact that $f \neq 0$ just implies that $f' = \frac{1}{2}$ on the union I wrote above. Now, it follows that $f(x) = \frac{1}{2}(x-a)$ for all $x \in \mathbb{R}$, by continuity.
The final step is to try and find $a$. We'll just plug this into the integral equality. We get:
$$\frac{1}{4}(x-a)^2 +C = \frac{1}{4}(x-a)^2-\frac{1}{4}a^2$$
which implies that $a^2 = -4C$. So, we could pick $a = \sqrt{-4C}$ or $a = -\sqrt{-4C}$. This gives two functions that satisfy the given equality so we are done.
