The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Problematic Bessely and Besselh fucntions in Matlab.
Replies: 2   Last Post: Oct 11, 2013 12:28 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Nasser Abbasi

Posts: 6,677
Registered: 2/7/05
Re: Problematic Bessely and Besselh fucntions in Matlab.
Posted: Oct 11, 2013 12:28 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On 10/10/2013 11:23 PM, Nasser M. Abbasi wrote:
> On 10/10/2013 10:33 PM, i2000s wrote:
>> Hi there,
>> I found there is a bug in Bessel functions. For example, the Hankel function besselh
>> should be defined as a combination of besselj and 1i*bessely, but in Matlab,
>> this relation does not hold. I suspect, close to the origin, the besselh
>> and bessely functions may not be correct. Does anyone have a tempary
>> solution on this? I am using besselh and bessely to do integrals, which always fail for my studies. Thanks.
>> Testing Commands:

>>>> besselj(1,0.0001)+bessely(1,0.0001)*1i-besselh(1,1,0.0001)
>> ans =
>> -3.8982e-13

> I do not see a bug really, it seems to be just a floating point
> noise issue? Unless Both Mathematica and Maple and Matlab
> happen to have the same bug. The result is close to zero.
> EDU>> r=besselj(1,0.0001)+bessely(1,0.0001)*sqrt(-1)
> 4.99999999375e-05 - 6366.19803645576i
> EDU>> z=besselh(1,1,0.0001)
> 5.00000003273172e-05 - 6366.19803645576i
> EDU>> r-z
> -3.89817152624157e-13
> Mathematica:
> BesselJ[1, 0.0001] + BesselY[1, 0.0001]*I - HankelH1[1, 0.0001];
> 0.` + 0.` I
> Maple:
> restart;
> BesselJ(1,0.0001)+BesselY(1,0.0001)*I-HankelH1(1,0.0001);
> 0. + 0. I

May be I should show the intermidate results:
r = BesselJ[1, 0.0001] + BesselY[1, 0.0001]*I
0.0000499999999375 - 6366.19803645576 I

HankelH1[1, 0.0001]
0.0000499999999375 - 6366.19803645576 I

Same with Maple. i.e. the real part of r and the real part
of Hankel first kind, is exactly the same. If this is what you
mean, then, yes, there seems to be a numerical issue here. The result
should have come out zero.

It depends how Hankel function was implemented in Matlab. But Maple
and Mathematica do give zero, while Matlab have that small floating
point result there. May be someone should look more into this.


Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.