From: "Mauricio Fernández" Date: 2003-02-06T08:11:54+09:00 Subject: Re: Error in Complex On Thu, Feb 06, 2003 at 07:20:33AM +0900, Daniel Carrera wrote: > Martin, > > I can see that your answer is right. Perhaps you can show me what I'm > doing wrong. My colleagues and I can't figure it out: > > > -i = exp(i*3*pi/2) > > 2/3 > (-i) = exp(i * 3pi/2 *(2/3)) > = exp(i * pi) > = -1 > > What am I doing wrong? Nothing :) My TI says that (-1)^(3/2) = -i . So does (1/2-sqrt(3)/2). For (1/2+sqrt(3)/2) ^(3/2) it says +i because it is doing (1/2+sqrt(3)/2)^3 == -1 and then taking the square root and only considering one of the 2 values :) See: (-i)^(2/3) = exp(i*(3pi/2 - 2Pi) * 2/3) = exp(i*(pi -4pi/3)) = exp(-i*pi/3) = 1/2 - sqrt(3)/2 (-i)^(2/3) = exp(i*(3pi/2 + 2Pi) * 2/3) = exp(i*(pi +4pi/3)) = exp(+i*pi/3) = 1/2 + sqrt(3)/2 1 has in n n-order roots. You must add their arguments to that of your (only) result. Consider the following: (-i)^(2/3) = ((-i) ^ (1/3)) ^ 2 It turns out that a^(1/3) = |a|^(1/3) * exp( j * 2PI / 3 * n + j * arg(a)/3 ) with n = 0,1,2 In this case (-i) ^ (1 / 3) = 1 * exp ( j * -PI/6 + j * 2PI/3*n ) ( ) ^2 = exp(j (-pi/3)) exp(j) exp(j (pi/3)) You can also see it graphically: (-i) ^(2/3) means the cube (?) root of -1 If I could draw here, I'd point at the 3 cube (is that the terminology in English?) roots of the "minus unity" :-) What should a well-behaved Complex library do about multiple roots? It even happens for 1! sqrt(1) ===> 1 taken by convention -1 silently discarded PS: eqs.gsub!(/j/, "i") My EE background haunts me :) -- _ _ | |__ __ _| |_ ___ _ __ ___ __ _ _ __ | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ | |_) | (_| | |_\__ \ | | | | | (_| | | | | |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_| Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com 'Ooohh.. "FreeBSD is faster over loopback, when compared to Linux over the wire". Film at 11.' -- Linus Torvalds