# Proving Convexity of Multivariate Function using Conditional Univariate Convexity

I have a function $f:\mathbb{R}^p\rightarrow\mathbb{R}$. For the purposes of illustration let's say that $p=2$. I want to prove that $f$ is convex. Suppose I can show that both

$f(\alpha x_1 + (1-\alpha)x_2,y)\leq\alpha f(x_1,y)+(1-\alpha)f(x_2,y) \quad \forall y \in \mathbb{R}$

and

$f(x,\alpha y_1 + (1-\alpha)y_2)\leq\alpha f(x,y_1)+(1-\alpha)f(x,y_2) \quad \forall x \in \mathbb{R}$

is true, i.e. I can show that the resulting univariate functions obtained by holding all but one of the arguments fixed is convex.

Is this sufficient to prove that $f$ is convex in $x$ and $y$? Namely

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

I am looking for a proof or counter example.

Merely applying each conditional inequality sequentially gives $f(\alpha x_1 + (1-\alpha)x_2,\alpha y_1 + (1-\alpha)y_2)\leq \alpha^2 f(x_1,y_1) + \alpha (1-\alpha) f(x_1,y_2) + \alpha (1-\alpha) f(x_2,y_1) + (1-\alpha)^2 f(x_2,y_2)$

If $f$ is a convex function, this implies the first two univariate inequalities of this post. This post is asking if the reverse direction holds.

NO, Take $f(x,y) =xy$ then $f$ is linear in each arguments, but not convex. Look at its hessian.