PHP Function Reference

PHP atan() Function



The PHP atan() function returns arc tangent of a value. The returned value will be in the range -𝜋/2 through 𝜋/2. In special cases it returns the following:

  • If the argument is NAN, then the result is NAN.

Syntax

atan(number)

Parameters

number Required. Specify the value.

Return Value

Returns the arc tangent of the value.

Example:

In the example below, atan() function is used to find out the arc tangent of a given value.

<?php
echo "atan(-2) = ".atan(-2)."\n";
echo "atan(-1) = ".atan(-1)."\n";
echo "atan(0) = ".atan(0)."\n";
echo "atan(1) = ".atan(1)."\n";
echo "atan(2) = ".atan(2)."\n";
echo "atan(100) = ".atan(100)."\n";
echo "atan(NAN) = ".atan(NAN)."\n";
?>

The output of the above code will be:

atan(-2) = -1.1071487177941
atan(-1) = -0.78539816339745
atan(0) = 0
atan(1) = 0.78539816339745
atan(2) = 1.1071487177941
atan(100) = 1.5607966601082
atan(NAN) = NAN

❮ PHP Math Reference