Post Reply 
DB48X - Complex Number Handling
08-31-2023, 02:20 PM
Post: #1
DB48X - Complex Number Handling
Hello:

I've started this new thread, separate from the main DB48X thread as my testing/interests here will be on the Complex Number performance which may not be of general interest to other DB48X testers. If others believe it should be in the main thread, I can put it there.

1. When using 'y to the x' function, the result returned is sometimes in polar form. Other times it is displayed in a form that is unintelligible.

Ex:

i to the i power returns a response in polar form.

2+i raised to the 2+i power returns a result I cannot read. (I cannot find a 'Show' function.)
(the result is about (-0.504, 3.104) Using the Re and Im functions shows that the calculator returned the correct result.

2. Regarding Complex number output, I would like to select between the following output formats:
a. X + iY
b. (X,Y)
c. R/Theta

I could not find a setting in the Modes menu for this functionality.

Again, thank you very much for your fine work!

TomC
Find all posts by this user
Quote this message in a reply
10-19-2023, 03:33 PM
Post: #2
RE: DB48X - Complex Number Handling
Entering Complex Numbers:

On the HP48 I would type:

(3 4) or (3,4) to input the complex number 3 +i4.

What is the simplest way to do this on the DB48X?

TomC
Find all posts by this user
Quote this message in a reply
10-21-2023, 03:58 PM
Post: #3
RE: DB48X - Complex Number Handling
(08-31-2023 02:20 PM)TomC Wrote:  Hello:

I've started this new thread, separate from the main DB48X thread as my testing/interests here will be on the Complex Number performance which may not be of general interest to other DB48X testers. If others believe it should be in the main thread, I can put it there.

To me, it is convenient to have a thread dedicated to complex numbers. However, I only noticed it because you pinged me in a PM. I wonder if there is a way to teach MyBB to send me notifications for a given keyword...

Quote:1. When using 'y to the x' function, the result returned is sometimes in polar form. Other times it is displayed in a form that is unintelligible.

It's actually always in polar form. Currently, the result of complex functions is returned in the format that makes the computation easiest. y^x is computed as exp(x*ln(y)). The complex exp(a+ib) is computed as exp(a)*exp(ib), which is in polar form (a;<b). So naturally, the result of power is computed in polar form.

There will be a setting some day that forces results to always be generated in polar or rectangular, but for the moment, the result depends on the computation and sometimes on the input (e.g. multiplication can be done both in rectangular and polar form efficiently).

Also note that using the EEX key (the E next to the letter O) without entering digits first invokes the Cycle command, and for complex numbers, this cycles between polar and rectangular form.

Quote:i to the i power returns a response in polar form.

2+i raised to the 2+i power returns a result I cannot read. (I cannot find a 'Show' function.)

The "Show" function is not implemented yet, but it will be at the same keyboard location as on the DM42. In the meantime, values that do not fit on screen display with a grayed out "..." in the middle. This choice is because very often, the interesting stuff is either at the beginning or the end of an object, so showing a bit of both.

When something does not fit, the most "RPL-ish" way to get it is to hit the "Down" key. That brings the top-level of the stack in the editor, and then you can use the arrows to scroll left and right.

There are other useful options:

- Using the various number display modes in the DISP menu. For example, the (2+i)^(2+i) value displays well using SIG 10 (10 significant digits). Using SIG 20 is good for real numbers, but if you generally use complex numbers, SIG 10 or below will be better. SIG is like a FIX without trailing zeroes.

- You can adjust the font size using the UI menu (from the Modes menu). Using value 2 (smallest font) for Result and Stack will let you see 20 digits for your complex numbers. But you need good eyes.

Quote:(the result is about (-0.504, 3.104) Using the Re and Im functions shows that the calculator returned the correct result.

Actually, if it returned the correct result, it's probably that your calculator was set to compute in radians, see https://github.com/c3d/DB48X-on-DM42/issues/452. This will be fixed in 0.4.8 which is scheduled for tomorrow.

Quote:2. Regarding Complex number output, I would like to select between the following output formats:
a. X + iY
b. (X,Y)
c. R/Theta

I could not find a setting in the Modes menu for this functionality.

As indicated above, the setting to force the result to be either rectangular or polar will appear in a later revision. For now, the output is in the most efficient form based on the computation that was performed, and if that form does not suit you, hit the Cycle key.

I was not planning to have an (X,Y) output. One of the reasons is that it is problematic for European countries that use , as a decimal separator (and, being French, that's my default setting). HP used to "solve" that with ; as a separator when FM, was set, but that means the separator is different based on locale, which makes parsing (1,2) context sensitive: does it mean 1.2 with parentheses around it, or does it mean complex number with re=1 and im=2? I decided to not open this can of worms, and only accept space or ; as separators on input.

DB48X still accepts (1;2) as input for compatibility reasons, but it's hard to enter that from the keyboard (you essentially have to do it in Alpha mode). It can be convenient if you type RPL programs on a PC, where the 'i' character used for complex numbers is not easily found (and the regular 'i' means variable i).

In your idea, would (X,Y) just be a display preference for complex numbers? What benefits do you see to it?
Find all posts by this user
Quote this message in a reply
10-21-2023, 04:15 PM (This post was last modified: 10-21-2023 04:17 PM by c3d.)
Post: #4
RE: DB48X - Complex Number Handling
(10-19-2023 03:33 PM)TomC Wrote:  Entering Complex Numbers:

On the HP48 I would type:

(3 4) or (3,4) to input the complex number 3 +i4.

What is the simplest way to do this on the DB48X?

TomC

Shift G for Complex Menu (matching the COMPLEX label on the DM42).
Then 'i' is on the first function key (F1), and the angle sign is on the second function key (F2). So you type 3 F1 4 ENTER to enter 3+4i, and 3 F2 45 to enter a number with modulus 3 and argument 45 degrees. This approach usually requires less keystrokes than on the HP48, because you skip the "shift parentheses" step (two keystrokes), and the right key to skip the right parenthese when in an equation.

Note that internally, the polar form is stored with the argument as a fraction of pi, irrespective of the angle mode. They get converted to the current angle mode on display. This means that many computations can remain exact. For example, in degrees mode, type 3 F2 45 ENTER 4 F2 90 * 8 Y^X, and you get a number where the imaginary part is exactly 0 and the argument is an integer. The HP50 doing the same computation will display the argument with a .001 at the end.
Find all posts by this user
Quote this message in a reply
10-22-2023, 11:26 PM (This post was last modified: 10-22-2023 11:27 PM by c3d.)
Post: #5
RE: DB48X - Complex Number Handling
(08-31-2023 02:20 PM)TomC Wrote:  2+i raised to the 2+i power returns a result I cannot read. (I cannot find a 'Show' function.)
(the result is about (-0.504, 3.104) Using the Re and Im functions shows that the calculator returned the correct result.

I believe that you will find the display of such numbers in 0.4.8 to be much improved. You can download it from https://github.com/c3d/DB48X-on-DM42/rel...tag/v0.4.8.

Output directly after the operation:
   

After typing EEX:
   

Expect release 0.4.9 to be a bit smarter about where it cuts the lines.
Find all posts by this user
Quote this message in a reply
10-23-2023, 05:21 PM
Post: #6
RE: DB48X - Complex Number Handling
Reflashed and started testing....comments/responses later.
Thank you,
TomC

(10-22-2023 11:26 PM)c3d Wrote:  
(08-31-2023 02:20 PM)TomC Wrote:  2+i raised to the 2+i power returns a result I cannot read. (I cannot find a 'Show' function.)
(the result is about (-0.504, 3.104) Using the Re and Im functions shows that the calculator returned the correct result.

I believe that you will find the display of such numbers in 0.4.8 to be much improved. You can download it from https://github.com/c3d/DB48X-on-DM42/rel...tag/v0.4.8.

Output directly after the operation:


After typing EEX:


Expect release 0.4.9 to be a bit smarter about where it cuts the lines.
Find all posts by this user
Quote this message in a reply
Post Reply 




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