Learn and Learn

Learn And Learn - great place for tutorials, references and how-to

Ruby – Find Arc Tangent using atan2() Method for Complex Number – Examples & Explanation

In Ruby, atan2() is a method in CMath class which is used to find the arc tangent of specified given complex numbers in Ruby language to determine the quadrant. To get the arc tangent of given complex numbers we use CMath.atan2(x, y) method.

atan2() method in Ruby

atan2() method exists in Standard atan2() Library of Ruby. The purpose of this method is to provide perfect arc tangent of specified given complex numbers to determine the quadrant.

Syntax of the atan2() method in Ruby

Syntax of atan2() method is:

Parameters of atan2() method in Ruby

Parameter Description
xAny valid complex numbers. These parameter are required.

Note: if the x parameter is not a complex number, atan2() method will return an error.

Return Value of atan2()

atan2() method will return the arc tangent of given complex numbers.

Ruby atan2() Example 1


Output:
1.5707963267948966+0.0i

Ruby atan2() Example 2


Output:
-1.4701377726075762+0.09932544936725085i

Ruby atan2() Example 3


Output:
-1.373400766945016-0.0i

Ruby atan2() Example 4


Output:
Error

Loading...
LearnAndLearn.com © 2018 - All rights reserved