SciPy

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.

See also

expm1, log1p

Examples

>>> import scipy.special as sc

It is more accurate than computing cos(x) - 1 directly for x around 0.

>>> x = 1e-30
>>> np.cos(x) - 1
0.0
>>> sc.cosm1(x)
-5.0000000000000005e-61

Previous topic

scipy.special.expm1

Next topic

scipy.special.round