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.
    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <script type="text/javascript">
       document.write("Output : " + Math.atan(1));
    </script>

    chevron_right

    
    

    Output:

    Output : 0.7853981633974483
  2. When 0 is passed as a parameter.
    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <script type="text/javascript">
       document.write("Output : " + Math.atan(0));
    </script>

    chevron_right

    
    

    Output:

    Output : 0
  3. When -0 is passed as a parameter.
    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <script type="text/javascript">
       document.write("Output : " + Math.atan(-0));
    </script>

    chevron_right

    
    

    Output:

    Output : -0
  4. When Infinity is passed as a parameter.
    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <script type="text/javascript">
       document.write("Output : " + Math.atan(Infinity));
    </script>

    chevron_right

    
    

    Output:

    Output : 1.5707963267948966
  5. When -Infinity is passed as a parameter.
    filter_none

    edit
    close

    play_arrow

    link
    brightness_4
    code

    <script type="text/javascript">
       document.write("Output : " + Math.atan(-Infinity));
    </script>

    chevron_right

    
    

    Output:

    Output : -1.5707963267948966


My Personal Notes arrow_drop_up

I am a technology enthusiast who has a keen interest in programming I am pursuing Engineering in Computer Science from GEU, Dehradun I like to unwind by watching movies and English sitcomsI have a keen interest in music

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.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.