octave-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

## [Octave-bug-tracker] [bug #44280] asin, asind, atan, and atand may have

 From: Dan Sebald Subject: [Octave-bug-tracker] [bug #44280] asin, asind, atan, and atand may have incorrect values Date: Tue, 17 Feb 2015 03:31:15 +0000 User-agent: 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:

>> asind(3)
ans =   90.000 - 100.998i
>> atand(5i)
ans = -90.000 + 11.616i
>> atan(5i)
ans = -1.57080 + 0.20273i
>> asin(3)
ans =  1.5708 - 1.7627i

This looks to be an incorrect formula for arc tangent in
liboctave/numberic/lo-mappers.c:

Complex
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:

<http://savannah.gnu.org/bugs/?44280>

_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/

```

reply via email to

 [Prev in Thread] Current Thread [Next in Thread]