A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.tutorialspoint.com/python/python_cmath_log_function.htm below:

Python cmath.log() Function

Python cmath.log() Function

The Python cmath.log() function provides a way to perform logarithm operation on complex numbers. This method returns the logarithm of a complex number with respect to base.

If there is a single argument passed then it calculates the natural logarithm with base e. In case of multiple arguments, this method returns the logarithm of the initial argument with the base of the final argument.

If the specified argument is zero or negative then this returns ValueError, and if it is not a number then this returns TypeError.

Syntax

Following is the syntax of the Python cmath.log() method −

cmath.log(a, base = None)
Parameters

This method accepts following parameters −

Return Value

This function returns the logarithm of the complex number.

Example 1

Following is the basic example of the Python cmath.log() function. Here we are trying to calculate the simple logarithm with base 10.

import cmath
x=cmath.log(5, 10)
print(x)
Output

The output of the above code is as follows −

(0.6989700043360187+0j)
Example 2

In this example, we are calculating logarithm of the given complex number using cmath.log().

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

The output obtained is as follows −

(1.2824746787307684+0.982793723247329j)

python_modules.htm


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4