Sympy: Wrong results. (Limit, Integral, sphere(Space polar coordinates))

Created on 20 Dec 2018  ยท  3Comments  ยท  Source: sympy/sympy

p = symbols('p')
alpha = symbols('ฮฑ', positive=True)
pprint(Limit(4 * pi * p ** (-alpha) * (p ** 3 - p ** alpha) / (alpha - 3), p, 0))
     โŽ›     -ฮฑ โŽ› 3    ฮฑโŽžโŽž
     โŽœ4โ‹…ฯ€โ‹…p  โ‹…โŽp  - p โŽ โŽŸ
 lim โŽœโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โŽŸ
pโ”€โ†’0โบโŽ      ฮฑ - 3      โŽ 



md5-79cfb4f1d7fcfbec6d25b4abe71a549e



-4โ‹…ฯ€
โ”€โ”€โ”€โ”€โ”€
ฮฑ - 3

but correct results are:

-4โ‹…ฯ€
โ”€โ”€โ”€โ”€โ”€ (0 < ฮฑ < 3)
ฮฑ - 3

oo (ฮฑ > 3)
```

My Step-by-Step Solution

Wrong Result functions.elementary.piecewise limits series

All 3 comments

This boils down to

>>> Limit(p ** (-alpha) * (p ** 3 - p ** alpha), p, 0).doit()
-1

versus

>>> Limit(p ** (-alpha) * (p ** 3 - p ** alpha), p, 0).expand().doit()
NotImplementedError: Result depends on the sign of sign(ฮฑ - 3)

It might be possible to prevent the wrong result, but it seems the most we can expect is NotImplementedError. When limit detects such dependence, it throws an error instead of splitting the computation in two or three cases.

See the discussion at https://github.com/sympy/sympy/issues/13312 about making limit able to return Piecewise objects.

The non-expanded version not giving the error is definitely a wrong result.

I would like to work on this issue. @asmeurer , @normalhuman can you guide me what exactly to do.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cbm755 picture cbm755  ยท  5Comments

rtrwalker picture rtrwalker  ยท  3Comments

GarkGarcia picture GarkGarcia  ยท  4Comments

Huyston picture Huyston  ยท  3Comments

asmeurer picture asmeurer  ยท  3Comments