arcsin, arccos reject valid arguments

Issue #781 closed
Former user created an issue

Hi,

I am using SpeedCrunch 0.12 on Windows 10 (64-bit). I have noticed that the built-in arccos and arcsin seem to erratically reject valid arguments saying "undefined for argument domain".

For example: arcsin(0.2) -> OK arcsin(0.25) -> "undefined" arcsin(0.251) -> OK arcsin(0.2511) -> "undefined" arcsin(0.25111) -> OK

Replacing arccos for arcsin, I get exactly the same sequence of results, so I figured it might be a problem with the parser?

Thanks for investigating this.

Best regards, Martin

Comments (9)

  1. Pol Welter

    Hi Martin,

    I cannot reproduce that behaviour. Can you post some more details about the output, e.g. the exact numbers for those lines that do not fail? Also tell us what your settings are, specifically if you have complex numbers enabled or not.

    Could it be that you set the decimal separator to , instead of .? See Settings -> Input Format -> Radix Character. Then it would reject arcsin(0.2) = arcsin(2), provided that complex numbers are disabled.

  2. Pol Welter

    The issue is the following:

    1. With complex numbers enabled, arcsin uses the complex definition involving square roots and logarithms to compute the result.
    2. Rounding errors introduce a small imaginary part, on the order of 10^-80.
    3. The result is still in radians, so we convert it to degrees. The corresponding code checks if the number is real, because otherwise the conversion makes no sense (geometrically speaking).
    4. The rounding error kills it.

    Not sure what our policy should be here. We could just make it so that the user cannot enable complex numbers while in degrees mode and vice versa.

    Maybe the easiest solution would just be to remove the check to see if the 'angle' is real. Is ther any important reason for it, apart from the fact that a complex angle makes no geometric sense? I don't remember us putting it in place to fix some specific bug.

    Let's decide on either approach, and I'll prepare a PR.

    EDIT: Apparently some people argue that complex angles do make sense. Duh. I'll do that then.

  3. Martin F. Schumann

    Hi Pol,

    Thank you so much for looking into this and submitting a patch so quickly, that's awesome!

    Best, Martin

  4. Log in to comment