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!!!

  • 4
    $\begingroup$ Actually, you have only one function: the max of three different functions. $\endgroup$
    – Cliff AB
    Dec 6, 2018 at 20:14
  • 1
    $\begingroup$ Not sure if this is on topic here. Might be better on maths.se $\endgroup$ Dec 6, 2018 at 22:01

2 Answers 2


Most of the job can be done without using derivatives. Seeing squares and fourth powers suggests that perhaps we have a convex function. Indeed:

  1. $x_1^6$ is clearly convex;
  2. $\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;
  3. Checking the Hessian matrix of the third function shows that it also is convex;
  4. A maximum of convex functions is a convex function.

Thus, $f$ is convex.


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$.

  • 1
    $\begingroup$ The problem with this approach is that convexity can fail merely by failing at a single boundary point. For instance, the function $x\to x^2+\mathbb{I}(x\ge 0)$ is locally convex almost everywhere in your sense of having a positive-definite Hessian, but nevertheless it's not convex due to that jump at $0.$ "Simply have to find the boundaries" is not an easy problem, either! $\endgroup$
    – whuber
    Dec 6, 2018 at 23:20
  • $\begingroup$ Yes, that's true. I suppose I was just looking at convexity at a single point or over a subregion (i.e., locally). Even with this approach you could falsify concavity/convexity by finding a point that counters it. $\endgroup$
    – Ben
    Dec 6, 2018 at 23:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.