[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: problem with acos
From: |
zampala |
Subject: |
Re: problem with acos |
Date: |
Wed, 29 Jul 2009 01:38:13 -0700 (PDT) |
>
> | I need to calculate the inverse cosine of this matrix (2x2, complex
> values):
> |
> | P =
> |
> | 9.9422e-01 - 0.0000e+00i 8.9732e+08 - 0.0000e+00i
> | -1.0151e+00 + 0.0000e+00i 3.0910e+05 - 0.0000e+00i
> |
> | octave:97> acos(P)
> | ans =
> |
> | 0.10755 - 0.00000i NaN + Infi
> | 3.14159 - 0.17368i 0.00000 + 13.33457i
> |
> | octave:98> acos(P(1,2))
> | ans = NaN + Infi
>
> Apparently your matrix P has some small imaginary components. Try
>
> format long
> P
>
> so that they will be displayed.
I tried that, but still a long series of zero. However,
octave:39> isreal(P(1,2))
ans = 0
octave:40>
meaning that the imaginary component is small but not zero.
>
> When you write it this way, you are setting the imaginary part to
> exactly 0.
Yeah, the best fix I could think of is to set to zero imaginary or real
parts smaller than, say, 1e-5.
> What do you expect the value of
> acos (X) to be when X is real and outside the range [-1,1]? What do
> you expect it to be when X is complex, and there is a large real part
> and a small imaginary part?
Actually I don't know what to expect from the acos output.
The problem is indeed with a complex number made of big real and small
imaginary component - performed a quick test.
Could anyone confirm this? Does it make any mathematical sense?
Any better fix that I could use?
Going down to the C library level is beyond my skills
mirko
--
View this message in context:
http://www.nabble.com/problem-with-acos-tp24698044p24714856.html
Sent from the Octave - General mailing list archive at Nabble.com.