Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

arg() function for complex numbers is wrong #36

Closed
be9 opened this issue Nov 29, 2013 · 1 comment
Closed

arg() function for complex numbers is wrong #36

be9 opened this issue Nov 29, 2013 · 1 comment

Comments

@be9
Copy link

be9 commented Nov 29, 2013

Both ComplexFloat and ComplexDouble classes contain wrong implementation of arg().

E.g.

    public float arg() {
        return (float) Math.atan2(r, i);
    }

must be replaced with

    public float arg() {
        return (float) Math.atan2(i, r);
    }

exp(ix) = cos(x) + i*sin(x). atan2(y, x) = arctan(y/x) for non-zero x. So to get x = arg(exp(ix)), you need to take atan2(im(exp(ix)), re(exp(ix))) = atan2(sin(x), cos(x)) = arctan(tan(x)) = x (for x in proper range).

@mikiobraun
Copy link
Member

Hi be9,

after almost two years I finally get around to taking care of this.

Thanks for spotting and reporting it!

Best,

-M

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants