# How to get the arctangent of the quotient of its arguments in JavaScript?

In this tutorial, we will learn how to get the arctangent of the quotient of its arguments in JavaScript.

The JavaScript math object has several constants and methods for performing mathematical operations. It does not have constructors, unlike the date object.

JavaScript Math is one of the built-in objects that contains attributes and methods for mathematical constants and functions, as well as methods for executing mathematical operations. It is neither a function nor a function object. Because Math's properties and methods are static, you can refer to it as an object without constructing it.

Following are the ways to find the arctangent of the quotient of its arguments in JavaScript.

## Using Math.atan2() Method

The Math.atan2() method always returns a numeric value between -π and π expressing a (x, y) point's angle theta. This is the counter-clockwise angle in radians measured between the positive X-axis and the point (x, y). It's worth noting that the y-coordinate comes first, followed by the x-coordinate.

For Math.atan2(), the angle in the plane (in radians) between the positive x-axis and the ray from (0,0) to the point (x,y) is returned (y,x).

### Syntax

Math.atan2(value);


To find its arctangent, the value is passed as a parameter to the Math.atan2() method.

### Example

In this example, we see how the Math.atan2() method is used to calculate the arctangent of the quotient of its inputs in radians, which are supplied as parameters. The value1 variable takes a negative number between -1 and 0 as an input and returns the arctangent. This division yields infinity.

The variable value2 uses two positive integers as parameters to calculate the arctangent of their quotient. The variable value3 accepts zero and a positive integer as input and returns the quotient’s arctangent in radians to the console. The variable value4 accepts a positive integer and one as parameters and outputs the result to the console.

<html>
<body>
<h3>Get the arctangent of the quotient using <i>Math.atan2()</i> method.</h3>
<p id = "root"> </p>
<p id = "root1"> </p>
<p id = "root2"> </p>
<p id = "root3"> </p>
</body>
<script>
let root = document.getElementById("root");
let root1 = document.getElementById("root1");
let root2 = document.getElementById("root2");
let root3 = document.getElementById("root3");
let value1 = Math.atan2(-1,0);
root.innerHTML = "Math.atan2(-1,0) = " + value1;
let value2 = Math.atan2(24,28);
root1.innerHTML = "Math.atan2(24,28) = " + value2;
let value3 = Math.atan2(0,9);
root2.innerHTML = "Math.atan2(0,9) = " + value3;
let value4 = Math.atan2(244,1);
root3.innerHTML = "Math.atan2(244,1) = " + value4;
</script>
</html>


## Using the math.js Library

Math.js is a large math library that is used in JavaScript and Node.js. It also holds a flexible expression parser and provides an integrated optimal solution for working with numbers such as complex numbers, units, matrices, and big numbers.

It accepts numbers, big numbers, complex numbers, fractions, units, strings, arrays, and matrices. It is compatible with the built-in library of JavaScript.

It has a versatile expression parser. It can perform any symbolic calculation. The math.js package includes a huge number of built-in constants and functions, and it might also be used as a command line program. This library will work with any JavaScript engine. It is easily expandable. The math.js library is open source.

### Syntax

math.atan2(x,y);


Two values are supplied as parameters whose quotient would require math.atan2() method to compute its arctangent.

### Example

In this example, we see how the math.atan2() method of the math.js library is used to calculate the arctangent of the quotient of its inputs in radians, which are supplied as parameters.

The value1 variable takes a negative number as x and a positive number as y and returns the arctangent of x/y. The variable value2 takes two positive integers as parameters and computes the arctangent of the quotient of these numbers. The variable value3 accepts zero and a positive integer as input, and its quotient is the arctangent in radians, which is written to the console. The variable value4 takes a positive integer and one as parameters and writes the result to the console.

<html>
<body>
<h3> Get the arctangent of the quotient using math.js <i>math.atan2()</i> method</h3>
<p id = "root"> </p>
<p id = "root1"> </p>
<p id = "root2"> </p>
<p id = "root3"> </p>
</body>
<script src="https://unpkg.com/mathjs/lib/browser/math.js"></script>
<script>
let root = document.getElementById("root");
let root1 = document.getElementById("root1");
let root2 = document.getElementById("root2");
let root3 = document.getElementById("root3");
let value1 = math.atan2(-2,8);
root.innerHTML = "math.atan2(-2,8) = " + value1;
let value2 = math.atan2(17,33);
root1.innerHTML = "math.atan2(17,33) = " + value2;
let value3 = math.atan2(0,4);
root2.innerHTML = "math.atan2(0,4) = " + value3;
let value4 = math.atan2(212,1);
root3.innerHTML = "math.atan2(212,1) = " + value4;
</script>
</html>


In this tutorial, we looked at two approaches for calculating the arctangent of the quotient of the inputs in radians. The first option is to use the Math functions included in JavaScript. The second method is to utilize an external Mathematical library called math.js and use the mathematical functions provided by this library to determine the arctangent of the quotient of the parameters.