help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unexpected behavior of backslash for singular matrix


From: Carlo De Falco
Subject: Re: Unexpected behavior of backslash for singular matrix
Date: Sun, 24 May 2020 13:12:24 +0000

Hi,

> Il giorno 24 mag 2020, alle ore 13:49, Matthias Gobbert <address@hidden> ha 
> scritto:
> 
> Dear Colleagues,
> 
> The following small linear system has a singular system matrix, as Octave 
> confirms readily by det(A) giving an exact 0, but when attempting to solve 
> the linear system by the obvious sequence of commands
> 
> A = [1 1 0 1; 2 1 -1 1; 4 -1 -2 2; 3 -1 -1 2]
> b = [2; 1; 0; -3]
> x = A \ b
> 
> results in the output below.
> 
> Octave gives a warning, but then outputs a 'solution' vector x that has no 
> "inf" or "NaN" in it. I find this behavior unexpected.

It is not unexpected, it is documented and mathematically sound behaviour 
[1,2,3] :

"If the matrix is not square, or any of the previous solvers flags a singular 
or near singular matrix, find a least squares solution using the LAPACK xGELSD 
function. "

"x" in "xGELSD" here stands for either "D", "S", "C", or "Z", the value "D" 
would apply in your example.

HTH,
c.

[ 1] https://octave.org/doc/v5.2.0/Techniques-Used-for-Linear-Algebra.html
[ 2] https://www.netlib.org/lapack/lug/node27.html
[ 3] https://en.wikipedia.org/wiki/Linear_least_squares
[ 4] 
http://www.netlib.org/lapack/explore-html/d7/d3b/group__double_g_esolve_ga94bd4a63a6dacf523e25ff617719f752.html#ga94bd4a63a6dacf523e25ff617719f752


reply via email to

[Prev in Thread] Current Thread [Next in Thread]