abs2

cmp.abs2 â real Instance Public methods Returns square of the absolute value. Complex(-1).abs2 #=> 1 Complex(3.0, -4.0).abs2 #=> 25.0

abs

cmp.abs â real Instance Public methods Returns the absolute part of its polar form. Complex(-1).abs #=> 1 Complex(3.0, -4.0).abs #=> 5.0

==

cmp == object â true or false Instance Public methods Returns true if cmp equals object numerically. Complex(2, 3) == Complex(2, 3) #=> true Complex(5) == 5 #=> true Complex(0) == 0.0 #=> true Complex('1/3') == 0.33 #=> false Complex('1/2') == '1/2' #=> false

/ 2

cmp / numeric â complexcmp.quo(numeric) â complex Instance Public methods Performs division. Complex(2, 3) / Complex(2, 3) #=> ((1/1)+(0/1)*i) Complex(900) / Complex(1) #=> ((900/1)+(0/1)*i) Complex(-2, 9) / Complex(-9, 2) #=> ((36/85)-(77/85)*i) Complex(9, 8) / 4 #=> ((9/4)+(2/1)*i) Complex(20, 9) / 9.8 #=> (2.0408163265306123+0.9183673469387754i)

-@

-cmp â complex Instance Public methods Returns negation of the value. -Complex(1, 2) #=> (-1-2i)

-

cmp - numeric â complex Instance Public methods Performs subtraction. Complex(2, 3) - Complex(2, 3) #=> (0+0i) Complex(900) - Complex(1) #=> (899+0i) Complex(-2, 9) - Complex(-9, 2) #=> (7+7i) Complex(9, 8) - 4 #=> (5+8i) Complex(20, 9) - 9.8 #=> (10.2+9i)

+

cmp + numeric â complex Instance Public methods Performs addition. Complex(2, 3) + Complex(2, 3) #=> (4+6i) Complex(900) + Complex(1) #=> (901+0i) Complex(-2, 9) + Complex(-9, 2) #=> (-11+11i) Complex(9, 8) + 4 #=> (13+8i) Complex(20, 9) + 9.8 #=> (29.8+9i)

**

cmp ** numeric â complex Instance Public methods Performs exponentiation. Complex('i') ** 2 #=> (-1+0i) Complex(-8) ** Rational(1, 3) #=> (1.0000000000000002+1.7320508075688772i)

*

cmp * numeric â complex Instance Public methods Performs multiplication. Complex(2, 3) * Complex(2, 3) #=> (-5+12i) Complex(900) * Complex(1) #=> (900+0i) Complex(-2, 9) * Complex(-9, 2) #=> (0-85i) Complex(9, 8) * 4 #=> (36+32i) Complex(20, 9) * 9.8 #=> (196.0+88.2i)

rectangular

Complex.rectangular(real[, imag]) â complex Class Public methods Returns a complex object which denotes the given rectangular form. Complex.rectangular(1, 2) #=> (1+2i)