Ok so the problem is in gruntz, in a sense: when you do something like
gruntz(x-oo, x, oo) then the leadterm expansion is w - oo, and gruntz
assumes that this tends to oo, simply because gruntz does not deal
with unbounded numbers at all.
The proper way to fix this is to make gruntz aware of "unbounded
numbers", this extending mrv_leadterm and changing a few things
slightly in gruntz.py. It should be easy. Downside is that 1) it
involves parts of the code that are touched in my gruntz_eval branch,
so I'd rather not fix this before the branch is in, and 2) that really
this is only going to work in trivial cases like x+oo because a)
behaviour of oo and the like is not really specified in complicated
expressions and b) series expansions at any rate are not ware of this.
An alternative (recognising that we are only going to be able to
handle trivial cases) would be to change limit(), e.g. like this:
diff --git a/sympy/series/limits.py b/sympy/series/limits.py
index 12a27d7..ae1c3ec 100644
--- a/sympy/series/limits.py
+++ b/sympy/series/limits.py
@@ -37,6 +37,14 @@ def limit(e, z, z0, dir="+"):
z = sympify(z)
z0 = sympify(z0)
+ if e.is_Mul or e.is_Add:
+ a, b = e.as_independent(z)
+ if b != e:
+ return e.func(a, limit(b, z, z0, dir))
+
+ if e.has(oo, -oo):
+ raise NotImplementedError('Could not separate infinites')
+
if e == z:
return z0
But then there is a second problem: this exception is actually raised
in some tests (where slightly ludicrous limits like (1+x)**oo are
computed). Remove the check would fix this, but then we might
sometimes compute the wrong answer.
I don't really think it's worth the hassle fixing this as long as we
can only do trivial cases anyway.
On 29 Apr., 09:55, Tom Bachmann <[email protected]> wrote:
> Evidently neither gruntz nor limit play along particularly well with
> infinities. Clearly this should be nan. I'll try to look into the
> gruntz issue today.
>
> On 29 Apr., 09:25, smichr <[email protected]> wrote:
>
> > I would have expected NaN to be returned but I get:
>
> > h[1] >>> limit(x-oo,x,oo)
> > oo
> > h[2] >>> limit(oo-x,x,oo)
> > -oo
>
>
--
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.