Merge pull request #926 from skirpichev/fix-637
Use sum_accurately() in hankel1/2()
This commit is contained in:
@@ -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):
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user