The tanh()
function in R returns a number’s hyperbolic tangent in radians.
The following illustration shows the mathematical representation of the tanh()
function.
tanh(num)
This function requires a number that represents an angle in radians as a parameter.
To convert degrees to radians, use:
radians = degrees * ( PI / 180.0 )
tanh()
returns the hyperbolic tangent of a number (in radians) that is set as a parameter.
#positive number in radiansa <- tanh(2.3);print(paste0("tanh(2.3): ", a))#negative number in radiansb <- tanh(-2.3);print(paste0("tanh(-2.3): ", b))#converting the degrees angle into radians and then applying tanh()#degrees = 45c <- tanh(45 * (pi / (180)));print(paste0("tanh(45 * (pi / (180))): ", c))