PHP atan() Function

In this chapter you will learn:

  1. Definition for PHP atan() Function
  2. Syntax for PHP atan() Function
  3. Parameter for PHP atan() Function
  4. Return for PHP atan() Function
  5. Example - Return the arc tangent of different numbers with the 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/*from   j ava 2  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.

Next chapter...

What you will learn in the next chapter:

  1. Definition for PHP atan2() Function
  2. Syntax for PHP atan2() Function
  3. Parameter for PHP atan2() Function
  4. Return for PHP atan2() Function
  5. Example - Return the arc tangent of two variables