# An optimization problem involving the calculation of MatrixRank gets wrong

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}]


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

• 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]. – ilian Nov 11 '16 at 0:01
• For your simple example you can do: Solve[Det[{{a11, 2}, {2, 4}}] == 0, a11] – bill s Nov 11 '16 at 0:26

Select[Table[

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