I'm using CVXPY. Given a $2\times2$ matrix $A$, is it possible to add a singularity constraint?

Anything equivalent to:

  • $|A| = 0$: The determinant is $0$
  • $\operatorname{rank}(A) \leq 1$
  • Smallest eigenvalue is $0$
  • etc...
  • 1
    $\begingroup$ X-posted. I would expect someone with some 15K rep points on SO to know the etiquette. $\endgroup$ Commented Mar 26, 2021 at 12:43
  • $\begingroup$ @RodrigodeAzevedo Yes, I'm aware - it's just that this site is a better fit but still in Beta so I wasn't sure about the right place to put it... I should have at least put a cross-link. Sorry. $\endgroup$
    – Adi Shavit
    Commented Mar 26, 2021 at 12:45
  • 1
    $\begingroup$ Try to use the nuclear norm instead of the rank. It is convex, at least. $\endgroup$ Commented Mar 26, 2021 at 13:50
  • $\begingroup$ With proper scaling this does seem to do the trick when I put it in the objective and minimize it. It does not let me create a constraint with it though. $\endgroup$
    – Adi Shavit
    Commented Mar 26, 2021 at 14:48
  • 1
    $\begingroup$ I don't have the big picture. If you edited your question and showed all your work and made an effort to present it clearly, it would be easier for everyone. $\endgroup$ Commented Mar 26, 2021 at 15:15

1 Answer 1


No, it is an intrinsically non-convex constraint. Just take a diagonal matrix, and the feasible set would be the coordinate axes, i.e. nonconvex and highly ill-conditioned as the feasible set has measure 0.

  • $\begingroup$ I have an upper bound and a lower for all the matrix values. Does that help? $\endgroup$
    – Adi Shavit
    Commented Mar 26, 2021 at 11:05
  • $\begingroup$ No, you're still looking at the coordinate axes in the special case, but now constrained to a box. In general for a 2x2 matrix you have a quadratic equality $a_1 a_4-a_2 a_3 = 0$ $\endgroup$ Commented Mar 26, 2021 at 11:09
  • $\begingroup$ Yes. Ofc. But that’s non affine and CVXPY won’t let me add that expression. It’s non DCP. $\endgroup$
    – Adi Shavit
    Commented Mar 26, 2021 at 11:11
  • 4
    $\begingroup$ Yes, that is precisely what this answer says. It is a non-convex constraint. $\endgroup$ Commented Mar 26, 2021 at 11:21

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.