R Tutorial R Charts & Graphs R Statistics R References

R - atanh() Function



The R atanh() function returns inverse hyperbolic tangent of a value. The inverse hyperbolic tangent of x is defined as:

atanh

where e is an Euler's number.

In special cases it returns the following:

  • If the argument is NaN, then the result is NaN.
  • If the absolute value of argument is greater than 1, then the result is NaN.
  • If the argument is 1 or -1, then the result is infinity with same sign as argument.

Syntax

atanh(x)

Parameters

x Required. Specify column to compute on.

Return Value

Returns the inverse hyperbolic tangent of the value.

Example:

In the example below, atanh() function is used to find out the inverse hyperbolic tangent of the value.

#operating on single element atomic vector
print(atanh(-1))
print(atanh(0))
print(atanh(1))

cat("\nOperating on vector\n")
#operating on vector
v <- c(-0.5, 0, 0.5)
print(atanh(v))

cat("\nOperating on matrix\n")
#operating on matrix
m <- matrix(c(-0.5, -0.2, 0, 0.2, 0.5, NaN), nrow=2)
print(atanh(m))

cat("\nOperating on first column of matrix\n")
#operating on first column of matrix
print(atanh(m[,1]))

The output of the above code will be:

[1] -Inf
[1] 0
[1] Inf

Operating on vector
[1] -0.5493061  0.0000000  0.5493061

Operating on matrix
           [,1]      [,2]      [,3]
[1,] -0.5493061 0.0000000 0.5493061
[2,] -0.2027326 0.2027326       NaN

Operating on first column of matrix
[1] -0.5493061 -0.2027326

❮ R Math Functions