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: 277
Joined: Fri Jun 23, 2017 5:10 am

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

Post by mcc »

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 release v.:3.22. / DMCP 3.24. as compiled by SwissMicros
User avatar
Walter
Posts: 3070
Joined: Tue May 02, 2017 11:13 am
Location: On a mission close to DRS, Germany

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

Post by Walter »

AFAIK (IIRC) matrix exponentiation isn't defined for the general case.
WP43 SN00000, 34S, and 31S for obvious reasons; HP-35, 45, ..., 35S, 15CE, DM16L S/N# 00093, DM42β SN:00041
User avatar
ijabbott
Posts: 253
Joined: Fri Dec 15, 2017 2:34 pm
Location: GB-MAN

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

Post by ijabbott »

The real HP-42S does the same thing.
mcc
Posts: 277
Joined: Fri Jun 23, 2017 5:10 am

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

Post by mcc »

Hi,
ijabbott wrote:
Fri Nov 16, 2018 9: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 release v.:3.22. / DMCP 3.24. as compiled by SwissMicros
grsbanks
Posts: 1122
Joined: Tue Apr 25, 2017 11:23 am
Location: Preston, Lancs, UK
Contact:

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

Post by grsbanks »

mcc wrote:
Fri Nov 16, 2018 10: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.
There are only 10 kinds of people in the world: those who understand binary and those who do not.
User avatar
Walter
Posts: 3070
Joined: Tue May 02, 2017 11:13 am
Location: On a mission close to DRS, Germany

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

Post by Walter »

mcc wrote:
Fri Nov 16, 2018 8: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.
WP43 SN00000, 34S, and 31S for obvious reasons; HP-35, 45, ..., 35S, 15CE, DM16L S/N# 00093, DM42β SN:00041
whuyse
Posts: 198
Joined: Thu Dec 21, 2017 1:23 pm

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

Post by whuyse »

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
41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE, DM15L
User avatar
ijabbott
Posts: 253
Joined: Fri Dec 15, 2017 2:34 pm
Location: GB-MAN

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

Post by ijabbott »

whuyse wrote:
Sat Nov 17, 2018 10: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
User avatar
Walter
Posts: 3070
Joined: Tue May 02, 2017 11:13 am
Location: On a mission close to DRS, Germany

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

Post by Walter »

whuyse wrote:
Sat Nov 17, 2018 10:24 am
X^2 will square all the matrix elements, it will not square the matrix.
Rats! :shock: I tend to forget that. :? I was reacting on the "matrix exponential" quoted by mcc.
whuyse wrote:
Sat Nov 17, 2018 10: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. ;)
WP43 SN00000, 34S, and 31S for obvious reasons; HP-35, 45, ..., 35S, 15CE, DM16L S/N# 00093, DM42β SN:00041
Thomas Okken
Posts: 1100
Joined: Tue May 02, 2017 5:48 pm
Location: Netherlands
Contact:

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

Post by Thomas Okken »

Walter wrote:
Sat Nov 17, 2018 1:32 pm
whuyse wrote:
Sat Nov 17, 2018 10: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 2:55 pm, edited 1 time in total.
Post Reply