asinh
Returns the inverse hyperbolic sine of a number, defined for every real value.
asinh(float $num): float- Added in PHP 4.1.0
Parameters
| Parameter | Type | Description |
|---|---|---|
$num | float | The argument to process. Any real number is valid. |
Return value
floatThe inverse hyperbolic sine of num.
Errors
Throws a TypeError if num cannot be coerced to float.
asinh() is the inverse of sinh(). It equals log($num + sqrt($num ** 2 + 1)), but the built-in keeps its accuracy for very small and very large arguments where that formula does not.
When to reach for it
Unlike its sibling acosh(), asinh() accepts every real number, which makes it far more useful in day-to-day data work than the hyperbolic label suggests. It behaves like a logarithm for large values and like the identity function near zero, so it is the standard substitute for log() when your data contains zeros and negative numbers — account balances, profit and loss, temperature anomalies, sensor deltas. Charting libraries call this a "symlog" scale; asinh() is the smooth version of it.
It also appears in geometry (the arc length of a parabola) and in map projections, where the Mercator y-coordinate is asinh(tan($latitude)).
What trips people up
The result is a hyperbolic angle, not an angle on a circle, so passing it to rad2deg() produces a meaningless number. The function is odd — asinh(-$x) === -asinh($x) — which is exactly the property that makes it work as a signed scale. Finally, the growth is slow: asinh(1000) is only about 7.6, so do not expect the output to resemble the input's order of magnitude.
Example
When to use it
- Apply a log-like scale to a chart axis whose data includes zero and negative values.
- Compute the Mercator y-coordinate of a latitude as asinh(tan($lat)).
- Compress a wide range of signed sensor deltas before feeding them to a model.
Frequently asked questions
Does asinh() have a restricted domain like acosh()?
No. sinh() covers every real number, so asinh() accepts any float and never returns NAN for an in-range input. Only INF and NAN inputs propagate.
Why use asinh() instead of log() for scaling data?
Because log() is undefined at zero and for negative numbers, while asinh() is defined everywhere, is symmetric about zero, and still grows logarithmically for large magnitudes.
What is the difference between asinh() and asin()?
asin() inverts the circular sine and only accepts values from -1 to 1, returning an angle. asinh() inverts the hyperbolic sine, accepts any real number, and returns a hyperbolic angle.
More examples
A log scale that survives zero and negatives
The output runs from -9.210 to 9.210 and passes cleanly through 0. log() would fail on the zero and the negatives, while asinh() compresses the large magnitudes and stays symmetric about the origin.
<?php
$balances = [-5000, -50, 0, 50, 5000];
foreach ($balances as $b) {
printf("%7d -> %7.3f\n", $b, asinh($b));
}Mercator projection y-coordinate
The equator maps to 0 and 45 degrees maps to about 0.88137, but 85 degrees maps to roughly 3.13 — the output shows how violently Mercator stretches distances near the poles.
<?php
foreach ([0.0, 45.0, 60.0, 85.0] as $lat) {
$y = asinh(tan(deg2rad($lat)));
printf("lat %.0f -> y %.5f\n", $lat, $y);
}
Discussion