Atan2 vs fabs


The code atan2(sin(x),cos(x)) achieves the same computation as fabs(x,2*pi()). The manual warns that fabs() can induce sampling issues; would the same issues apply to the atan2 version?


Warning is due to possible discontinuity in gradient. The same applies for any function which may produce discontinuity in gradient.


Gotcha. I have nil training in calculus; presumably atan2(sin(x),cos(x)) has a discontinuous gradient?


At n*pi, the derivative is undefined because the function is discontinuous.


Gotcha, thanks @yizhang