Accuracy problem [message #47950] |
Fri, 10 March 2006 19:38 |
Juan Arrieta
Messages: 6 Registered: February 2006
|
Junior Member |
|
|
Hi!
I am preparing a simple code to transform between cartesian vectors
and Keplerian elements (semimajor axis, inclination, eccentricity, and
so forth). This is a simple problem in astrodynamics.
At some point in my code, I need to obtain unit vectors. For instance,
a line of the code is:
U0 = ACOS( (TRANSPOSE(NDVCT) # R) / ( NORM(NDVCT) * NORM(R) ) )
(the argument of Latitude, U0. An angle)
This is nothing more than dot( NDVCT , R ) / ( |NDVCT| * |R| ). This
is supposed to be less than or equal to one (absolute value). What
happens, is that the result is slightly more than one (as it appears)
and the ACOS function throws an exception (ACOS of a number greater
than one is an exception).
For instance, consider this output:
print,NDVCT
0.91855860 0.53033008 -0.0000000
print,R
1.2990381 0.75000000 0.0000000
arg = (TRANSPOSE(NDVCT) # R) / ( NORM(NDVCT) * NORM(R) )
print,arg
1.0000000
print,arg gt 1
1
help, arg
ARG DOUBLE = Array[1]
U0 = ACOS( TRANSPOSE(NDVCT) # R / ( NORM(NDVCT) * NORM(R) ))
% Program caused arithmetic error: Floating illegal operand
print,U0
NaN
I am using a Sun JAVA Workstation, with AMD64 processors (opteron
250).
Any comments as for what would the problem be? This seems like a
roundoff error somewhere in the program, but I am not doing anything
"fancy" here.
Thank you for your time and help.
Juan
|
|
|