Le mardi 04 novembre 2014 à 09:22 -0800, isa...@gmail.com a écrit : > I have recently become aware of Julia and have been impressed with its > ease of use and speed. While I was converting my previous code to > Julia, I noticed that trigonometric functions at infinity yield > DomainError and abort the program. Try sin(Inf), sin(-Inf), cos(Inf), > tan(Inf), etc. I checked the behavior of Numpy and it returns a NaN > and a warning of invalid value to the function. I remember Matlab was > yielding a NaN too. But they both wouldn't abort the program. > > Returning a NaN instead of aborting the program might be useful when > the following computations don't depend on only this result of NaN. > For example, consider finding the smallest element of x =cos( [1.0, > 2.0, Inf]) which would have given the number I am interested in if > cos(Inf) gives a NaN. Here I cos(2.0) < NaN would be false > nevertheless findmin cleverly finds the correct answer 2.0 ( so does > Numpy). Note that Inf is usually a result of an intermediate step of > an algorithm. You'll probably be interested in this discussion: https://github.com/JuliaLang/julia/issues/7866
> If the following computations involve NaN and yield compilation error > than checking elements of x being not NaN is necessary. But since it > does occur rarely, avoiding this check might be useful for speed. > > What would be your thoughts? Thanks. > >