[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: problem with acos
From: |
John W. Eaton |
Subject: |
Re: problem with acos |
Date: |
Wed, 29 Jul 2009 12:44:53 -0400 |
On 29-Jul-2009, zampala wrote:
| This is what I get
|
| octave:309> imag (P) == 0
| ans =
|
| 1 1
| 1 1
|
| I suppose the imaginary part is there, although small.
No, apparently it is exactly zero. How was P created?
| I'm wondering if setting a very small number to zero is correct and,
| ultimately, this will affect my results on which I have no clue of what they
| should look like
For complex variables (whether the imaginary part is zero or not)
Octave uses a standard C++ library function to compute the complex
inverse cosine. For real variables, it uses a different C library
function. For example, note what happens if you do
octave:1> acos (2)
ans = NaN
octave:2> acos (complex (2, 0))
ans = 0.00000 - 1.31696i
octave:3> cos (ans)
ans = 2.0000
What are you trying to acomplish by computing the inverse cosine of a
real number outside the range [-1, 1]?
This discussion brings up an implementation question: should Octave
switch to complex acos if the some of the arguments are real and
outside the range [-1, 1]? I suppose that makes the most sense.
jwe