atan()

hitesh_mittal's avatar
Published Jul 24, 2023
Contribute to Docs

The built-in math function atan() determines the arc tangent of a given value. It is also known as the inverse tangent function, it identifies the angle whose tangent is equal to the specified value. The inverse function of atan() is the tan() function.

Syntax

$result = atan($number);

The atan() function takes one parameter:

  • $number (required): The number for which the arc tangent is to be calculated.

The atan() method returns a floating point number which is the arc tangent value of the number passed. The resulting numeric value will be between -pi/2 and pi/2 radians.

To convert radians to degrees, use the following:

$degrees = $radians * ( 180.0 / M_PI );

Example

The example below illustrates the use of the atan() function to calculate the arc tangent of a number and print the result.

<?php
echo("atan(0.5): " . atan(0.5) . " Radians");
?>

This will result in the following output:

atan(0.5): 0.46364760900081 Radians

Codebyte Example

The example below uses the atan() function to obtain the arc tangent value of a number in radians, and then converts it into degrees.

Code
Output
Loading...

All contributors

Contribute to Docs

Learn PHP on Codecademy