
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Compute the inverse Hyperbolic tangent of array elements in Python
The arctanh is a multivalued function: for each x there are infinitely many numbers z such that tanh(z) = x. The convention is to return the z whose imaginary part lies in [-pi/2, pi/2]. The inverse hyperbolic tangent is also known as atanh or tanh^-1.
To compute the inverse Hyperbolic tangent of array elements, use the numpy.arctanh() method in Python Numpy. The method returns the array of the same shape as x. This is a scalar if x is a scalar. The 1st parameter, x is input array. The 2nd and 3rd parameters are optional.
The 2nd parameter is an ndarray, A location into which the result is stored. If provided, it must have a shape that the inputs broadcast to. If not provided or None, a freshly-allocated array is returned.
The 3rd parameter is the condition is broadcast over the input. At locations where the condition is True, the out array will be set to the ufunc result. Elsewhere, the out array will retain its original value.
Steps
At first, import the required library −
import numpy as np
Create an array using the array() method in Numpy −
arr = np.array((0, 0.2, 0.3, 0.5, 0.11))
Displaying our array −
print("Array...\n",arr)
Get the datatype −
print("\nArray datatype...\n",arr.dtype)
Get the dimensions of the Array −
print("\nArray Dimensions...\n",arr.ndim)
Get the number of elements of the Array −
print("\nNumber of elements in the Array...\n",arr.size)
To find the inverse hyperbolic tangent of the array elements, use the numpy.arctanh() method in Python Numpy −
print("\nResult...",np.arctanh(arr))
Example
import numpy as np # To compute the inverse Hyperbolic tangent of array elements, use the numpy.arctanh() method in Python Numpy # The method returns the array of the same shape as x. This is a scalar if x is a scalar. # The 1st parameter, x is input array print("Get the Trigonometric inverse Hyperbolic tangent of array elements...") # Create an array using the array() method in Numpy arr = np.array((0, 0.2, 0.3, 0.5, 0.11)) # Display the array print("\nArray...\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 find the inverse hyperbolic tangent of the array elements, use the numpy.arctanh() method in Python Numpy print("\nResult...",np.arctanh(arr))
Output
Get the Trigonometric inverse Hyperbolic tangent of array elements... Array... [0. 0.2 0.3 0.5 0.11] Our Array type... float64 Our Array Dimensions... 1 Number of elements... 5 Result... [0. 0.20273255 0.3095196 0.54930614 0.11044692]
- Related Articles
- Compute the inverse Hyperbolic tangent in Python
- Compute the Hyperbolic tangent of the array elements in Python
- Compute the inverse Hyperbolic sine of array elements in Python
- Compute the inverse Hyperbolic cosine of array elements in Python
- Compute the inverse hyperbolic tangent with scimath in Python
- Compute the Hyperbolic tangent in Python
- Compute the inverse Hyperbolic sine in Python
- Compute the inverse Hyperbolic cosine in Python
- Compute the Hyperbolic sine of the array elements in Python
- Compute the Hyperbolic cosine of the array elements in Python
- Get the Trigonometric inverse tangent of the array elements in Python
- Finding the Inverse Hyperbolic Tangent of Complex Number in Golang
- Finding the Inverse Hyperbolic Tangent of Specified Number in Golang
- How to compute the inverse cosine and inverse hyperbolic cosine in PyTorch?
- How to compute the inverse hyperbolic sine in PyTorch?
