Graph of a function $(x^2+2)x(x-2)$ 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?
 A: 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.
A: For the general case.
Let $f(x) = (x^2+2)g(x)$ with $g(x) = x(x-2)(x-3)(x-4)...(x-2n)$.
Then $f'(x) = 0$ and $f(x)\neq 0 \iff (x^2+2)g(x) + 2xg'(x) = 0$ and $x\neq 0$ and $g(x)\neq 0 \iff \dfrac{g'(x)}{g(x)}  + \dfrac{x^2+2}{2x} = 0$
But $\dfrac{g'(x)}{g(x)} = \dfrac 1 x + \dfrac 1 {x-2} + \ldots + \dfrac 1{x-2n}$.
So the equation $f'(x) = 0$ with $f(x)\neq 0$ is equivalent to $h(x) = x + \dfrac 2x + \dfrac 1 {x-2} + \ldots + \dfrac 1{x-2n} = 0$
This $h(x)$ is a sum of increasing functions, each of which is  increasing over each interval it is defined on. So $h(x)$ is increasing over each of the intervals $(-\infty,0)$, $(0,2)$, $(2,4)$, and so on.
Hence it can be equal to zero just once per interval. So the same holds for $f'$.
So $f$ can have only one extremum per interval. QED.
