Hi, all:

Though this is essentially a commentary to a posting by Ralph, I'm starting a new thread as my commentary isn't directly related to the original thread, "Some 49G+ Limitations".

Ralph posted:

*"c)asin(acos(atan(tan(cos(sin(7))))))
[...]
HP41CX(6.999519575) worse than HP49G+, HP48G
*

Lest people would think that the HP-41CX has serious accuracy problems with this particular computation, let's make clear that this lack of accuracy stems from the fact that this example is *very ill-conditioned*, as the cosine function is being evaluated for a *very small argument*, where serious cancellation is taking place. Let's see:

- The Cosine function, COS, is being applied to an argument which itself is a sine function, which will return a value in the range [0-1]. Thus COS' argument will be 1 at most (in this particular example, it is SIN(7º) ).
- Further, though not stated by Ralph, all trigonometric functions are being calculated in Degrees, not Radians.
- This means that we're computing the Cosine of a very small angle, between 0º and 1º, namely SIN(7º) in this particular example which is 0.1218+, so we're in fact computing COS(0.1218º), a truly small angle indeed, which, to add insult to injury, is equivalent to 0.00213+ radians, i.e., a really, really small argument.
- And, regrettably, this petite argument causes a large loss of accuracy, because for very small arguments, in radians, we have:

COS(X) = approx. equal to 1 - X^2/2

and as X is very small to begin with, half its square is much smaller (0.000002262109806), which, when subtracted from 1, effectively

*loses half its significant digits*, giving 0.9999977379.

You can see the loss easily, just subtract this result from 1 again, to get 0.0000022621, which is missing its last 5 digits of accuracy (namely ...09806). So, it's no wonder the HP-41CX gives such a seemingly "inaccurate" final result. The loss would be even greater if still smaller arguments were tested, for instance let's try 1 instead of 7:

asin(acos(atan(tan(cos(sin(1)))))) = 0.9990167403which loses

*7 digits*of accuracy instead of 5-6 in the original example. Now, just to further see that the problem has nothing to do with the HP-41CX's internal algorithms, let's evaluate this second, worse example, but this time in RADians instead of DEGrees:

XEQ RADwhich gives aasin(acos(atan(tan(cos(sin(1)))))) = 1.000000000

*perfect*result back and clearly shows the true accuracy, once we're no longer dealing with an ill-conditioned problem. Another revealing test, this time in the original DEGrees setting, is to exchange the order of evaluation of SIN and COS (and also that of ACOS and ASIN as well):

XEQ DEGand you can see that we have a decent result, with a mere loss of slightly over one significant digit, because this time the argument for COS is 7º, instead of 0.1218º, i.e., almost 60 times greater.acos(asin(atan(tan(sin(cos(7)))))) -> 6.999999972

I hope this helps to understand what's happening and why a seemingly poor performance while doing the original test doesn't necessarily mean same poor overall performance, far from it. The original test is a contrived, ill-conditioned case, not to be regarded as a valid measure of general accuracy for the model tested.

Best regards from V.

*Edited: 11 Feb 2005, 10:22 a.m. *