numpy.arctanh in Python() (original) (raw)
Last Updated : 29 Nov, 2018
numpy.arctanh() : This mathematical function helps user to calculate inverse hyperbolic tangent, element-wise for all arr.
Syntax : numpy.arctanh(arr, /, out=None, *, where=True, casting=’same_kind’, order=’K’, dtype=None, ufunc ‘arctanh’)
Parameters :arr : array_like
Input array.
out : [ndarray, optional] 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.
where : array_like, optional
Values of True indicate to calculate the ufunc at that position, values of False indicate to leave the value in the output alone.
****kwargs :**Allows to pass keyword variable length of argument to a function. Used when we want to handle named argument in a function.Return : An array with inverse hyperbolic tangent of arr
for all arr i.e. array elements.Note :
2pi Radians = 360 degrees
The convention is to return the angle of arr whose imaginary part lies in [-pi/2, pi/2].
Code #1 : Working
import
numpy as np
in_array
=
[
0.2
,
0.11
,
0.5
,
0.99
]
print
(
"Input array : \n"
, in_array)
arctanh_Values
=
np.arctanh(in_array)
print
(
"\nInverse hyperbolic tangent values of input array : \n"
, arctanh_Values)
Output :
Input array : [0.2, 0.11, 0.5, 0.99]
Inverse hyperbolic tangent values of input array : [ 0.20273255 0.11044692 0.54930614 2.64665241]
Code #2 : Graphical representation
import
numpy as np
import
matplotlib.pyplot as plt
in_array
=
np.linspace(
0.1
,
0.99
,
25
)
out_array1
=
np.tan(in_array)
out_array2
=
np.arctanh(in_array)
print
(
"in_array : "
, in_array)
print
(
"\nout_array with tan : "
, out_array1)
print
(
"\nout_array with arctanh : "
, out_array2)
plt.plot(in_array, out_array1,
`` color
=
'blue'
, marker
=
"."
)
plt.plot(in_array, out_array2,
`` color
=
'red'
, marker
=
"+"
)
plt.title(
"blue : numpy.tan() \nred : numpy.arctanh()"
)
plt.xlabel(
"X"
)
plt.ylabel(
"Y"
)
Output :
in_array : [ 0.1 0.13708333 0.17416667 0.21125 0.24833333 0.28541667 0.3225 0.35958333 0.39666667 0.43375 0.47083333 0.50791667 0.545 0.58208333 0.61916667 0.65625 0.69333333 0.73041667 0.7675 0.80458333 0.84166667 0.87875 0.91583333 0.95291667 0.99 ]
out_array with tan : [ 0.10033467 0.13794852 0.17594936 0.21444958 0.25356734 0.29342809 0.33416626 0.37592723 0.41886955 0.46316761 0.5090147 0.55662672 0.60624669 0.65815012 0.7126517 0.77011355 0.83095552 0.89566817 0.96482941 1.03912577 1.11938038 1.20658966 1.30197266 1.40703805 1.52367674]
out_array with arctanh : [ 0.10033535 0.13795183 0.17596049 0.21447937 0.25363582 0.29356929 0.33443481 0.37640728 0.41968694 0.4645065 0.51114049 0.5599181 0.61124089 0.66560789 0.72365253 0.78619832 0.85434644 0.92961997 1.01421559 1.11147549 1.22686186 1.37025371 1.5625545 1.86258009 2.64665241]
Similar Reads
- numpy.arctan() in Python numpy.arctan(x[, out]) = ufunc 'arctan') : This mathematical function helps user to calculate inverse tangent for all x(being the array elements). Parameters : array : [array_like]elements are in radians. out : [array_like]array of same shape as x. Note : 2pi Radians = 360 degrees The convention is 2 min read
- numpy.arctan2() in Python The numpy.arctan2() method computes element-wise arc tangent of arr1/arr2 choosing the quadrant correctly. The quadrant is chosen so that arctan2(x1, x2) is the signed angle in radians between the ray ending at the origin and passing through the point (1, 0), and the ray ending at the origin and pas 2 min read
- numpy.arcsinh() in Python numpy.arcsinh() : This mathematical function helps user to calculate inverse hyperbolic sine, element-wise for all arr. Syntax : numpy.arcsinh(arr, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, ufunc 'arcsinh') Parameters : arr : array_like Input array. out : [ndarray, opti 2 min read
- numpy.arcsin() in Python numpy.arcsin(x[, out]) = ufunc 'arcsin') : This mathematical function helps user to calculate inverse sine for all x(being the array elements). Parameters : array : [array_like]elements are in radians. out : [array_like]array of same shape as x. Return : An array with inverse sine of x for all x i.e 2 min read
- numpy.arccosh() in Python numpy.arccosh() : This mathematical function helps user to calculate inverse hyperbolic cosine, element-wise for all arr. Syntax : numpy.arccosh(arr, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, ufunc 'arccosh') Parameters : arr : array_like Input array. out : [ndarray, op 2 min read
- NumPy Array in Python NumPy (Numerical Python) is a powerful library for numerical computations in Python. It is commonly referred to multidimensional container that holds the same data type. It is the core data structure of the NumPy library and is optimized for numerical and scientific computation in Python. Table of C 2 min read
- numpy.arccos() in Python numpy.arccos(x[, out]) = ufunc 'arccos') : This mathematical function helps user to calculate inverse cos for all x(being the array elements). Parameters : array : [array_like]elements are in radians. out : [array_like]array of same shape as x. Note : 2pi Radians = 360 degrees The convention is to r 2 min read
- numpy.cosh() in Python The numpy.cosh() is a mathematical function that helps user to calculate hyperbolic cosine for all x(being the array elements). Equivalent to 1/2 * (np.exp(x) - np.exp(-x)) and np.cos(1j*x). Syntax : numpy.cosh(x[, out]) = ufunc 'cos') Parameters : array : [array_like] elements are in radians. 2pi R 2 min read
- numpy.alen() in Python numpy.alen() function is used to return the length of the first dimension of the input array. Syntax : numpy.alen(arr) Parameters : arr : [array_like] Input array. Return : [int]Length of the first dimension of arr. Code #1 : # Python program explaining # alen() function import numpy as geek # input 1 min read
- numpy.asarray() in Python numpy.asarray()function is used when we want to convert input to an array. Input can be lists, lists of tuples, tuples, tuples of tuples, tuples of lists and arrays. Syntax : numpy.asarray(arr, dtype=None, order=None) Parameters : arr : [array_like] Input data, in any form that can be converted to a 2 min read