# Checking whether a multivariable function is convex

I have a simple question. I have a multi-variable function that I'm supposed to check whether convex or not. I know the definition for convexity as follows:

The function $f(x)$ is convex if:

$$f(\lambda x_1 + (1 - \lambda x_2)) \leq \lambda f(x_1) + (1 - \lambda )f(x_2)$$

But this is for the single variable case. How do I generalize it for multi-variable case? The author of this question seems to be showing that the function $f(x,y)$ is convex if,

$$f(\lambda x_1 + (1 - \lambda x_2),\lambda y_1 + (1 - \lambda y_2) ) \leq \lambda f(x_1,y_1) + (1 - \lambda )f(x_2,y_2)$$

But it hasn't been explicitly written anywhere. Is this correct?

EDIT: The two functions should be corrected as: $$f(\lambda x_1 + (1 - \lambda) x_2) \leq \lambda f(x_1) + (1 - \lambda )f(x_2)$$ $$f(\lambda x_1 + (1 - \lambda) x_2,\lambda y_1 + (1 - \lambda) y_2 ) \leq \lambda f(x_1,y_1) + (1 - \lambda )f(x_2,y_2)$$

• Yes, it is correct, but you need to fix parenthesis there, it is not $(1-\lambda x)$ but $(1-\lambda)x$. $\lambda$ ranges between zero and one. Also it only makes sense if the domain itself is convex – la flaca Feb 20 '17 at 16:17
• @laflaca thanks for pointing the error out. I corrected it. Please explain what you mean by domain being convex? I haven't heard of this before. many thanks. – PPGoodMan Feb 20 '17 at 16:22

A set $X \subset \mathbb{R}^n$ is said to be convex if for any $\lambda \in [0,1]$ and any $x,y \in X$ the following holds: $$\lambda x+(1-\lambda)y \in X$$ This just means that if you pick any two points of the set, the segment joining them lies entirely in the set, and you need that hypothesis because otherwise you could not evaluate $f(\lambda x+(1-\lambda)y)$ for any $\lambda \in [0,1]$