PHP | atan2( ) Function

The atan2() function is a builtin function in PHP and is used to calculate the arc tangent of two variables x and y passed to it as arguments.
The function returns the result in radians, which is between -Pi and Pi (inclusive).


float atan2($y, $x)

Parameters: This function accepts two parameters and are described below:

  1. $y: This parameter specifies the dividend.
  2. $x: This parameter specifies the divisor.

Return Value: It returns a float value which is the arc tangent of y/x in radians.


Input : atan2(0.50, 0.50)
Output : 0.78539816339745

Input : atan2(-0.50, -0.50)
Output : -2.3561944901923

Input : atan2(5, 5) 
Output : 0.78539816339745

Input : atan2(10, 20) 
Output : 0.46364760900081

Below programs, taking different values of the parameters are used to illustrate the atan2() function in PHP: