Inf/Inf = NaN?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Inf/Inf = NaN?

John Utz-3
Hello everybody;

On my fake pentium-100 running FreeBSD-2.2-GAMMA and octave-2.0.5 compiled
with gcc-2.7.2 i get the above result ( Inf/Inf = NaN ). Shouldn't this
equal 1?

        I was thinking of hacking if(a==Inf)&&(b==Inf) result = 1 into my
code, but this is not how i like to work.

note, the specific operation is  (Inf-foo)/(Inf+foo) where foo is a real
positive int. This should be equal to 1, but...does the fact that i am
performing operations on Inf cause the math to "throw up it's hands and
surrender", so to speak?

tnx!

john

*******************************************************************************
 John Utz [hidden email]
        idiocy is the impulse function in the convolution of life


Reply | Threaded
Open this post in threaded view
|

Re: Inf/Inf = NaN?

Andres Weingessel
>>>>> On Wed, 16 Apr 1997 22:42:53 -0700 (PDT),
>>>>> John Utz wrote:

> Hello everybody;
> On my fake pentium-100 running FreeBSD-2.2-GAMMA and octave-2.0.5 compiled
> with gcc-2.7.2 i get the above result ( Inf/Inf = NaN ). Shouldn't this
> equal 1?

No, Inf/Inf = NaN is correct. The reason is that, simply speaking,
Infinity does not necessarily equal Infinity. For example, 2 times
Infinity is still Infinity, as well as 10*Inf=Inf, so I could also
argue that Inf/Inf should be 2 or 10 or ... . Infinity just can not be
regarded as a "large" real number.

        Andreas

> I was thinking of hacking if(a==Inf)&&(b==Inf) result = 1 into my
> code, but this is not how i like to work.

> note, the specific operation is  (Inf-foo)/(Inf+foo) where foo is a real
> positive int. This should be equal to 1, but...does the fact that i am
> performing operations on Inf cause the math to "throw up it's hands and
> surrender", so to speak?

> tnx!

> john

> *******************************************************************************
>  John Utz [hidden email]
> idiocy is the impulse function in the convolution of life

************************************************************************
*                          Andreas Weingessel                          *
************************************************************************
* Institut für Statistik      *                Tel: (+43 1) 58801 4541 *
* Technische Universität Wien *                Fax: (+43 1)  504 14 98 *
* Wiedner Hauptstr. 8-10/1071 *     [hidden email] *
* A-1040 Wien, Austria        * http://www.ci.tuwien.ac.at/~weingessel *
************************************************************************



Reply | Threaded
Open this post in threaded view
|

Re: Inf/Inf = NaN?

Ted.Harding
In reply to this post by John Utz-3
( Re Message From: John Utz )

>
> On my fake pentium-100 running FreeBSD-2.2-GAMMA and octave-2.0.5 compiled
> with gcc-2.7.2 i get the above result ( Inf/Inf = NaN ). Shouldn't this
> equal 1?
>
> I was thinking of hacking if(a==Inf)&&(b==Inf) result = 1 into my
> code, but this is not how i like to work.
>
> note, the specific operation is  (Inf-foo)/(Inf+foo) where foo is a real
> positive int. This should be equal to 1, but...does the fact that i am
> performing operations on Inf cause the math to "throw up it's hands and
> surrender", so to speak?

As far as I know "Inf/Inf = NaN" since the beginning of time in octave.

The point about "NaN" is that it represents the indeterminate outcome of
an operation whose result is not defined or is not unique.

So inf*inf = inf, 1/inf = 0, 1*inf = inf, 1+inf = inf and 1-inf = -inf

are OK. But Inf itself is not a determinate entity but represents a
limiting concept. So Inf is indeterminate in so far as the limit of the
expression in which it occurs does not depend on the limits of the terms
in the expression.

For instance, as X -> inf, Y = X*X -> inf;

so, in the limit,
(X-foo)/(Y+foo) = inf/inf and
(Y-foo)/(X+foo) = inf/inf

but, in the limit, the first -> 0 but the second -> inf. Likewise

(a*X - foo)/(b*X + foo) -> a/b  but " = inf/inf"

where a & b are anything. This is why "Inf/Inf" is indeterminate in
general and should be represented by "NaN".

Clearly what you have in mind for your calculation is the equivalent
of (X-foo)/(X+foo) -> 1 as X -> inf, but this is a special case of all the
possible limiting expressions that could correspond to inf/inf, which
between them lead to all possible results. So it's fine for you to write
code which says "if(a==Inf)&&(b==Inf) result = 1", provided you're only
dealing with cases like (X-foo)/(X+foo). But if you're dealing with
anything else then you should define "result" accordingly. The use of
"NaN" to flag an indeterminate result is very valuable, and the arithmetic
of "inf" should not be subverted by resolving the indeterminacy in a
particular way.

All the best,
Ted.                                    ([hidden email])

Reply | Threaded
Open this post in threaded view
|

Re: Inf/Inf = NaN?

Craig Earls-2
In reply to this post by John Utz-3
John Utz wrote:
>
> Hello everybody;
>
> On my fake pentium-100 running FreeBSD-2.2-GAMMA and octave-2.0.5 compiled
> with gcc-2.7.2 i get the above result ( Inf/Inf = NaN ). Shouldn't this
> equal 1?

No, if it is a value of a function, it can be evaluated using L'Hopitals
rule, i.e.

lim [f(x)/g(x)]=lim [ df/dx / dg/dx]
x->A            x->A

where f(x)/g(x) =inf/inf as x->A, where A is any real Number.
--
-----------------------------------------------------------------
Craig P Earls                                 [hidden email]
LT US Navy, MIT Ocean Engineering             [hidden email]
-----------------------------------------------------------------


--
-----------------------------------------------------------------
Craig P Earls      [hidden email]
LT US Navy, MIT Ocean Engineering      [hidden email]
-----------------------------------------------------------------