Which Solution Does `\` Return?

I saw this insightful discussion on Slack (Made some editing for clarity):

@baggepinnen :

The \ (Operator) should produce the minimum norm solution if many exist, and that’s what it does.

@RoyiAvital :

I am not sure \ will always yield the minimum norm vector. At least it doesn’t on MATLAB. Which uses QR for basic solution for non square matrices.

@ Andreas Noack:

[In Julia] / will give a minimum norm solution for rectangular problems but not square problems (which is indeed a bit odd).
When the problem is underdetermined, MATLAB produces a basic solution (i.e. with zeros) whereas Julia chooses the minimum norm solution. The latter but not the former is built into some LAPACK routines. However, it’s quite easy to build a basic solution from a pivoted QR.

@ Dominique:

Also, \ only returns the min-norm solution if A is dense. If A is sparse (and rectangular), \ returns a basic solution, i.e., one with many zeros.

If anyone else had more info to add, please do.

2 Likes

I think the important thing to emphasize is that it returns

  1. a minimum error solution for over-determined systems
  2. the solution for fully determined systems
  3. a solution for under-determined systems

What specific solution we return for under-determined systems is an implementation detail, and if you really care about which solution you get, you probably shouldn’t use \.

1 Like