python cmath.log10() Function



The Python cmath.log10() function is used to acquire the logarithm of the given complex number with base-10. If we pass a string value as a parameter to this function a TypeError will be generated.

Syntax

Following is the basic syntax for the cmath.log10() function −

cmath.log10(z)

Parameters

This function accepts a numeric expression of a complex number as a parameter.

Return Value

This method returns base-10 logarithm of z from z>(0,-).

Example 1

Let us discuss the basic Python program of cmath.log10() value with complex number.

import cmath
x=2+3j
y=cmath.log10(x)
print(y)

Output

When we run the above program,it produces following result −

(0.5569716761534184+0.42682189085546657j)

Example 2

In the below code we are creating tuple and list of numbers. Then, in the log10 method, we will find the logarithm of the value at index 2 in the tuple and at index 3 in the list using cmath.log10().

import cmath
Tuple = (6,11,-24,35,-65)
List = [5,15,-25,45.67,-75]
print('The log10() value of Tuple is:',cmath.log10(Tuple[2]))
print('The log10() value of List is:',cmath.log10(List[3]))

Output

The above program generates the following output−

The log10() value of Tuple is: (1.380211241711606+1.3643763538418412j)
The log10() value of List is: (1.6596310116070006+0j)

Example 3

If we pass string as an argument then this method returns TypeError. In the below code we are acquiring the cmath.log10() value of a string.

import cmath
y='TutorialsPoint'
print('The log10() value of string is:',math.log10(y))

Output

We will get the output as shown in the below while executing the code −

Traceback (most recent call last):
  File "/home/cg/root/83980/main.py", line 6, in <module>
    print('The log10() value of string is:',cmath.log10(y))
TypeError: must be real number, not str

Example 4

If we are passing zero as an argument to this method ,it raises ValueError.

import cmath
x=0.0
res=cmath.log10(x)
print('The result for x is:',res)

Output

The output obtained is as follows −

Traceback (most recent call last):
  File "/home/cg/root/91202/main.py", line 3, in <module>
    res=cmath.log10(x)
ValueError: math domain error
python_modules.htm
Advertisements
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy