Perl Math - asin() Function

The Perl Math asin() function returns arc sine of a value. The returned value will be in the range -𝜋/2 through 𝜋/2.

asin(x)

Parameters

 x Specify the value.

Return Value

Returns the arc sine of the value.

Example:

In the example below, asin() function is used to find out the arc sine of a given value.

use Math::Trig;

print("asin(-1) = ".asin(-1)."\n");
print("asin(-0.5) = ".asin(-0.5)."\n");
print("asin(0) = ".asin(0)."\n");
print("asin(0.5) = ".asin(0.5)."\n");
print("asin(1) = ".asin(1)."\n");

The output of the above code will be:

asin(-1) = -1.5707963267949
asin(-0.5) = -0.523598775598299
asin(0) = 0
asin(0.5) = 0.523598775598299
asin(1) = 1.5707963267949

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

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

Mathematically, it can be expressed as: Example:

In the example below, asin() function is used to find out the complex arc sine of a given complex number.

use Math::Complex;

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

The output of the above code will be:

asin(2+2i) = 0.754249144698046+1.73432452148797i
asin(2) = 1.5707963267949-1.31695789692482i
asin(2i) = 1.44363547517881i

❮ Perl Math Functions

5