[scilab-Users] Atan function
Samuel GOUGEON
Samuel.Gougeon at univ-lemans.fr
Tue May 10 20:54:49 CEST 2011
Hi,
----- Message d'origine -----
De : Laurent Berger
Date : 10/05/2011 14:38:
> In this program
>
> clear;
> N=256;
> n=0:N-1;
> Xr=zeros(1,N);
> f0=2;
> Xr(f0+1)=1/(2*%i);
> Xr(N-(f0+1)+2)=-1/(2*%i);
> Xr=Xr.*exp(%i*%pi*2*6*n/N);
> xr=ifft(Xr);
> disp (atan(imag(Xr(11:12)),real(Xr(11:12))))
> disp (Xr(11)-Xr(12))
>
> results are
> 0. 3.1415927
>
> 0
>
> I don't understand why two numbers with a difference of 0 can have a numerical
> phase of 0 or pi .
> In matlab results are
> 0 0
> 0
This result is mathematically possible, since the phase of the origin 0 -- that
is here considered --
is undefined (or conventional). So any phase is possible, provided that the
modulus is zero.
The issue is that both Xr(11) and Xr(12) are apparently (complex: ok) (really)
null, with the same
actually null real parts and imaginary parts, with no epsilon-machine residues:
-->format("e",15)
-->real(Xr(11:12))
ans =
0.00000000D+00 0.00000000D+00
-->imag(Xr(11:12))
ans =
0.00000000D+00 0.00000000D+00
-->imag(Xr(11:12))==[0 0]
ans =
T T
-->real(Xr(11:12))==[0 0]
ans =
T T
// BUT
-->atan(imag(Xr(11:12)),real(Xr(11:12)))
ans =
0.00000000D+00 3.14159265D+00
// whereas
-->atan([0 0],[0 0])
ans =
0.00000000D+00 0.00000000D+00
// !!!!!
The issue may come from real() or/and imag(), instead of atan().
Or from somewhere else.
Regards
Samuel
More information about the users
mailing list