rectangular 2

cmp.rect â arraycmp.rectangular â array Instance Public methods Returns an array; [cmp.real, cmp.imag]. Complex(1, 2).rectangular #=> [1, 2]

rect 2

cmp.rect â arraycmp.rectangular â array Instance Public methods Returns an array; [cmp.real, cmp.imag]. Complex(1, 2).rectangular #=> [1, 2]

real?

cmp.real? â false Instance Public methods Returns false.

real

cmp.real â real Instance Public methods Returns the real part. Complex(7).real #=> 7 Complex(9, -4).real #=> 9

rationalize

cmp.rationalize([eps]) â rational Instance Public methods Returns the value as a rational if possible (the imaginary part should be exactly zero). Complex(1.0/3, 0).rationalize #=> (1/3) Complex(1, 0.0).rationalize # RangeError Complex(1, 2).rationalize # RangeError See to_r.

quo

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)

polar 2

cmp.polar â array Instance Public methods Returns an array; [cmp.abs, cmp.arg]. Complex(1, 2).polar #=> [2.23606797749979, 1.1071487177940904]

phase

cmp.phase â float Instance Public methods Returns the angle part of its polar form. Complex.polar(3, Math::PI/2).arg #=> 1.5707963267948966

numerator

cmp.numerator â numeric Instance Public methods Returns the numerator. 1 2 3+4i <- numerator - + -i -> ---- 2 3 6 <- denominator c = Complex('1/2+2/3i') #=> ((1/2)+(2/3)*i) n = c.numerator #=> (3+4i) d = c.denominator #=> 6 n / d #=> ((1/2)+(2/3)*i) Complex(Rational(n.real, d), Rational(n.imag, d)) #=> ((1/2)+(2/3)*i) See denominator.

magnitude

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