I have a program that includes the command to evaluate the K-Bessel
function using Pari: it will sometimes be called with arguments like
the following:

bessel_K(5*i,320,"pari",100)

which evaluates the Bessel function at index (first variable) 5i,
value (second variable) 320, with 100 precision.

This exhibits some unexpected behavior when called from within SAGE,
as follows. The bessel_K fucntion, with fixed index, and growing
second variable exhibits exhibits exponential decay, as shown by these
(correct) calculations performed in Pari itself:

? besselk(5*I,10)

%21 = 0.0000052781217651491219933022050407280366666 + 0.E-63*I

? besselk(5*I,20)

%22 = 0.00000000031100590842180056295117848690804514567 +
1.0123223351797578055 E-56*I

? besselk(5*I,50)

%23 = 2.6618248851542254648076325142970767971 E-23 + 0.E-99*I

? besselk(5*I,100)

%24 = 4.1118977682833709016799697590620762478 E-45 + 0.E-102*I

? besselk(5*I,200)

%25 = 1.1515969255360280546036312473791321981 E-88 +
1.7485172637427202649 E-133*I

(the imaginary parts in the answer are really 0 and can easily be
removed).



however, the same calculations performed with the SAGE interface to
PARI yield:

sage: bessel_K(5*i,10,"pari",100)

5.2781217651491219933022050407e-6

sage: bessel_K(5*i,20,"pari",100)

3.1100590842180056295117848685e-10

sage: bessel_K(5*i,50,"pari",100)

2.6281390403939624075513589787e-23

sage: bessel_K(5*i,100,"pari",100)

-0.029088364960963220354623866640 - 0.040723710945348508499861545085*I

sage: bessel_K(5*i,200,"pari",100)

-4.3246147682420463563103557554e40 +
4.3246147682420463567825924037e40*I

So they agree until the second variable reaches at least 50, but then
SAGE starts reporting wrong answers.

Apparently, SAGE is interpreting very small floating point numbers as
very large ones, "wrapping around" the exponents. What I would like to
do is (obviously) have SAGE report the real answer, or failing that,
have it instead judge a very small floating point number to be 0 and
return 0 as the answer instead of a very large floating point.

Thanks,
Eliot

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to