

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Compute the logarithm base 10 with scimath in Python
To compute the logarithm base 10 with scimath, use the scimath.log10() method in Python Numpy. The method returns the log base 10 of the x value(s). If x was a scalar, so is out, otherwise an array object is returned.
For a log10() that returns NAN when real x < 0, use numpy.log10 (note, however, that otherwise numpy.log10 and this log10 are identical, i.e., both return -inf for x = 0, inf for x = inf, and, notably, the complex principle value if x.imag != 0). The 1st parameter, x is the value(s) whose log base 10 is (are) required.
Steps
At first, import the required libraries −
import numpy as np
Creating a numpy array using the array() method −
arr = np.array([10**1, -10**1, -10**2, 10**2, -10**3, 10**3])
Display the array −
print("Our Array...\n",arr)
Check the Dimensions −
print("\nDimensions of our Array...\n",arr.ndim)
Get the Datatype −
print("\nDatatype of our Array object...\n",arr.dtype)
Get the Shape −
print("\nShape of our Array object...\n",arr.shape)
To compute the logarithm base 10 with scimath, use the scimath.log10() method −
print("\nResult (log10)...\n",np.emath.log10(arr))
Example
import numpy as np # Creating a numpy array using the array() method arr = np.array([10**1, -10**1, -10**2, 10**2, -10**3, 10**3]) # Display the array print("Our Array...\n",arr) # Check the Dimensions print("\nDimensions of our Array...\n",arr.ndim) # Get the Datatype print("\nDatatype of our Array object...\n",arr.dtype) # Get the Shape print("\nShape of our Array object...\n",arr.shape) # To compute the logarithm base 10 with scimath, use the scimath.log10() method in Python Numpy print("\nResult (log10)...\n",np.emath.log10(arr))
Output
Our Array... [ 10 -10 -100 100 -1000 1000] Dimensions of our Array... 1 Datatype of our Array object... int64 Shape of our Array object... (6,) Result (log10)... [1.+0.j 1.+1.36437635j 2.+1.36437635j 2.+0.j 3.+1.36437635j 3.+0.j ]
- Related Questions & Answers
- Compute the logarithm base n with scimath in Python
- Compute the logarithm base 2 with scimath in Python
- Compute the natural logarithm with scimath in Python
- Compute the inverse cosine with scimath in Python
- Compute the inverse sine with scimath in Python
- Get the base 10 logarithm of a value in Java
- Compute the inverse hyperbolic tangent with scimath in Python
- Compute the Natural Logarithm in Python
- Return the base 10 logarithm of the input array element-wise in Numpy
- Compute the square root of complex inputs with scimath in Python
- Compute the Natural logarithm for complex-valued input in Python
- Return the base 2 logarithm of the input array in Python
- Return the base 2 logarithm for complex value input in Python
- Complement of Base 10 Integer in Python
- Compute the sign and natural logarithm of the determinant of an array in Python