# Prove a function is non convex

I have a simple function dependent on two variables $x_1$ and $x_2$:

$$f(x) = \ln\left(\frac{x_1}{x_2}\right)$$

where $x_1, x_2 > 0$ (strictly positive).

I know this function is non convex as, given $0 < \lambda < 1$, I can easily find a numerical example with points $a,\, b\, (a < b)$ that violates:

$$f((1-\lambda) a + \lambda b) \leq (1-\lambda) f(a) + \lambda f(b)$$

Also, since the function is an equality and it is not linear it cannot be convex.

However, I am looking to prove analytically that the function above is nonconvex, how could I do that?

Thank you very much.

• Just a correction, this sentence: Also, since the function is an equality and it is not linear it cannot be convex. should be understood as "the feasible region defined by this equality is not convex" – Chicoscience Sep 20 '13 at 16:58
• The function is defined on a subset of $\mathbb R^2$ and the assertion $a\lt b$ means nothing for $a$ and $b$ in $\mathbb R^2$. Please explain what you mean. – Did Sep 20 '13 at 17:03
• It was a mistake, we can forget $a < b$ – Chicoscience Sep 20 '13 at 17:12

## 2 Answers

Well, calculating the Hessian matrix of your function yields:

$$H= \begin{pmatrix} \frac{-1}{x_1^2} & 0\\ 0&\frac{1}{x_2^2} \end{pmatrix}$$ So the function is not convex, since H is clearly not positive (semi-)definite.

• I wish I could set two answers as right, thanks – Chicoscience Sep 20 '13 at 17:29
• @Chicoscience you're welcome – ftfish Sep 20 '13 at 17:32

Almost no function $f:(x_1,x_2)\mapsto g(x_1)-g(x_2)$ is convex.

If $f$ is convex, the functions $t\mapsto f(t,x_2)$ and $t\mapsto f(x_1,t)$ are convex, for every $x_1$ and $x_2$, hence the functions $g$ and $-g$ are convex.

This is only possible if $g$ is affine hence $f(x_1,x_2)=a\cdot(x_1-x_2)$ for some parameter $a$.