Skip to content

DualNumbers and ArcTan[x,y] #7

@rudolfoldenbourg

Description

@rudolfoldenbourg

Dear Sjoerd,
I continue to look for the best approach to minimize a mean squared error function that has many variables connected in part by trigonometric functions, among them ArcTan[x,y].

In using DualNumbers, I noticed that ArcTan[Dual[x,dx],Dual[y,dy]] remains unevaluated, both, the Standard and NonStandard part, while ArcTan[Dual[y,dy]/Dual[x,dx]] seems to evaluates to the correct result when x and y are both positive. As is well known, difficulties arise when x and/or y become negative, as the quadrants need to be considered for evaluating to the correct angle. Therefore, Mathematica implements the ArcTan[x,y] version of the function to keep track of the quadrants the sign of the x and y variables are pointing to.

Curiously, though, while the Standard part of ArcTan[Dual[y,dy]/Dual[x,dx]] follows the expectation of ArcTan[y/x] and gives the same result for x negative and y positive as for x positive and y negative, the NonStandard part of ArcTan[Dual[y,dy]/Dual[x,dx]] distinguishes between these two cases and gives the correct results for the partial derivatives:
Pasted Graphic

This also applies when both x and y are negative. While the standard part gives the same result, incorrectly, as if both variables were positive, the NonStandard part correctly switches sign between the partial derivatives for the two cases, either both variables negative or both positive:
Pasted Graphic 1

In my computations for minimizing the mean squared error function, it is important to be able to distinguish between angles from different quadrants.

Therefore, I would like to ask you a) if my analysis presented above is correct and b) if so, do you have suggestions for how to use DualNumbers when angles between -Pi and +Pi need to be correctly identified?

Thanks for any advice you can give.

Rudolf

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions