Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #6623 > unrolled thread

Bad Precision output for SphericaBesselY and BesselY

Started byAntonio Alvaro Ranha Neves <aneves@gmail.com>
First post2011-11-22 10:43 +0000
Last post2011-11-25 10:11 +0000
Articles 6 — 4 participants

Back to article view | Back to comp.soft-sys.math.mathematica


Contents

  Bad Precision output for SphericaBesselY and BesselY Antonio Alvaro Ranha Neves <aneves@gmail.com> - 2011-11-22 10:43 +0000
    Re: Bad Precision output for SphericaBesselY and BesselY "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> - 2011-11-23 12:03 +0000
    Re: Bad Precision output for SphericaBesselY and BesselY Peter Pein <petsie@dordos.net> - 2011-11-23 12:14 +0000
    Re: Bad Precision output for SphericaBesselY and BesselY Antonio Alvaro Ranha Neves <aneves@gmail.com> - 2011-11-24 12:12 +0000
      Re: Bad Precision output for SphericaBesselY and BesselY Peter Falloon <pfalloon@gmail.com> - 2011-11-25 10:04 +0000
      Re: Bad Precision output for SphericaBesselY and BesselY "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> - 2011-11-25 10:11 +0000

#6623 — Bad Precision output for SphericaBesselY and BesselY

FromAntonio Alvaro Ranha Neves <aneves@gmail.com>
Date2011-11-22 10:43 +0000
SubjectBad Precision output for SphericaBesselY and BesselY
Message-ID<jafud8$rrr$1@smc.vnet.net>
Dear users,

Recently I'm working with precision calculations of spherical functions. Example, let,

n = 150
x = SetPrecision[120.3, 100]
BesselY[n + 1/2, x] // Precision
BesselJ[n+ 1/2, x] // Precision


Yields 67.2708 and 96.9297 respectively. The two questions are:
1) Why does BesselY results in a worse than BesselJ?
2) How to redefine, BesselY to automatically output a result with a desired pecision?

Note: Simply using N[expr,90], does not yield a result of expr with 90 precision but maintains the same 67.2708.

Thanks,
Antonio

[toc] | [next] | [standalone]


#6648

From"Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com>
Date2011-11-23 12:03 +0000
Message-ID<jained$eeg$1@smc.vnet.net>
In reply to#6623
On Tue, 22 Nov 2011 10:43:52 -0000, Antonio Alvaro Ranha Neves  
<aneves@gmail.com> wrote:

> Dear users,
>
> Recently I'm working with precision calculations of spherical functions.  
> Example, let,
>
> n = 150
> x = SetPrecision[120.3, 100]
> BesselY[n + 1/2, x] // Precision
> BesselJ[n+ 1/2, x] // Precision
>
>
> Yields 67.2708 and 96.9297 respectively. The two questions are:
> 1) Why does BesselY results in a worse than BesselJ?
> 2) How to redefine, BesselY to automatically output a result with a  
> desired pecision?
>
> Note: Simply using N[expr,90], does not yield a result of expr with 90  
> precision but maintains the same 67.2708.
>
> Thanks,
> Antonio
>
>

Both functions lose precision, and BesselY loses a lot. Why this would be  
I don't know off-hand as I'm not sure what method these functions use to  
calculate their outputs. However, the essential problem is that there  
isn't enough precision in your input. If you try

x = SetPrecision[120.3, Infinity]

or better

x = Rationalize[120.3]

then N is able to give you an output with the full 90 digits of precision  
in both cases.

[toc] | [prev] | [next] | [standalone]


#6659

FromPeter Pein <petsie@dordos.net>
Date2011-11-23 12:14 +0000
Message-ID<jaio3h$epb$1@smc.vnet.net>
In reply to#6623
Am 22.11.2011 11:43, schrieb Antonio Alvaro Ranha Neves:
> Dear users,
>
> Recently I'm working with precision calculations of spherical functions. Example, let,
>
> n = 150
> x = SetPrecision[120.3, 100]
> BesselY[n + 1/2, x] // Precision
> BesselJ[n+ 1/2, x] // Precision
>
>
> Yields 67.2708 and 96.9297 respectively. The two questions are:
> 1) Why does BesselY results in a worse than BesselJ?
> 2) How to redefine, BesselY to automatically output a result with a desired pecision?
>
> Note: Simply using N[expr,90], does not yield a result of expr with 90 precision but maintains the same 67.2708.
>
> Thanks,
> Antonio
>
>

Hi Antonio,

  to get an idea which input precision is needed to get an output 
precision of 90:

In[1]:= 
FindRoot[Precision[BesselY[301/2,SetPrecision[120.3,p]]]==90,{p,90},Evaluated->False]
Out[1]= {p->122.729}

the same for Accuracy gives {p -> 127.776}


hth,
Peter

[toc] | [prev] | [next] | [standalone]


#6705

FromAntonio Alvaro Ranha Neves <aneves@gmail.com>
Date2011-11-24 12:12 +0000
Message-ID<jalcav$snk$1@smc.vnet.net>
In reply to#6623
Thank you Oleksander, Peter, Oliver, and Richard for the reply.

@Oleksander
Why is Rationalize[120.3] better than SetPrecision[120.3, Infinity]?
Each command gives me a rational output,
1203/10
And
8465359924572979/70368744177664
Respectivaly.
I used 120.3 as an example, but my actual number is an irrational number with a high precision (output of a findroot)

@Peter
I really liked the FindRoot solution to the problem. It inspired me to write,
ListMap=ParallelTable[Replace[p,FindRoot[Precision[BesselY[n+1/2,SetPrecision[x,p]]]==90,{p,90},Evaluated->False]],{x,100},{n,100}];
ListPlot3D[ListMap,Mesh->None,ColorFunction->"SouthwestColors"]

Maybe this will shed some light on how the precision is affected by BesselY[n+1/2,x] algorithm. As one can see, when x is approximately n the required precision is maximum, and when x>n there are some =93instabilities=94.

[toc] | [prev] | [next] | [standalone]


#6728

FromPeter Falloon <pfalloon@gmail.com>
Date2011-11-25 10:04 +0000
Message-ID<janp86$b46$1@smc.vnet.net>
In reply to#6705
On Nov 24, 11:12 pm, Antonio Alvaro Ranha Neves <ane...@gmail.com>
wrote:
> Thank you Oleksander, Peter, Oliver, and Richard for the reply.
>
> @Oleksander
> Why is Rationalize[120.3] better than SetPrecision[120.3, Infinity]?
> Each command gives me a rational output,
> 1203/10
> And
> 8465359924572979/70368744177664
> Respectivaly.
> I used 120.3 as an example, but my actual number is an irrational number with a high precision (output of a findroot)
>
> @Peter
> I really liked the FindRoot solution to the problem. It inspired me to write,
> ListMap=ParallelTable[Replace[p,FindRoot[Precision[BesselY[n+1/2,SetPrecisi on[x,p]]]==90,{p,90},Evaluated->False]],{x,100},{n,100}];
> ListPlot3D[ListMap,Mesh->None,ColorFunction->"SouthwestColors"]
>
> Maybe this will shed some light on how the precision is affected by BesselY[n+1/2,x] algorithm. As one can see, when x is approximately n the required precision is maximum, and when x>n there are some =93instabilities=9 4.

FWIW, I think this loss of precision is an unavoidable feature of
these functions -- and not just an artifact of the calculation method.
It comes about because the function is a (finite) sum of terms with
alternating signs and a large range of magnitudes, such that the final
result is much smaller than its largest terms.

The following gives a feel for this:

Clear[x];
n = 150;
besselYTerms[x_] = List @@ Expand @ BesselY[n + 1/2, x]
ListPlot[Sign[#]Log[Abs[#]] & /@ besselYTerms[120.3`100]]

Cheers,
Peter.

[toc] | [prev] | [next] | [standalone]


#6742

From"Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com>
Date2011-11-25 10:11 +0000
Message-ID<janpkk$b84$1@smc.vnet.net>
In reply to#6705
On Thu, 24 Nov 2011 12:12:15 -0000, Antonio Alvaro Ranha Neves  
<aneves@gmail.com> wrote:

> @Oleksander
> Why is Rationalize[120.3] better than SetPrecision[120.3, Infinity]?
> Each command gives me a rational output,
> 1203/10
> And
> 8465359924572979/70368744177664
> Respectivaly.
> I used 120.3 as an example, but my actual number is an irrational number  
> with a high precision (output of a findroot)
>

Simply because, when representing 120.3 as a rational number, in most  
cases one probably prefers a value that reproduces the number actually  
entered rather than one corresponding to the machine-precision real number  
closest to it. In this case the result of SetPrecision[120.3, Infinity] is  
equal to 1203/10 + 1/351843720888320, i.e. slightly more than 120.3. If  
the number is only known to finite precision to start with rather than  
being entered as something that could conceivably represent an exact  
rational value, it most likely makes little difference whether Rationalize  
or SetPrecision is used.

Of course, in your example, it will probably be better to use the  
PrecisionGoal option to get a number having sufficient precision from  
FindRoot, rather than accepting the default precision and then using a  
rational representation of that output in further calculations.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web