# bug #57145: Matlab heuristic for backslash-operator and overdetermined systems of linear equations

 Submitted by: Muhali Submitted on: Wed 30 Oct 2019 04:34:39 PM UTC Category: Octave Function Severity: 1 - Wish Priority: 3 - Low Item Group: Matlab Compatibility Status: Wont Fix Assigned to: None Originator Name: Open/Closed: Closed Release: 5.1.0 Operating System: GNU/Linux

You are not logged in

## Discussion

Fri 24 Jan 2020 03:09:24 AM UTC, comment #3:

Thank you for the pointer in comment #2 and comment #3.  Agree to the wiki: well defined behavior is preferable to an undocumented heuristic.

> If A is a rectangular m-by-n matrix with m ~= n, and B is a matrix with m rows, then A\B returns a least-squares solution to the system of equations A*x= B.

> If the rank of A is less than the number of columns in A, then x = A\B is not necessarily the minimum norm solution.

If anyone wants to figure out Matlab's heuristic, we can open this item again.

Kai Torben Ohlhus <siko1056>
Thu 23 Jan 2020 02:00:11 PM UTC, comment #2:
Anonymous
Wed 30 Oct 2019 09:27:38 PM UTC, comment #1:

Is this a recent change of how matlab interprets its backslash operator? Indeed, its documentation says that multiplication by the pinv gives the minimum-norm solution (that's guaranteed by the properties of the Moore-Penrose pseudoinverse), while the backslash operator according to the mldivide documentation "is not necessarily the minimum norm solution", and only according to the pinv documentation "is special because it has only three nonzero elements" in the present example. I do not find a general rule, so I would say it is undocumented what matlab really computes in the case of underdetermined problems. If it is the solution with the least number of non-zero entries, then this is not unique as I see it. Perhaps it is the one with the smallest norm among those with the smallest number of non-zero entries (but I am not sure if even that is unique in general).

In contrast, for octave it is well-defined: it is the minimum-norm solution, just as what you would get by pinv (but computed more efficiently). So your point a) is valid (but as I said, does matlab even define its behaviour in this case?), but b) is not true in general (I would even estimate that the minimum-norm solution gives a smaller error in general).

Michael Leitner <mleitner>
Wed 30 Oct 2019 04:34:39 PM UTC, original submission:

A = magic(8);
A = A(:,1:6) ;
b = 260*ones(8,1) ;

x1 = A\b
x2 = pinv(A)*b

x3 = [3 4 0 0 1 0]' ;
norm(A*x1-b)
norm(A*x3-b)

There are two (possibly well known) issues here.

a) x1 differs from Matlab (which gives x3).

b) solution x3 is "closer" than solution x1.

The example comes from the Matlab pinv help. ML probably uses a different/better optimization algorithm, so the difference should perhaps be mentioned at least.

Muhali <muhali>

## Attached Files

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

Comment:

No files currently attached

## Dependencies

Depends on the following items: None found

Items that depend on this one: None found

Carbon-Copy List
• -email is unavailable- added by siko1056 (Posted a comment)
• -email is unavailable- added by mleitner (Posted a comment)
• -email is unavailable- added by muhali (Submitted the item)
•

Do you think this task is very important?
This task has 0 encouragements so far.

Only project members can vote.