<s>[INST] 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?
 [/INST] 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.
</s>