Merge pull request #926 from skirpichev/fix-637

Use sum_accurately() in hankel1/2()
This commit is contained in:
Sergey B Kirpichev
2025-03-09 02:24:50 +03:00
committed by GitHub
2 changed files with 12 additions and 2 deletions
+8 -2
View File
@@ -180,11 +180,17 @@ def besselk(ctx, n, z, derivative=0, **kwargs):
@defun_wrapped
def hankel1(ctx,n,x,**kwargs):
return ctx.besselj(n,x,**kwargs) + ctx.j*ctx.bessely(n,x,**kwargs)
def terms():
return [ctx.besselj(n,x,**kwargs),
ctx.j*ctx.bessely(n,x,**kwargs)]
return ctx.sum_accurately(terms)
@defun_wrapped
def hankel2(ctx,n,x,**kwargs):
return ctx.besselj(n,x,**kwargs) - ctx.j*ctx.bessely(n,x,**kwargs)
def terms():
return [ctx.besselj(n,x,**kwargs),
-ctx.j*ctx.bessely(n,x,**kwargs)]
return ctx.sum_accurately(terms)
@defun_wrapped
def whitm(ctx,k,m,z,**kwargs):
+4
View File
@@ -2433,3 +2433,7 @@ def test_issue_634():
def test_issue_908():
assert mp.besselj(-10+0j, 0+0j) == 0
def test_issue_637():
assert hankel1(1, 1 + 30j).ae(-7.25495e-15 - 1.17346e-14j)
assert hankel2(1, 1 - 30j).ae(-7.25495e-15 + 1.17346e-14j)