# Compute the inverse hyperbolic tangent with scimath in Python

PythonNumpyServer Side ProgrammingProgramming

To compute the inverse hyperbolic tangent with arctanh, use the numpy.emath.arctanh() method in Python. Returns the “principal value” of arctanh(x). For real x such that abs(x) < 1, this is a real number. If abs(x) > 1, or if x is complex, the result is complex. Finally, x = 1 returnsinf and x=-1 returns -inf.

The method returns the inverse hyperbolic tangent(s) of the x value(s). If x was a scalar so is out, otherwise an array is returned. The 1st parameter is the value(s) whose arctanh is (are) required.

## Steps

At first, import the required libraries −

import numpy as np

Create a numpy array using the array() method −

arr = np.array([0, 1j, 2j])


Display the array −

print("Array...\n", arr)

Get the type of the array −

print("\nOur Array type...\n", arr.dtype)


Get the dimensions of the Array −

print("\nOur Array Dimensions...\n",arr.ndim)

To compute the inverse hyperbolic tangent with arctanh, use the numpy.emath.arctanh() method in Python −

print("\nResult...\n",np.emath.arctanh(arr))


## Example

import numpy as np

# Create a numpy array using the array() method
arr = np.array([0, 1j, 2j])

# Display the array
print("Array...\n", arr)

# Get the type of the array
print("\nOur Array type...\n", arr.dtype)

# Get the dimensions of the Array
print("\nOur Array Dimensions...\n",arr.ndim)

# Get the number of elements in the Array
print("\nNumber of elements...\n", arr.size)

# To compute the inverse hyperbolic tangent with arctanh, use the numpy.emath.arctanh() method in Python
print("\nResult...\n",np.emath.arctanh(arr))

## Output

Array...
[0.+0.j 0.+1.j 0.+2.j]

Our Array type...
complex128

Our Array Dimensions...
1

Number of elements...
3

Result...
[0.+0.j 0.+0.78539816j 0.+1.10714872j]