What is acos() in R?

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

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

Figure 1: Mathematical representation of inverse cosine function

Figure 2 below shows the visual representation of the acos() function.

Figure 2: Visual representation of inverse cosine function

Methodology

To convert radians to degrees, use the following formula:


degrees = radians * ( 180.0 / pi )

Syntax


acos(num)

Parameter

The acos() function requires a number as a parameter.

Return value

acos() returns the inverse cosine of the number that is sent as a parameter. The return value lies in interval [0, pi] radians.

Code

#Positive number in radians
a <- acos(0.5);
print(paste0("acos(0.5): ", a, " radians"))
#negative number in radians
b <- acos(-0.5);
print(paste0("acos(-0.5): ", b, " radians"))
#applying acos() and then converting the result in radians to degrees
#radians = 0.5
c <- acos(0.5) * (180.0 / pi);
print(paste0("acos(0.5): ", c, " degrees"))

Free Resources

Attributions:
  1. undefined by undefined