What is cosh() in PHP?

The cosh() function in PHP returns the hyperbolic cosine of a number in radians.

The following illustration shows the mathematical representation of the cosh() function.

Mathematical representation of the hyperbolic cosine function

Syntax

cosh(float $num): float

Parameter

As a parameter, this function requires a number that represents an angle in radians.

To convert degrees to radians, use the following formula.

radians = degrees * ( M_PI / 180.0 )

Return value

cosh() returns the hyperbolic cosine of a number (in radians) that is sent in as a parameter.

  • If the value of num is NaNnot a number, then the return value is NaN.

  • If the value of num is positive/negative infinity, then the return value is positive infinity.

Code

<?php
#Positive number in radians
echo("cosh(2.3): ");
echo (cosh(2.3));
?>
<?php
#Negative number in radians
echo("cosh(-2.3): ");
echo (cosh(-2.3));
?>
<?php
#converting the degrees angle into radians and then applying cosh()
#degrees = 180
echo("cosh(180 * (M_PI / (180))): ");
echo (cosh(180 * (M_PI / (180))));
?>
New on Educative
Learn any Language for FREE all September 🎉
For the entire month of September, get unlimited access to our entire catalog of beginner coding resources.
🎁 G i v e a w a y
30 Days of Code
Complete Educative’s daily coding challenge every day in September, and win exciting Prizes.

Free Resources