[Date Index]
[Thread Index]
[Author Index]
Re: A question about N[...]
*To*: mathgroup at smc.vnet.net
*Subject*: [mg89415] Re: A question about N[...]
*From*: "David Park" <djmpark at comcast.net>
*Date*: Mon, 9 Jun 2008 02:27:02 -0400 (EDT)
*References*: <g2fug6$2kg$1@smc.vnet.net>
This appears to be a numerical precision problem in evaluating
HypergeometricPFQ. We could just take an indefinite integral and evaluate
for an upper limit.
Integrate[BesselJ[0, 2405/1000*r]^2, r]
% /. r -> 20.
r HypergeometricPFQ[{1/2, 1/2}, {1, 1, 3/2}, -((231361 r^2)/40000)]
0.
Now let's plot this versus r with MachinePrecision. The plot goes quite bad
before we reach r = 20.
Plot[r HypergeometricPFQ[{1/2, 1/2}, {1, 1, 3/2}, -((231361 r^2)/
40000)], {r, 0, 30},
PlotRange -> Automatic,
WorkingPrecision -> MachinePrecision]
Next, let's plot with a much higher precision. Things still go bad, but not
until a higher value of r.
Plot[r HypergeometricPFQ[{1/2, 1/2}, {1, 1, 3/2}, -((231361 r^2)/
40000)], {r, 0, 30},
PlotRange -> Automatic,
WorkingPrecision -> 60]
So, let's use N with the same higher precision.
r HypergeometricPFQ[{1/2, 1/2}, {1, 1, 3/2}, -((231361 r^2)/40000)];
% /. r -> 20
N[%, 60]
20 HypergeometricPFQ[{1/2, 1/2}, {1, 1, 3/2}, -(231361/100)]
0.864755185740518759537796371015077138945014301003469172726221
So one has to know the ins and outs of HypergeometricPFQ and why it requires
such high precision.
--
David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/
<wyelen at gmail.com> wrote in message news:g2fug6$2kg$1 at smc.vnet.net...
>
> Recently I came across a puzzling problem which I believed to be
> related to the function N.
>
> My platform is Mathematica 6.0 for Microsoft Windows (32-bit). When
> calculating the following
> integral, I got different results from Integrate & NIntegrate:
>
> In[1]:= Integrate[BesselJ[0, 2.405 * r]^2, {r, 0, 20}]
>
> Out[1]= 0.
>
> In[2]:= NIntegrate[BesselJ[0, 2.405 * r]^2, {r, 0, 20}]
>
> Out[2]= 0.864755
>
> Guessing a problem caused by numerical number 2.405, I rewrote it as
> an exact number:
>
> In[3]:= Integrate[BesselJ[0, (2 + 405/1000)*r]^2, {r, 0,
> 20}]
>
> Out[3]= 20*HypergeometricPFQ[{1/2, 1/2}, {1, 1, 3/2}, -
> (231361/100)]
>
> then evaluated the numerical value, which was surprisingly still 0.:
>
> In[4]:= N[%]
>
> Out[4]= 0.
>
> but evaluating with 6-digit precision gave the same result as
> NIntegrate:
>
> In[5]:= N[%%,6]
>
> Out[5]= 0.864755
>
> In help page for N it said "N[expr] is equivalent to
> N[expr,MachinePrecision]", but evaluating with a
> approximate precision didn't gave 0.:
>
> In[6]:= N[MachinePrecision]
>
> Out[6]= 15.9546
>
> In[7]:= N[%3,15.9546]
>
> Out[7]= 0.8647551857405188
>
> I wonder is this caused by the function N ,or whether I should just
> turn to another OS (say Linux) and things will go well.
>
> Thanks a lot for your reply!
>
Prev by Date:
**Re: A question about N[...]**
Next by Date:
**Re: Adding markers on the surface of a Plot3D?**
Previous by thread:
**Re: A question about N[...]**
Next by thread:
**How to get an optimal simplification?**
| |