[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bug when dividing a scalar by a vector?
From: |
Sebastian Schöps |
Subject: |
Re: Bug when dividing a scalar by a vector? |
Date: |
Thu, 12 Jan 2017 17:23:31 +0100 |
> 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.
Bye
Sebastian