7
$\begingroup$

I'm currently learning about gradients, and I thought khanacademy could help me acquiring some intuition. The actual computation is clear to me, however I'm having trouble understand the intuition.

This is the video I'm talking about, and the part I have a part with is 6:11. He says the gradient vector shows the direction you have to travel in the x,y-plane in order to get a maximum slope in the z-direction.

This sounds like gibberish to me. How do you have to 'travel' it? Why do you get a maximum slope? I just have no clue.

$\endgroup$
  • $\begingroup$ video link is dead $\endgroup$ – baxx Aug 28 '17 at 9:52
14
$\begingroup$

At each point in the $xy$-plane the function you have gives you a value. Normally this value is visualized as altitude, that is, a $z$-value, but it can just as easily be anything else. Examples that come to mind are grayscale tones (if the $xy$-plane is a black-and-white picture), density (if the $xy$-plane is a plate made from varying materials), or, maybe the most important one, potential in some force field (often gravitational or electric fields). Of course, in practice, these examples rarely gives you a function that is nice to work with, but in textbook examples it usually works out.

Now, imagine that you are walking around in the $xy$-plane, sniffing or measuring that value, whatever it represents. At some point in time you're standing at the point $(5, 3)$, and the gradient of your function at that point is $(-1, 2)$. That means if you turn around so that you're facing the direction $(-1, 2)$ at the point $(5, 3)$ (that is, you're looking directly at the point $(4, 5)$), then that is the direction where (at least for the first gazillionths of a meter you travel) your value will increase the fastest, out of all the directions you can pick.

I can do even better. I can tell you how much it will grow for that gazillionths of a meter. Since the amplitude of the gradient is $\sqrt 5$, your function value will grow approximately $\dfrac{\sqrt{5}}{\text{gazillion}}$ of whatever unit it's measured in. (Approximately because even over that short distance, the gradient might change a little bit. Studying how these changes affect the end result is what partial differential equations, and especially using computers to solve them, are all about. But that's another story entirely)


Traveling around in the $xy$-plane is something we mathematicians do all the time. When you finally get some intuition, it's much easier (and more fun) to play around with that intuition if you imagine yourself being at a point in the plane and walk around, rather than just imagining a point moving around.


Also, as for why the gradient gives you a maximal slope, say again that you have a gradient of $(-1, 2)$ at the point $(5, 3)$. That means if you go from that point, and move directly parallel to the $x$-axis (for a very short distance), in the positive direction (towards $(6, 3)$), then your function value will decrease at the speed of $1$ per meter travelled. This is, after all, how the $-1$ in $(-1, 2)$ came to be in the first place. So if you want the value to increase, you're better off moving in the negative $x$-direction.

Likewise, if you move in the positive $y$-direction (towards $(5, 4)$), your function value will increase by $2$ per meter travelled. So you can see that the function grows faster in the positive $y$-direction than in the negative $x$-direction. However, the direction that will give you the fastest growth is a balanced mix of the two. Hence both the directions $(-1, 0)$ and $(0, 1)$ will give you growth, but the fastest growth is the direction $(-1, 2)$. Twice as much in the $y$-direction because the function grows twice as fast that way as in the $x$-direction.

$\endgroup$
  • 2
    $\begingroup$ Hello! You said "However, the direction that will give you the fastest growth is a balanced mix of the two. " near the end of the solution. I do agree with this point. But do you mind provide me with some more intuitive explanation on why that is true? Because intuitive tells me that shouldn't we just go for y direction since it increases the most? And it seems like we should not trade of our distance in y for x because y is faster growth. $\endgroup$ – Kun Dec 16 '15 at 3:27
  • 2
    $\begingroup$ @Kun The intuitive reasoning lies in the Pythagorean theorem. It says that while the $x$-step is small and the $y$-step is large, trading in a little $y$ gives us a lot of $x$. $\endgroup$ – Arthur Dec 16 '15 at 9:38
5
$\begingroup$

Here's another viewpoint. From single variable calculus, we know that if a function $f$ is differentiable at $x$, then \begin{equation} f(x + \Delta x) \approx f(x) + f'(x) \Delta x \end{equation} and the approximation is good when $\Delta x$ is small.

The situation in multivariable calculus is analogous. Suppose $f:\mathbb R^2 \to \mathbb R$ is differentiable at a point $x = (x_1,x_2) \in \mathbb R^2$. Then \begin{equation} f(x+\Delta x) \approx f(x) + \langle \nabla f(x), \Delta x \rangle \end{equation} and the approximation is good when the vector $\Delta x$ is small.

We could ask, how should we pick $\Delta x$ so that $f(x + \Delta x)$ is as large as possible? We certainly don't want $\Delta x$ to be pointing in the opposite direction as $\nabla f(x)$, because then $\langle \nabla f(x), \Delta x \rangle$ will be negative -- the value of $f$ will decrease! Nor do we want $\Delta x$ to be orthogonal to $\nabla f(x)$, because then $\langle \nabla f(x), \Delta x \rangle = 0$, which doesn't seem to help $f$ get any larger. We want to pick $\Delta x$ to be in the same direction as $\nabla f(x)$.

$\endgroup$
1
$\begingroup$

This graph (click here) tries to give some intuition

1) Vector A is the gradient

2) z=f(x,y) is not shown in the graph

3) Don't miss the point that both angles (theta) are the same!

4) Point represented by the end of vector B is the result of moving in the x and y direction from (1,2) but maintaining the proportion given by the gradient vector. So, if A gives a 2/1 relation –y against x–, then you can remove two units of x (dz/dx=1) and add one unit of y (dz/dy=2), and z will remain the same.

5) The magnitude of vector B is higher that the magnitude of vector A. So, if you take a vector in the B direction but with the magnitude of vector A –that is, smaller than B–, then the positive impact in z due to the variation of y will be lower than the negative impact in z due to the variation of x (the angle formed by the variation of both x and y will be less than theta).

6) Finally, either A' or A'' share the same magnitude than A, but in both cases, the trade off between x and y causes z to go down.

$\endgroup$
  • $\begingroup$ While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review $\endgroup$ – Armando j18eos Jul 27 '18 at 10:02
  • $\begingroup$ I am just writing the text! Please give enough time to write down all the letters I need more reputation to put images; until then, StackExhange only allows me to insert a link :) $\endgroup$ – Pablo J. Vázquez Jul 27 '18 at 10:20
0
$\begingroup$

Suppose we have a scalar field (z) in a (x,y) plane –e.g. the temperature of the floor of your room. Then, the gradient is defined by two numbers that can be combined in a single vector (G): (dz/dx, dz/dy). The first number tells how much you will grow in z if you take a little step in the x-direction (suppose dz/dx=1); and the second, how much if we move in the y-direction (suppose dz/dy=2). Then, you have a ratio. For example, 1/2 (variation of z due to variation of x against variation of z due to variation of y). Important now is to realize that any change we made in both x and y, trying to maintain z constant, has to obey the inverse relation; that is, the variation in x has to double the variation in y, because the impact on z of the former is half the impact on z of the latter.

Now, set an origin point and two perpendicular axis on the floor and plot the gradient vector. If you rotate that vector 360º you will cover all the posible movements in the (x,y) plane with the same magnitude (square root of 5). We will need this later.

Define also angle theta as the angle –viewed from (1,2)– formed by the gradient vector and the line x=1. Make sure you understand that we can find the same angle in another place. Go again to point (1,2) and plot from there to the left –until you reach the y-axis– two lines: one perpendicular to the gradient (line P), and the other parallel to the x-axis. As you can check, they also form an angle theta.

Plot also a vector (B) that goes from the origin to any point (C) in the P line.

Finally, the important question: how does z change as we move from (1,2) to C? The answer: no change at all. We have follow the proportion that angle theta dictates: any variation in x will be followed by half of that variation in y. Remember: we are obeying the inverse relation stated by the gradient (impact in z from y doubles impact in z from x), so nothing changes.

But vector B is larger than the gradient vector G... Let's get back to 360º rotation of vector G and choose a vector with the same length than G but pointing in the direction of vector B. This new vector (B') will cross the parallel line to x-axis that we draw before, but will not touch the P line. What does this mean? If we move from point (1,2) to the end of vector B' we will have a higher decrease in x and a smaller increase in y compared to the case where we moved from (1,2) to C. In other words, z will drop.

That's all: if you do not respect the gradient when you move, you will not achieve the highest value in z.

Hope it helps!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.