What is atan() in PHP?
The atan() functionarc tangent functionatan() returns the inverse tangent of a number in radians.
This means that
tan(atan(x))would be equal tox.
Figure 1 shows the mathematical representation of the atan() function.
To convert radians to degrees, use:
degrees = radians * ( 180.0 / M_PI )
Below is the graphical representation of the atan function.
Graphical representation of atan() function
Syntax
float atan(num)
Parameter
This function requires a number as a parameter.
Return value
atan() will return the inverse tangent of a number (in radians) that is sent as a parameter. The return value lies within [-pi/2,pi/2] radians.
Example
<?php#Positive number in radiansecho("atan(0.5): ");echo (atan(0.5));echo(" Radians")?><?php#Negative number in radiansecho("atan(-0.5): ");echo (atan(-0.5));echo(" Radians")?><?php#tan(atan(x))echo("tan(atan(0.5)): ");echo (tan(atan(0.5)));echo(" Radians")?><?php#applying atan() and then converting the result in radians to degrees#radians = 1echo("atan(1) * (180.0 / M_PI)): ");echo (atan(1) * (180.0 / M_PI));echo(" Degrees")?>