Open In App

Compute the logarithm base 10 with NumPy-scimath in Python

Last Updated : 25 Apr, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

The NumPy package provides us with numpy.lib.scimath.log10 to Compute the logarithm base 10 with scimath in Python. Let’s go through the syntax as per the following to understand the method much better.

Syntax: lib.scimath.log10(x)

Returns the “primary value” of (see numpy.log10). This is a real number if real x > 0 (log10(0) = -inf, log10(np.inf) = inf). The complicated principle value is returned if none of the above conditions are met.

Parameters:

  • x: input array

Returns: 

array or scalar. if x is scalar , a scalar is returned. if x is array, a computed array is returned.

Example 1:

The NumPy package is imported. we create an array and find its shape, dimensions, and dtype with the .shape, .ndim and .dtype attributes. lib.scimath.log10() method is used to find the logarithm base 10. 

Python3




# import packages
import numpy as np
 
# Creating an array
array = np.array([10,20,30])
print(array)
 
# shape of the array is
print("Shape of the array is : ",array.shape)
 
# dimension of the array
print("The dimension of the array is : ",array.ndim)
 
# Datatype of the array
print("Datatype of our Array is : ",array.dtype)
 
# computing log10 for the given array
print(np.lib.scimath.log10(array))


Output:

[10 20 30]
Shape of the array is :  (3,)
The dimension of the array is :  1
Datatype of our Array is :  int64
[1.         1.30103    1.47712125]

Example 2:

As described np.lib.scimath.log10() returns infinity when np.inf is passed, -inf is returned when 0 is passed, and when -inf is passed inf is returned. 

Python3




import numpy as np
 
# computing log10
print(np.lib.scimath.log10(np.inf))
print(np.lib.scimath.log10(-np.inf))
print(np.lib.scimath.log10(0))


Output:

inf
(inf+1.3643763538418412j)
-inf


Similar Reads

Compute the logarithm base n with scimath in Python
In this article, we will be looking at the approach to computing the logarithm base n with scimath in Python. The NumPy package provides us the numpy.lib.scimath.logn() method to compute the logarithmic base n. the method takes log base n of x. Let's check the syntax to know the method better. The solution is computed and returned in the complex do
2 min read
How to compute natural, base 10, and base 2 logarithm for all elements in a given array using NumPy?
numpy.log( ) function in Python returns natural logarithmic of the input where the natural logarithm of a number is its logarithm to the base of the mathematical constant e, where e is an irrational and transcendental number approximately equal to 2.718281828459. Syntax: numpy.log(arr,out) Parameters: arr : Input Value. Can be scalar and numpy ndim
2 min read
Compute the inverse sine with scimath using NumPy in Python
In this article, we will cover how to compute the inverse sine with scimath in Python. np.emath.arcsin method A NumPy array can be created in different ways like, by various numbers, and by defining the size of the Array. It can also be created with the use of various data types such as lists, tuples, etc. NumPy method np.emath.arcsin() method from
2 min read
Compute the square root of complex inputs with scimath in Python
In this article, we will cover how to compute the square root of complex inputs with scimath in Python using NumPy. ExampleInput: [-1 -2] Output: [0.+1.j 0.+1.41421356j] Explanation: Square root of complex input.NumPy.emath.sqrt method The np.emath.sqrt() method from the NumPy library calculates the square root of complex inputs. A complex value is
3 min read
Compute the inverse cosine with scimath in Python
In this article, we will compute the inverse cosine with scimath in Python using NumPy. numpy.arccos method A NumPy array can be created in different ways like, by various numbers, and by defining the size of the Array. It can also be created with the use of various data types such as lists, tuples, etc. The np.emath.arccos() method from the NumPy
2 min read
Compute the natural logarithm of one plus each element in floating-point accuracy Using NumPy
Let's see the program for computing the natural logarithm of one plus each element of a given array in floating-point accuracy using NumPy library. For doing this task we are using numpy.log1p() function of NumPy. This function returns the array of natural logarithm of one plus each element of the input array. Syntax: numpy.log1p(arr, out = None, *
1 min read
Compute the sign and natural logarithm of the determinant of an array in Python
In this article, we will cover how to compute the sign and natural logarithm of the determinant of an array in Python using NumPy. numpy.linalg.slogdet() method The numpy.linalg.slogdet() method provides us to compute the sign and natural logarithm of the determinant of an array in Python. A call to slogdet may overflow or underflow if the determin
3 min read
Return the result of the power to which the negative input value is raised with scimath in Python
In this article, we will discuss how to Return the result of the power to which the negative input value is raised with scimath in Python and NumPy. Example Input: [-1,-2,-3] Output: [1.-0.j 4.-0.j 9.-0.j] Explanation: It return x to the power p, (x**p), If x contains negative values, the output is converted to the complex domain. NumPy.lib.scimath
3 min read
Return the result of the power to which the input value is raised with scimath in Python
This article will discuss how to Return the result of the power to which the input value is raised with sci math in Python using NumPy. Example Input: [1,2,3] Output: [1 4 9] Explanation: It returns x to the power p, (x**p).NumPy.lib.scimath.power method The lib.scimath.power() method from the NumPy package is used to return the power to which the
2 min read
Compute the outer product of two given vectors using NumPy in Python
In Python, we can use the outer() function of the NumPy package to find the outer product of two matrices. Syntax : numpy.outer(a, b, out = None) Parameters : a : [array_like] First input vector. Input is flattened if not already 1-dimensional. b : [array_like] Second input vector. Input is flattened if not already 1-dimensional. out : [ndarray, op
3 min read