# Why must the gradient vector always be directed in an increasing direction?

I don't understand why it is not possible for some function, say for example $f(x,y)$, to not have some point where the partial derivatives combine to a gradient vector that points in a decreasing direction. Why must it always be negated to get a decreasing direction vector?

-

Intuitively, $f(x + \Delta x) \approx f(x) + \langle \nabla f(x), \Delta x \rangle$. (I'm using the convention that $\nabla f(x)$ is a column vector.) So if $\Delta x = \epsilon \nabla f(x)$ (here $\epsilon > 0$ is tiny), then \begin{align*} f(x + \Delta x) & \approx f(x) + \epsilon \langle \nabla f(x), \nabla f(x) \rangle \\ &= f(x) + \epsilon \| \nabla f(x) \|^2 \\ &\geq f(x). \end{align*}

So when we move a bit in the direction of $\nabla f(x)$, the value of $f$ increases.

-

I prefer to explain that is slightly different way:

Actually we define gradient to be always pointing to to the maximum increasing direction! take look at the following:

Consider a function $f(x,y)$, then it's full derivative is:

$df(x,y)=\frac{\partial f}{\partial x}dx+\frac{\partial f}{\partial y}dy=\left(\frac{\partial f}{\partial x},\frac{\partial f}{\partial y}\right)\left(dx,dy\right)=\left(\frac{\partial f}{\partial x},\frac{\partial f}{\partial y}\right)\vec{dr}=\left\Vert \left(\frac{\partial f}{\partial x},\frac{\partial f}{\partial y}\right)\right\Vert \left\Vert \vec{dr}\right\Vert \cos\alpha$

so if we consider for simplicity that $\left\Vert \vec{dr}\right\Vert =1$ finaly we get that:

$df(x,y)=\left\Vert \left(\frac{\partial f}{\partial x},\frac{\partial f}{\partial y}\right)\right\Vert \cos\alpha$

So because cosine function is always less or equal to one , we see that the first term is the maximum possible value for our function increase (because that correspond to $\alpha=0$ ) thus if we define this first term as the length of some vector and we name it gradient, then this vector will point out to the direction of maximum possible increase of our function $f(x,y)$.

-
Can you please explain this notation on the right ? ∂f∂xdx+∂f∂ydy=(∂f∂x,∂f∂y)(dx,dy) –  chris white Oct 27 '12 at 23:30
I just rewrote the left hand side as a scalar product of two vectors $\overrightarrow{a}\overrightarrow{b}=(a_{x},a_{y})(b_{x},b_{y})=a_{x}b_{x}+a_{y‌​}b_{y}$ –  TMS Oct 28 '12 at 10:14

It's not obvious:

Consider the function $$f(x,y):=\cases{0&\bigl((x,y)=(0,0)\bigr),\cr x+y-{4|xy|^{4/3}\over x^2+y^2}&(else) .\cr}$$ Then $f$ is continuous at $(0,0)$ and $\nabla f(0,0)=(1,1)$, but $$f(t,t)-f(0,0)=2t-{4|t|^{8/3}\over 2t^2}=2|t|^{2/3}\bigl(|t|^{1/3}{\rm sgn(t)}-1\bigr)<0\qquad(0<|t|<1)\ .$$ This shows that $f$ is actually decreasing in the direction of the gradient.

Now the considered $f$ is not differentiable at $(0,0)$, and the gradient defined via partial derivatives exists only by coincidence. For any $f$ which is actually differentiable at $(0,0)$ one has $$f(x,y)-f(0,0)=\nabla f(0,0)\cdot (x,y)+o(r)\qquad(r:=\sqrt{x^2+y^2}\to0)\ .$$ Now, if $\nabla f(0,0)=(a,b)\ne(0,0)$ and you choose $(x,y):=(ta,tb)$ with $t>0$ then $$f(ta,tb)-f(0,0)=t(a^2+b^2)+o(t)=t (a^2+b^2)(1+o(1))\qquad(t\to0)\ ;$$ and therefore $f(ta,tb)-f(0,0)$ is $>0$ for sufficiently small $t>0$.

-

Here's another way to look at it: Define $g_v(t) = f(tv)$. Then $g'_v(0)$ represents the rate of increase of $f$ as we walk in the direction of $v$ from $0$. But we can use the chain rule to compute that $g'_v(0) = v \cdot \nabla f(0)$. Looking at the expression $v \cdot \nabla f(0)$, we see that among all unit vectors $v$, the maximum occurs when $v$ points in the same direction as $\nabla f(0)$. We also see that it's at the minimum when it points in the opposite direction. The key to all this is that $f$ be differentiable.

-