Skip to content

Core\Math::sinh

Returns the hyperbolic sine of a number. That is (exp($n) - exp(-$n)) / 2, where exp is Core\Math::exp.

The result is 0.0 at zero, and it has the same sign as the number. A negative number gives the same result as the positive one, with a minus sign. The result grows very fast. Above about 710 it is too big for a float and becomes INFINITY. Below about -710 it becomes -INFINITY. NaN (a value that means "not a number") gives NaN.

In plain words: a cable that hangs between two poles makes a curve. The hyperbolic sine gives the length of that curve.

The examples below show a few results, then very large numbers, then how much cable is needed between two poles.

Parameters

  • $nfloatAny number.

Return value

Returns float. A number with the same sign as $n. It is INFINITY when $n is above about 710, and -INFINITY when $n is below about -710. NaN gives NaN.

Examples

A few results

<?nvs
// Shows the hyperbolic sine of a few numbers.
// The result at zero is 0. This prints 0.
echo Core\Math::sinh(0.0), "\n";
// A negative number gives the same result with a minus sign.
// These lines print 1.1752011936438 and -1.1752011936438.
echo Core\Math::sinh(1.0), "\n";
echo Core\Math::sinh(-1.0), "\n";
Output
0
1.1752011936438
-1.1752011936438

Very large numbers

<?nvs
// Shows how fast the hyperbolic sine grows.
// This prints 11013.232874703.
echo Core\Math::sinh(10.0), "\n";
// At 710 the result is still a number. This prints 1.1169973830809E+308.
echo Core\Math::sinh(710.0), "\n";
// At 711 the result is too big for a `float`. This prints INF.
echo Core\Math::sinh(711.0), "\n";
// At -711 the result is equal to `-Core\Math::INFINITY`. This prints yes.
echo Core\Math::sinh(-711.0) == -Core\Math::INFINITY ? 'yes' : 'no', "\n";
Output
11013.232874703
1.1169973830809E+308
INF
yes

How much cable

<?nvs
// Shows how a planning tool finds how much cable it needs between two poles.
class Cable
{
// `$tension` is a number for how tight the cable is. A bigger number means a tighter cable.
public static function length(float $span, float $tension): float
{
float $meters = 2.0 * $tension * Core\Math::sinh($span / (2.0 * $tension));
return Core\Math::round($meters, { precision: 2 });
}
}
// Two poles 100 meters apart. This prints 101.04, so the cable is 101.04 meters long.
echo Cable::length(100.0, 200.0), "\n";
// A tighter cable is shorter. This prints 100.17.
echo Cable::length(100.0, 500.0), "\n";
Output
101.04
100.17