Core\Math::asinh
Returns the inverse hyperbolic sine of the number you give it. It undoes Core\Math::sinh, so Core\Math::asinh(Core\Math::sinh(2.0)) gives 2.0 back.
Every number has a result. The result has the same sign as the number, and 0.0 gives 0.0. Near zero, the result is close to the number itself. For big numbers the result grows slowly, like a logarithm.
Good to know: Core\Math::log has no usable result for zero or for a negative number. Core\Math::asinh works for every number. That makes it a common way to draw a scale for values that can be negative, such as profit and loss.
The examples below show a few results, then negative and very big numbers, then the bar heights of a profit and loss chart.
Parameters
$nfloatAny number.
Return value
Returns float. The number whose hyperbolic sine is $n. It has the same sign as $n. NaN gives NaN.
Examples
Undo a hyperbolic sine
<?nvs// Shows a few results of `Core\Math::asinh`, and how it undoes `Core\Math::sinh`.
// The result for 0.0 is 0.0. This prints 0.echo Core\Math::asinh(0.0), "\n";
// This prints 0.88137358701954.echo Core\Math::asinh(1.0), "\n";
// `Core\Math::sinh` turns 2.0 into 3.626860407847. `Core\Math::asinh` turns it back.// This prints 2.echo Core\Math::asinh(Core\Math::sinh(2.0)), "\n";00.881373587019542Negative and very big numbers
<?nvs// Shows that `Core\Math::asinh` has a result for negative and for very big numbers.
// A negative number gives the same result with a minus sign. This prints -0.88137358701954.echo Core\Math::asinh(-1.0), "\n";
// Ten billion becomes about 24. This prints 23.7189981105.echo Core\Math::asinh(10000000000.0), "\n";
// The biggest `float` still gives an ordinary number. This prints 710.47586007394.echo Core\Math::asinh(Core\Math::FLOAT_MAX), "\n";-0.8813735870195423.7189981105710.47586007394A profit and loss chart
<?nvs// Shows how a sales report draws the profit and loss of each day as a bar.// Some days lose money, so the scale must work for negative numbers and zero.
class Chart{ // Returns the height of a bar, with one decimal place. public static function height(float $amount): float { // `Core\Math::asinh` makes big amounts small and keeps the sign. // A day that lost money gets a bar below zero. return Core\Math::round(Core\Math::asinh($amount / 10.0), { precision: 1 }); }}
// A big profit, a small profit, a day with no sales, and a loss.array<float> $days = [25000.0, 120.0, 0.0, -450.0];
// This prints 8.5, 3.2, 0 and -4.5.foreach ($days as float $amount) { echo Chart::height($amount), "\n";}8.53.20-4.5