Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
17678: return unsigned_infinity as special value; additions and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
rwst committed Feb 13, 2015
1 parent c729ed9 commit 1d27cb1
Showing 1 changed file with 28 additions and 19 deletions.
47 changes: 28 additions & 19 deletions src/sage/functions/bessel.py
Expand Up @@ -307,26 +307,29 @@ def _eval_(self, n, x):
"""
EXAMPLES::
sage: n = var('n')
sage: bessel_J(0, 0)
1
sage: bessel_J(5/2, 0)
0
sage: bessel_J(-5/2, 0)
+Infinity
Infinity
sage: bessel_J(1/2, x)
sqrt(2)*sqrt(1/(pi*x))*sin(x)
sage: bessel_J(-1/2, x)
sqrt(2)*sqrt(1/(pi*x))*cos(x)
sage: bessel_J(n, 0)
bessel_J(n, 0)
"""
from sage.rings.infinity import infinity
from sage.rings.infinity import unsigned_infinity
if x == 0:
if n == 0:
return ZZ(1)
elif n > 0 or n in ZZ:
return ZZ(0)
else:
return infinity
if n == QQ(1)/2:
elif not isinstance(n, Expression):
return unsigned_infinity
elif n == QQ(1)/2:
return sqrt(2/pi/x) * sin(x)
elif n == QQ(-1)/2:
return sqrt(2/pi/x) * cos(x)
Expand Down Expand Up @@ -507,17 +510,18 @@ def _eval_(self, n, x):
"""
EXAMPLES::
sage: n = var('n')
sage: bessel_Y(1, 0)
-Infinity
Infinity
sage: bessel_Y(1/2, x)
-sqrt(2)*sqrt(1/(pi*x))*cos(x)
sage: bessel_Y(-1/2, x)
sqrt(2)*sqrt(1/(pi*x))*sin(x)
"""
from sage.rings.infinity import infinity
if x == 0 and n >= 0:
return -infinity
if n == QQ(1)/2:
from sage.rings.infinity import unsigned_infinity
if x == 0 and not isinstance(n, Expression):
return unsigned_infinity
elif n == QQ(1)/2:
return -sqrt(2/pi/x) * cos(x)
elif n == QQ(-1)/2:
return sqrt(2/pi/x) * sin(x)
Expand Down Expand Up @@ -691,29 +695,31 @@ def _eval_(self, n, x):
"""
EXAMPLES::
sage: y=var('y')
sage: n,y = var('n,y')
sage: bessel_I(y, x)
bessel_I(y, x)
sage: bessel_I(0, 0)
1
sage: bessel_I(7/2, 0)
0
sage: bessel_I(-7/2, 0)
+Infinity
Infinity
sage: bessel_I(1/2, 1)
sqrt(2)*sinh(1)/sqrt(pi)
sage: bessel_I(-1/2, pi)
sqrt(2)*cosh(pi)/pi
sage: bessel_I(n, 0)
bessel_I(n, 0)
"""
from sage.rings.infinity import infinity
from sage.rings.infinity import unsigned_infinity
# special identities
if x == 0:
if n == 0:
return ZZ(1)
elif n > 0 or n in ZZ:
return ZZ(0)
else:
return infinity
elif not isinstance(n, Expression):
return unsigned_infinity
if n == QQ(1)/2:
return sqrt(2 / (pi * x)) * sinh(x)
elif n == -QQ(1)/2:
Expand Down Expand Up @@ -879,15 +885,18 @@ def _eval_(self, n, x):
"""
EXAMPLES::
sage: n = var('n')
sage: bessel_K(1, 0)
+Infinity
Infinity
sage: bessel_K(1/2, x)
sqrt(1/2)*sqrt(pi)*e^(-x)/sqrt(x)
sage: bessel_K(n, 0)
bessel_K(n, 0)
"""
from sage.rings.infinity import infinity
from sage.rings.infinity import unsigned_infinity
# special identity
if x == 0:
return infinity
if x == 0 and not isinstance(n, Expression):
return unsigned_infinity
if n == QQ(1)/2 or n == -QQ(1)/2 and x > 0:
return sqrt(pi / 2) * exp(-x) * x ** (-Integer(1) / Integer(2))

Expand Down

0 comments on commit 1d27cb1

Please sign in to comment.