PHP acosh() Function

Beginner
5 min read
Updated: Nov 2026
3 examples
Math

Definition

The PHP acosh() function returns the inverse hyperbolic cosine of a number.

It is the opposite of cosh(), and it only gives a real answer when the input is 1 or greater.

Syntax

Call acosh() with the values you need. Start with this line.

PHP
$result = acosh($num);
CallWhat it does
acosh(1)Returns 0 because cosh(0) is 1.
acosh(2)Returns about 1.317.
acosh(0.5)Returns NAN because the input is below 1.

Only numbers 1 and above work. Anything smaller gives NAN.

Library declarations
PHP
acosh(float $num): float

Parameters

ParameterDescription
numRequired. The value to work on. It must be 1 or greater to get a real result.

Return Value

Return ValueDescription
floatThe inverse hyperbolic cosine of $num. Returns NAN if $num is less than 1.

PHP Examples

Example 1 — Basic acosh() usage

This example calls acosh() with a few valid inputs and rounds the answers to 4 decimals.

PHP
<?php
echo acosh(1) . PHP_EOL;
echo round(acosh(2), 4) . PHP_EOL;
echo round(acosh(10), 4) . PHP_EOL;

How It Works

  1. acosh(1) is exactly 0, because cosh(0) equals 1.
  2. acosh(2) is about 1.3169578969, and round(..., 4) gives 1.317.
  3. PHP drops the trailing zero, so 1.3170 is printed as 1.317.
  4. acosh(10) is about 2.9932, which grows slowly as the input grows.

Example 2 — Input below 1 returns NAN

Because cosh() is never smaller than 1, there is no real number whose cosh is below 1. PHP returns NAN for those inputs.

PHP
<?php
var_dump(acosh(0.5));
var_dump(acosh(-3));

$result = acosh(0.9);
echo is_nan($result) ? 'Invalid input' : 'Valid input';
echo PHP_EOL;

How It Works

  1. acosh(0.5) is out of range, so PHP returns float(NAN).
  2. Negative numbers like -3 are also out of range and give NAN.
  3. We store acosh(0.9) in $result and test it with is_nan().
  4. The test is true, so the script prints Invalid input.

Example 3 — Round trip with cosh()

acosh() and cosh() cancel each other out. This is a handy way to check your understanding.

PHP
<?php
$x = 1.5;
$y = cosh($x);
$back = acosh($y);

echo "cosh(1.5) = " . round($y, 4) . PHP_EOL;
echo "acosh back = " . round($back, 4) . PHP_EOL;

How It Works

  1. We start with $x = 1.5.
  2. cosh($x) gives about 2.3524, which is above 1, so acosh() can accept it.
  3. acosh($y) reverses the operation and returns the original 1.5.
  4. round() hides tiny floating point differences so the output looks clean.

Frequently Asked Questions

acosh() returns the inverse hyperbolic cosine of a number. In simple words, it finds the number whose cosh() equals your input.
cosh() never returns a value below 1, so there is no real answer for inputs below 1. PHP returns NAN to show that.
It is exactly 0, because cosh(0) is 1.
No. It quietly returns NAN. Use is_nan() to detect it.
No. acos() is the inverse of the normal cosine and works with -1 to 1. acosh() is the inverse of the hyperbolic cosine and works with 1 and above.

Next: asin()

asin() function returns the arc sine of a number, which is the angle whose sine is that nu.

asin() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful