PHP acosh() Function

PHPServer Side ProgrammingProgramming

Definition and Usage

The acosh() function returns the inverse hyperbolic cosine ratio of given angle in of given parameter. In other words, the return value of asinh() is hyperbolic sine of given parameter. A hyperbolic inverse hyperbolic cosine function is defined as −.

acosh(x) = log(x+sqrt(pow(x,2)-1))

This function returns a float value.

Syntax

acosh ( float $arg ) : float

Parameters

Sr.NoParameter & Description
1arg
A floating point value whose inverse hyperbolic cosine is to be calculated

Return Values

PHP acosh() function returns inverse 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 acosh(pi/2) and returns 1.0232274785476 which is also the result of formula definition −

 Live Demo

<?php
   $arg=M_PI_2;
   $val=acosh($arg);
   $ret=log($arg+sqrt(pow($arg,2)-1));
   echo "acosh(" . $arg . ") = " . $val . "\n";
   echo "using formula = " . $ret;
?>

Output

This will produce the following result −

acosh(1.5707963267949) = 1.0232274785476
using formula = 1.0232274785476

Example

 Live Demo

The following example uses deg2rad() function to convert degrees to radians and then uses acosh(60). Result is 0.30604210861327 −

<?php
   $arg=deg2rad(60);
   $val=acosh($arg);
   echo "acosh(" . $arg . ") = " . $val;
?>

Output

This will produce the following result −

acosh(1.0471975511966) = 0.30604210861327

Example

 Live Demo

Let's check find out acosh(0). It returns NAN −

<?php
   $arg=0;
   $val=acosh($arg);
   echo "acosh(" . $arg . ") = " . $val;
?>

Output

This will produce the following result −

acosh(0) = NAN

Example

 Live Demo

Following example computes cosh(pi)

<?php
   $arg=M_PI;
   $val=acosh($arg);
   echo "acosh(" . $arg . ") = " . $val;
?>

Output

This will produce the following result −

acosh(3.1415926535898) = 1.8115262724609
raja
Published on 11-Jun-2020 13:21:30
Advertisements