New answers tagged

3

An alternative is to take the Cholesky decomposition of the matrix, and use the squares of the diagonal elements (which should be nonnegative) as the constraints: g = CholeskyDecomposition[{{1, 0}, {0, a}}]; NMinimize[{a, And @@ Thread[Diagonal[g]^2 >= 0]}, a] {0., {a -> 0.}}


4

One idea would be to use an explicit penalty function. (I couldn't get it to work with the "PenaltyFunction" option.) npsQ[m_?(MatrixQ[#, NumericQ] &)] := Boole@Not@PositiveSemidefiniteMatrixQ[m]; mat = {{1, 0}, {0, a}}; NMinimize[a (1 - 2 npsQ[mat]), a] (* {1.8919*10^-9, {a -> -1.8919*10^-9}} *) Plot[{a (1 - 2 npsQ[mat])}, {a, -1, 2}] ...


1

As Oleksandr pointed out as well, you may not be able to use your constraint as stated. Your alternative expressed as an inequality should actually be quite function, if you can calculate the eigenvalues of your target matrix symbolically in a reasonable time. You first obtain a symbolic expression for your eigenvalues, by running Eigenvalues once only, and ...



Top 50 recent answers are included