Signature
asinh(float $num): floatPurpose
asinh() computes the inverse hyperbolic sine of a number. Given a value num, it returns the number whose hyperbolic sine equals num. In other words, it undoes sinh(). If sinh($y) gives $x, then asinh($x) gives back $y, apart from tiny floating-point rounding differences.
The function belongs to PHP's math family alongside sinh(), asin(), acosh() and atanh(). It is useful in scientific code, signal processing, and data transformations. A common case is a variance-stabilising transform that behaves like a logarithm for large values but stays defined at zero and for negative numbers.
Signature
The function is available in PHP 4.1.0 and later, and the signature is the same in PHP 8.4.
Parameters and defaults
| Parameter | Type | Default | Meaning |
|---|---|---|---|
$num |
float | none (required) | The value to process |
There are no optional parameters. Integers are accepted and converted to floats. In PHP's default coercive typing mode, numeric strings such as "2.5" are also converted. Under declare(strict_types=1), passing a string is rejected.
Return value and failure cases
The function returns a float: the inverse hyperbolic sine of $num. Unlike acosh() or atanh(), which have restricted input ranges, asinh() is defined for every real number, so ordinary finite input never yields NAN.
The cases to know are:
- A value that cannot be used as a float, such as an array or a non-numeric string, causes a
TypeError. asinh(INF)returnsINFandasinh(-INF)returns-INF.asinh(NAN)returnsNAN.- The result for
0is the float zero.
Example 1: basic values and symmetry
The function is odd, meaning asinh(-$x) equals -asinh($x). The example uses number_format() so the printed text does not depend on float display precision.
echo number_format(asinh(0), 6), "\n";
echo number_format(asinh(1), 6), "\n";
echo number_format(asinh(-1), 6), "\n";0.000000 0.881374 -0.881374
Example 2: round trip with sinh()
Because the two functions are inverses, applying sinh() to the result of asinh() recovers the original number. Rounding for display hides the tiny floating-point error.
$x = 2.5;
$y = asinh($x);
echo number_format(sinh($y), 6), "\n";
echo number_format(asinh(sinh(3)), 6), "\n";2.500000 3.000000
Example 3: logarithm formula and special values
Mathematically, asinh(x) equals ln(x + sqrt(x² + 1)). The built-in function is preferable in real code because it is clearer and is designed to handle the numerically awkward cases. The comparison below shows the two agree for a moderate input. The last line shows how infinities and NAN pass through.
$formula = log(10 + sqrt(10 ** 2 + 1));
echo number_format($formula, 6), "\n";
echo number_format(asinh(10), 6), "\n";
echo json_encode([is_infinite(asinh(INF)), is_infinite(asinh(-INF)), is_nan(asinh(NAN))]), "\n";2.998223 2.998223 [true,true,true]
Edge cases
- Small inputs: for values close to zero,
asinh($x)is very nearly$x. The curve is almost a straight line through the origin. - Large inputs: growth is logarithmic. Multiplying the input by ten adds only about 2.3 to the result, which is why the function is popular for compressing wide-ranging data.
- Negative inputs: the result has the same magnitude as for the positive number, with the opposite sign.
- Integer input:
asinh(1)receives an integer, but the result is still a float. - Floating-point comparison: the result is an approximation. Never test it with
==against a hand-typed decimal. Round it or compare with a small tolerance.
Common mistakes
- Confusing it with
asin().asin()is the ordinary inverse sine, limited to inputs from -1 to 1 and returning radians.asinh()is the hyperbolic version and accepts any real number. - Expecting degrees or radians. Hyperbolic functions do not measure angles in the circular sense, so no degree conversion applies.
- Using a hand-written formula. Writing the logarithm expression yourself invites precision problems for large negative inputs, where
x + sqrt(x² + 1)involves cancellation. Prefer the built-in function. - Comparing floats exactly. After a
sinh()round trip the value may differ in the last digits. Useround(),number_format()or a tolerance. - Passing non-numeric data. Passing
null, arrays or text that is not numeric is a type problem, not something to rely on for a default of zero. Validate user input first. - Mixing it up with
acosh()oratanh(). These have restricted domains and can returnNAN.asinh()does not need a domain check for finite numbers.
Related functions
sinh()is the hyperbolic sine, the inverse ofasinh().asin()is the circular arc sine.acosh()is the inverse hyperbolic cosine.atanh()is the inverse hyperbolic tangent.log()andsqrt()can express the same relationship by formula.
Recap
asinh(float $num): float returns the value whose hyperbolic sine is $num. It accepts any real number, is an odd function, grows logarithmically, and passes infinities and NAN through. Round results before display or comparison, and do not confuse it with asin().
Tested examples
echo number_format(asinh(0), 6), "\n";
echo number_format(asinh(1), 6), "\n";
echo number_format(asinh(-1), 6), "\n";
0.000000 0.881374 -0.881374
$x = 2.5;
$y = asinh($x);
echo number_format(sinh($y), 6), "\n";
echo number_format(asinh(sinh(3)), 6), "\n";
2.500000 3.000000
$formula = log(10 + sqrt(10 ** 2 + 1));
echo number_format($formula, 6), "\n";
echo number_format(asinh(10), 6), "\n";
echo json_encode([is_infinite(asinh(INF)), is_infinite(asinh(-INF)), is_nan(asinh(NAN))]), "\n";
2.998223 2.998223 [true,true,true]