Spivak Calculus: $f$ satisfies $f''(x)+f'(x)g(x)-f(x)=0$, for some g. Prove that if  is 0 at two points, then  is 0 on the interval between them. The following is a problem from chapter 11, "Significance of the Derivative" from Spivak's Calculus



*Suppose that $f$ satisfies $$f''(x)+f'(x)g(x)-f(x)=0\tag{1}$$ for some function $g$. Prove that if $f$ is $0$ at two points, then $f$ is $0$
on the interval between them. Hint: Use Theorem 6.


Here is the theorem referred to above.

Theorem 6: Suppose $f''(a)$ exists. If $f$ has a local minimum at $a$,
then $f''(a) \geq 0$; if $f$ has a local maximum at $a$, then $f''(a) \leq 0$.

The solution manual solution is as follows

Suppose $f(a)=f(b)=0$. If $x$ is a local maximum point of $f$ on
$[a,b]$, then $f'(x)=0$ and $f''(x) \leq 0$; from the equation
$$f''(x)+f'(x)g(x)-f(x)=0$$ we can conclude that $f(x) \leq 0$.
Similarly, $f$ cannot have a negative local minimum on $(a,b)$.

My question regards the above proof, which seems terse to the point that I don't understand how the desired result ensues from it.
Let me go through it in more words and steps.
If we assume that $(1)$ is true for all $x$, then $f$ is (twice) differentiable at all $x$.
The interval $[a,b]$ is closed, and $f$ is continuous on this interval. Therefore any max or min on $[a,b]$ must either be a critical point, one of the endpoints, or points where $f$ isn't differentiable.
Suppose there is a local max in $x_1 \in [a,b]$. Theorem 6 tells us that $f''(x_1)<0$ and $(1)$ tell us that $$f''(x_1)=f(x_1)<0\tag{2}$$
The proof above stops here and seems to imply that whatever $(2)$ means or implies is clear. It is not, however, clear to me.
Could we not have a situation such as

Though I can't quite finish the reasoning, it seems the situation above also leads to a contradiction.
Reasoning 1
Since $x_1$ is a local max, there is an interval around it where $f$ is smaller than $f(x_1)$.
In particular, $\exists x_2, x_2 < x_1 \land f(x_2)<f(x_1)$. The Intermediate Value Theorem tells us that there is some $x_3 \in [a,x_2]$ such that $f(x_3)=f(x_1)$.
Hence, by Rolle's Theorem, there is some $x_4 \in [x_3, x_1]$ such that $f'(x_4)=0$. But then $(1)$ tell us that $f''(x_4)=f(x_4) \leq 0$. So $x_4$ is a local max.
I can't quite finish this reasoning, but it seems to imply that there are infinite local maxima in $(a,b)$, at every local max $f$ is negative, and every critical point at which $f$ is negative is a local max.
The reasoning when we assume there is a local min in $(a,b)$ should be analogous.
Is the reasoning above on the right track, and if so how do I finish it (ie explicitly conclude that $f=0$ in $[a,b]$)?
Reasoning 2
Since $f''(x_1)<0$, and $f'(x)<0$ in an interval around $x_1$, $f$ is decreasing as we move to the left of $x_1$ and decreasing as we move to the left of $x_1$. But since $f(a)=f(b)=0$, and $f$ is continuous, it will need to increase at some point between $x_1$ and $a$, and between $x_1$ and $b$.
But then $f'$ needs to be positive, and hence $f''$ needs to be positive so that $f'$ increases from a negative value to a positive value. But then $f$ is positive at such points by $(1)$, which contradicts the fact that actually $f$ is negative whenever the sign of $f''$ changes because $f$ is negative and decreasing when that happens.
Again, this seems to mean contradiction, which means $f$ can't have a local max at a point where $f<0$.
I can't seem to satisfy myself with the details though. The reasoning doesn't seem rigorous enough.
 A: $f$ attains $0$ on the endpoints of $[a,b]$.
One possibility is that $f$ is the constant zero function on the whole interval $[a,b]$.
The task is to show that the other possibility, that $f$ is not the constant zero function, leads to a contradiction.
$\\$
Suppose $f$ attains a positive value somewhere on $(a,b)$.
Then there exists $c\in(a,b)$ be such that $f(c)\geq f(x)$ for all $x\in[a,b]$. (You can work this out, starting from the Extreme Value Theorem.) Choose such a $c$.
Clearly $f(c)>0$.
Theorem $6$ implies that $f'(c)=0$ and that $f''(c)\leq 0$.
But hold on! We would then have $f''(c)-f(c)<0$ which is a contradiction.
$\\$
Do something similar after supposing that $f$ attains a negative value somewhere on $(a,b)$.
A: Suppose $f$ attains a local maximum $f(x_1)>0$ at $x_1\in(a,b)$ (it must if $f(x)\neq0$ for all $x\in(a,b)$, by the Extreme Value Theorem). Then $f'(x_1)=0$ and $f''(x_1)\leq0$, meaning
$$f''(x_1)=f(x_1)\leq0,$$
which is a contradiction. Conversely, suppose $f$ has a local minimum $f(x_1)<0$ at $x_1\in(a,b)$ (again by the EVT). Then $f'(x_1)=0$ and $f''(x_1)\geq0$, meaning
$$f''(x_1)=f(x_1)\geq0,$$
which is again a contradiction. Thus, since $f$ can't take on positive or negative values, we must have $f(x)=0$.
