HP Forums

Full Version: HP-50g Algebraic matrix expressions
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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!
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).
Thanks so much, Giuseppe!

Looks weird but it works.
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.
Sure, but that's not what the original poster wanted!
Hello Guiseppe,

sorry for posting something similar. I beg your pardon. I hope that wasn't too hard for you reading it.
@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?
To paraphrase Diego's signature line, "Read twice, post once" Wink
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.
Reference URL's