PHP acos Function | Calculate Arc Cosine of a Number

Trigonometry is one of the most important concepts in Mathematics. PHP acos is an inbuilt Math Function in PHP. It calculates the arc cosine of a number in radians which works the opposite of PHP cos Function. In this article, we will discuss the PHP acos Function. Also, we will discuss an example of using it.

Syntax

float acos ($value)

Parameters

The function expects only one parameter. The number for which you want to find the arc cosine value is the input to the function. Also, the input value must be in the value between -1 and 1. However, if the input lies outside this range, the function returns NAN.

Return Value

The function returns a float value which is the arc cosine value of the input value. However, if the input value is not in between -1 and 1, the function returns NAN.

Input: acos(1)
Output: 0

Input: acos(-1)
Output: 3.1415926535898

Input: acos(0)
Output: 1.5707963267949

Input: acos(0.5)
Output: 1.0471975511966

Input: acos(2)
Output: NAN

PHP acos Function

Example

For example, consider the following example of using the function to determine the arc cosine value of a number.

<?php

	echo acos(1);

	echo acos(-1);

	echo acos(0);

	echo acos(0.5);

	echo acos(2);

?>

The above example prints the following.

Output:
0
3.1415926535898
1.5707963267949
1.0471975511966
NAN

Conclusion

In conclusion, we discussed the PHP acos function. Additionally, you can read more about it on the Official Documentation of PHP. Also, you can read more on PHP Math Functions on Concatly.

Spread the Knowledge

Leave a Reply

Your email address will not be published. Required fields are marked *