Consider $f(x)=(x^2+2)x(x-2)$. It has two real roots: $0$ and $2$.
If $x<0$, then $f(x)$ is positive, and if $x>2$, then also $f(x)$ is positive.
If $x$ is in $(0,2)$, then $f(x)$ is negative.
I am trying to understand why $f(x)$ has unique local minima in the interval $(0,2)$, so that the graph of $f(x)$ in interval $(0,2)$ is U-shaped. Can one explain, why this happens?
Even if we modify $f(x)$ by $$f(x)=(x^2+2)x(x-2)(x-4)\cdots (x-2n)$$ still, in each interval of the form $(2k, 2k+2)$, the graph of $f(x)$ is U-shaped or reverse-U shaped.
Why it can't be (smooth) w-shaped? Why this is happening?
One way would be to find $f'$ and assess the roots that way, but as $f'$ is a cubic that is likely unpleasant at the best of times. I'll assume solving quadratics and the use of an explicit form of $f''$ (at least for your original $f$) is admissible, however.
Well, we know that $f'(\xi) = 0$ for some $\xi \in (0,2)$ by Rolle's theorem (since $f(0) = f(2) = 0$). So there's definitely a local extremum, and it's easy to see by the first or second derivative tests that it must be a minimum.
Suppose there exists a second extremum, some $\xi_\ast \in (0,2), \xi_\ast \ne \xi$. Then $f'(\xi_\ast) = 0$ as well.
Of course, Rolle's theorem will apply to these two as well, under $f'$, since $f'(\xi) = f'(\xi_\ast) = 0$.
Hence there is an $\eta \in (\xi_\ast,\xi)$ (or $(\xi,\xi_\ast)$, whichever ordering is relevant) where $f''(\eta) = 0$.
One can calculate $f''$ directly, however, and see that $f''(x) = 12x^2 -12x+4$, and this has no real roots, a contradiction.