I was trying to solve an optimization problem involving rank of a matrix and experimenting with a very simple one. A 2x2 matrix which contains only one parameter a11 is {{a11,2},{2,4}} and I want to minimize the rank of this matrix. Obviously, the matrix can have a minimum rank of 1 when a11 equals 1. But when I use the following commands,

answ = NMinimize[{MatrixRank[{{a11, 2}, {2, 4}}]}, {a11}]

It gives the answer

{2., {a11 -> 0}}

which indicates a rank of 2 with a11=0. I do not quite understand why this is the case. Is it the NMinimize function has difficulties handing the MatrixRank computation? Any comment is welcomed.

  • 1
    $\begingroup$ The arguments of NMinimize are being evaluated first, and with symbolic a11, MatrixRank[{{a11, 2}, {2, 4}}] immediately evaluates to the constant 2, so you are effectively doing NMinimize[2, a11]. $\endgroup$
    – ilian
    Nov 11, 2016 at 0:01
  • $\begingroup$ For your simple example you can do: Solve[Det[{{a11, 2}, {2, 4}}] == 0, a11] $\endgroup$
    – bill s
    Nov 11, 2016 at 0:26

1 Answer 1


One way to determine matrix rank is to count the number of zero eigenvalues. For the simple case:

   Solve[Eigenvalues[{{a, 2}, {2, 4}}][[i]] == 0, a], {i, 2}], Length[#] > 0 &]

This checks to find values of a that give zero eigenvalues and selects all those with non-empty solutions.


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.