From: Jean-Julien Fleck Date: 2010-06-08T04:42:34+09:00 Subject: Re: Complex numbers contradiction? 2010/6/7 Andrew Duncan : > I have ruby 1.8.7 (2009-06-08 patchlevel 173) [universal-darwin10.0] > > BTW, I hope that was 1/2 - 1/2i in your post... > > If this is a bug, it's pretty egregious. Seems to be a bug when both real and imaginary parts are integers: >> require 'complex' => true >> 1/Complex(1,1) => Complex(0, -1) >> Complex(1,1)**(-1) => Complex(Rational(1, 2), Rational(-1, 2)) >> 1/Complex(1,0) => Complex(1, 0) >> 1/Complex(1,0.5) => Complex(0.8, -0.4) >> 1/Complex(1,1) => Complex(0, -1) >> 1/Complex(1,2) => Complex(0, -1) >> 1/Complex(1,3) => Complex(0, -1) >> 1/Complex(1,4) => Complex(0, -1) >> 1/Complex(1,4.4) => Complex(0.0491159135559921, -0.216110019646365) >> 1/Complex(1,-1) => Complex(0, 0) >> 1/Complex(1,-2) => Complex(0, 0) >> 1/Complex(2,-2) => Complex(0, 0) >> 1/Complex(2.2,-2) => Complex(0.248868778280543, 0.226244343891403) >> 1/(Complex(1.0001,1.0001)) => Complex(0.4999500049995, -0.4999500049995) Brisingr ~>ruby -v ruby 1.8.7 (2009-06-08 patchlevel 173) [universal-darwin10.0] Cheers, -- JJ Fleck PCSI1 Lycée Kléber