automatic Inf+NaN*i conversion

Jaroslav Hajek highegg at gmail.com
Fri Apr 25 11:42:57 CDT 2008


On Fri, Apr 25, 2008 at 3:42 PM, Rolf Fabian <Rolf.Fabian at gmx.de> wrote:
> > Datum: Fri, 25 Apr 2008 13:49:56 +0200
>  > Von: "Jaroslav Hajek" <highegg at gmail.com>
>  > An: "Rolf Fabian" <Rolf.Fabian at gmx.de>
>  > CC: bug-octave at octave.org
>  > Betreff: Re: automatic Inf+NaN*i conversion
>
>
>  > The rest, as you have suspected, is intended behaviour, given by the
>  > fact that `Inf' and `NaN' are functions.You can construct exceptional
>  > complex numbers reliably using `complex'.
>  >
>  > >  octave-3.0.0.exe:2> isnan(x)
>  > >  ans =
>  > >    1   1     # agree
>  > >
>  > >  Checking x for finiteness :
>  > >  octave-3.0.0.exe:3> finite (x)
>  > >  ans =
>  > >    0   0     # agree
>  > >
>  > >  But the result of the following check contradicts
>  > >  above result because 1st element of x cannot be
>  > >  neither finite nor infinite !
>  >
>  > I believe that's exactly true for NaN - it is neither finite nor
>  > infinite. What support do you have for the opposite claim?
>
>  Maybe I've not been precise enough, but it seems to me that you
>  didn't get my point yet:
>
>  octave-3.0.0.exe:> isinf(Inf+NaN*i)   |- ans = 0
>  octave-3.0.0.exe:> isinf(NaN+Inf*i)   |- ans = 1
>
>  Thus NaN+Inf*i is considered to be finite by Octave,
>  but  Inf+NaN*i is NOT considered to be finite by Octave as:
>  I expect that either BOTH of them are considered (by definition)
>  as infinite, or BOTH of them as finite, but the appearing
>  'mixed case' is the worst case selection.
>

No, you are just plain wrong. As you have seen earlier, Inf+NaN*i does not give
complex(Inf, NaN), but rather complex(NaN, NaN), due to the fact that
it is calculated as
complex(Inf + 0*NaN, 0 + 1*NaN). The behaviour of isinf is OK - it
gives infinity if either part of the complex number is Inf.


>  If we compare to the isnan function
>  for the same arguments as above :
>
>  octave-3.0.0.exe:> isnan(Inf+NaN*i)
>  ans =  1
>  octave-3.0.0.exe:> isnan(NaN+Inf*i)
>  ans =  1
>  we get get a unique result no matter whether the
>  NaN appears in the real part or the imag part.
>
>  I don't see any mathematical necessity to differentiate
>  between the outputs of
>  octave-3.0.0.exe:> isinf(Inf+NaN*i)   |- ans = 0
>  octave-3.0.0.exe:> isinf(NaN+Inf*i)   |- ans = 1
>  and there are further arguments against that than just
>  simply saying that this definition 'breaks symmetry'.
>
>  Ben already pointed out that ML has the same 'feature'
>  implemented. Thus, from former experience, it makes
>  absolutely no sense for me to dig publicly further into
>  this matter because I believe to already know the majority
>  of your eventual comments and replies in advance.
>
>  R:
>
>  --
>  Ist Ihr Browser Vista-kompatibel? Jetzt die neuesten
>  Browser-Versionen downloaden: http://www.gmx.net/de/go/browser
>



-- 
RNDr. Jaroslav Hajek
computing expert
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz


More information about the Bug-octave mailing list