M
Me
I have a function (say F) from the law of cosines that should evaluate
between [-1,1].
so from the LOC -> C^2 = A^2 + B^2 - 2ABcos(Theta)
solve for Theta -> Theta = ACOS( -(C^2-A^2-B^2)/(2AB) )
My function F -> F = -(C^2-A^2-B^2)/(2AB)
A, B, and C are pseudo-randomly generated values and it appears that F
has some precision problems that after evaluation the values can fall
outside the bounds by a little bit on either side. I've seen F be
1.00000024 and I've seen negative values of F off by about the same
amount. It appears this is the best precision I can get with the how
I'm generating these values, not that it matters much 'cause the weird
part comes later.
I understand that the ACOS function must be [-1,1] so I use an IF to
make a correction before evaluating the ACOS. I'm not to worried
about the error so I have a cell do this:
=IF( F > 1, 1, IF( F < -1, -1, F) )
The value in this cell appears to give a value of 1 and -1 to 30
decimal places when looking through the Format Cell->Numbers->Number
option. Now, here's the wierd part: If I type in a cell =ACOS(1) I
get 0. If I type in a cell =ACOS(-1) I get Pi. But if I reference
the cell with the IF statement above (which appears to have values
between 1 or -1) I end up with a #NUM! error every time F was outside
-1 and 1.
Anyone have any ideas??
between [-1,1].
so from the LOC -> C^2 = A^2 + B^2 - 2ABcos(Theta)
solve for Theta -> Theta = ACOS( -(C^2-A^2-B^2)/(2AB) )
My function F -> F = -(C^2-A^2-B^2)/(2AB)
A, B, and C are pseudo-randomly generated values and it appears that F
has some precision problems that after evaluation the values can fall
outside the bounds by a little bit on either side. I've seen F be
1.00000024 and I've seen negative values of F off by about the same
amount. It appears this is the best precision I can get with the how
I'm generating these values, not that it matters much 'cause the weird
part comes later.
I understand that the ACOS function must be [-1,1] so I use an IF to
make a correction before evaluating the ACOS. I'm not to worried
about the error so I have a cell do this:
=IF( F > 1, 1, IF( F < -1, -1, F) )
The value in this cell appears to give a value of 1 and -1 to 30
decimal places when looking through the Format Cell->Numbers->Number
option. Now, here's the wierd part: If I type in a cell =ACOS(1) I
get 0. If I type in a cell =ACOS(-1) I get Pi. But if I reference
the cell with the IF statement above (which appears to have values
between 1 or -1) I end up with a #NUM! error every time F was outside
-1 and 1.
Anyone have any ideas??