carg (?) bug



Alexey Beshenov pisze:
> On Sunday 11 January 2009 15:48:09 Adam Majewski wrote:
>> Hi,
>>
>> I make complex number in exponential form :
>> R:16;
>> T:1/3;
>> Z:R*exp(T*%i*2*%pi);
>>
>> output is :
>> 16*((sqrt(3)*%i)/2-1/2)
>>
>> Then check radius :
>>
>> r:abs(Z)
>>   16
>>
>> it is good , but carg :
>>
>> (%i6) t:carg(Z)
>> (%o6) (2*%pi)/3
>>
>> It gives 2/3 not 1/3 .
>> Is it a bug ?
> 
> No. Complex argument of z is defined as angle \theta
> (-\pi < \theta <= \pi) such that z = |z| exp (\theta i).
> 
> So is is clear that carg(R*exp(T*%i*2*%pi)) = 2*%pi*T.
> 
better version :

( carg gives negative values fo numbers below horizontal ( x ) axis
"(...) produces results in the range (??, ?] It can be mapped to [0, 2?) 
by adding 2? to the negative values"

so


/* principial value of argument of complex number in turns  */

carg_pv_t(z):=block(
	[t],
	t:carg(z)/(2*%pi), /* now in turns */
	if t<0 then t:t+1, /* map from (-pi,pi] to [0, 2?) */
	return(t)
	)$



Adam