PHP Tutorial - PHP atan() Function






Definition

The atan() function calculates the arc tangent value. It reverses the operation of tan().

Syntax

PHP atan() Function has the following format.

float atan ( float num )

Parameter

ParameterDescription
numRequired. Specifies an argument to process

Return

The arc tangent of arg in radians.

We can use the rad2deg() to convert radians to degrees.

Example

Return the arc tangent of different numbers with the atan() function:


<?php/*w  ww  . j a  va2  s .  c o  m*/
$atan1 = atan(0.46); 
echo $atan1;
$atan2 = atan(tan(80)); 
echo $atan2;

echo(atan(0.5) . "\n");
echo(atan(-0.5) . "\n");
echo(atan(5) . "\n");
echo(atan(-5) . "\n");
echo(atan(100) . "\n");
echo(atan(-100));
?>

The code above generates the following result.