# function is convex if and only if its derivative is monotonically increasing for multivariate functions

I know the theorem which says If the differential function is (strictly) convex, then its derivative (strictly) monotonically increasing. and I know how to prove it for univariate function. But is it true for multi variable functions too? So for example if I have a function y=f(x,y) can I say if f is convex then each component of the gradient which is $\frac{\partial f(x,y)}{\partial y}$ and $\frac{\partial f(x,y)}{\partial x}$ are monotonically increasing and if yes how is the proof?

Thank you!

If $f(x,y)$ is a convex function of $2$ variables, its restrictions to lines $x = constant$ and $y = constant$ are convex, and so $\partial f/\partial x$ is increasing as a function of $x$ and $\partial f/\partial y$ is increasing as a function of $y$. However, $\partial f/\partial x$ need not be increasing as a function of $y$: for example, try $f(x,y) = (x-y)^2$ where $\partial f/\partial x = 2 (x - y)$ is decreasing as a function of $y$.

On the other hand, even if $\partial f/\partial x$ and $\partial f/\partial y$ are strictly increasing as functions of both $x$ and $y$, it doesn't imply the function is convex. For example, $f(x,y) = x^2 + 3 x y + y^2$ has this property, but is not convex: $f(-1,1) = f(1,-1) = -1$ but $f(0,0) = 0$.

• Thank you! that was very helpful – AFDOONE Jul 1 '17 at 20:46

It is a necessary, but not sufficient condition. The surface may be convex along $x$-axis and $y$-axis ($z_x$ and $z_y$ are increasing), however along $y=x$ and $y=-x$ the surface may not be convex (or may have relatively different curvature). For example, imagine the bottom surface of the plastic bottle of Coke (or any othe drink). The sufficient condition of convexity of $z(x,y)$ is: $$z_{xx}>0, z_{xx}z_{yy}-z_{xy}^2>0.$$ For example:

$z=x^2+3xy+y^2$ is not convex, but $z=x^2+xy+y^2$ is convex.

• Interesting, thank you! – AFDOONE Jul 1 '17 at 20:47

The multi-dimensional equivalent of the statement that a function is convex if and only if it has nondecreasing derivative is the following:

A differentiable function $f:\mathbb{R}^n \subseteq U \mapsto \mathbb{R}$ is convex if and only if for every $x,y \in U$, $(x-y) \cdot (\nabla f(x)-\nabla f(y)) \geq 0$.

It becomes clear why this is analogous when we look at what this means if we look at the line joining $x$ and $y$: defining $g(t)= f((1-t)x+ty)$, the chain rule gives $$g'(t) = (y-x) \cdot \nabla f((1-t)x+ty).$$ $g$ is then convex if and only if this function is nondecreasing, so in particular $g'(0) \leq g'(1)$. But this is just $$0 \leq g'(1)-g'(0) = (y-x) \cdot (\nabla f(y)-\nabla f(x)),$$ which is the same as the condition quoted above.

In particular, this idea shows that $f$ has to be convex on any line, not just those parallel to the axes.