Calculates the natural logarithm (the base-e logarithm) of a number.
1def setup(): 2 i = 12 3 py5.println(py5.log(i)) 4 py5.println(log10(i)) 5 6 j = -5 7 py5.println(py5.log(j)) 8 9# Calculates the base-10 logarithm of a number 10# use this if you don't want to use numpy's log10 function 11def log10(x): 12 return (py5.log(x) / py5.log(10))
Calculates the natural logarithm (the base-e logarithm) of a number. This function expects the
n parameter to be a value greater than 0.0. This function is the compliment to exp().
This function makes a call to the numpy
log() function. If the
n parameter is less than or equal to 0.0, you will see a
RuntimeWarning and the returned result will be numpy’s Not-a-Number value,
log(value: Union[float, npt.ArrayLike]) -> Union[float, npt.NDArray]
value: Union[float, npt.ArrayLike] - number greater than 0.0
Updated on February 26, 2022 13:22:44pm UTC