[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #43349] asin behaves differently from Matlab f
From: |
John W. Eaton |
Subject: |
[Octave-bug-tracker] [bug #43349] asin behaves differently from Matlab for arguments larger than 1 |
Date: |
Mon, 06 Oct 2014 17:31:32 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0 Iceweasel/31.0 |
Follow-up Comment #8, bug #43349 (project octave):
Some care is needed here. You don't want to just throw away the signbit on
the imaginary part of the argument to sqrt if it happens to be zero. So I
think the fix belongs in rc_asin functions, not the asin (Complex) functions.
Something like
diff --git a/liboctave/numeric/lo-mappers.cc
b/liboctave/numeric/lo-mappers.cc
--- a/liboctave/numeric/lo-mappers.cc
+++ b/liboctave/numeric/lo-mappers.cc
@@ -496,7 +496,17 @@
Complex
rc_asin (double x)
{
- return fabs (x) > 1.0 ? asin (Complex (x)) : Complex (asin (x));
+ if (fabs (x) > 1.0)
+ {
+ static Complex i (0, 1);
+
+ // Don't forward to asin (Complex (x)) because the value of
+ // Complex (1.0 - x*x) != 1.0 - (Complex (x) * Complex (x))!
+
+ return -i * log (i*x + sqrt (Complex (1.0 - x*x)));
+ }
+ else
+ return Complex (asin (x));
}
FloatComplex
We probably need to review all of these functions that convert real-valued
arguments to complex.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?43349>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #43349] asin behaves differently from Matlab for arguments larger than 1, Ricardo Biloti, 2014/10/02
- [Octave-bug-tracker] [bug #43349] asin behaves differently from Matlab for arguments larger than 1, Rik, 2014/10/06
- [Octave-bug-tracker] [bug #43349] asin behaves differently from Matlab for arguments larger than 1, Ricardo Biloti, 2014/10/06
- [Octave-bug-tracker] [bug #43349] asin behaves differently from Matlab for arguments larger than 1, Michael Godfrey, 2014/10/06
- [Octave-bug-tracker] [bug #43349] asin behaves differently from Matlab for arguments larger than 1, Rik, 2014/10/06
- [Octave-bug-tracker] [bug #43349] asin behaves differently from Matlab for arguments larger than 1, Ricardo Biloti, 2014/10/06
- [Octave-bug-tracker] [bug #43349] asin behaves differently from Matlab for arguments larger than 1, Rik, 2014/10/06
- [Octave-bug-tracker] [bug #43349] asin behaves differently from Matlab for arguments larger than 1, John W. Eaton, 2014/10/06
- [Octave-bug-tracker] [bug #43349] asin behaves differently from Matlab for arguments larger than 1,
John W. Eaton <=
- [Octave-bug-tracker] [bug #43349] asin behaves differently from Matlab for arguments larger than 1, Rik, 2014/10/06
- [Octave-bug-tracker] [bug #43349] asin() behaves differently from Matlab for arguments larger than 1, Rik, 2014/10/06
- [Octave-bug-tracker] [bug #43349] asin() behaves differently from Matlab for arguments larger than 1, Michael Godfrey, 2014/10/06
- [Octave-bug-tracker] [bug #43349] asin() behaves differently from Matlab for arguments larger than 1, Michael Godfrey, 2014/10/06
- [Octave-bug-tracker] [bug #43349] asin() behaves differently from Matlab for arguments larger than 1, Rik, 2014/10/06
- [Octave-bug-tracker] [bug #43349] asin() behaves differently from Matlab for arguments larger than 1, Michael Godfrey, 2014/10/06
- [Octave-bug-tracker] [bug #43349] asin() behaves differently from Matlab for arguments larger than 1, John W. Eaton, 2014/10/06
- [Octave-bug-tracker] [bug #43349] asin() behaves differently from Matlab for arguments larger than 1, Rik, 2014/10/06
- Re: [Octave-bug-tracker] [bug #43349] asin() behaves differently from Matlab for arguments larger than 1, Doug Stewart, 2014/10/06
- [Octave-bug-tracker] [bug #43349] asin() behaves differently from Matlab for arguments larger than 1, John W. Eaton, 2014/10/06