I think this is the correct way of thinking about it. Basically, the expression 
is not well-defined to any one point, so we return nan.  A rule of thumb is 
that any of the l'Hopital's rule "indeterminate forms" should return nan.

The one exception to this rule is that we follow Python's convention that 0**0 
== 1 (see http://code.google.com/p/sympy/issues/detail?id=2260).

Aaron Meurer

On Apr 18, 2011, at 12:07 PM, Tom Bachmann wrote:

> Imho there are (at least) two ways of thinking about this. One
> consistent way is the following:
> 
> Let c, d be "extended numbers" (reals, complexes, oo, zoo, etc).
> Let f(x,y) be any function of two "ordinary numbers".
> 
> We define f(c,d) = e if for all expressions e1, e2 such that limit(e1)
> = c, limit(e2) = d we have limit(f(e1, e2)) = e.
> We define f(c,d) = nan if there exist expressions e1, e2, e3, e4 with
> limit(e1) = c, limit(e2) = c, limit(e3) = d, limit(e4) = d and
> limit(f(e1, e3)) != limit(f(e2, e4)).
> [It is understood here that all limits are of the same kind, e.g. all
> as x->0 in C or all es x->oo in R, or whatever.]
> 
> In particular then for f(x,y) = x - y, it follows that zoo-zoo = nan,
> since e1=z, e2=z, e3=z+1, e4=z have the desired properties.
> 
> A slightly less ad-hoc way of thinking about this is using filters,
> c.f. the wiki [1].
> 
> Actually I think that no matter what the "high-powered" definition is
> going to be, the first property I described should be whenever the
> result is not nan.
> 
> Obviously not more involved in sympy than you are, I'm just reporting
> what I have caught up, hence take my words with a (big) grain of
> salt :-).
> 
> [1] https://github.com/sympy/sympy/wiki/Infinities-and-Singularities
> 
> On 18 Apr., 17:33, Saptarshi Mandal <[email protected]> wrote:
>> I am just having difficulty wrapping my head around zoo - zoo. Complex
>> infinity should be unsigned. And even if you did write something like
>> this should this be nan or zoo?
>> 
>> Otoh, since zoo - zoo doesnt make sense, S.NaN should actually be the
>> correct answer. Can someone more knowledgeable about this enlighten
>> me?
>> 
>> On Apr 18, 4:36 pm, "Alexey U. Gudchenko" <[email protected]> wrote:
>> 
>>> 18.04.2011 08:20, smichr пишет:
>> 
>>>> Does zoo absorb everything in an addition or multiplication (except
>>>> maybe oo or another zoo)?
>> 
>>> It is related with this old 
>>> issue:http://code.google.com/p/sympy/issues/detail?id=360
>> 
>>> And with this open pull 
>>> request:https://github.com/sympy/sympy/pull/173/files
>> 
>>> E.g. Those assertions have quit right behavior:
>> 
>>> assert zoo == zoo
>>> assert zoo != oo
>>> assert 1*zoo == zoo
>>> assert 2*zoo == zoo
>>> assert 1 != zoo
>>> assert zoo != 1
>>> assert zoo != Symbol("x")**3
>>> assert zoo + 1 == zoo + 1
>>> assert zoo + 1 == zoo
>>> assert 2 + zoo == zoo
>>> assert 3*zoo + 2 == zoo
>>> assert 1/zoo == 0
>> 
>>> x = Symbol('x')
>> 
>>> assert zoo + zoo == nan
>>> assert zoo - zoo == nan
>>> assert zoo + oo == nan
>>> assert zoo - oo == nan
>> 
>>> assert zoo + I == zoo
>>> assert zoo * I == zoo
>>> assert zoo + x + 2 + 3*I == zoo + x
>>> assert zoo * x * 2 * 3*I * -oo == zoo * x
>> 
>>> assert zoo * (1+I) == zoo
>>> assert zoo * (4+I+x) != zoo
>> 
>>> assert zoo * 0 == nan
>>> assert zoo * nan == nan
>>> assert 0 * zoo == nan
>>> assert nan * zoo == nan
>>> assert zoo + nan == nan
>> 
>>> assert zoo**zoo == nan
>>> assert zoo**0   == nan
>>> assert zoo**2   == zoo
>>> assert zoo**(-1) == 0
>> 
>>> assert abs(zoo) == oo
>> 
>>> If anyone disagree with those assertions please let us know.
>> 
>>> --
>>> Alexey U.
>> 
>> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "sympy" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/sympy?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sympy?hl=en.

Reply via email to