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)
| 3429 | |
| 3430 | @array_function_dispatch(_i0_dispatcher) |
| 3431 | def i0(x): |
| 3432 | """ |
| 3433 | Modified Bessel function of the first kind, order 0. |
| 3434 | |
| 3435 | Usually denoted :math:`I_0`. |
| 3436 | |
| 3437 | Parameters |
| 3438 | ---------- |
| 3439 | x : array_like of float |
| 3440 | Argument of the Bessel function. |
| 3441 | |
| 3442 | Returns |
| 3443 | ------- |
| 3444 | out : ndarray, shape = x.shape, dtype = float |
| 3445 | The modified Bessel function evaluated at each of the elements of `x`. |
| 3446 | |
| 3447 | See Also |
| 3448 | -------- |
| 3449 | scipy.special.i0, scipy.special.iv, scipy.special.ive |
| 3450 | |
| 3451 | Notes |
| 3452 | ----- |
| 3453 | The scipy implementation is recommended over this function: it is a |
| 3454 | proper ufunc written in C, and more than an order of magnitude faster. |
| 3455 | |
| 3456 | We use the algorithm published by Clenshaw [1]_ and referenced by |
| 3457 | Abramowitz and Stegun [2]_, for which the function domain is |
| 3458 | partitioned into the two intervals [0,8] and (8,inf), and Chebyshev |
| 3459 | polynomial expansions are employed in each interval. Relative error on |
| 3460 | the domain [0,30] using IEEE arithmetic is documented [3]_ as having a |
| 3461 | peak of 5.8e-16 with an rms of 1.4e-16 (n = 30000). |
| 3462 | |
| 3463 | References |
| 3464 | ---------- |
| 3465 | .. [1] C. W. Clenshaw, "Chebyshev series for mathematical functions", in |
| 3466 | *National Physical Laboratory Mathematical Tables*, vol. 5, London: |
| 3467 | Her Majesty's Stationery Office, 1962. |
| 3468 | .. [2] M. Abramowitz and I. A. Stegun, *Handbook of Mathematical |
| 3469 | Functions*, 10th printing, New York: Dover, 1964, pp. 379. |
| 3470 | https://personal.math.ubc.ca/~cbm/aands/page_379.htm |
| 3471 | .. [3] https://metacpan.org/pod/distribution/Math-Cephes/lib/Math/Cephes.pod#i0:-Modified-Bessel-function-of-order-zero |
| 3472 | |
| 3473 | Examples |
| 3474 | -------- |
| 3475 | >>> np.i0(0.) |
| 3476 | array(1.0) |
| 3477 | >>> np.i0([0, 1, 2, 3]) |
| 3478 | array([1. , 1.26606588, 2.2795853 , 4.88079259]) |
| 3479 | |
| 3480 | """ |
| 3481 | x = np.asanyarray(x) |
| 3482 | if x.dtype.kind == 'c': |
| 3483 | raise TypeError("i0 not supported for complex values") |
| 3484 | if x.dtype.kind != 'f': |
| 3485 | x = x.astype(float) |
| 3486 | x = np.abs(x) |
| 3487 | return piecewise(x, [x <= 8.0], [_i0_1, _i0_2]) |
| 3488 |