Post Reply 
HP49-HP50 (a, b) into 'a+bi'
03-13-2023, 04:07 PM
Post: #1
HP49-HP50 (a, b) into 'a+bi'
I want to convert a complex
from the (a, b) form into 'a+b*i'.

Is there a command linked to a achieve this
instead of my cumbersome
\<< (5.,6.) C\->R "*i" + "'" ROT + "+" + SWAP + OBJ\->
\>> ?
Find all posts by this user
Quote this message in a reply
03-13-2023, 04:48 PM
Post: #2
RE: HP49-HP50 (a, b) into 'a+bi'
The command \->Q in the Convert/Rewrite menu works, but if the parts of z are irrational numbers, it will return a rational approximation.
Find all posts by this user
Quote this message in a reply
03-13-2023, 05:39 PM
Post: #3
RE: HP49-HP50 (a, b) into 'a+bi'
Great, many thanks.

Now with matrix M
[[ 11 12 ]
[ 21 22 ]] in the stack,

we have two ways to replace
its element 22 by (2,2):

A) Transform M into a complex matrix
M (1,0) *
{2 2} (2,2) PUT

or B) Leave M real
& transform (2,2) into algebraic '(2,2)'
M
{2 2} (2,2) —>Q PUT

Your given solution B is cleaner (simpler)
or more appropriate.

Regards,
Gil
Find all posts by this user
Quote this message in a reply
03-18-2023, 10:04 PM (This post was last modified: 03-18-2023 10:06 PM by BruceH.)
Post: #4
RE: HP49-HP50 (a, b) into 'a+bi'
(03-13-2023 04:07 PM)Gil Wrote:  I want to convert a complex
from the (a, b) form into 'a+b*i'.

Is there a command linked to a achieve this
instead of my cumbersome
\<< (5.,6.) C\->R "*i" + "'" ROT + "+" + SWAP + OBJ\->
\>> ?

Sorry - bit late in replying. How about:
Code:
« → c 'RE(c) + IM(c)*i' » 'C' STO

Then, if you have (3,4) on the stack you just run C to get '3+4*i'. If you need to do this frequently then put C into the custom menu.
Find all posts by this user
Quote this message in a reply
03-18-2023, 10:42 PM (This post was last modified: 03-18-2023 10:47 PM by Gil.)
Post: #5
RE: HP49-HP50 (a, b) into 'a+bi'
Nice — provided , of course, you set previously flag -27.

The same applies to —>Q (shorter than your suggested solution, but the latter needs RAD mode).

My solution with string
\<< (5.,6.) C\->R "*i" + "'" ROT + "+" + SWAP + OBJ\->
\>>,
valid in any configuration, but not at all nice.

NB
Try (-5 - 6) with the above solutions:
you will never get the simple '-5-6*i',
but, instead, '-(5+6*i)' or '-5.+-6.*i'.

Apparently, there is no way in the algebraic results
to get, instead of the unnecessary 'a+-b',
the simple (more straightforward) 'a-b'.
Find all posts by this user
Quote this message in a reply
03-19-2023, 04:34 AM
Post: #6
RE: HP49-HP50 (a, b) into 'a+bi'
(03-18-2023 10:42 PM)Gil Wrote:  NB
Try (-5 - 6) with the above solutions:
you will never get the simple '-5-6*i',
but, instead, '-(5+6*i)' or '-5.+-6.*i'.

Apparently, there is no way in the algebraic results
to get, instead of the unnecessary 'a+-b',
the simple (more straightforward) 'a-b'.

(-5.,-6.) →Q DISTRIB --> '-5-6*i'

<0|ɸ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
03-19-2023, 03:26 PM
Post: #7
RE: HP49-HP50 (a, b) into 'a+bi'
Again — as usual, it worked.

Thanks to the HP Forum master(s).

Regards,
Gil
Find all posts by this user
Quote this message in a reply
03-20-2023, 01:17 AM (This post was last modified: 03-20-2023 01:23 AM by Gil.)
Post: #8
RE: HP49-HP50 (a, b) into 'a+bi'
About Bruce small program
« → c 'RE(c) + IM(c)*i' » 'C' STO

Beside flag -27 for a+bi,
you have to be
- in exact mode (-105 CF)
- & in complex mode (-103 SF),
so that your program could be
« PUSH -27 SF -103 SF 105 CF→ c 'RE(c) + IM(c)*i' POP » 'C' STO

About John Keith suggestion:
(5.6 7.9) —>Q returns, logically, '(56+79*i)/10'
(and not the simpler '5.6+7.9*i').
Find all posts by this user
Quote this message in a reply
03-20-2023, 05:39 PM
Post: #9
RE: HP49-HP50 (a, b) into 'a+bi'
(03-20-2023 01:17 AM)Gil Wrote:  About John Keith suggestion:
(5.6 7.9) —>Q returns, logically, '(56+79*i)/10'
(and not the simpler '5.6+7.9*i').

That is because →Q converts approximate numbers into exact rational numbers. '5.6+7.9*i' may seem simpler but the HP49/50 typically represent approximate numbers in the form (5.6, 7.9) while representing exact complex numbers in the form '3*4+i'.
Find all posts by this user
Quote this message in a reply
03-20-2023, 08:24 PM
Post: #10
RE: HP49-HP50 (a, b) into 'a+bi'
I take this opportunity to mention a nice feature of the HP50g
Note
->Q and ->QPi is using the number of digits shown when converting to rationals, or simple symbolics.

Try
A)
Exact mode
Mode, number format std

2. 5. SQRT * -->NUM ->QPi result in 2 SQRT(5) (symbolic)
2. 5. SQRT * -->NUM ->Q result in 930249/208010

B) Mode number format fix 3
2. 5. SQRT * -->NUM ->QPi result in 76/17
2. 5. SQRT * -->NUM ->Q result in 161/36

br Gjermund
Find all posts by this user
Quote this message in a reply
03-20-2023, 09:12 PM
Post: #11
RE: HP49-HP50 (a, b) into 'a+bi'
Nice indeed, this Qpi, working with pi and sqrt, though I have not used very often.

Thanks for the hint and other comments.

Really, this HP49-HP50 is a huge calculator,
with directories, Var-menus, free choice of variables with the exception perhaps regarding the graphing part, not so easy to manage.
Find all posts by this user
Quote this message in a reply
03-21-2023, 02:23 PM
Post: #12
RE: HP49-HP50 (a, b) into 'a+bi'
(03-20-2023 08:24 PM)Gjermund Skailand Wrote:  2. 5. SQRT * -->NUM ->QPi result in 2 SQRT(5) (symbolic)
2. 5. SQRT * -->NUM ->Q result in 930249/208010

B) Mode number format fix 3
2. 5. SQRT * -->NUM ->QPi result in 76/17
2. 5. SQRT * -->NUM ->Q result in 161/36

That's interesting, I never realized that →QPi returned results different than →Q for values that did not involve pi.
Find all posts by this user
Quote this message in a reply
03-21-2023, 02:36 PM
Post: #13
RE: HP49-HP50 (a, b) into 'a+bi'
But it does not always work as might be expected:

'173*sqrt (123) '
—>NUM
1918.66281561

1) And 1918.66281561
—>Qpi
'1826567/952' no SQRT appears.

2) And 1826567/952' —>NUM
1918.66281513≈1918.66281561
Find all posts by this user
Quote this message in a reply
Post Reply 




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