[scilab-Users] Atan function

Samuel GOUGEON Samuel.Gougeon at univ-lemans.fr
Wed May 11 15:49:19 CEST 2011


  ----- Message d'origine -----
De : Serge Steer
Date : 10/05/2011 22:57:
> Le 10/05/2011 21:18, Samuel GOUGEON a écrit :
>>  Look at that:
>>
>> -->atan(0, 0)
>>  ans  =
>>     0.00000000D+00
>>
>> -->atan(0, -0)
>>  ans  =
>>     3.14159265D+00
>>
>> --> -0 == 0
>>  ans  =
>>   T
>>
>> :-(( Funny, isn't it ?!
> This later result is really quite  funny, but the atan result is just due to 
> the branch cut definition for that function
The "special" branching cut is used only when atan() is used with a single argument.
It is not the case here. The help page states: The range of atan(y,x) is (-pi, pi].
while : atan(-0,-0)== -%pi  => %T

By the way, how is it possible to explain that the sign of -0 looks to be recorded
in floating point mode?? This "feature" makes Scilab somewhat unconsistent:
-->floor(-0)
  ans  =
     0.
// -1 would instead be expected!
-->sign(-0)
  ans  =
     0.
-->sign(-number_properties("tiniest"))
  ans  =
   - 1.
This is why atan(y,x) should return always the same result if x and y are reals 
and null.
-->help minus // does not document this special feature, no more than
-->help sign

Finally, to answer to Laurent:

How can I guess that variable x is -0 and not 0?

is_0minus = (x==0 & atan(0,x)==%pi);

but we should hope that this puzzling feature will be fixed.

Samuel




More information about the users mailing list