PHP Tutorial PHP Advanced PHP Resources
Python Java C++ C C# PHP R SQL DS Algo InterviewQ

PHP Math - cosh() Function



The PHP Math cosh() function returns hyperbolic cosine of a value. The hyperbolic cosine of x is defined as:

cosh

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 argument is infinite, then the result is positive infinity.
  • If the argument is zero, then the result is 1.0.

Syntax

cosh(number)

Parameters

number Required. Specify the value.

Return Value

Returns the hyperbolic cosine of a value.

Example:

In the example below, cosh() function is used to find out the hyperbolic cosine of a value.

<?php
echo "cosh(-2) = ".cosh(-2)."\n";
echo "cosh(-1) = ".cosh(-1)."\n";
echo "cosh(0) = ".cosh(0)."\n";
echo "cosh(1) = ".cosh(1)."\n";
echo "cosh(2) = ".cosh(2)."\n";
echo "cosh(INF) = ".cosh(INF)."\n";
echo "cosh(-INF) = ".cosh(-INF)."\n";
echo "cosh(NAN) = ".cosh(NAN)."\n";
?>

The output of the above code will be:

cosh(-2) = 3.7621956910836
cosh(-1) = 1.5430806348152
cosh(0) = 1
cosh(1) = 1.5430806348152
cosh(2) = 3.7621956910836
cosh(INF) = INF
cosh(-INF) = INF
cosh(NAN) = NAN

❮ PHP Math Functions

5