atan()

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.

us
Visit us
code
Hide code
Code
Output
Hide output
Hide output
Loading...

All contributors

Looking to contribute?

Learn PHP on Codecademy