-->atan(0,0)
!--error 32
singularity of log or tan function
How to deal with it?
You probably need to write your code so that you don't try it,
since this function is not defined for (0,0). Alternatively,
if you don't care about the answer, and the input values are
restricted, and the precision of the answers isn't too critical
{enough disclaimers yet??} you could add some small value to
one or the other component to avoid the origin.
-frank
That expression is undefined from the mathematical point of view, so do not
try to use it. atan(x,y) is used to calculate atan(x/y) but also takes the
signs of x and y into account and y is allowed to be zero. atan(0,0) has 0/0
as subexpression which is undefined; the atan of an undefined value is also
undefined.
Or, to be more concise, you can't compute the azimut of the null vector.
Wolfgang
--
Wolfgang von Hansen, IPF, Universitaet Karlsruhe, Tel. +49 (0)721 608-6993
Frank Miles <7css2a$508$1...@nntp6.u.washington.edu> wrote:
>Doo Jin Cho <dj...@madang.ajou.ac.kr> wrote:
>>-->atan(0,0)
>> !--error 32
>>singularity of log or tan function
>
If you consider starting at any point on the plane (so atan2(x,y) is well defined)
and moving in a straight line to the origin, atan2 should remain constant.
Therefore any choice for atan2(0,0) is mathematically wrong, and may introduce
an unexpected error in a code that relies on correct mathematical behavior.
The right way is to check if you are on the origin before calling atan2.
Steve
In a previous article, "Doo Jin Cho" <dj...@madang.ajou.ac.kr> wrote:
->Thanks for your comments. Although I agree about ill-definition of
->atan(0,0), it would be better to assign zero instead of producing error. For
->example, Matlab and visual c++ give zero for atan2(0,0). It is cumbersome
->and against the merit of an vectorized language like scilab for programmers
->to care about this problem as you suggested.
->
->Frank Miles <7css2a$508$1...@nntp6.u.washington.edu> wrote:
->>Doo Jin Cho <dj...@madang.ajou.ac.kr> wrote:
->>>-->atan(0,0)
->>> !--error 32
->>>singularity of log or tan function
->>
->>You probably need to write your code so that you don't try it,
->>since this function is not defined for (0,0). Alternatively,
->>if you don't care about the answer, and the input values are
->>restricted, and the precision of the answers isn't too critical
->>{enough disclaimers yet??} you could add some small value to
->>one or the other component to avoid the origin.
->
->
->