From: serialhex Date: 2011-05-13T03:46:26+09:00 Subject: Re: Math cube root --000e0cd72dba05136404a3189b28 Content-Type: text/plain; charset=ISO-8859-1 On Thu, May 12, 2011 at 2:30 PM, Josh Cheek wrote: > Which we don't here, given that the cube root of -1 isn't imaginary :/ there are actually 3 cube roots of -1 (and 4 quad roots of -1, and 5 penta roots of -1 and...) behold the code: ruby-1.9.2-p180 :004 > a = (-1)**(1/3) => (0.5000000000000001+0.8660254037844386i) ruby-1.9.2-p180 :005 > a.conj => (0.5000000000000001-0.8660254037844386i) ruby-1.9.2-p180 :006 > a.conj**3 => (-1.0-3.885780586188048e-16i) ruby-1.9.2-p180 :007 > a**3 => (-1.0+3.885780586188048e-16i) ruby-1.9.2-p180 :008 > (-1)**3 => -1 (conjugation simply flips the sign of the imaginary number, which is helpful for a bunch of things) so while there may be 1 _real_ root for a given number, there are n roots for any number taken to the (1/n)th power. and while most people will want the (simple) (-1)**(1/3) == (-1) answer, they are all right (minus the floating-point rounding errors... which is kind of odd cause i would think that i would be getting the rational representation of the complex numbers instead of floats... idfk... whatev!) hex --000e0cd72dba05136404a3189b28--