Proper way to check convexity or concavity for a function I am working with a function I would like to check if it is convex or concave. The function is the next:
$$f(x_1,x_2)= \max\{x_1^6,e^{x_1+3x_2^2},3x_1^2-x_1x_2+x_2^4-\log(x_2+2)\}$$
With $x_2>-2$
I knowusing derivatives I can check for one function but in this case I have a set of functions. How can I check convexity or concavity of this function? 
Many thanks!!!
 A: Most of the job can be done without using derivatives. Seeing squares and fourth powers suggests that perhaps we have a convex function. Indeed:


*

*$x_1^6$ is clearly convex;

*$\exp(x_1+3x_2^2)$ is a composition of a convex function $\exp(\cdot)$ and a sum of convex functions, so that it is also convex;

*Checking the Hessian matrix of the third function shows that it also is convex;

*A maximum of convex functions is a convex function.


Thus, $f$ is convex.
A: If you want to look at the concavity/convexity of $f$ then you are probably going to have to find the ranges of the argument variables over which each of the sub-functions is the maximising one.  This will allow you to write $f$ as a piece-wise continuous function and you can then find its second derivative via ordinary calculus techniques.  To do this, define the sub-functions:
$$\begin{equation} \begin{aligned}
f_1(x_1,x_2) &= x_1^6, \\[6pt]
f_2(x_1,x_2) &= e^{x_1+3x_2^2}, \\[6pt]
f_3(x_1,x_2) &= 3x_1^2-x_1x_2+x_2^4-\log(x_2+2),
\end{aligned} \end{equation}$$
and define the choice-function:
$$M(x_1,x_2) = \begin{cases}
1 & & \text{for } f_1(x_1,x_2) > \max(f_2(x_1,x_2), f_3(x_1,x_2)), \\[6pt]
2 & & \text{for } f_2(x_1,x_2) > \max(f_1(x_1,x_2), f_3(x_1,x_2)), \\[6pt]
3 & & \text{otherwise}. \\[6pt]
\end{cases}$$
Your function can now be written as:
$$f(x_1,x_2) = \sum_{m=1}^3 f_{m}(x_1,x_2) \cdot \mathbb{I}(M(x_1,x_2) = m).$$
Hence, at all points other than the boundaries of the changes of $M$, the second-derivative (Hessian matrix) of the function is:
$$\nabla^2 f(x_1,x_2) = \sum_{m=1}^3 \nabla^2 f_{m}(x_1,x_2) \cdot \mathbb{I}(M(x_1,x_2) = m).$$
Each Hessian matrix for the sub-functions can easily be obtained from differentiation of those functions.  This now gives you the curvature of your function, expressed in terms of the curvatures of the underlying functions.  To implement this to find the curvature at a particular point, you simply have to find the boundaries of the regions demarcating different values of $M$.

Finding the boundaries: I won't do this fully, but I'll get you started.  Comparing just the first two of these functions you have:
$$f_1(x_1,x_2) > f_2(x_1,x_2) \quad \quad \iff \quad \quad |x_2| < \sqrt{\max(0, 2 \ln|x_1| - \tfrac{1}{3} x_1}).$$
Hence, you have:
$$\max(f_1(x_1,x_2), f_2(x_1,x_2)) = \begin{cases}
x_1^6 & & \text{for } |x_2| < \sqrt{\max(0, 2 \ln|x_1| - \tfrac{1}{3} x_1}), \\[6pt]
e^{x_1+3x_2^2} & & \text{for } |x_2| \geqslant \sqrt{\max(0, 2 \ln|x_1| - \tfrac{1}{3} x_1}). \\[6pt]
\end{cases}$$
If you keep going you can find the boundaries between this function and $f_3$ and you will eventually be able to write conditions for the boundaries of $M$.
