In numpy, a library of the high-level programming language Python, we can use the log10 function to calculate the base 10 logarithm element-wise.
The numpy library must be imported to use the log10 function:
import numpy as np
np.log10(x, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj])= <ufunc 'log10'>
A universal function (
ufunc) is a function that operates on ndarrays in an element-by-element fashion. Thelog10method is a universal function.
The log10 function only accepts the following arguments:
x: An array-like structure on the contents of which the log10 function will be applied.out: (optional) The function’s output is stored at this location.where: (optional) If set True, a universal function is calculated at this position.casting: (optional) This enables the user to decide how the data will be cast. If set as same_kind, safe casting will take place.order: (optional) This determines the memory layout of the output. For example, if set as K, the function reads data in the order they are written in memory.dtype: (optional) This is the data type of the array.subok: (optional) To pass subclasses, subokmust be set as True.The log10 function returns an array of type float.
If a number can not be represented as a real number or infinity, it returns nan, and the invalid floating point error flag is set. The log10 function has branch cuts at [-inf,0]
and is continuous above it for complex inputs.
For real inputs, the log10 function returns real input.  It treats the floating-point negative zero as an infinitesimal negative number, following the C99 standard.
If
xis scalar, then return type is scalar.
The following example demonstrates how to use the log10 function.
import numpy as npprint(np.log10([0 , 1, 4, 6]))
Free Resources