Re: Free42 - A Complex glitch?

The bug in this case is in the code that calculates the complex square root in the log(x+sqrt(x^2+1)) evaluation; it returns the wrong root because the imaginary part of its argument is -0.

In a word: aargh! I'm sure there are good reasons why IEEE-754 has negative zero, but in this case it (or maybe I should say, the way atan2() treats it) is biting me in the ass. It's easy to fix, but I'll have to check all occurrences of atan2() to see if they have the same potential problem. Fortunately, there aren't all that many...

Hi THomas,

can we expect a fix for this new bug, too? ;-)




i'm just going to add another twist here.

a bit late to the party, but i just tried the same acos(cos((200+200i)) on my reckon calculator. unfortunately it fails too. i am using an equally lame formula.

i changed my acos(z) routine to use this:

acos(z) = -2i*log(sqrt((1+z)/2) + i*sqrt((1-z)/2))

it's from Kahan 1987, but i dont have the paper with the theory behind it. anyhow it works fine for this problem. i've changed reckon to use this way of calculating acos and asin.

> acos(cos(200+200i))

my 2c.

-- hugh.


looks like my test case is getting a lot of attention :-)

thanks for the formulas, it's an interesting approach.



I'll fix the complex ASIN and ASINH in the Binary version this weekend, and check if any of the other code that uses atan2() in the Binary version is affected by the "negative zero" issue.

The "negative zero" thing only affects the Binary versions, so that doesn't affect my iPhone and Android builds, which are Decimal only. (Is anyone aware of problems with Free42's complex ACOS/ACOSH?)

Edited: 23 Sept 2011, 2:08 a.m.

Possibly Related Threads…
Thread Author Replies Views Last Post
  HP Prime: complex numbers in CAS. Alberto Candel 1 1,904 12-06-2013, 02:36 PM
Last Post: parisse
  [HP Prime] Plots containing complex numbers bug? Chris Pem10 7 3,635 12-05-2013, 07:40 AM
Last Post: cyrille de Brébisson
  Complex Number Entry on Prime Jeff O. 19 5,141 11-16-2013, 12:34 PM
Last Post: Jeff O.
  HP Prime complex results Javier Goizueta 0 981 10-06-2013, 12:59 PM
Last Post: Javier Goizueta
  HP Prime Solving Nonlinear System of Equations for Complex Results Helge Gabert 11 4,226 09-30-2013, 03:44 AM
Last Post: From Hong Kong
  [HP-Prime xcas] operations with complex numbers + BUGs + Request CompSystems 9 3,461 09-08-2013, 10:40 PM
Last Post: CompSystems
  Elliptic integrals of 1st and 2nd kind calculated by complex agm Gjermund Skailand 3 1,459 06-29-2013, 03:39 PM
Last Post: Gjermund Skailand
  HP-11C and complex numbers Antlab 5 2,202 06-28-2013, 08:59 AM
Last Post: Antlab
  71B Complex User Defined Functions in Calc Mode? Michael Burr 0 936 03-18-2013, 09:38 PM
Last Post: Michael Burr
  HP 34S complex # problem Richard Berler 2 1,201 02-17-2013, 11:01 PM
Last Post: Richard Berler

Forum Jump: