Perl Math - sinh() Function

The Perl Math sinh() function returns hyperbolic sine of a value. The hyperbolic sine of x is defined as: where e is an Euler's number.

In special cases it returns the following:

• If the argument is NaN, then the result is NaN.
• If the argument is infinite, then the result is an infinity with the same sign as the argument.

sinh(x)

Parameters

 x Specify the value.

Return Value

Returns the hyperbolic sine of a value.

Example:

In the example below, sinh() function is used to find out the hyperbolic sine of a value.

use Math::Trig;

print("sinh(-2) = ".sinh(-2)."\n");
print("sinh(-1) = ".sinh(-1)."\n");
print("sinh(0) = ".sinh(0)."\n");
print("sinh(1) = ".sinh(1)."\n");
print("sinh(2) = ".sinh(2)."\n");
print("sinh(Inf) = ".sinh(Inf)."\n");
print("sinh(-Inf) = ".sinh(-Inf)."\n");
print("sinh(NaN) = ".sinh(NaN)."\n");

The output of the above code will be:

sinh(-2) = -3.62686040784702
sinh(-1) = -1.1752011936438
sinh(0) = 0
sinh(1) = 1.1752011936438
sinh(2) = 3.62686040784702
sinh(Inf) = Inf
sinh(-Inf) = -Inf
sinh(NaN) = NaN

This function can also be used to calculate complex hyperbolic sine of a complex number z. It is a function on complex plane, and has no branch cuts. It is periodic with respect to the imaginary component, with period 2𝜋i.

Mathematically, it can be expressed as: Example:

In the example below, sinh() function is used to find out the complex hyperbolic sine of the given number.

use Math::Complex;

\$z1 = 2 + 2*i;
\$z2 = 2;
\$z3 = 2*i;
print("sinh(\$z1) = ".sinh(\$z1)."\n");
print("sinh(\$z2) = ".sinh(\$z2)."\n");
print("sinh(\$z3) = ".sinh(\$z3)."\n");

The output of the above code will be:

sinh(2+2i) = -1.50930648532362+3.42095486111701i
sinh(2) = 3.62686040784702
sinh(2i) = 0.909297426825682i

❮ Perl Math Functions

5