Repository: sympy/sympy
Pull request: zero raised to power -infinity gives zoo
<!-- Your title above should be a short description of what
was changed. Do not include the issue number in the title. -->

#### References to other Issues or PRs
<!-- If this pull request fixes an issue, write "Fixes #NNNN" in that exact
format, e.g. "Fixes #1234" (see
https://tinyurl.com/auto-closing for more information). Also, please
write a comment on that issue linking back to this pull request once it is
open. -->
Fixes #19572

#### Brief description of what is fixed or changed
Earlier  0 ** -oo gave 0 instead of zoo

#### Other comments


#### Release Notes

<!-- Write the release notes for this release below. See
https://github.com/sympy/sympy/wiki/Writing-Release-Notes for more information
on how to write release notes. The bot will check your release notes
automatically to see if they are formatted correctly. -->

<!-- BEGIN RELEASE NOTES -->
- core
     - Zero raised to power Negative Infinity gives ComplexInfinity(zoo) instead of zero
<!-- END RELEASE NOTES -->

Problem statement:
0**-oo produces 0, the documentation says it should produce zoo
Using SymPy 1.5.1, evaluate `0**-oo` produces `0`.

The documentation for the Pow class states that it should return `ComplexInfinity`, aka `zoo`

| expr | value | reason |
| :-- | :-- | :--|
| `0**-oo` | `zoo` | This is not strictly true, as 0**oo may be oscillating between positive and negative values or rotating in the complex plane. It is convenient, however, when the base is positive.|

Hints from issue discussion:

Commit message: zero raised to power -infinity gives zoo

Patch to review:
diff --git a/sympy/core/power.py b/sympy/core/power.py
index 984398c760e0..85d1d2e892a9 100644
--- a/sympy/core/power.py
+++ b/sympy/core/power.py
@@ -291,6 +291,8 @@ def __new__(cls, b, e, evaluate=None):
             ).warn()
 
         if evaluate:
+            if b is S.Zero and e is S.NegativeInfinity:
+                return S.ComplexInfinity
             if e is S.ComplexInfinity:
                 return S.NaN
             if e is S.Zero:
diff --git a/sympy/core/tests/test_power.py b/sympy/core/tests/test_power.py
index 413fbd453217..060b2428d83d 100644
--- a/sympy/core/tests/test_power.py
+++ b/sympy/core/tests/test_power.py
@@ -579,3 +579,7 @@ def _(a, b):
     assert power(a, b) == NewPow(a, b)
     assert power(b, a) == NewPow(b, a)
     assert power(b, b) == NewPow(b, b)
+
+def test_issue_19572():
+    assert 0 ** -oo is zoo
+    assert power(0, -oo) is zoo


Code review comments:
diff_hunk: @@ -579,3 +579,7 @@ def _(a, b):
     assert power(a, b) == NewPow(a, b)
     assert power(b, a) == NewPow(b, a)
     assert power(b, b) == NewPow(b, b)
+
+def test_issue_19572():
+    assert 0 ** -oo is zoo
+    assert power(0, -oo) is zoo
path: sympy/core/tests/test_power.py
text: @user1:
Can you add this to `test_zero` above rather than a new test function? You can include the url for the issue in a comment.

@author:
Yes sure