[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #44280] asin, asind, atan, and atand may have
[Octave-bug-tracker] [bug #44280] asin, asind, atan, and atand may have incorrect values
Tue, 17 Feb 2015 03:31:15 +0000
Mozilla/5.0 (X11; Linux x86_64; rv:18.0) Gecko/20100101 Firefox/18.0 SeaMonkey/2.15
Follow-up Comment #1, bug #44280 (project octave):
Thanks for reporting this. I've confirmed one bug for sure.
Here's what I'm seeing on a linux system:
ans = 90.000 - 100.998i
ans = -90.000 + 11.616i
ans = -1.57080 + 0.20273i
ans = 1.5708 - 1.7627i
This looks to be an incorrect formula for arc tangent in
atan (const Complex& x)
static Complex i (0, 1);
return i * log ((i + x) / (i - x)) / 2.0;
I think it should be (i - x) / (i + x) in the argument of the complex
logarithm. Or i/2 * (ln(i-x) - ln(i+x)). In the case of x=5i, something for
which the argument of the logarithm is solely imaginary (i.e., -4i and 6i),
the imaginary portion of the logarithm in both cases is -pi/2*i - -pi/2*i =
-pi*i, multiplying by i/2 gives us pi/2, or 90 degrees.
So, yes, atand() seems like a bug. But more than that we should have some
good test cases to find these bugs, and that's a bit of a project.
But I don't know why your build of Octave is having problems with asin() as
well. Different library for the Apple products? I don't know. I will look
into this more and try making some guesses.
Reply to this item at:
Message sent via/by Savannah