Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

php
math
cosine
communitycreator

What is cosh() in PHP?

harris910

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))));
?>

RELATED TAGS

php
math
cosine
communitycreator
RELATED COURSES

View all Courses

Keep Exploring