Compute the logarithm base 10 of `x`. Return the "principal value" (for a description of this, see `numpy.log10`) of :math:`log_{10}(x)`. For real `x > 0`, this is a real number (``log10(0)`` returns ``-inf`` and ``log10(np.inf)`` returns ``inf``). Otherwise, the complex princi
(x)
| 291 | @set_module('numpy.lib.scimath') |
| 292 | @array_function_dispatch(_unary_dispatcher) |
| 293 | def log10(x): |
| 294 | """ |
| 295 | Compute the logarithm base 10 of `x`. |
| 296 | |
| 297 | Return the "principal value" (for a description of this, see |
| 298 | `numpy.log10`) of :math:`log_{10}(x)`. For real `x > 0`, this |
| 299 | is a real number (``log10(0)`` returns ``-inf`` and ``log10(np.inf)`` |
| 300 | returns ``inf``). Otherwise, the complex principle value is returned. |
| 301 | |
| 302 | Parameters |
| 303 | ---------- |
| 304 | x : array_like or scalar |
| 305 | The value(s) whose log base 10 is (are) required. |
| 306 | |
| 307 | Returns |
| 308 | ------- |
| 309 | out : ndarray or scalar |
| 310 | The log base 10 of the `x` value(s). If `x` was a scalar, so is `out`, |
| 311 | otherwise an array object is returned. |
| 312 | |
| 313 | See Also |
| 314 | -------- |
| 315 | numpy.log10 |
| 316 | |
| 317 | Notes |
| 318 | ----- |
| 319 | For a log10() that returns ``NAN`` when real `x < 0`, use `numpy.log10` |
| 320 | (note, however, that otherwise `numpy.log10` and this `log10` are |
| 321 | identical, i.e., both return ``-inf`` for `x = 0`, ``inf`` for `x = inf`, |
| 322 | and, notably, the complex principle value if ``x.imag != 0``). |
| 323 | |
| 324 | Examples |
| 325 | -------- |
| 326 | >>> import numpy as np |
| 327 | |
| 328 | (We set the printing precision so the example can be auto-tested) |
| 329 | |
| 330 | >>> np.set_printoptions(precision=4) |
| 331 | |
| 332 | >>> np.emath.log10(10**1) |
| 333 | 1.0 |
| 334 | |
| 335 | >>> np.emath.log10([-10**1, -10**2, 10**2]) |
| 336 | array([1.+1.3644j, 2.+1.3644j, 2.+0.j ]) |
| 337 | |
| 338 | """ |
| 339 | x = _fix_real_lt_zero(x) |
| 340 | return nx.log10(x) |
| 341 | |
| 342 | |
| 343 | def _logn_dispatcher(n, x): |
searching dependent graphs…