WP 34S : Operation with complex numbers



#21

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.


#22

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

#23

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.

#24

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


#25

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.


#26

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


#27

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.


#28

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?

#29

Ignore Walter, this isn't going to happen ;-)

I saved tens of bytes maximum.


- Pauli


#30

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. :-)


#31

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


#32

Pauli, if it were only you and me without Walter, 34S would be a "do everything for nobody" device. ;-)


#33

Agreed :)

- Pauli


#34

Thanks, colleagues, for your very kind words [blush] d:-)

#35

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.


#36

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


#37

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.)


#38

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


#39

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]


#40

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.


Possibly Related Threads...
Thread Author Replies Views Last Post
  [WP-34S] Unfortunate key damage with update to V3 :( svisvanatha 5 1,007 12-10-2013, 11:37 PM
Last Post: Les Bell
  WP-34S (Emulator Program Load/Save) Barry Mead 1 556 12-09-2013, 05:29 PM
Last Post: Marcus von Cube, Germany
  HP Prime: complex numbers in CAS. Alberto Candel 1 595 12-06-2013, 02:36 PM
Last Post: parisse
  [HP Prime] Plots containing complex numbers bug? Chris Pem10 7 1,145 12-05-2013, 07:40 AM
Last Post: cyrille de Brébisson
  DIY HP 30b WP 34s serial flash/programming cable Richard Wahl 2 798 12-04-2013, 11:14 AM
Last Post: Barry Mead
  Complex Number Entry on Prime Jeff O. 19 2,095 11-16-2013, 12:34 PM
Last Post: Jeff O.
  WP 34S/43 ?'s Richard Berler 3 712 11-10-2013, 02:27 AM
Last Post: Walter B
  My FrankenCulator (wp-34s) FORTIN Pascal 4 739 11-09-2013, 06:18 PM
Last Post: FORTIN Pascal
  WP 34S Owner's Handbook Walter B 5 971 11-09-2013, 05:34 PM
Last Post: Harald
  wp 34s overlay and programming. FORTIN Pascal 6 1,006 11-08-2013, 01:28 PM
Last Post: Nick_S

Forum Jump: