Perl Tutorial Perl References

Perl Math - atanh() Function



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

atanh

Syntax

atanh(x)

Parameters

x Specify the value.

Return Value

Returns the inverse hyperbolic tangent of a value.

Example:

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

use Math::Trig;

print("atanh(-0.9) = ".atanh(-0.9)."\n");
print("atanh(-0.5) = ".atanh(-0.5)."\n");
print("atanh(0) = ".atanh(0)."\n");
print("atanh(0.5) = ".atanh(0.5)."\n");
print("atanh(0.9) = ".atanh(0.9)."\n");

The output of the above code will be:

atanh(-0.9) = -1.47221948958322
atanh(-0.5) = -0.549306144334055
atanh(0) = 0
atanh(0.5) = 0.549306144334055
atanh(0.9) = 1.47221948958322

This function can also be used to calculate complex inverse hyperbolic tangent of a complex number z. It is a function on complex plane, and has two branch cuts:

  • Extends from 1 along the real axis to ∞, continuous from below.
  • Extends from -1 along the real axis to -∞, continuous from above.

Mathematically, it can be expressed as:

complex atanh

Example:

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

use Math::Complex;

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

The output of the above code will be:

atanh(2+2i) = 0.238877861256859+1.31122326967164i
atanh(2) = 0.549306144334055+1.5707963267949i
atanh(2i) = 1.10714871779409i

❮ Perl Math Functions

5