The Museum of HP Calculators

HP Forum Archive 20

 WP 34S : Operation with complex numbersMessage #1 Posted by Miguel Toro on 31 Aug 2011, 2:21 p.m. Hola, I was trying some examples from the 15c handbook and I got a little strange result from the one in page 133: ``` - 15c in complex mode: sin-1(2.404) = 1.5708-1.5239i - 42s: same result = 1.5708-1.5239i. But - 34s: sin-1(2.404) = 1.5708+1.5239i (so imaginary part is positif!) ``` I am doing the following sequence: ```0, [ENTER], 2.404, [CPX], [g][SIN-1] = 1.5708+1.5239i ``` I think this is the proper way to enter it...or maybe not. Saludos, Miguel Edited: 31 Aug 2011, 2:24 p.m.

 Re: WP 34S : Operation with complex numbersMessage #2 Posted by Walter B on 31 Aug 2011, 3:52 p.m.,in response to message #1 by Miguel Toro Olá Miguel, si, it's the right way to enter this little problem. And it looks like you've found a pretty old bug, since build 1108 returns the same result as build 1551 does :-/ Thank you for reporting :-) Walter

 Re: WP 34S : Operation with complex numbersMessage #3 Posted by Jeff O. on 31 Aug 2011, 4:27 p.m.,in response to message #1 by Miguel Toro As Walter reports, you are entering it correctly. Prior to Walter's repsonse I prepared the following. Not sure if it is pertinent, but I will let it stand. I note the following: if you take sin(1.5708+i1.5239) on all three calculators, you get 2.4040 (plus a small imaginary component that would be zero with infinite precision.) If you take sin(1.5708-i1.5239) on all three calculators, you get 2.4040. So apparently both answers are valid. Being mostly a math dummy, I googled “complex arcsin” (actually I use startpage, but “startpaged” is not a common term for “entered into an internet search engine”) and found the following at wolfram.com: Quote: The inverse sine is a multivalued function and hence requires a branch cut in the complex plane… This follows from the definition of sin-1 z as: sin-1 z = -i ln (-i z + (1 - z 2) 1/2) If I use the above formula, and use the positive value of the square root, I get the answer that the 15C and 42s provide. If I use the negative value of the square root, I get the value that wp34s provides. I do not know if that is how wp34s (prior to the next revision if it is to be changed) calculates the inverse sine of a complex value. edit: Per Pauli's correction, the above formula should be: sin-1 z = -i ln (i z + (1 - z 2) 1/2) I'll leave the mistake for posterity. Edited: 31 Aug 2011, 9:10 p.m.

 Re: WP 34S : Operation with complex numbersMessage #4 Posted by Paul Dale on 31 Aug 2011, 5:57 p.m.,in response to message #1 by Miguel Toro The complex inverse trigonometric function on the 34S are defined by these formulas: ```arcsin(z) = k PI + (-1)^k . asin(beta) + i (-1)^k ln(alpha+sqrt(alpha^2-1)) arccos(z) = 2k PI +- (acos(beta) - i ln(alpha+sqrt(alpha^2-1))) where alpha = 1/2 sqrt((x+1)^2+y^2) + 1/2 sqrt((x-1)^2+y^2) beta = 1/2 sqrt((x+1)^2+y^2) - 1/2 sqrt((x-1)^2+y^2) arctan(z) = k PI + 0.5 atan(2a / (1-a^2-b^2) + i/4 ln((a^2+(b+1)^2)/(a^2+(b-1)^2)) ``` (in the doc/formulas file). It looks like the branch cut here is different :-( - Pauli

 Re: WP 34S : Operation with complex numbersMessage #5 Posted by hugh steers on 31 Aug 2011, 7:49 p.m.,in response to message #4 by Paul Dale when i put complex numbers into my library, i specially arranged the branch cuts to be the same as on HP calcs. specifically, i checked everything against the 15c. i know they're arbitrary, but i found this gave me a level of sanity and comparability.

 Re: WP 34S : Operation with complex numbersMessage #6 Posted by Paul Dale on 31 Aug 2011, 8:05 p.m.,in response to message #5 by hugh steers Probably a good idea. I trust the 15c's complex handling :) I've updated the 34S to use the log based formula (there is a typo above BTW). Saved a bit of space too. - Pauli

 Re: WP 34S : Operation with complex numbersMessage #7 Posted by Jeff O. on 31 Aug 2011, 9:20 p.m.,in response to message #6 by Paul Dale Quote: I've updated the 34S to use the log based formula (there is a typo above BTW). Crap. Something I mention gets implemented and I screwed it up. Wish I could take credit for suggesting it, but I was just trying to figure out what was going on. (If I had suggested it, maybe I could have asked for a favor, like using the saved space to display the imaginary component or angle in the dot-matrix display area after ->REC and->POL commands. Sorry, I could not resist.) I have added the correct formula to my message above. I left the error so that your comment makes sense.

 Re: WP 34S : Operation with complex numbersMessage #8 Posted by Walter B on 1 Sept 2011, 1:52 a.m.,in response to message #7 by Jeff O. Quote: using the saved space to display the imaginary component or angle in the dot-matrix display area after ->REC and->POL commands. The great dot matrix allows for displaying something like -2.3E-4i up there. Is this what you want, what you really, really want?

 Re: WP 34S : Operation with complex numbersMessage #9 Posted by Paul Dale on 1 Sept 2011, 2:36 a.m.,in response to message #8 by Walter B Ignore Walter, this isn't going to happen ;-) I saved tens of bytes maximum. - Pauli

 Re: WP 34S : Operation with complex numbersMessage #10 Posted by Marcus von Cube, Germany on 1 Sept 2011, 3:48 a.m.,in response to message #9 by Paul Dale Actually the save is in the 100 bytes arena. We still have some headroom. Not enough for another user flash region but hopefully enough for further bug fixing. Walter is good at insisting on bugs getting fixed. :-)

 Re: WP 34S : Operation with complex numbersMessage #11 Posted by Paul Dale on 1 Sept 2011, 4:01 a.m.,in response to message #10 by Marcus von Cube, Germany Walter, is very very good at this. The reason the 34S is so good is mostly down to Walter's tenaciousness. Otherwise it would be more like the Elektronikas with lots of hidden features and surprises (but still numerically sound). - Pauli

 Re: WP 34S : Operation with complex numbersMessage #12 Posted by Marcus von Cube, Germany on 1 Sept 2011, 4:36 a.m.,in response to message #11 by Paul Dale Pauli, if it were only you and me without Walter, 34S would be a "do everything for nobody" device. ;-)

 Re: WP 34S : Operation with complex numbersMessage #13 Posted by Paul Dale on 1 Sept 2011, 4:40 a.m.,in response to message #12 by Marcus von Cube, Germany Agreed :) - Pauli

 Re: WP 34S : Operation with complex numbersMessage #14 Posted by Walter B on 1 Sept 2011, 2:50 p.m.,in response to message #13 by Paul Dale Thanks, colleagues, for your very kind words [blush] d:-)

 Re: WP 34S : Operation with complex numbersMessage #15 Posted by Jeff O. on 1 Sept 2011, 8:13 a.m.,in response to message #8 by Walter B Quote: The great dot matrix allows for displaying something like -2.3E-4i up there. Is this what you want, what you really, really want? As near as I can tell, the dot matrix area could support up to a 9 character display (plus radix, plus the "i" or "<") in small font, 7 characters in the large font. So at worst you have is something like "i-8.89e-333" in the small font. I hardly ever deal with numbers requiring 3-digit powers of 10. Much of time, I believe the number could be formatted to look decent. I guess what I really, really want is to display the imaginary or angle, honoring the display setting if possible, changing the display setting for the number as needed to display it as best as possible. But I can see that that might be a lot of work. I’d be happy with just appending the number to the “i” or ”<”, cutting off what does not fit and alpha-displaying it. I'll accept that to do that, I have to learn C programming and all the other steps necessary to change the code myself. Just to be clear, my "helpful" suggestions are not intended to indicate disappointment or dissatisfaction with wp34s. Far from that. But, if I conceive something that sounds good to me (as most things that I conceive do, curiously), I figure it cannot hurt to suggest it. At best, maybe one day I’ll suggest something that resonates with the developers and it will happen. At worst, you say “can’t do” or “won’t do”, but at least I asked.

 Re: WP 34S : Operation with complex numbersMessage #16 Posted by Walter B on 1 Sept 2011, 3:26 p.m.,in response to message #15 by Jeff O. No need for excuses :-) Please continue your helpful suggestions (did I tell about the different meanings of quotation marks in different languages? ;-) ). Anyway, here's what's feasible spacewise: No more. So you know what can be done before you start programming ;-) Walter

 Re: WP 34S : Operation with complex numbersMessage #17 Posted by Jeff O. on 1 Sept 2011, 9:45 p.m.,in response to message #16 by Walter B Hmmmm...I can get -2.34e-5i (or i-2.34e-5 as I would probably implement it) to display in large font on my 30b running rev. 1551. I get the same results as you show in small font. It also uses a small letter e in both large and small font. But no matter, you are correct, it is not ideal. But I would probably give it try if I had the power. I'm not sure if you have told about the different meanings of quotation marks in different languages. I used them above in a casual English manner meaning "perhaps not really." Do people do the so called "air quotes" in other parts of the world? (If they do not, that term probably won't make any sense at all.)

 Communication (OT, was Re: WP 34S : Operation with complex numbers)Message #18 Posted by Walter B on 2 Sept 2011, 1:55 a.m.,in response to message #17 by Jeff O. Quote: I used them above in a casual English manner meaning "perhaps not really." Do people do the so called "air quotes" in other parts of the world? That are two ways I use them as well. Additionally we use them for quoting (surprise! :-) . But I know many people here employ them for emphasizing (being too lazy for underlining), and I thought so far that custom came from the US of A. IIRC we had this topic here some years (?) ago with the example of a German butcher advertising Heute "frische" Wurst! - an ad I wouldn't call an ad in my understanding ;-) Walter

 Re: Communication (OT, was Re: WP 34S : Operation with complex numbers)Message #19 Posted by Andrés C. Rodríguez (Argentina) on 3 Sept 2011, 10:27 a.m.,in response to message #18 by Walter B Quite a number of people here use quotation marks for emphasis. I do share Walter's concern, and pointed the issue to friends, coworkers, students, etc. many times, but it seems there are strong (and unknown) reasons for this to happen so frequently. [Please disregard any idiomatic mistake]

 Re: Communication (OT, was Re: WP 34S : Operation with complex numbers)Message #20 Posted by Jeff O. on 3 Sept 2011, 1:26 p.m.,in response to message #19 by Andrés C. Rodríguez (Argentina) I had not noticed, now it will probably annoy me. Emphasis should be denoted by bold, italic, underline, or maybe _this_, whatever it is called. Or _all four methods_ for super emphasis.

Go back to the main exhibit hall