Tutorialspoint.dev

Math.atan( ) In JavaScript

The Math.atan( ) function in JavaScript is used to return the arctangent of a number in radians.

Math.atan(x)=arctan(x)=unique y,where y belongs to [-pi/2;pi/2] such that tan(y)=x

The Math.atan() method returns a numeric value between -pi/2 and pi/2 radians.
atan() is a static method of Math, therefore, it is always used as Math.atan(), rather than as a method of a Math object created.

Syntax:

Math.atan(value)

Parameters Used:
Value:A number in radians who arctangent you want to find.

Return Value:
The Math.atan() function returns the arctangent of the given number in radians.



Examples:

Input : Math.atan(1)
Output : 0.7853981633974483
     
Input : Math.atan(0)
Output : 0

Input : Math.atan(-0)
Output : -0

Input : Math.atan(Infinity)
Output : 1.5707963267948966

Input : Math.atan(-Infinity)
Output : -1.5707963267948966

  1. When 1 is passed as a parameter.
    <script type="text/javascript">
       document.write("Output : " + Math.atan(1));
    </script>

    Output:

    Output : 0.7853981633974483
  2. When 0 is passed as a parameter.
    <script type="text/javascript">
       document.write("Output : " + Math.atan(0));
    </script>

    Output:

    Output : 0
  3. When -0 is passed as a parameter.
    <script type="text/javascript">
       document.write("Output : " + Math.atan(-0));
    </script>

    Output:

    Output : -0
  4. When Infinity is passed as a parameter.
    <script type="text/javascript">
       document.write("Output : " + Math.atan(Infinity));
    </script>

    Output:

    Output : 1.5707963267948966
  5. When -Infinity is passed as a parameter.
    <script type="text/javascript">
       document.write("Output : " + Math.atan(-Infinity));
    </script>

    Output:

    Output : -1.5707963267948966


This article is attributed to GeeksforGeeks.org

leave a comment

code

0 Comments

load comments

Subscribe to Our Newsletter