scipy.special.cosm1#
- scipy.special.cosm1(x, out=None) = <ufunc 'cosm1'>#
cos(x) - 1 for use when x is near zero.
- Parameters:
- xarray_like
Real valued argument.
- outndarray, optional
Optional output array for the function results.
- Returns:
- scalar or ndarray
Values of
cos(x) - 1
.
Notes
cosm1
has experimental support for Python Array API Standard compatible backends in addition to NumPy. Please consider testing these features by setting an environment variableSCIPY_ARRAY_API=1
and providing CuPy, PyTorch, JAX, or Dask arrays as array arguments. The following combinations of backend and device (or other capability) are supported.Library
CPU
GPU
NumPy
✅
n/a
CuPy
n/a
✅
PyTorch
✅
⛔
JAX
⚠️ no JIT
⛔
Dask
✅
n/a
See Support for the array API standard for more information.
Examples
>>> import numpy as np >>> import scipy.special as sc
It is more accurate than computing
cos(x) - 1
directly forx
around 0.>>> x = 1e-30 >>> np.cos(x) - 1 0.0 >>> sc.cosm1(x) -5.0000000000000005e-61