PHP atan() Function

PHPServer Side ProgrammingProgramming

Definition and Usage

The atan() function returns the arc tan or tan inverse of arg in radians. atan() is the inverse function of tan(). Therefore if tan(x)=y, atan(y)=x.

For example, tan(pi/3)= 1.73205080757 (Squre Root of 3) and atan(1.73205080757)=1.04719755 rad which is equal to pi/3.

This function returns a float value .

Syntax

atan ( float $arg ) : float

Parameters

Sr.NoParameter & Description
1arg
A floating point number whose arc tan is to be calculated.

Return Values

PHP atan() function returns arc tan of given number. It is angle represented in radians. Returned value is between -pi/2 and pi/2

PHP Version

This function is available in PHP versions 4.x, PHP 5.x as well as PHP 7.x.

Example

 Live Demo

Following example calculates atan(0.57735026919) and returns 0.52359877559858 radians which is equivalent to pi/6. Note that tan(pi/6) is 1/sqrt(3) −

<?php
   $arg=0.57735026919;
   $val=atan($arg);
   echo "atan(" . $arg . ") = " . $val . " radians";
?>

Output

This will produce following result −

atan(0.57735026919) = 0.52359877559858 radians

Example

 Live Demo

Following example calculates atan(0) and returns 0 radians which is equivalent to tan(0) −

<?php
   $arg=0;
   $val=atan($arg);
   echo "atan(" . $arg . ") = " . $val . " radians";
?>

Output

This will produce following result −

atan(0) = 0 radians

Example

 Live Demo

Let's check find out atan(-1). It returns -0.78539816339745 radians (which is -pi/4) −

<?php
   $arg=-1;
   $val=atan($arg);
   echo "atan(" . $arg . ") = " . $val . " radians";
?>

Output

This will produce following result −

atan(-1) = -0.78539816339745 radians

Example

 Live Demo

Following example calculates atan(1.6331239E+16) which is a very large number and returns 1.5707963267949 radians which is equivalent to pi/2 −

<?php
   $arg=1.6331239e+16;
   $val=atan($arg);
   echo "atan(" . $arg . ") = " . $val . " radians";
?>

Output

This will produce following result −

atan(1.6331239E+16) = 1.5707963267949 radians
raja
Published on 29-Jun-2020 11:54:18
Advertisements