Modified Bessel function of the first kind, order 0. Usually denoted :math:`I_0`. Parameters ---------- x : array_like of float Argument of the Bessel function. Returns ------- out : ndarray, shape = x.shape, dtype = float The modified Bessel funct
(x)
| 3543 | |
| 3544 | @array_function_dispatch(_i0_dispatcher) |
| 3545 | def i0(x): |
| 3546 | """ |
| 3547 | Modified Bessel function of the first kind, order 0. |
| 3548 | |
| 3549 | Usually denoted :math:`I_0`. |
| 3550 | |
| 3551 | Parameters |
| 3552 | ---------- |
| 3553 | x : array_like of float |
| 3554 | Argument of the Bessel function. |
| 3555 | |
| 3556 | Returns |
| 3557 | ------- |
| 3558 | out : ndarray, shape = x.shape, dtype = float |
| 3559 | The modified Bessel function evaluated at each of the elements of `x`. |
| 3560 | |
| 3561 | See Also |
| 3562 | -------- |
| 3563 | scipy.special.i0, scipy.special.iv, scipy.special.ive |
| 3564 | |
| 3565 | Notes |
| 3566 | ----- |
| 3567 | The scipy implementation is recommended over this function: it is a |
| 3568 | proper ufunc written in C, and more than an order of magnitude faster. |
| 3569 | |
| 3570 | We use the algorithm published by Clenshaw [1]_ and referenced by |
| 3571 | Abramowitz and Stegun [2]_, for which the function domain is |
| 3572 | partitioned into the two intervals [0,8] and (8,inf), and Chebyshev |
| 3573 | polynomial expansions are employed in each interval. Relative error on |
| 3574 | the domain [0,30] using IEEE arithmetic is documented [3]_ as having a |
| 3575 | peak of 5.8e-16 with an rms of 1.4e-16 (n = 30000). |
| 3576 | |
| 3577 | References |
| 3578 | ---------- |
| 3579 | .. [1] C. W. Clenshaw, "Chebyshev series for mathematical functions", in |
| 3580 | *National Physical Laboratory Mathematical Tables*, vol. 5, London: |
| 3581 | Her Majesty's Stationery Office, 1962. |
| 3582 | .. [2] M. Abramowitz and I. A. Stegun, *Handbook of Mathematical |
| 3583 | Functions*, 10th printing, New York: Dover, 1964, pp. 379. |
| 3584 | https://personal.math.ubc.ca/~cbm/aands/page_379.htm |
| 3585 | .. [3] https://metacpan.org/pod/distribution/Math-Cephes/lib/Math/Cephes.pod#i0:-Modified-Bessel-function-of-order-zero |
| 3586 | |
| 3587 | Examples |
| 3588 | -------- |
| 3589 | >>> import numpy as np |
| 3590 | >>> np.i0(0.) |
| 3591 | array(1.0) |
| 3592 | >>> np.i0([0, 1, 2, 3]) |
| 3593 | array([1. , 1.26606588, 2.2795853 , 4.88079259]) |
| 3594 | |
| 3595 | """ |
| 3596 | x = np.asanyarray(x) |
| 3597 | if x.dtype.kind == 'c': |
| 3598 | raise TypeError("i0 not supported for complex values") |
| 3599 | if x.dtype.kind != 'f': |
| 3600 | x = x.astype(float) |
| 3601 | x = np.abs(x) |
| 3602 | return piecewise(x, [x <= 8.0], [_i0_1, _i0_2]) |