# Convexity / Concavity --> Formal Definition

How do I show that $f(x, y)=(x + y)^2$ is convex/concave using the formal definition of convexity/concavity?

Let $x=(x_1,x_2)$ and $y=(y_1,y_2)$. We will show that $$f(tx+(1-t)y)\le tf(x)+(1-t)f(y)$$ for each $t\in[0,1]$.
We have that $$(tx_1+(1-t)y_1+tx_2+(1-t)y_2)^2\le t(x_1+x_2)^2+(1-t)(y_1+y_2)^2,$$ $$-t(1-t)(x_1+x_2)^2+2t(1-t)(x_1+x_2)(y_1+y_2)-t(1-t)(y_1+y_2)^2\le0,$$ $$-t(1-t)((x_1+x_2)-(y_1+y_2))^2\le0.$$ Hence, the function $f$ is convex.
Use linearity of the mapping $(x,y)\mapsto x+y$ and convexity of $t\mapsto t^2$.