# How FunctionConvexity is implemented in Wolfram Mathematica?

I am wondering how FunctionConvexity was implemented in Wolfram Mathematica.

I am trying to prove the convexity of the function $$A(v)$$:

$$A(v) = -\dfrac{k-1}{\displaystyle\sum_{i=1}^k \frac{1}{v_i}},$$

where $$k\geq 2$$ is some integer constant and $$1 \leq v_i \leq k-1$$.

The function is easily passed in Mathematica as convex,meaning that it somehow passes the following condition:

$$f(t x +(1-t)y)\leq t f(x)+(1-t)f(y) ,$$

where $$0\leq t\leq 1.$$

However, I am having trouble verifying it by hand.

A similar question is also up on math.stackexchange.

Here is my guess (Many years of teaching stand behind.). Indeed,

FunctionConvexity[{-(3 - 1)/Sum[1/v[j], {j, 1, 3}],
v[1] >= 1 && v[2] >= 1 && v[3] >= 1&& v[1] <= 2 && v[2] <= 2 && v[3] <= 2}, {v[1], v[2], v[3]}]


results in 1 which means the function is convex on the cube. I think the command does not check the definition of convexity here, but uses the nonnegativity of its Laplacian by

Minimize[{Laplacian[-(3 - 1)/Sum[1/v[j], {j, 1, 3}], {v[1], v[2],
v[3]}], {v[1], v[2], v[3]} >= 1&& {v[1], v[2], v[3]} <=2}, {v[1], v[2], v[3]}]


{4/9, {v[1] -> 2, v[2] -> 2, v[3] -> 2}}

The same in other dimensions.

Addition. I think the above is true, however the general approach is more complicated (see Wiki for info):

m = ResourceFunction["HessianMatrix"][-(3 - 1)/
Sum[1/v[j], {j, 1, 3}], {v[1], v[2], v[3]}];
Minimize[{{a, b, c} . m.{a, b, c}, {v[1], v[2], v[3]} >= 1 && {v[1], v[2], v[3]} <=
2}, {a, b, c}]


{Piecewise[{{0, Inequality[1, LessEqual, v[2], LessEqual, 2] && Inequality[1, LessEqual, v[1], LessEqual, 2] && Inequality[1, LessEqual, v[3], LessEqual, 2]}}, Infinity], {a -> Piecewise[{{0, Inequality[1, LessEqual, v[2], LessEqual, 2] && Inequality[1, LessEqual, v[1], LessEqual, 2] && Inequality[1, LessEqual, v[3], LessEqual, 2]}}, Indeterminate], b -> Piecewise[{{0, Inequality[1, LessEqual, v[2], LessEqual, 2] && Inequality[1, LessEqual, v[1], LessEqual, 2] && Inequality[1, LessEqual, v[3], LessEqual, 2]}}, Indeterminate], c -> Piecewise[{{0, Inequality[1, LessEqual, v[2], LessEqual, 2] && Inequality[1, LessEqual, v[1], LessEqual, 2] && Inequality[1, LessEqual, v[3], LessEqual, 2]}}, Indeterminate]}}

and this means the convexity.

Edit. My guess concerning the Laplacian is not true as $$x^2-y^2$$ demonstrates. I missed subharmonic and convex functions: explanation, but not justification. The gradient or the Hessian matrix can be used to this end.

• Thank you for your answer. I am not familiar with the concept of Laplacian, I am reading about it at this very moment. Could be a valid approach for analytical proof? Also, please note that there is a similar question where we are looking for analytical proof on math.stackexchange.
– Oleh
Commented Dec 18, 2021 at 19:24
• I familiarised myself with a concept. However, I guess that the non-negativity of Laplacian implies that the function is element-wise convex. I am not sure that we can conclude that the function is convex over its domain using this method. Please, correct me if I am wrong.
– Oleh
Commented Dec 18, 2021 at 19:55
• @Oleh: You are right. The non-negativity of the Laplacian does not imply the convexity. A simple example is $x^2-y^2$. Commented Dec 18, 2021 at 21:08