What is asin() in Perl?

The asin() function, also called the arc sine function, calculates and returns the inverse sine of a number.

To be more specific, it returns the inverse sine of a number in radians.

Figure 1 below shows the mathematical representation of the asin() function.

Figure 1: Mathematical representation of inverse sine function

Figure 2 shows the visual representation of the asin() function.

Figure 2: Visual representation of inverse sine function

Methodology

To convert radians to degrees, use the following function:


rad2deg(angleInRadians)

Syntax


asin(num)

Parameter

This function requires a number as a parameter.

Return value

asin() returns the inverse sine of a number (in radians) that is set as a parameter. The return value lies in the interval [-pi/2, pi/2] radians.

Code

#this header for rad2deg() function
use Math::Trig;
#Positive number in radians
$a = asin(0.5);
print "asin(0.5): $a Radians\n";
#negative number in radians
$b = asin(-0.5);
print "asin(-0.5): $b Radians\n";
#applying asin() and then converting the result in radians to degrees
#radians = 0.5
$c = rad2deg(asin(0.5));
print "asin(0.5): $c Degrees\n";

Free Resources