Calculates the inverse hyperbolic tangent.
What Is atanh() in PHP?
Calculates the inverse hyperbolic tangent.
Its syntax is:
atanh(float $num): float
Parameters:
$num— Accepted as float; required argument.
Return type: float. Real finite results require input strictly between -1 and 1. Endpoints yield infinities and values outside the interval yield NAN.
Availability: Available in standard PHP.
Example 1: Basic Usage
<?php
echo atanh(0);
Output:
0
Real finite results require input strictly between -1 and 1. Endpoints yield infinities and values outside the interval yield NAN.
Example 2: A Different Input
<?php
echo round(atanh(0.5), 4);
Output:
0.5493
Real finite results require input strictly between -1 and 1. Endpoints yield infinities and values outside the interval yield NAN.
Practical Example: Applying It in a Program
<?php
$values = [-0.5, 0, 0.5];
foreach ($values as $value) { echo round(atanh($value), 3) . PHP_EOL; }
Output:
-0.549
0
0.549
Real finite results require input strictly between -1 and 1. Endpoints yield infinities and values outside the interval yield NAN.
Important Behavior and Edge Cases
- Key behavior: Real finite results require input strictly between -1 and 1. Endpoints yield infinities and values outside the interval yield NAN.
- Environment: Available in standard PHP.
Comparison With Related Functions
| Function | Purpose |
|---|---|
atanh() | calculates the inverse hyperbolic tangent. |
atan() | atan() takes one ratio and does not independently identify the coordinate quadrant; atan2() uses y and x. |
Common Beginner Mistakes
| Mistake | Correct Approach |
|---|---|
| Ignoring this behavior: Real finite results require input strictly between -1 and 1 | Real finite results require input strictly between -1 and 1. Endpoints yield infinities and values outside the interval yield NAN. |
Key Takeaways
- calculates the inverse hyperbolic tangent.
- Real finite results require input strictly between -1 and 1. Endpoints yield infinities and values outside the interval yield NAN.
- Available in standard PHP.
Summary: Real finite results require input strictly between -1 and 1. Endpoints yield infinities and values outside the interval yield NAN.