What is the numpy.expm1() function in NumPy?
Overview
The numpy.expm1 function in NumPy computes the exponential minus one (exp(x) - 1) for all elements of a given input array.
Syntax
numpy.expm1(x, out=None, where=True, *)
Syntax for the numpy.expm1() function
Parameter values
The numpy.expm1() function takes the following parameter values:
x: This is the array-like object that contains the input values. It is required.out: This is the location where the result obtained is stored. It is optional.where: This is the condition over which the broadcast is done over the input. It is optional.**kwargs: This represents keyword-only arguments.
Return value
The numpy.expm1 function returns an element-wise exponential minus one of the input array.
Example
import numpy as np# Implementing the numpy.expm1() functionprint(np.expm1(5))print(np.expm1(0.5))print(np.expm1(1e-10))
Explanation
- Line 1: We import the
numpymodule. - Lines 4–6: We implement the
numpy.expm1()function on different input values. Then, we print each result to the console.