HP-50g Algebraic matrix expressions
06-26-2020, 04:38 AM
Post: #1
 Sleazey Junior Member Posts: 5 Joined: Feb 2015
HP-50g Algebraic matrix expressions
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!
06-26-2020, 06:17 AM (This post was last modified: 06-26-2020 03:36 PM by Giuseppe Donnini.)
Post: #2
 Giuseppe Donnini Member Posts: 79 Joined: Feb 2014
RE: HP-50g Algebraic matrix expressions
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).
06-26-2020, 06:21 AM
Post: #3
 Sleazey Junior Member Posts: 5 Joined: Feb 2015
RE: HP-50g Algebraic matrix expressions
Thanks so much, Giuseppe!

Looks weird but it works.
06-26-2020, 06:31 AM (This post was last modified: 06-26-2020 06:37 AM by peacecalc.)
Post: #4
 peacecalc Member Posts: 154 Joined: Dec 2013
RE: HP-50g Algebraic matrix expressions
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.
06-26-2020, 06:33 AM
Post: #5
 Giuseppe Donnini Member Posts: 79 Joined: Feb 2014
RE: HP-50g Algebraic matrix expressions
Sure, but that's not what the original poster wanted!
06-26-2020, 06:49 AM
Post: #6
 peacecalc Member Posts: 154 Joined: Dec 2013
RE: HP-50g Algebraic matrix expressions
Hello Guiseppe,

sorry for posting something similar. I beg your pardon. I hope that wasn't too hard for you reading it.
06-26-2020, 07:32 AM (This post was last modified: 06-26-2020 03:37 PM by Giuseppe Donnini.)
Post: #7
 Giuseppe Donnini Member Posts: 79 Joined: Feb 2014
RE: HP-50g Algebraic matrix expressions
@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?
06-26-2020, 02:56 PM
Post: #8
 mfleming Senior Member Posts: 569 Joined: Jul 2015
RE: HP-50g Algebraic matrix expressions
To paraphrase Diego's signature line, "Read twice, post once"

Who decides?
06-26-2020, 04:07 PM
Post: #9
 Wes Loewer Member Posts: 238 Joined: Jan 2014
RE: HP-50g Algebraic matrix expressions
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.
 « Next Oldest | Next Newest »

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