np.exp() do in numpy?np.exp() calculates the exponential of all elements in the input array. It raises the mathematical constant e (about 2.718) to the power of each element.
np.log() in numpy?np.log() computes the natural logarithm (log base e) of each element in the input array. It is the inverse operation of np.exp().
x = np.array([1, 2, 3]), what is the output of np.exp(x)?The output is an array where each element is e raised to the power of the corresponding element in x:
[e^1, e^2, e^3] ≈ [2.718, 7.389, 20.086]
np.log() to an array containing zero or negative numbers?Applying np.log() to zero or negative numbers results in -inf or nan values and usually raises a warning, because the natural logarithm is not defined for those values.
np.exp() and np.log() related mathematically?np.exp() and np.log() are inverse functions. This means np.exp(np.log(x)) = x for positive x, and np.log(np.exp(x)) = x for any real x.
np.exp(0) return?Since e^0 = 1, np.exp(0) returns 1.
np.log() calculates the natural logarithm of each element.
np.log(np.exp(3))?Because np.log() and np.exp() are inverse functions, the result is 3.
np.log(-1) return?Natural logarithm of negative numbers is not defined in real numbers, so numpy returns nan and raises a warning.
arr = np.array([1, 2, 3]), what does np.exp(arr) compute?np.exp(arr) calculates e to the power of each element in the array.
np.exp() and np.log() do and how they are related.np.log().