## All calculation are equal but complex number are more equal...?

Post here to share useful tips and tricks, to ask questions about using your DM42 or to report software-related problems
mcc
Posts: 208
Joined: Fri Jun 23, 2017 3:10 am

### All calculation are equal but complex number are more equal...?

Hi,

I have a complex 2x2 matrix on the stack, position X.
It is filled with complex numbers != 0.
I enter "2" and press Y^X ... and get "Invalid Type"

Same setup...same matrix at position X of the stack.
I press X^2 and the result is returned in the matrix.

Why doesn't the first work but the second does ?
From the mathematical point of view they are the same.

Cheers!
mcc
DM 42 - SN: 00373, Firmware v.:3.14. / 3.14. as compiled by SwissMicros

Walter
Posts: 1000
Joined: Tue May 02, 2017 9:13 am
Location: Close to FRA, Germany

### Re: All calculation are equal but complex number are more equal...?

AFAIK (IIRC) matrix exponentiation isn't defined for the general case.
DM42 SN: 00041 --- Follower of Platon.

HP-35, HP-45, ..., HP-50, WP 34S, WP 31S, DM16L

ijabbott
Posts: 146
Joined: Fri Dec 15, 2017 1:34 pm
Location: Manchester, UK

### Re: All calculation are equal but complex number are more equal...?

The real HP-42S does the same thing.

mcc
Posts: 208
Joined: Fri Jun 23, 2017 3:10 am

### Re: All calculation are equal but complex number are more equal...?

Hi,
ijabbott wrote:
Fri Nov 16, 2018 8:40 am
The real HP-42S does the same thing.
...repeating (possible) bug/annoyance with a new implementation make not
better.... Here is the defintion of matrix exponential:
https://en.wikipedia.org/wiki/Matrix_exponential

Looks way more stuff as "doesn't work in general" but is far beyond
the stuff I would understood...

Is there a mathmatician here ? Cheers!
mcc
DM 42 - SN: 00373, Firmware v.:3.14. / 3.14. as compiled by SwissMicros

grsbanks
Posts: 845
Joined: Tue Apr 25, 2017 9:23 am
Location: Preston, Lancs, UK
Contact:

### Re: All calculation are equal but complex number are more equal...?

mcc wrote:
Fri Nov 16, 2018 9:14 am
...repeating (possible) bug/annoyance with a new implementation make not
better.... True, but any HP-42S program that relies on this behaviour will be broken if this is "fixed".

That is why s good simulator will simulate the behaviour of the original exactly, warts & all. Even the bits that are not necessarily mathematically correct.
Not SwissMicros staff, just an enthusiast.

Walter
Posts: 1000
Joined: Tue May 02, 2017 9:13 am
Location: Close to FRA, Germany

### Re: All calculation are equal but complex number are more equal...?

mcc wrote:
Fri Nov 16, 2018 7:32 am
I have a complex 2x2 matrix on the stack, position X.
It is filled with complex numbers != 0.
I enter "2" and press Y^X ... and get "Invalid Type"

Same setup...same matrix at position X of the stack.
I press X^2 and the result is returned in the matrix.

Why doesn't the first work but the second does ?
From the mathematical point of view they are the same.
No, they are not. X^2 is clearly defined as multiplying the matrix by itself. Y^X, on the other hand, opens Pandora's box by allowing also noninteger exponents - for such cases, however, matrix exponentiation is not defined as is written in Wikipedia as well. So, since the calculator can't impede you from entering or using noninteger X in Y^X operating on a matrix Y, it doesn't allow Y^X operating on matrices at all. This is a wise decision IMHO.
DM42 SN: 00041 --- Follower of Platon.

HP-35, HP-45, ..., HP-50, WP 34S, WP 31S, DM16L

whuyse
Posts: 39
Joined: Thu Dec 21, 2017 12:23 pm

### Re: All calculation are equal but complex number are more equal...?

X^2 will square all the matrix elements, it will not square the matrix.
Only (all?) single-argument functions will work on all elements of the matrix.
Eg. MOD doesn't work, but SIN, IP, SIGN, XTOA etc. work.

Cheers, Werner
42S #3249S01123
DM42 #00345

ijabbott
Posts: 146
Joined: Fri Dec 15, 2017 1:34 pm
Location: Manchester, UK

### Re: All calculation are equal but complex number are more equal...?

whuyse wrote:
Sat Nov 17, 2018 9:24 am
X^2 will square all the matrix elements, it will not square the matrix.
Only (all?) single-argument functions will work on all elements of the matrix.
Eg. MOD doesn't work, but SIN, IP, SIGN, XTOA etc. work.

Cheers, Werner
Also, the +, -, *, / operations between a number and a matrix apply the operation to each element of the matrix, so they could have done the same thing for y^x, at least when Y is a matrix and X is a number.

It shouldn't be too hard to write a program to raise a square matrix to an integer power (assuming the matrix is invertible in the case of negative powers), but to optimize the number of matrix multiplications required, the absolute value of the exponent should be decomposed into a sum of powers of 2. In fact, Gerald H has already written such a program and posted it on the HP-Museum forum: http://www.hpmuseum.org/forum/thread-3096.html

Walter
Posts: 1000
Joined: Tue May 02, 2017 9:13 am
Location: Close to FRA, Germany

### Re: All calculation are equal but complex number are more equal...?

whuyse wrote:
Sat Nov 17, 2018 9:24 am
X^2 will square all the matrix elements, it will not square the matrix.
Rats! I tend to forget that. I was reacting on the "matrix exponential" quoted by mcc.
whuyse wrote:
Sat Nov 17, 2018 9:24 am
Only (all?) single-argument functions will work on all elements of the matrix.
Eg. MOD doesn't work, but SIN, IP, SIGN, XTOA etc. work.
Not all. 1/x inverts the matrix. Consistency, you're called HP. DM42 SN: 00041 --- Follower of Platon.

HP-35, HP-45, ..., HP-50, WP 34S, WP 31S, DM16L

Thomas Okken
Posts: 587
Joined: Tue May 02, 2017 3:48 pm
Location: New Jersey, USA
Contact:

### Re: All calculation are equal but complex number are more equal...?

Walter wrote:
Sat Nov 17, 2018 12:32 pm
whuyse wrote:
Sat Nov 17, 2018 9:24 am
Only (all?) single-argument functions will work on all elements of the matrix.
Eg. MOD doesn't work, but SIN, IP, SIGN, XTOA etc. work.
Not all. 1/x inverts the matrix. Consistency, you're called HP. No, it doesn't. INVRT inverts a matrix, 1/x inverts its elements.
Last edited by Thomas Okken on Sat Nov 17, 2018 1:55 pm, edited 1 time in total.