Python Tutorial Python Advanced Python References Python Libraries

Python cmath - log10() Function



The Python cmath.log10() function returns the base-10 logarithm of a given complex number z. It is a function on complex plane, and has a branch cut, from 0 along the negative real axis to -∞, continuous from above.

Syntax

cmath.log10(z)

Parameters

z Required. Specify the number.

Return Value

Returns the base-10 logarithm of z.

Example:

In the example below, log10() function is used to calculate the base-10 logarithm of a given complex number.

import cmath

z1 = 2 + 2j
z2 = 2
z3 = 2j

print("cmath.log10(z1):", cmath.log10(z1))
print("cmath.log10(z2):", cmath.log10(z2))
print("cmath.log10(z3):", cmath.log10(z3))

The output of the above code will be:

cmath.log10(z1): (0.4515449934959718+0.3410940884604603j)
cmath.log10(z2): (0.30102999566398114+0j)
cmath.log10(z3): (0.30102999566398114+0.6821881769209206j)

❮ Python cMath Module

5