Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

nump
log10

What is the log10 function in numpy?

Rukhshan Haroon

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

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

Syntax

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. The log10 method is a universal function.

Arguments

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.

Return value

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 x is scalar, then return type is scalar.

Example

The following example demonstrates how to use the log10 function.

import numpy as np
print(np.log10([0 , 1, 4, 6]))

RELATED TAGS

nump
log10

CONTRIBUTOR

Rukhshan Haroon
Copyright ©2022 Educative, Inc. All rights reserved

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring