HP Forums
HP-50g Algebraic matrix expressions - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: General Forum (/forum-4.html)
+--- Thread: HP-50g Algebraic matrix expressions (/thread-15261.html)



HP-50g Algebraic matrix expressions - Sleazey - 06-26-2020 04:38 AM

I usually do all my HP50 programming in RPL. And it has been a few years since I needed to do anything non-trivial.

But I have a need to use algebraic syntax for some complex expressions involving matrices, since the algebraic form is easier to verify visually for correctness.

How do I refer to a single element of a matrix variable with an algebraic expression?

"matrix1", "r", and "c" are all local variables in the current program fragment. I want to refer to the element in matrix1 at row r, column c.

The obvious approach generates an error when I try to save from the command line:
'matrix1[r,c]'.

This does not work.

I have tried several obvious variations, but none of them work:
'matrix1[[r,c]]'
'matrix1[r c]'
'matrix1[[r c]]'

Is what I am asking even possible with algebraic expressions?

If so, what is the correct syntax? I have been unable to find any examples online of using subscripts for a matrix in an algebraic expression. Any pointers to such would be welcome!

Thanks everyone!


RE: HP-50g Algebraic matrix expressions - Giuseppe Donnini - 06-26-2020 06:17 AM

You are very close!

Just use parentheses: 'Matrix1(r,c)'. Think of it as a binary function which returns exactly one value.
Like for any function, this works also for symbolic arguments, i.e. r and c can themselves be symbolic (variables or even expressions).


RE: HP-50g Algebraic matrix expressions - Sleazey - 06-26-2020 06:21 AM

Thanks so much, Giuseppe!

Looks weird but it works.


RE: HP-50g Algebraic matrix expressions - peacecalc - 06-26-2020 06:31 AM

Hello Sleazey,

Matrix is on Stacklevel 2
{row column}
GET

for example:

\[ stacklevel ~~ 2: \left( \begin{array}{rrr} 1 & 2 & 3 \\ 4 & 5 & 6 \\ \end{array} \right)\]

\[ stacklevel ~~ 1: \{ 2\quad 3 \} \]

\[ command:\quad GET \]

\[ returns: 6 \quad (element \quad second \quad row \quad third \quad column) \]


For this approach your matrix doesn't need to be stored in variable.


RE: HP-50g Algebraic matrix expressions - Giuseppe Donnini - 06-26-2020 06:33 AM

Sure, but that's not what the original poster wanted!


RE: HP-50g Algebraic matrix expressions - peacecalc - 06-26-2020 06:49 AM

Hello Guiseppe,

sorry for posting something similar. I beg your pardon. I hope that wasn't too hard for you reading it.


RE: HP-50g Algebraic matrix expressions - Giuseppe Donnini - 06-26-2020 07:32 AM

@peacecalc: I think you should calm down and stay ... peaceful.

In the interest of subsequent readers of this forum, I simply wanted to point out that your post doesn't address Sleazey's problem. Leaving it as the final answer to his question might suggest precisely that to a more casual reader. That's all.

Warum immer gleich alles persönlich nehmen?


RE: HP-50g Algebraic matrix expressions - mfleming - 06-26-2020 02:56 PM

To paraphrase Diego's signature line, "Read twice, post once" Wink


RE: HP-50g Algebraic matrix expressions - Wes Loewer - 06-26-2020 04:07 PM

FWIW, the GET command can also be used in Algebraic mode.

GET(matrix,{r,c})

It's not as nice looking as matrix(r,c), but GET can be used with a literal matrix.

[[10,20][30,40]]->MM
GET(MM,{2,2}) AND MM(2,2) both return 40.
GET( [[10,20][30,40]],{2,2}) works but [[10,20][30,40]](2,2) does not.
Likewise, GET(Ans(1),{2,2}) works but Ans(1)(2,2) does not.