JavaScript Math atan( ) Method

Below is the example of the Math atan( ) Method.

  • Example:
    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

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

    chevron_right

    
    

  • Output:
    When 1 is  passed as a parameter: 0.7853981633974483

The Math.atan( ) method is used to return the arctangent of a number in radians. The Math.atan() method returns a numeric value between -pi/2 and pi/2 radians. The 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.

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

Syntax:

Math.atan(value)

Parameters: This function accepts a single parameter as mentioned above and described below:



  • x: which is a number in radians who arctangent you want to find.

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

Below examples illustrate the Math atan( ) method in JavaScript

  • Example 1:
    Input : Math.atan(1)
    Output : 0.7853981633974483
  • Example 2:
    Input : Math.atan(0)
    Output : 0
  • Example 3:
    Input : Math.atan(-0)
    Output : -0
  • Example 4:
    Input : Math.atan(Infinity)
    Output :  1.5707963267948966
  • Example 5:
    Input : Math.atan(-Infinity)
    Output :  -1.5707963267948966

More example codes for the above method are as follows:

Program 1:

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

When 0 is  passed as a parameter: 0

Program 2:

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

When -0 is  passed as a parameter: 0

Program 3:

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

When Infinity is  passed as a parameter: 1.5707963267948966

Program 4:

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output:

When -Infinity is  passed as a parameter: -1.5707963267948966

Supported Browsers:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Opera
  • Safari

full-stack-img




My Personal Notes arrow_drop_up


If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.