bugGNU Octave - Bugs: bug #57145, Matlab heuristic for...

 
 

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

Submitter:  Muhali <muhali>
Submitted:  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
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

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.


https://www.mathworks.com/help/matlab/ref/mldivide.html

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

Kai Torben Ohlhus <siko1056>
Group Member
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>

 

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

Attach Files:
   
   
Comment:
   

No files currently attached

 

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)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 8 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-01-24 siko1056 SummaryMatlab heuristic for backslash and overdetermined Matlab heuristic for backslash-operator and overdetermined systems of linear equations
    2020-01-24 siko1056 CategoryNone Octave Function
        Severity3 - Normal 1 - Wish
        Priority5 - Normal 3 - Low
        Item GroupNone Matlab Compatibility
        StatusNone Wont Fix
        Open/ClosedOpen Closed
        Summary backslash vs. pinv Matlab heuristic for backslash and overdetermined

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code