octave-maintainers
[Top][All Lists]
Advanced

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

Re: Bug when dividing a scalar by a vector?


From: Ben Abbott
Subject: Re: Bug when dividing a scalar by a vector?
Date: Thu, 12 Jan 2017 11:47:24 -0500

> On Jan 12, 2017, at 11:23 AM, Sebastian Schöps <address@hidden> wrote:
> 
>> Am 12.01.2017 um 17:09 schrieb John W. Eaton <address@hidden>:
>> 
>> On 01/12/2017 10:42 AM, Sebastian Schöps wrote:
>>> Montgomery-Smith, Stephen wrote
>>>> My guess is that it is solving the underdetermined equation:
>>>> 
>>>> x1+x2+x3+x4=1.
>>>> 
>>>> So both solutions are correct answers.  There are infinitely many correct
>>>> answers.
>>>> 
>>>> If I had to choose, I guess I would go for the answer who square sum is
>>>> minimized, which would favor Octave's answer.
>>> 
>>> Thanks! That explains the behaviour and I agree that both solutions do make
>>> sense. However, is that documented somewhere? Shouldn't there be a warning?
>>> Similar to the case when a singular linear equation system is solved?
>> 
>> For which cases do you want warnings?
>> 
>> Do you want a warning because the particular solution is different from 
>> Matlab,
> no. This would be quite tedious :)
> 
>> or because the system is not square?
> yes. My confusion popped up because 1./x was meant but 1/x was written in the 
> code. Debugging took ages. Is this behaviour documented? - I use the Matlab 
> language for more than 15 years and I was not aware!
> 
>> Does Matlab always warn when solving least-squares problems?
> 
> I checked: no, Matlab does not warn in the case of 1/x. It does warn if you 
> solve a singular equation system ("Matrix is singular to working precision.") 
> but it does not mention that a least squares solution will be returned. Older 
> version of Octave were more explicit, right? I liked that but it seems that I 
> missed that it was changed. 
> 
> Conclusion: there is no bug and no Matlab incompatibility. However, I think a 
> warning would make sense even if Matlab does not. Sorry for the noise.

Its been a long time since I looked at this, but my recollection is that for 
non-square matrices Matlab would return a least squares solution (number of 
eqns > number of unknowns) or a minimum norm solution (number of unknowns is 
larger than the number of equations … hmmm, I  may be confusing what Matlab was 
supposed to do with what Octave was designed to do.

Personally, I prefer to minimum norm approach. I can easily produce the Matlab 
approach by adding some extra equations, but I don’t immediately remember the 
Matlab operator Matlab used to produce a minimum norm solution. Maybe there 
isn’t one?

Ben





reply via email to

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