3

Help! I think I'm stuck in a local minimum and I can't get out! Ok that's not news, many people all over the world are stuck in local minima everyday. What is news is that in my case I know there is a path out, and I'm wondering if a gradient calculation will help me find it. Here is my situation,... Imagine a bowl-shaped surface centered at x = 0, y = 0. Now imagine that there is a path out of this bowl but that it lies perfectly on the diagonal (so where x = y). In this case I think the partial derivative in the x-direction will tell me that I'm at the bottom of a 'U' and that there is no where to go, whilst the partial derivative in the y-direction will also tell me the same. So in the end the gradient should also tell me that I'm stuck at the bottom of a bowl. Is this correct? In other words,... do gradients have blind spots? Is it true that the 'gradient' calculation is in essence just an approximation based on 'sample' partial derivatives taken in the respective directions of the coordinate system? So if I change the coordinate system I might very well get a different value for the gradient even for the same point on the surface? Or is there another type of 'gradient' that I can calculate which will tell me how to get out of the bowl regardless of coordinate system?

Thanks for your patience,...

Terry

Terry
  • 33
  • 3
    The singular of "minima" is "minimum." – Matt Samuel Sep 07 '15 at 23:07
  • Oops, fixed. Thanks :) – Terry Sep 07 '15 at 23:08
  • Are you familiar with https://en.wikipedia.org/wiki/Gradient – user24142 Sep 07 '15 at 23:29
  • 1
    In order for a function to be differentiable, it's not enough for the partial derivatives to exist. In a sense, differentiability requires that the gradient has no "blind spots" (the function needs to be "locally affine"). So, your blind-spot function exists, but it's not differentiable. – Ben Grossmann Sep 07 '15 at 23:29
  • @Omnomnomnom: I think that's not quite true -- see my example. (Or maybe you and I are interpreting OP's "escape" thing differently.) – John Hughes Sep 07 '15 at 23:38
  • @user24142: Yes I went through the Wikipedia article before posting,... but it didn't tell me what I wanted to know (or at least I didn't understand it enough to feel that it was a strong enough answer). Basically I'm looking for confirmation that my understanding is correct (or not) that a 'gradient' doesn't tell you the path of steepest ascent after comparing all possible directions and that in fact there are indeed 'blind spots'). Or another way to look at it is that it's an approximation after only looking at the directions of the coordinate system. – Terry Sep 08 '15 at 05:42
  • Yes, maybe you need to measure using derivative filters of several scales. What looks like a minimum at a small scale may not be one in a larger perspective. – mathreadler Sep 08 '15 at 12:45

3 Answers3

3

The function $$ f(x, y) = [(x + y)(x - y)]^2 = (x^2 - y^2)^2 $$ has the property you've described: it's $U$-shaped when viewed in the $y = 0$ or $x = 0$ plane, but along the line $y = x$, it's horizontal, so there's a way to escape. It's also differentiable.

The real point is that "local min" implies "gradient is zero", but the other direction is not true at all (as $f(x, y) = x^2 - y^2 $ shows).

On the other hand, at places where the gradient is nonzero, it does tell you the direction of steepest descent...but only locally, and only to first order. If you stand on the slope of Bunker Hill in Boston, you can hardly expect the upward slope direction to point towards Mt. Everest, or even Mt. Washington.

John Hughes
  • 93,729
  • Thanks for this great example! Although I'm wondering whether it's possible for even a non-zero gradient to lie to you (locally and to the 1st order). Taking the bowl example, it seems to me that it might be possible to 'manipulate' the x and y cross sections in such a way that the resulting gradient might tell you to go in a different 'wrong' direction from the real direction of steepest slope (perhaps by for example having a 'mound' at the bottom where your point sits instead of the flat bottom of the bowl? – Terry Sep 11 '15 at 22:28
  • This function is horizontal along the line $y=-x$, too. http://www.wolframalpha.com/input/?i=z%3D%28x%5E2+-+y%5E2%29%5E2 – David K Oct 13 '15 at 00:01
  • @DavidK: Yeah after looking at it in Mathematica awhile back I realized that too,... – Terry Oct 14 '15 at 22:07
  • ...and I realized it when I built the function...but since I only needed to show one direction in which the function was constant and another in which it was concave up, I didn't mention it. :) – John Hughes Oct 15 '15 at 14:45
1

The gradient of a scalar function at a point $(x_0,y_0)$ describes the change in the value of a function as you step away from the point in the maximal direction. Let's see how.

Say you have a scalar function describing a surface z = T(x,y). Then the gradient is given by

$$\nabla T(x,y) = \left(\frac{d}{dx}\hat{x} + \frac{d}{dy}\hat{y}\right)T(x,y) = \frac{dT(x,y)}{dx}\hat{x} + \frac{dT(x,y)}{dy}\hat{y}$$

At a specified point $(x_0,y_0)$, we have

$$\nabla T(x_0,y_0) = \frac{dT(x_0,y_0)}{dx}\hat{x} + \frac{dT(x_0,y_0)}{dy}\hat{y}$$

How can we intuitively interpret this result? Well, it's a vector. It has two components, one giving a magnitude in the $x$ direction and another pointing in the $y$ direction. As a hiker using $(x,y)$ coordinates in the plane, you already like this. Could the gradient guide us out of the valley? Well, we need to know more. The thing is, we need to understand what the direction of gradient means.

Consider an arbitrary unit vector $\hat{v}$ and summon the definition of the dot product:

$$\hat{v}\cdot\nabla T = |\hat{v}||\nabla T|cos\theta = |\nabla T|cos\theta$$

If our arbitrary unit vector is parallel to the gradient, then $\theta = 0$ and the gradient is maximized.

$$\hat{v}\cdot\nabla T = |\nabla T|$$

So if we follow the gradient, we find the steepest incline or cough grad(i)e(nt). It tells us how quickly the walls of the metaphorical valley rise up in these two orthogonal directions, as we march in the maximal direction, and it does so by considering an infinitesimal change in either direction... the slightest nudge.

Now, if I elect to travel in a different direction , then I'm taking a directional derivative. Dotting this new direction to the gradient will tell me what sort of path I may encounter.

zahbaz
  • 10,441
0

The gradient tells you the path of steepest ascent/descent at the exact point where you are. The reason we are concerned about local minima vs. global minima is precisely that when you have a small "bump" or "dent" in a continuous multidimensional function plot, the gradient in the immediate neighborhood of the bump or dent will point toward the bump or dent and not toward a high mountain or deep valley that might exist elsewhere.

Imagine a round stone sitting high up on a hillside. The stone stays where it is because it is in a very shallow hole whose sides slope inward, so if you moved the stone a tiny bit in any direction it would just fall back to the bottom of the hole. But if you push the rock far enough in the right direction, you will push it out of the hole and it may roll all the way to the bottom of the hill.

At the very bottom (or top) of a local minimum (or maximum), the gradient is zero and does not tell you to go in any direction. You can also have a zero gradient that is neither a minimum nor a maximum: an inflection point or a saddle point.

In another answer, you have a function $f(x,y)=(x^2-y^2)^2$ which has actually a global minimum along the lines $y=x$ and $y=-x$. (The minimum is not unique, but it is global because there is no lower point anywhere on the plot of that function.) If you happen to be sitting at $(0,0)$, the gradient will be zero, giving you no clue which way to go. So try movements in "all" directions--or since you can't try all the infinitely many possible angles, some reasonable set of angles, but more than just the four directions given by "increase/decrease $x$" and "increase/decrease $y$".

If you don't always go in only the positive or negative $x$ or $y$ directions, and you happen to be a saddle point instead of actually at either a global or local minimum, for example, if your function were actually $g(x,y) = (x^2 - y^2)^2 - \frac12(x^4 + y^4)$ (see this function's three-dimensional plot) you would have a better chance of finding your way toward a minimum.

Note that for the function $g(x,y)$, the gradient at $(0,0)$ is zero even though the graph of the function drops off in four directions. (In four other directions it rises.) That's an example of a saddle point (though the usual examples drop off in just two directions).

Recall that even in two dimensions you can have a zero gradient (which in two dimensions is just a derivative) at a point that is not a minimum. One way of course is to be at a maximum, but you can also be at inflection point such as the point at $x=0$ in the graph of $y=x^3$. In three dimensions, the graph of $h(x,y) = -(x+y)^3$ has an "inflection" along the line $y=-x$ where the gradient is zero, but there clearly is neither a maximum nor minimum there.

The function $k(x,y) = (x-y)^2 - (x+y)^3$ (see its graph here) has a zero gradient at $(0,0)$, but slopes down everywhere else on the line $y=x$ as $x$ and $y$ increase.

It's even possible to have a "ledge" in a function where the gradient is zero over some region, but the function increases as you leave that region in some directions but decreases in others. There is a two-dimensional version of this, too.

So, just as in two dimensions, merely examining the gradient at one point does not tell you whether you're at a local minimum, nor does it always tell you which direction to go if you want to decrease the function. But you can still get information by looking at the gradients at multiple points. If you are at a local minimum, the gradients at all nearby points will point away from the bottom of the bowl (meaning you would go toward the bottom of the bowl to decrease the function from those points). If you are at a saddle point or some kind of inflection point, however, you will find some nearby gradients point away from that point and some point toward it. That's a clue that you are not at a minimum, and also a clue about which way to go in order to decrease the function value.

David K
  • 98,388
  • Thanks for your reply, I really appreciate it! Unlike John's example above where f(x,y)=(x^2−y^2)^2, my error function really only has one way out (I know this because I've been exploring it mathematically/visually in Mathematica for years actually, from all sorts of perspectives and at many resolutions), and it is very much a legitimate way out in the sense that the error really does drop as you exit the 'bowl'. So technically I'm not really even dealing with a local minima, and that's what irritates me to no end,... there should be no real reason why a gradient wouldn't work :) – Terry Oct 14 '15 at 22:08
  • I don't mind sitting in a legitimate local minima, then I can say well that's reasonable. But to have a legitimate way out and not be able to find it using what I consider to be reasonable tools for the job,... well that's another story :) As for the method of just trying out different directions,... I considered that option sometime back but it just seemed sort of,... incomplete, inelegant and unsatisfactory,... However given how difficult rotations in n-dimensions are,... perhaps it's worth a revisit :) – Terry Oct 14 '15 at 22:09
  • Basically, the issue is that the gradient is a very local measurement, and it's possible to have a local "pause" in the decrease of a function. You could have an answer that is a little more "complete" if you can describe the gradient at every point in a disc around a point. If you can't do that, trying many different points all around the given point is an alternative. There might be something you can do with higher derivatives, but the kind of minimization problems I deal with aren't even really susceptible to gradients so I have not given much thought to higher derivatives. – David K Oct 15 '15 at 14:20