# Can we tell if a function has a max or min by looking along specific directions?

Suppose we have a smooth function $f$ from $\mathbb R^n\to\mathbb R$ such that $\nabla f(0)=0$, and we want to check if $f$ has a local maximum at $0$ (as opposed to a local min or a saddle point).

For any vector $v$ in $\mathbb R^n$, we can form a function $g_v:\mathbb R\to\mathbb R$ defined by $g_v(x)=f(vx)$. Intuitively, we are looking at the behavior of $f$ along the $v$ direction. If $f$ has a local max at zero, then of course $g_v$ also has a local max at zero. My question is, is the converse true? If the single-variable function $g_v$ has a local max at $0$ for every possible direction $v$, does $f$ also have a local max at $0$?

If the Hessian of $f$ at zero has full rank, then this question is easily answered as yes. By taking $v$ to be in turn each of the eigenvectors of the Hessian, the fact that $g_v$ has a local max means that the corresponding eigenvalues are all negative, and so $f$ has a local max at $0$. But if some of the eigenvalues are $0$, then I'm not sure how to analyze it.

As a first step in a proof, I might think: well, for any fixed direction, there is some radius $r$ such that as long as $v$ is within distance $r$ of the origin, then $f(v)\le f(0)$. But since the $r$ depends on the direction, we can't necessarily find a single $r$ which works for all directions, so that might allow for a counter-example.

As a bonus, if it does hold for smooth functions, what about functions that are merely differentiable? Continuous? Or even all functions?

• I just had the same question myself. We can possibly apply compactness to get a minimum $r$, as long as we can choose $r$ as a continuous function of the direction, but I don't quite see a way to make this work. Jan 3, 2019 at 18:48

After thinking about it for a while I realized that the answer to this question is no, even for polynomial functions. Consider the following function, defined in polar coordinates: $$f(r,\theta)=r^4(r^2-\cos^2\theta)(r^2-2\cos^2\theta)$$ For any fixed value of $$\theta$$, we have a local min at $$0$$: if $$\cos\theta=0$$, then we just get $$g(r)=r^8$$, while for $$\cos\theta\ne 0$$, we get $$g(r)=2r^4\cos^4\theta-3r^6\cos^2\theta+r^8$$. The leading term for small $$r$$ is $$2r^4\cos^4\theta$$, which also has a local min at $$r=0$$.
However, can find arbitrarily small $$r$$ with $$f(r,\theta)<0$$. Given any (small) $$r$$, choose $$\theta$$ so that $$\frac{r}{\sqrt 2}<\cos\theta.
If we switch to rectangular coordinates, $$x=r\cos\theta$$, $$y=r\sin\theta$$, we get the degree $$8$$ polynomial: $$2x^4-3x^6+x^8-6x^4y^2+4x^6y^2-3x^2y^4+6x^4y^4+4x^2y^6+y^8$$ So this function is, in fact, a polynomial, the nicest type of function around!
• Neat construction! To visualize what's going on, we can factor $f(x,y)$ as $(x^2+y^2+x)(x^2+y^2-x)(x^2+y^2+\sqrt2 x)(x^2+y^2-\sqrt2 x)$: the product of four circles passing through $(0,0)$, two small ones inside two larger ones. For this product to be negative, $(x,y)$ must be inside a large circle but outside a small one; here is a plot of this region. In any direction from $0$, we must go through a positive region before reaching a negative one. Jan 3, 2019 at 21:12
• I guess on that basis, we could take half the picture for another counterexample: say, $f(x,y) = (x^2+y^2-x)(x^2+y^2-2x)$ would also work. Jan 3, 2019 at 21:18
• @MishaLavrov Ah, good thinking! Looking at the regions where $f$ is positive and negative is a nice way to visualize it. Jan 3, 2019 at 22:59