fn

modified_bessel_k1

Tensor
modified_bessel_k1(x: Tensor)
source

Modified Bessel function of the second kind, order 1.

Computes K1(x)K_1(x), the order-one analogue of K0K_0. Diverges as 1/x1/x near the origin and decays exponentially for large argument. Appears in Generalised-Inverse-Gaussian and Normal-Inverse-Gaussian log-densities.

Parameters

xTensor
Input tensor; only x>0x > 0 is in the domain.

Returns

Tensor

K1(x)K_1(x) element-wise, same shape and dtype as x.

Notes

Asymptotic forms:

K1(x)1x  as x0+,K1(x)π2xex  as x.K_1(x) \sim \frac{1}{x} \;\text{as } x \to 0^+, \qquad K_1(x) \sim \sqrt{\frac{\pi}{2x}}\, e^{-x} \;\text{as } x \to \infty.

Implementation: Abramowitz & Stegun §9.8 two-branch polynomial, accurate to 107\approx 10^{-7}. Use scaled_modified_bessel_k1 for numerically stable evaluation at large x.

Examples

>>> import lucid
>>> from lucid.special import modified_bessel_k1
>>> modified_bessel_k1(lucid.tensor([0.5, 1.0, 5.0]))
Tensor([1.6564, 0.6019, 0.0040])