The cosh()
function calculates the hyperbolic cosine of a number in radians.
The following illustration shows the mathematical representation of the cosh()
function.
cosh(num)
This function requires a number that represents an angle in radians as a parameter.
To convert degrees to radians, use the following function in Perl.
deg2rad(angleInDegrees)
This function returns the hyperbolic cosine of a number (in radians) sent as a parameter.
If the value of num
is NaN
.
If the value of num
is positive/negative infinity, then the return value is positive infinity
.
#this header for deg2rad() functionuse Math::Trig;#Positive number in radians$a = cosh(2.3);print "cosh(2.3): $a \n";#negative number in radians$b = cosh(-2.3);print "cosh(-2.3): $b \n";#converting the degrees angle into radians and then applying cosh()#degrees = 180$rad = deg2rad(180);$c = cosh($rad);print "cosh($rad): $c \n";#Inf values$d = cosh(Inf);print "cosh(Inf): $d \n";$e = cosh(-Inf);print "cosh(-Inf): $e \n";#NaN value$f = cosh(NaN);print "cosh(NaN): $f \n";