Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

perl
acos
math
communitycreator

What is acos() in Perl?

harris910

The acos() functionalso called the arc cosine function calculates the inverse cosine of a number. To be more specific, it returns the inverse cosine of a number in radians.

Figure 1 shows the mathematical representation of the acos() function, and Figure 2 shows the visual representation of the acos() function.

Figure 1: Mathematical representation of inverse cosine function
Figure 2: Visual representation of inverse cosine function

To convert radians to degrees, use the following function:

rad2deg(angleInRadians)

Syntax

acos(num)

Parameter

This function requires a number as a parameter.

Return value

This function returns the inverse cosine of a number (in radians) set as a parameter. The return value lies in the interval of [0, pi] radians.

Example

#this header for rad2deg() function
use Math::Trig;

#Positive number in radians
$a = acos(0.5);
print "acos(0.5): $a Radians\n";

#negative number in radians
$b = acos(-0.5);
print "acos(-0.5): $b Radians\n";

#applying acos() and then converting the result in radians to degrees
#radians = 0.5
$c = rad2deg(acos(0.5));
print "acos(0.5): $c Degrees\n";

RELATED TAGS

perl
acos
math
communitycreator
RELATED COURSES

View all Courses

Keep Exploring