# Check the convexity of a function

How can we check the convexity of a set ?

$S = \{(x,y) \in \mathbb{R}: x-y²\le y \le x+y²\}$

-

A set is $S \subseteq \mathbb R^2$ is convex iff $(x_1, y_1), (x_2, y_2) \in S$, $\lambda \in [0,1]$ imply that $\bigl((1-\lambda)x_1 + \lambda x_2, (1-\lambda)y_1 + \lambda y_2\bigr) \in S$. Check this for your set $S$, that is, check whether $$x_i - y_i^2 \le y_i \le x_i + y_i^2, \qquad i \in \{1,2\}$$ imply $$(1-\lambda)x_1 + \lambda x_2 - \bigl((1-\lambda)y_1 + \lambda y_2\bigr)^2 \le (1-\lambda)y_1 + \lambda y_2 \le (1-\lambda)x_1 + \lambda x_2 + \bigl((1-\lambda)y_1 + \lambda y_2\bigr)^2$$ for each $\lambda \in [0,1]$.