
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
PHP cosh Function
Definition and Usage
The cosh() function returns the hyperbolic cosine ratio of given angle in radians. In trigonometry, hyperbolic cosine ratio is defined as .
cosh(x) = (ex – e-x))/2
This function returns a float value .
Syntax
cosh ( float $arg ) : float
Parameters
Sr.No | Parameter & Description |
---|---|
1 |
arg A floating point value that represents angle in radians |
Return Values
PHP cosh() function returns hyperbolic cosine ratio of given parameter.
PHP Version
This function is available in PHP versions 4.x, PHP 5.x as well as PHP 7.x.
Example
Following example calculates cosh(pi/2) and returns 2.5091784786581 which is also the result of formula (ex + e-x))/2 −
<?php $arg=M_PI_2; $val=(exp($arg)+exp(-$arg))/2; $res=cosh($arg); echo "cosh(M_PI_2) = " . $val. "
"; echo "using formula = " . $res . "
"; ?>
Output
This will produce following result −
cosh(M_PI_2) = 2.5091784786581 using formula = 2.5091784786581
Example
Following example uses deg2rad() function to convert degrees to radians and then uses cosh(60). Result is 1.6002868577024 −
<?php $arg=deg2rad(60); $val=cosh($arg); echo "cosh(" . $arg . ") = " . $val; ?>
Output
This will produce following result −
cosh(1.0471975511966) = 1.6002868577024
Example
Let's check find out cosh(0). It returns 1 −
<?php $arg=0; $val=cosh($arg); echo "cosh(" . $arg . ") = " . $val; ?>
Output
This will produce following result −
cosh(0) = 1
Example
Following example computes cosh(pi)
<?php $arg=M_PI; $val=cosh($arg); echo "cosh(" . $arg . ") = " . $val; ?>
Output
This will produce following result −
cosh(3.1415926535898) = 11.591953275522