[SciPy-user] modified bessel fn of second kind K(n,z)

Gary Pajer gpajer at rider.edu
Mon Apr 25 10:53:58 CDT 2005


Robert Kern wrote:

> r help wrote:
>
>> hi
>>
>> i am trying to use the modified bessel function of the
>> second kind, K_n(z)
>> K is called the mod. bes. fn of second kind on
>> mathworld; K is called the mod. bes. fn of third kind in scipy.
>>
>> the integer order function special.kn(-20,3) gives the
>> same result on both mathematica and scipy:
>>
>> In [3]: special.kn(-20,3)
>> Out[3]: 16254643952204.371
>>
>> however the real valued special.kv(-20,3) gives
>> different answers each time i call it:
>>
>> In [2]: special.kv(-20,3)
>> Out[2]: -1.9924087524414062
>>
>> In [4]: special.kv(-20,3)
>> Out[4]: 166558.53135225689
>>
>> In [5]: special.kv(-20,3)
>> Out[5]: 166541.5313522513
>
>
> [etc]
>
> On a Mac:
>
> In [1]:special.kv(-20,3)
> Out[1]:-1.990829468774475
>
> In [2]:special.kv(-20,3)
> Out[2]:9.3170894640213688e-309
>
> In [3]:special.kv(-20,3)
> Out[3]:9.3170894640213688e-309
>
> Hmmm. Something fishy's going on here.
>
Yet

In [29]: scipy.special.kv(-20,3.)
Out[29]: 0.0

In [30]: scipy.special.kv(20,3.)
Out[30]: 16254643952204.338

Notice that the 3.  is a float .  The behavior is stable when the second 
argument is a float.
It doesn't seem to like negative orders and integer arguments in the 
second slot.



More information about the SciPy-user mailing list