Post Reply 
Saving expressions?
03-20-2020, 07:15 PM (This post was last modified: 03-20-2020 07:26 PM by Dands.)
Post: #1
Saving expressions?
Hi,

I have the following matrix in my CAS view and would like to save it for later use. The matrix has variables that I pre-assigned with values. What is the best way to save expressions in terms of variables as shown?

I tried to save it as a list but the saved entry does NOT carry variable names, just values.

Other questions I have:

- Why is it not possible to have upper case variable names in CAS? ex.: "Z"
- Is it possible to define variables using my computer and transfer them to my calculator?

[Image: Screen-Shot-2020-03-20-at-1-06-42-PM.png]

Thanks
Find all posts by this user
Quote this message in a reply
03-20-2020, 09:40 PM
Post: #2
RE: Saving expressions?
(03-20-2020 07:15 PM)Dands Wrote:  Hi,

I have the following matrix in my CAS view and would like to save it for later use. The matrix has variables that I pre-assigned with values. What is the best way to save expressions in terms of variables as shown?

I tried to save it as a list but the saved entry does NOT carry variable names, just values.

Other questions I have:

- Why is it not possible to have upper case variable names in CAS? ex.: "Z"
- Is it possible to define variables using my computer and transfer them to my calculator?

[Image: Screen-Shot-2020-03-20-at-1-06-42-PM.png]

Thanks

The System has predefined variables A-Z are Reals.
Read the Manual for the rest. Really: READ
Find all posts by this user
Quote this message in a reply
03-21-2020, 03:30 AM
Post: #3
RE: Saving expressions?
(03-20-2020 07:15 PM)Dands Wrote:  Hi,

I have the following matrix in my CAS view and would like to save it for later use. The matrix has variables that I pre-assigned with values. What is the best way to save expressions in terms of variables as shown?

I tried to save it as a list but the saved entry does NOT carry variable names, just values.

Other questions I have:

- Why is it not possible to have upper case variable names in CAS? ex.: "Z"
- Is it possible to define variables using my computer and transfer them to my calculator?

[Image: Screen-Shot-2020-03-20-at-1-06-42-PM.png]

Thanks

Hi Dands.

To be able to do that you'll either have to purge the variables, or just use single quotes around the matrix.

This way: med:='[[...]]';

Also, you can define variables through the conn kit, even works with copy-paste from spreadsheets!

The single letter uppercase variables are reserved in the calculator, that's why you can't use them as anything other than real numbers.
Find all posts by this user
Quote this message in a reply
03-21-2020, 04:19 AM
Post: #4
RE: Saving expressions?
(03-21-2020 03:30 AM)victorvbc Wrote:  Hi Dands.

To be able to do that you'll either have to purge the variables, or just use single quotes around the matrix.

This way: med:='[[...]]';

Also, you can define variables through the conn kit, even works with copy-paste from spreadsheets!

The single letter uppercase variables are reserved in the calculator, that's why you can't use them as anything other than real numbers.

That was truly helpful, Victor.

I was reading about user-defined functions (Creating your own functions section in the manual). I tried that but the system is zeroing out my inputs, it seems like it doesn't like matrices.

To be clear, I want to be able to use this matrix as it was a pre-defined variable. Just as it is with any user variable.

I tried the double '...' method and could not see the result. How should I access it?

Thanks
Find all posts by this user
Quote this message in a reply
03-21-2020, 10:47 AM
Post: #5
RE: Saving expressions?
(03-21-2020 03:30 AM)victorvbc Wrote:  The single letter uppercase variables are reserved in the calculator, that's why you can't use them as anything other than real numbers.

IMHO, that's one of the deficiencies of the Prime. I'd like complete freedom on deciding what goes under what variable name. There's no such restriction in C, Python, Pascal, BASIC, COBOL, FORTRAN, etc. FORTRAN does have a default of INTEGER for some variables but you can override it.

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
03-21-2020, 12:32 PM
Post: #6
RE: Saving expressions?
(03-21-2020 10:47 AM)toml_12953 Wrote:  
(03-21-2020 03:30 AM)victorvbc Wrote:  The single letter uppercase variables are reserved in the calculator, that's why you can't use them as anything other than real numbers.

IMHO, that's one of the deficiencies of the Prime. I'd like complete freedom on deciding what goes under what variable name. There's no such restriction in C, Python, Pascal, BASIC, COBOL, FORTRAN, etc. FORTRAN does have a default of INTEGER for some variables but you can override it.

Pascal restricts the type forever.
There's no such restrictions on HP Prime where you can freely reassign a free variable with your choice of content at any moment.
In COBOL one can do even better and overlap variables at will. Diaster waiting if your compiler can't handle it.
Fortran is (was?) quite restricted.
I prefer SysRPL-RPL Combo as it brings together Lisp and (almost) Forth. I like when one can modify an interpreted language on the fly! (or compile)
Also, back in the stone age when there was no Harward Architecture or separation of data and code one could poke around (pun) and fix the direct machine code for a loop branch or whatever+
Anyway, I think that there's enough name space to have your own clearly named variables besides those of the System in the dear old HP Prime.
Ane the flexibility of string & list processing.
I wish I could manipulate apps=programs as easily as on the HP 50G. – Ahhh...
VPN
PS: I C Ur •
Find all posts by this user
Quote this message in a reply
03-21-2020, 02:40 PM
Post: #7
RE: Saving expressions?
(03-21-2020 12:32 PM)CyberAngel Wrote:  
(03-21-2020 10:47 AM)toml_12953 Wrote:  IMHO, that's one of the deficiencies of the Prime. I'd like complete freedom on deciding what goes under what variable name. There's no such restriction in C, Python, Pascal, BASIC, COBOL, FORTRAN, etc. FORTRAN does have a default of INTEGER for some variables but you can override it.

Pascal restricts the type forever.
There's no such restrictions on HP Prime where you can freely reassign a free variable with your choice of content at any moment.
In COBOL one can do even better and overlap variables at will. Diaster waiting if your compiler can't handle it.
Fortran is (was?) quite restricted.

Pascal and C only restrict the type after you define a variable. You can use almost any letter or combination of letters you want. Defining the datatype ahead of time is considered good programming practice.

The ANSI/ISO standard for COBOL allows overlap of variables. Any standard-compliant compiler can handle it (almost all current compilers from mainframes to micros)

How is FORTRAN restricted? The default for variables starting with the letters I - N is integer but you can redefine them if you want. FORTRAN 90 only has these restrictions:

A variable name must start with an letter.
After that, the rest of the name can contain only letters (a-z), digits (0-9) or underscore.
A variable name can be no longer than 31 characters.

These don't seem like onerous restrictions to me. To be able to change the datatype stored in a variable at will isn't good programming practice. The increased flexibility is more than offset by the potential for errors.

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
03-21-2020, 04:38 PM
Post: #8
RE: Saving expressions?
(03-21-2020 02:40 PM)toml_12953 Wrote:  
(03-21-2020 12:32 PM)CyberAngel Wrote:  Pascal restricts the type forever.
There's no such restrictions on HP Prime where you can freely reassign a free variable with your choice of content at any moment.
In COBOL one can do even better and overlap variables at will. Diaster waiting if your compiler can't handle it.
Fortran is (was?) quite restricted.

Pascal and C only restrict the type after you define a variable. You can use almost any letter or combination of letters you want. Defining the datatype ahead of time is considered good programming practice.

The ANSI/ISO standard for COBOL allows overlap of variables. Any standard-compliant compiler can handle it (almost all current compilers from mainframes to micros)

How is FORTRAN restricted? The default for variables starting with the letters I - N is integer but you can redefine them if you want. FORTRAN 90 only has these restrictions:

A variable name must start with an letter.
After that, the rest of the name can contain only letters (a-z), digits (0-9) or underscore.
A variable name can be no longer than 31 characters.

These don't seem like onerous restrictions to me. To be able to change the datatype stored in a variable at will isn't good programming practice. The increased flexibility is more than offset by the potential for errors.

If you don't understand what I just wrote (Fortran, etc)
then there is no one who could help you to see the point.
One more try:
I wasn't talking about the variable names (which are still very flexible, although some short ones are reserved), but about the contents, which can be reassigned. It's right there after the nice RPL of the HP-48G and later. I like them!
Those reserved names in the HP Prime is a restriction that serves a purpose. One just reads a few manuals , a few thousand web pages with nice examples and learns those about 10,000 Commands (counting the different argument amount overload) and it n a few years one can learn to program the darn thing.
What bugs me is the bugs.
Find all posts by this user
Quote this message in a reply
03-21-2020, 04:58 PM
Post: #9
RE: Saving expressions?
So, any solutions for my question?

All I want is to store that matrix for later use. So far the only way I could find was to save it as a note, which is lame in my opinion.

I wanted to save it as a custom function that I can access at anytime.

Thanks
Find all posts by this user
Quote this message in a reply
03-21-2020, 05:23 PM (This post was last modified: 03-21-2020 05:34 PM by CyberAngel.)
Post: #10
RE: Saving expressions?
(03-21-2020 04:58 PM)Dands Wrote:  So, any solutions for my question?

All I want is to store that matrix for later use. So far the only way I could find was to save it as a note, which is lame in my opinion.

I wanted to save it as a custom function that I can access at anytime.

Thanks

I keyed in your variables and the matrix on an Android phone.
Seems to work. No 'quotes' were used.
I wonder what your are expecting?
[Image: Screenshot-2020-03-21-19-16-01-114-com-h...ulator.jpg]
VPN
PS: sorry for not answering right away
Find all posts by this user
Quote this message in a reply
03-21-2020, 06:48 PM (This post was last modified: 03-21-2020 07:05 PM by victorvbc.)
Post: #11
RE: Saving expressions?
Sorry for the delay.

What happens is when you call a variable that has an assigned value, it is usually evaluated. So if you declare the variables before assembling the matrix, it will always store the values, not the symbolic expressions in said matrix.

If you change those variables and call the matrix again, it won't update with the new values.

See:    

Now, if you use the single quotes (or declare before assigning anything to the variables), the matrix will actually store the symbolic expression, which will be evaluated with the current values whenever you call it on the command line.

See:    

This way, whenever you wanna see the expression without values, you just have to purge the variables.

Is this what you want? I'm not sure if I follow.
Find all posts by this user
Quote this message in a reply
03-21-2020, 08:18 PM (This post was last modified: 03-21-2020 08:21 PM by Dands.)
Post: #12
RE: Saving expressions?
(03-21-2020 06:48 PM)victorvbc Wrote:  Sorry for the delay.

What happens is when you call a variable that has an assigned value, it is usually evaluated. So if you declare the variables before assembling the matrix, it will always store the values, not the symbolic expressions in said matrix.

If you change those variables and call the matrix again, it won't update with the new values.

See:

Now, if you use the single quotes (or declare before assigning anything to the variables), the matrix will actually store the symbolic expression, which will be evaluated with the current values whenever you call it on the command line.

See:

This way, whenever you wanna see the expression without values, you just have to purge the variables.

Is this what you want? I'm not sure if I follow.

Yes, that what happens, it will assign the values to my expression. What I want to do is to ALWAYS have the abcd matrix (your example) whenever I call the variable m and without any values assigned to it.

In other words, I want to save the expression and use it anytime I need it in other calculations. I think using the '' might work for me, but I wish they had a better way to do this.

I know it's possible to define functions in the TI Nspire calculators as follows:

[Image: Screen-Shot-2020-03-21-at-2-17-05-PM.png]

If I do this in that calculator, I can call the function anytime and pass values with no problem. I want to be able to do the same in my HP Prime. Ideas?
Find all posts by this user
Quote this message in a reply
03-21-2020, 08:26 PM (This post was last modified: 03-22-2020 02:37 AM by toml_12953.)
Post: #13
RE: Saving expressions?
(03-21-2020 08:18 PM)Dands Wrote:  I know it's possible to define functions in the TI Nspire calculators as follows:

[Image: Screen-Shot-2020-03-21-at-2-17-05-PM.png]

If I do this in that calculator, I can call the function anytime and pass values with no problem. I want to be able to do the same in my HP Prime. Ideas?

You can define functions in the Prime, too. Programs can be called as functions. Just Return the value you want at the end of the program.

Code:
EXPORT MED(Y,Z)
BEGIN
  RETURN [[1+Y*Z/2,Z],[Y*(1+Y*Z/4),1+Y*Z/2]];
END;

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
Post Reply 




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