The Museum of HP Calculators

HP Forum Archive 21

[ Return to Index | Top of Index ]

Dangerous factorization
Message #1 Posted by Juraj O. on 9 Jan 2013, 2:54 p.m.

I was doing some calculations on 50g and have noticed a numerical error that happens sometimes. I narrowed it to this:

consider x sqrt (-x). Substituting x with -1 gives -1. Now use FACTOR on the expression to get i sqrt(x) ^ 3. Now, substituting x with -1 yields 1!!

Is this a bug in CAS?

      
Re: Dangerous factorization
Message #2 Posted by Nigel J Dowrick on 9 Jan 2013, 4:00 p.m.,
in response to message #1 by Juraj O.

No, it's an ambiguity in the square root function. The square root function is double-valued (if x^2=c, then (-x)^2=c as well) and it isn't possible to make it single-valued over the whole complex plane without having a discontinuity somewhere. This type of discontinuity is called a branch cut. From memory, the HP-50g makes the standard choice of having the cut along the negative real axis. So you'll find that it gives sqrt (-1) = i , sqrt (-1 + 0.000001 i) = i (roughly) but sqrt (-1 - 0.0000001 i) = -i (roughly).

This discontinuity means that equations like sqrt(ab) = sqrt(a) sqrt(b) are not necessarily true (e.g., try this with a = b = -1 + i on your HP-50g) and will sometimes not work. It's arguable that FACTOR on the HP-50g should be aware of the problem and refuse to do a rearrangement that might not work, but whether it works or not depends on the values of a and b which the calculator might not know.

Nigel (UK)

            
Re: Dangerous factorization
Message #3 Posted by Angel Martin on 10 Jan 2013, 3:14 a.m.,
in response to message #2 by Nigel J Dowrick

Absolutely correct and well explained. The 41Z yields exactly the same results to the examples you supplied - as a consequence of always choosing the main value of the logarithm function (the one with the argument between -pi/2 and pi/2) - as there's always a logarithm involved in the calculation of a square root.

Same fun happens calculating inverse trigonometric functions, also due to their logarithm expressions.

Cheers, 'AM


[ Return to Index | Top of Index ]

Go back to the main exhibit hall