Find a formula for $f''$ in terms of $f$, where $f\gt 0$ and $(f')^2=f-\frac{1}{f^2}.$ Problem:

Suppose that a function $f \gt 0$ has the property 
  $$
(f')^2=f-\frac{1}{f^2}
$$
  Find a formula for $f''$ in terms of $f$. Hint: Use Theorem 7.

Theorem 7: 

Suppose that $f$ is continuous at $a$, and that $f'(x)$ exists for all $x$ in some interval containing $a$, except perhaps for $x=a$. Suppose, moreover, that $\lim_{x\to a}f'(x)$ exists. Then $f'(a)$ also exists, and 
  $$
f'(a)=\lim_{x\to a}f'(x)
$$

I think this problem assumes $f''$ exists everywhere. This is my work so far. 
By Chain Rule, $2f'f''=f'+\frac{2f'}{f^3}$. Dividing by $f'$, we get $f''=1/2+1/f^3$, at all points $x$ where $f'(x)\neq 0.$ Since $(f')^2=\frac{f^3-1}{f^2}$, we have $f'(x)=0$ only for $f(x)=1$. So I need to compute $f''(x)$ for such $x$. Using the hint, I first guessed that Theorem $7$(applied to $f'$) implies that the formula holds in this case also, with $f''(x)=\lim_{y\to x}1/2+1/f^3(y)=\frac{1}{2}+1=\frac{3}{2}$. 
However, upon close inspection, I realized that this may not be true, as for any neighborhood around such $x$, there may be another $x_0$ such that $f(x_0)=1$, and in such case I cannot compute the limit as above. How can I resolve this situation, or is the problem wrong? I would greatly appreciate any help.
 A: I will assume that we are looking for functions $f$ which are defined and $\mathcal{C}^2$ on an open interval.
There are two cases:


*

*if $f$ is constant and equal to $1$, then $f''$ obviously vanishes.

*Assume that $f$ is not constant. If $f(x) \neq 1$ for all $x$, then $f'' = \frac{1}{2}+\frac{1}{f^3}$. So, let us assume that there exists $x_0$ such that $f(x_0) = 1$.
In the later case, since $f$ is not constant, there exists $x_1$ such that $f(x_1) \neq 0$. Assume that $x_1 > x_0$ (the other case is similar). Let $x_* := \sup \{x \in [x_0, x_1]: \ f(x) = 1\}$. Then, by continuity, $f(x_*) = 1$, and $x_* < x_1$,  and $f(x) \neq 1$ for all $x \in (x_*, x_1]$. But then, $f'' = \frac{1}{2}+\frac{1}{f^3}$ on $(x_*, x_1]$, so $\lim_{x \to x_*^+} f'' (x) = \frac{3}{2}$. Since $f$ is assumed to be $\mathcal{C}^2$, this yields $f'' (x_*) = \frac{3}{2}$, so $x_*$ is an isolated solution of $f = 1$.
Now, let us prove that $x_*$ is the only solution of the equation $f = 1$. Assume that there exists another solution $x_2$. Assume that $x_2 < x_*$ (the other case is similar), and put $x_\circ := \sup \{x \in [x_2, x_*): \ f(x) = 1\}$. Since $x_*$ is an isolated solution of $f = 1$, we have $x_2 \leq x_\circ < x_*$. By continuity, $f(x_\circ) = 1$. By Rolle's theorem, there exists $x \in (x_\circ, x_*)$ such that $f'(x) = 0$. But then, $f(x) > 1$, so at the same time $|f'(x)| > 0$: this is a contradiction.
Hence, $f$ takes the value $1$ at at most one point. At this point, we have proved that the relation $f'' = \frac{1}{2}+\frac{1}{f^3}$ still holds. Hence, $f'' = \frac{1}{2}+\frac{1}{f^3}$ everywhere.
Note that this assume that $f$ is $\mathcal{C}^2$; then, the function $f$ is either monotonous (and strictly larger than $1$), or decreases to $1$ and then increases. If $f$ is only assumed to be $\mathcal{C}^1$, I suspect that there are more complicated situations (e.g. f decreases to $1$, then take the value $1$ on an interval, then increases).
