Complex-step-compatible atan2()

atan2() or arctan2() function that is compatible with complex-step derivative operations.
24 Downloads
Aktualisiert 27. Okt 2021

Lizenz anzeigen

The function atan2(Y,X) [or arctan2(Y,X)] is the four quadrant arctangent of the elements of X and Y such that -pi <= atan2(Y,X) <= pi.
MATLAB atan2() reports an error when inputs are complex. This function reproduces MATLAB atan2() results for real inputs, but can be used with complex inputs to enable complex-step derivative operations.
There is an output discontinuity at T = pi and -pi. However, the output derivative is continuous, so, at T = pi and -pi, this function calculates the derivative analytically and adds complex-step-equivalent perturbations to the output.
Because the function remains discontinuous, the user should carefully consider before using atan2() output for gradient-based optimization.
Complex step is a numerical differentiation technique. See description:

Zitieren als

Anthony Ricciardi (2026). Complex-step-compatible atan2() (https://de.mathworks.com/matlabcentral/fileexchange/101193-complex-step-compatible-atan2), MATLAB Central File Exchange. Abgerufen.

Kompatibilität der MATLAB-Version
Erstellt mit R2016b
Kompatibel mit allen Versionen
Plattform-Kompatibilität
Windows macOS Linux
Version Veröffentlicht Versionshinweise
1.0.0