Checking whether Hessian matrix of a function is positive semidefinite on a hypercube

Given parameters w_1, \ldots, w_n > 0 with \sum_{j=1}^n w_j = 1 (n\ge 2), define function

f(x_1, \ldots, x_{n-1})= \sum_{j=1}^{n} \frac{x_j}{1-x_j} \cdot \sum_{j=1}^n \frac{w_j}{1-w_j} - \sum_{j=1}^n \frac{x_j}{1-w_j} \cdot \sum_{j=1}^n \frac{w_j}{1-x_j}

with

x_n = 1-\sum_{j=1}^{n-1}x_j

for x_1, \dots, x_{n-1} \in (0,1).

For example, for n=3 the function is

f(x_1, x_2)= \left ( \frac{x_1}{1-x_1} + \frac{x_2}{1-x_2}+ \frac{1- x_1-x_2}{x_1+x_2}\right) \left ( \frac{w_1}{1-w_1} + \frac{w_2}{1-w_2}+ \frac{w_3}{1-w_3}\right)- \left ( \frac{w_1}{1-x_1} + \frac{w_2}{1-x_2}+ \frac{w_3}{x_1+x_2}\right) \left ( \frac{x_1}{1-w_1} + \frac{x_2}{1-w_2}+ \frac{1- x_1-x_2}{1-w_3}\right)

Working on a conjecture in this MO question, for n= 3, 4, 5, I want to numerically check whether the Hessian matrix of f(x_1, \ldots, x_{n-1}) is positive semi-definite over the hypercube (0,1)^{n-1} for any parameters w_1, \ldots, w_n > 0 with \sum_{j=1}^n w_j = 1.

I could manage the case n=3 using a desmos graph, which shows the answer is yes. Could you help me efficiently use Mathematica to handle the two remaining cases n=4,5?

I found a related question discussing how one can check whether a matrix is positive semi-definite by Mathematica.

Please provide your efforts in the form of the Wolfram Language code. This will make it easier for other members to help you. Check several methods available to include your code in the rules http://wolfr.am/READ-1ST

I haven’t made any progress using Mathematica to solve my problem yet. I could solve the problem for n=3 using a Desmos graph.

Unless I have made a mistake, there seem to be counterexamples:

In[13]:= 
f[n_] := Sum[x[j]/(1 - x[j]), {j, n}]*Sum[w[j]/(1 - w[j]), {j, n}] -
    Sum[x[j]/(1 - w[j]), {j, n}]*Sum[w[j]/(1 - x[j]), {j, n}] /.
   {x[n] :> 1 - Sum[x[j], {j, n - 1}],
    w[n] :> 1 - Sum[w[j], {j, n - 1}]};
hessianMatrix = D[f[3], {Array[x, 2], 2}];
sol = FindInstance[Det[hessianMatrix] < 0 &&
   0 < x[1] < 1 && 0 < x[2] < 1 && 0 < w[1] < 1 && 0 < w[2] < 1 &&
   w[2] == 1/2 && w[1] + w[2] < 1,
  {x[1], x[2], w[1], w[2]}, Reals]
Eigenvalues[hessianMatrix /. sol[[1]]] // N

Out[15]= {{x[1] -> 5/608, x[2] -> 15/1216, w[1] -> 7/608, w[2] -> 1/2}}

Out[16]= {465210., -0.271271}

Thank you Gianluca for your kind consideration! However, it is not consistent with what I see from my method at the point. In this link, I depicted the two diagonal elements and the determinant of the Hessian matrix. You may see that all the three quantities are highly positive at the point you obtained (see the intersection of the green and orange lines). The reason may be that x_3 is used instead of 1-x_1-x_2, or something else.

I think your plot of the determinant misses the behaviour near the origin. Just calculate the determinant at x=1/100, y=1/100, for example.

Thanks! It was very helpful. In fact, the determinant of the Hessian matrix may have sharp drops near some of the extreme points of the hypercube, which cannot be detected by checking the Desmos figure.