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