cmath.atanh() Method in Python:
The cmath.atanh() method returns the complex number’s inverse hyperbolic tangent.
There are two types of branch cuts:
- Extends along the real axis from 1 to ∞, and is continuous from below.
- Extends along the real axis from -1 to -∞, and is continuous from above.
Syntax:
cmath.atanh(x)
Parameters
x: This is Required. It is a number used to calculate the inverse hyperbolic arctangent of
Return Value:
Returns a complex value that represents the complex number’s inverse hyperbolic tangent.
Examples:
Example1:
Input:
Given Complex Number = 3-4j
Output:
The given complex number's (3-4j) inverse hyperbolic tangent value = (0.1175009073114339-1.4099210495965755j)
Example2:
Input:
Given realpart = 5 Given imaginary part = 3
Output:
The given complex number's (5+3j) inverse hyperbolic tangent value = (0.14694666622552977+1.4808695768986575j)
Note: The above input format is for dynamic input.
cmath.atanh() Method with Examples in Python
Method #1: Using Built-in Functions (Static Input)
Approach:
- Import cmath module(for complex number operations) using the import keyword.
- Give the complex number as static input and store it in a variable.
- Pass the given complex number as an argument to the cmath.atanh() method that returns the given complex number’s inverse hyperbolic tangent value.
- Store it in another variable.
- Print the inverse hyperbolic tangent value of the given complex number.
- The Exit of the Program.
Below is the implementation:
# Import cmath module(for complex number operations) using the import keyword.
import cmath
# Give the complex number as static input and store it in a variable.
complexnumb = 3-4j
# Pass the given complex number as an argument to the cmath.atanh() method that
# returns the given complex number's inverse hyperbolic tangent value.
# Store it in another variable.
rslt = cmath.atanh(complexnumb)
# Print the inverse hyperbolic tangent value of the given complex number.
print("The given complex number's", complexnumb,
"inverse hyperbolic tangent value = ")
print(rslt)
Output:
The given complex number's (3-4j) inverse hyperbolic tangent value = (0.1175009073114339-1.4099210495965755j)
Method #2: Using Built-in Functions (User Input)
Approach:
- Import cmath module(for complex number operations) using the import keyword.
- Give the real part and imaginary part of the complex number as user input using map(), int(), split().
- Store it in two variables.
- Using a complex() function convert those two variables into a complex number and store it in a variable.
- Pass the given complex number as an argument to the cmath.atanh() method that returns the given complex number’s inverse hyperbolic tangent value.
- Store it in another variable.
- Print the inverse hyperbolic tangent value of the given complex number.
- The Exit of the Program.
Below is the implementation:
# Import cmath module(for complex number operations) using the import keyword.
import cmath
# Give the real part and imaginary part of the complex number as user input
# using map(), int(), split().
# Store it in two variables.
realnumb, imaginarynumb = map(int, input(
'Enter real part and complex part of the complex number = ').split())
# Using a complex() function convert those two variables into a complex number.
complexnumb = complex(realnumb, imaginarynumb)
# Pass the given complex number as an argument to the cmath.atanh() method that
# returns the given complex number's inverse hyperbolic tangent value.
# Store it in another variable.
rslt = cmath.atanh(complexnumb)
# Print the inverse hyperbolic tangent value of the given complex number.
print("The given complex number's", complexnumb,
"inverse hyperbolic tangent value = ")
print(rslt)
Output:
Enter real part and complex part of the complex number = 5 3 The given complex number's (5+3j) inverse hyperbolic tangent value = (0.14694666622552977+1.4808695768986575j)