Best way to convert complex numbers, rect, polar, euler

09122018, 06:23 AM
Post: #1




Best way to convert complex numbers, rect, polar, euler
Hello
I have tried several ways to convert complex numbers between differents formats. What i am looking for is a way to convert all of them between all formats. As example: polar to cartesian: r * exp(i*phi) => a+ib cartesian to euler: a+ib => r(cos(phi)+ i*sin(phi) ) is there a simple command or trick to easily do this conversion? Or do i have to write a program for that? Thanks 

09122018, 12:58 PM
Post: #2




RE: Best way to convert complex numbers, rect, polar, euler
It's built in. Press the angle [∡] key (Shift ×) to toggle any result between rectangular and polar notation. The angle will be interpreted according to the current angle mode, of course.
Example: 3+4i Enter > 3+4*i [∡] > 5 ∡ 0.9273 (radian mode) 1∡2 Enter > 1∡2 (radian mode) [∡] > 0.4161+0.9093*i You can also use (x,y) notation instead of x+yi notation for inputs, and in Home Settings you can select whether you want outputs to be in (x,y) or x+yi notation. The programmable functions polar_coordinates and rectangular_coordinates are also available. See their help screens for more info. <0ɸ0> Joe 

09122018, 06:46 PM
Post: #3




RE: Best way to convert complex numbers, rect, polar, euler  
09122018, 06:51 PM
Post: #4




RE: Best way to convert complex numbers, rect, polar, euler
Just find.
This does not work: ’3+4*i’ Enter ∡ This works: 3 Enter 4 Enter i * + 

09122018, 06:52 PM
(This post was last modified: 09122018 06:53 PM by Didier Lachieze.)
Post: #5




RE: Best way to convert complex numbers, rect, polar, euler
In RPN mode:
(3,4) Enter > 3+4*i [∡] > 5 ∡ 0.9273 (radian mode) 1∡2 Enter > 1∡2 (radian mode) [∡] > 0.4161+0.9093*i 

09122018, 06:56 PM
Post: #6




RE: Best way to convert complex numbers, rect, polar, euler  
09122018, 07:30 PM
Post: #7




RE: Best way to convert complex numbers, rect, polar, euler
3i4 also works from memory.
TW Although I work for HP, the views and opinions I post here are my own. 

09122018, 07:35 PM
Post: #8




RE: Best way to convert complex numbers, rect, polar, euler
Yes, 3i4 works also. Thank You, Tim.


09122018, 09:20 PM
(This post was last modified: 09132018 12:18 AM by Anders.)
Post: #9




RE: Best way to convert complex numbers, rect, polar, euler  
09202018, 05:13 PM
Post: #10




RE: Best way to convert complex numbers, rect, polar, euler
Thanks very much for all of your answers.


09202018, 11:40 PM
Post: #11




RE: Best way to convert complex numbers, rect, polar, euler
(09122018 09:20 PM)Anders Wrote: 3i4 =3*4*i =12i so it did not work on my G2 calc. It does work in RPN mode, as was requested. <0ɸ0> Joe 

09212018, 12:41 AM
Post: #12




RE: Best way to convert complex numbers, rect, polar, euler
(09202018 11:40 PM)Joe Horn Wrote:(09122018 09:20 PM)Anders Wrote: 3i4 =3*4*i =12i so it did not work on my G2 calc. I think the RPN mode RPL is crippled. The stack should be a special list A new parser is needed for #RPL //programs similar to command line Stacks could be T0..T9 where :T6:STACK would set the default as T6 but if needed a command could refer to another stack (or not in the first beta) I hhope that my idea will be recarded as the Next Big, no, HUUUUUUUGE Thing for the HP Prime RPN mode and #RPL Programs like a symbolic vector is internally a list so could be a stack I have even imagined :666:SIN operating on the object upon the stack level 666 Thus :5:DROPN would first take the 'N' from the level 1 then DROP that many stack elements or items starting from the new level 5 Thus the default with this tagged reference method would be :1:DROPN If only I had the time... :T4::3Q would take a square of the value in stack T4, level 3 and also return the answer at level 3  like the stack started from there One could "debug" the stack(s) using the buildin List Editor I want a real RPL environment.... Sorry for the rant  slightly off topic on the subject, but still about RPN & Prime VPN 

09212018, 07:38 AM
Post: #13




RE: Best way to convert complex numbers, rect, polar, euler
(09202018 11:40 PM)Joe Horn Wrote:(09122018 09:20 PM)Anders Wrote: 3i4 =3*4*i =12i so it did not work on my G2 calc. You are kind of proving my larger point that the implementation of the complex number formats standard and functions is screwy. Certain formats and functions/buttons works in some modes and in others not. This is confusing the user constantly... 1. There is a [∡] button and it works as it should in Home but not in CAS (super frustrating  forcing people to implement their own conversion functions  see various attempts in the http://www.hpmuseum.org/forum/forum15.html ). 2. Some complex number formats work in RPN but not in CAS or textbook (home), e.g. 2i4 is interpreted different. It short it’s a mess. An engineer (EE, CE in particular), who needs to constantly move back and forth between polar and cartesian coordinates (and calc/pre calc high school student too for that matter), should be able to expect the calculator to accept the same number formats and operate the same regardless of he/she is using RPN, textbook format (home) or CAS. Wouldn't it be great if we could standardize across all three, e.g. 4i3, 3∡(pi/2) works everywhere  simple notation that saves key strokes. You can then do things like (4i3) * (3∡(pi/2)) in Textbook (Home) and CAS or in RPN: 4i3 <enter> 3∡(pi/2) <enter> * <enter> and the expected results 

09212018, 07:56 AM
Post: #14




RE: Best way to convert complex numbers, rect, polar, euler
(09212018 07:38 AM)Anders Wrote:(09202018 11:40 PM)Joe Horn Wrote: It does work in RPN mode, as was requested. "operate the same regardless of he/she is using RPN, textbook format (home) or CAS." Impossible with the RPN. It *IS* different by it's very nature. Possible, but not feasible with [Home] vs [CAS], which still needs a lot of work. The CAS is never going to change. It is used in various other platforms and the sole genius developer has a certain consistent philosophy behind it. He has already made many special exceptions just for us. Lucky enough this unmentioned professor still fixes bugs and even answers questions in this very forum  in English (and French). Therefore the Home needs to adapt to be more like CAS (or CAS+). Using CAS("Expression") or CAS.casfunction() you already have extras, but ... I'm afraid that you're right... it is different. <sigh> I suggest you stick to Home for your [∡] problems and learn that environment well. VPN 

09212018, 03:09 PM
(This post was last modified: 09212018 03:20 PM by Anders.)
Post: #15




RE: Best way to convert complex numbers, rect, polar, euler
(09212018 07:56 AM)CyberAngel Wrote:(09212018 07:38 AM)Anders Wrote: You are kind of proving my larger point that the implementation of the complex number formats standard and functions is screwy. Obviously RPN is different. I've used HP calculators for years so I am pretty familiar with that concept (67, 42S 28S 48GX, 50g etc). Yes I used phrase "the same" loosely here but was hoping people would get what I mean. Ok I'll try again: There is no reason why 4i2 and 3∡1.4 could not be made to work in the 3 modes. Nor is there reason why the ∡ button could not be made to work the "same" way (except considering the inherent differences in RPN vs Text book mode). The way you solve this is buy shielding the underlying CAS or Home functionality (Textbook or RPN mode) with a UI parser that parsers the key strokes as the user types them, convert the key strokes into tokens and organized the tokens in to an abstract syntax tree. The correct syntax for complex numbers and how i, ∡ buttons work in different contexts are described as regular expressions and with BNF notation. A simple lexical scanner and a LALR type parser can then be used to generate the AST. Once user hit's enter the parser passes the tree in the form that CAS or Home expects it. No core code need to change in CAS except actual interface to CAS (UI). Now, I am assuming the HP Prime have UI parser(s) already that front ends Home and CAS (how else do they do it today?). Therefore, all you need to do is update them/it per above. Could be as simple as adding/updating the existing grammar/formal language (catalog of valid regular expressions and BNF rules). 

« Next Oldest  Next Newest »

User(s) browsing this thread: 1 Guest(s)