fn

modified_bessel_k0

Tensor
modified_bessel_k0(x: Tensor)
source

Modified Bessel function of the second kind, order 0.

Computes K0(x)K_0(x), the exponentially decaying solution of the modified Bessel equation at order 0. Appears as the Green's function of the 2D Helmholtz operator and as the log-density kernel of certain heavy-tailed distributions.

Parameters

xTensor
Input tensor; only x>0x > 0 is in the domain. Any floating-point dtype.

Returns

Tensor

K0(x)K_0(x) element-wise, same shape and dtype as x.

Notes

Asymptotic forms:

K0(x)log(x/2)γ  as x0+,K0(x)π2xex  as x.K_0(x) \sim -\log(x/2) - \gamma \;\text{as } x \to 0^+, \qquad K_0(x) \sim \sqrt{\frac{\pi}{2x}}\, e^{-x} \;\text{as } x \to \infty.

Implementation: Abramowitz & Stegun §9.8 polynomial branches at the cutoff x=2x = 2, accurate to 107\approx 10^{-7}. For numerically stable evaluation at large arguments use scaled_modified_bessel_k0.

Examples

>>> import lucid
>>> from lucid.special import modified_bessel_k0
>>> modified_bessel_k0(lucid.tensor([0.5, 1.0, 5.0]))
Tensor([0.9244, 0.4210, 0.0037])