Related Tags

php
math
acos
communitycreator

# What is acos() in PHP?

harris910

The acos()also called the “arc cosine” function function in PHP 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

### Methodology

To convert radians to degrees, use the following formula.

degrees = radians * ( 180.0 / M_PI)


### Syntax

float acos(num)


### Parameter

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

### Return value

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

### Code

<?php
echo("acos(0.5): ");
echo (acos(0.5));
?>
<?php
echo("acos(-0.5): ");
echo (acos(-0.5));
?>

<?php
#applying acos() and then converting the result in radians to degrees
echo("acos(0.5) * (180.0 / M_PI)): ");
echo (acos(0.5) * (180.0 / M_PI));
echo(" Degrees")
?>



RELATED TAGS

php
math
acos
communitycreator

CONTRIBUTOR

harris910
RELATED COURSES

View all Courses

Keep Exploring

Learn in-demand tech skills in half the time 