Calculates the inverse hyperbolic cosine.
What Is acosh() in PHP?
Calculates the inverse hyperbolic cosine.
Its syntax is:
acosh(float $num): float
Parameters:
$num— Accepted as float; required argument.
Return type: float. The real-number domain starts at 1. Values below 1 produce NAN. This function is not the same as acos().
Availability: Available in standard PHP.
Example 1: Basic Usage
<?php
echo acosh(1);
Output:
0
The real-number domain starts at 1. Values below 1 produce NAN. This function is not the same as acos().
Example 2: A Different Input
<?php
echo round(acosh(2), 4);
Output:
1.317
The real-number domain starts at 1. Values below 1 produce NAN. This function is not the same as acos().
Practical Example: Applying It in a Program
<?php
$measurements = [1.0, 1.5, 3.0];
foreach ($measurements as $measurement) { echo round(acosh($measurement), 3) . PHP_EOL; }
Output:
0
0.962
1.763
The real-number domain starts at 1. Values below 1 produce NAN. This function is not the same as acos().
Important Behavior and Edge Cases
- Key behavior: The real-number domain starts at 1. Values below 1 produce NAN. This function is not the same as acos().
- Environment: Available in standard PHP.
Comparison With Related Functions
| Function | Purpose |
|---|---|
acosh() | calculates the inverse hyperbolic cosine. |
acos() | acos() accepts a cosine value within -1 to 1; acosh() accepts a hyperbolic cosine value of at least 1. |
Common Beginner Mistakes
| Mistake | Correct Approach |
|---|---|
| Ignoring this behavior: The real-number domain starts at 1 | The real-number domain starts at 1. Values below 1 produce NAN. This function is not the same as acos(). |
Key Takeaways
- calculates the inverse hyperbolic cosine.
- The real-number domain starts at 1. Values below 1 produce NAN. This function is not the same as acos().
- Available in standard PHP.
Summary: The real-number domain starts at 1. Values below 1 produce NAN. This function is not the same as acos().