Perl Tutorial Perl References

Perl Math - acosh() Function



The Perl Math acosh() function returns inverse hyperbolic cosine of a value. The inverse hyperbolic cosine of x is defined as:

acosh

Syntax

acosh(x)

Parameters

x Specify the value.

Return Value

Returns the inverse hyperbolic cosine of a value.

Example:

In the example below, acosh() function is used to find out the inverse hyperbolic cosine of a value.

use Math::Trig;

print("acosh(1) = ".acosh(1)."\n");
print("acosh(2) = ".acosh(2)."\n");
print("acosh(3) = ".acosh(3)."\n");
print("acosh(4) = ".acosh(4)."\n");
print("acosh(Inf) = ".acosh(Inf)."\n");

The output of the above code will be:

acosh(1) = 0
acosh(2) = 1.31695789692482
acosh(3) = 1.76274717403909
acosh(4) = 2.06343706889556
acosh(Inf) = Inf

This function can also be used to calculate complex inverse hyperbolic cosine of a complex number z. It is a function on complex plane, and has one branch cut, extending left from 1 along the real axis to -∞, continuous from above.

Mathematically, it can be expressed as:

complex acosh

Example:

In the example below, acosh() function is used to find out the complex inverse hyperbolic cosine of a given complex number.

use Math::Complex;

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

The output of the above code will be:

acosh(2+2i) = 1.73432452148797+0.816547182096851i
acosh(2) = 1.31695789692482
acosh(2i) = 1.44363547517881+1.5707963267949i

❮ Perl Math Functions

5