Post Reply 
Write an equation that contains several variables, and go immediately to solve them
02-26-2021, 09:42 PM (This post was last modified: 02-27-2021 05:04 AM by CharlieF.)
Post: #1
Write an equation that contains several variables, and go immediately to solve them
First of all, thank you very much in advance, and greetings to all. Thanks to you I have bought an HP Prime.

Let's assume this function - equation (as it's an example, I'm making it up, but it's a good example I think):

2/3 * PrXs_011- (PreXs_053 - 77.2) = (2 / PreTAM_034) * 24.7 - (LOCFm_01 + 5)

These are the variables, then:
PrXs_011
PreXs_053
PreTAM_034
LOCFm_01

In the HP 50G that equation is written directly (thus, writing those variables on the screen, with their uppercase and lowercase letters), it is stored in the EQ variable, it is given to the SOLVER key, and you already have the variables not only created, but ready to 'play' with their values, assigning some and correcting others. In other words: with three keystrokes, you already have the set of variables (to enter and calculate and recalculate) on the screen. In fact, I have created a program (and assigned it to a key) using, if you remember, the commands MINIT, MSOLVR, EVAL, etc. so, it's no longer three keystrokes, but the press of a single key.

In the Casio ClassPAD II ... after writing the equation, it is not even necessary to store it anywhere: you drag and drop, and on the screen appears the box in which the variables are arranged to enter or enter the values ​​you want and be able 'play' between those values.

Could you please give me a suggestion, how this can be done on the HP Prime (thus, as simple as it is done on the HP-50G or the Casio ClassPAD II)? Keep in mind that a large part of the pre-university Chemistry or Physics problems, and the first of a technical career, are very similar to the one I have raised.

Thank you very much in advance. And greetings to all.

Carlos
Madrid, Spain
Casio ClassPad II, HP17BII, HP48GX, HP50g, HP Prime G2
Find all posts by this user
Quote this message in a reply
02-27-2021, 03:00 AM
Post: #2
RE: Write an equation that contains several variables, and go immediately to solve them
Hi! Welcome to the forum.

You mean something like this?
   

Cheers.
Find all posts by this user
Quote this message in a reply
02-27-2021, 05:58 AM
Post: #3
RE
Thank you for your prompt response, Victor. And thanks for the welcome.

Well…: I'm not really sure that's what I'm trying to do.

What I intend…, I am going to develop it, and explain it now a little more:

First step: I want to be able to write in the calculator (somewhere), this equation (with those names of those variables exactly)
2/3 * PrXs_011- (PreXs_053 - 77.2) = (2 / PreTAM_034) * 24.7 - (LOCFm_01 + 5)
(In the Home View area, I can't (gives syntax error) because the variable names do not support lowercase letters (gives syntax error)
(In the CAS area, I can't because before writing that equation, I must first write each of those variables and assign them a value (say, for example, zero), or else, it gives syntax error)


Second step: I want to bring that equation to the Solve Symboliv View (Solve Application), to the E1 line, for example

3rd step: that expression, written in E1, I want to be able to evaluate it, in such a way that after pressing the Eval key, an environment with these four variables appears to me, to be able to play calculating and recalculating one and the other.


This that I describe, and that apparently seems very complicated, on the HP50G is one of the first things to be learned, due to its simplicity and its usefulness (the procedure is that simple: you turn on the calculator, write that expression, store it in the variable EQ, press the SOLVE key, and you're done! On the Casio ClassPad, it's also one of the first things you learn, and it's even easier if possible than with the HP 50G.

It is clear that if I am still not able to do that with the HP PRime, it is that I still do not understand well how the HP Prime works. That is why I ask you for help, please, to do what I ask, which is so simple.

Thanks in advance.

PS. I suppose that the way to achieve this must be resolved in one of the poles of these 145 pages that make up this section of the forum (I have already read from 140 to 145, and I am still not able to grasp how it can be done this I propose)

Carlos
Madrid, Spain
Casio ClassPad II, HP17BII, HP48GX, HP50g, HP Prime G2
Find all posts by this user
Quote this message in a reply
02-27-2021, 07:24 AM
Post: #4
RE: Write an equation that contains several variables, and go immediately to solve them
Hi,

In the Solve App you can define an equation. If you use the names of your original equation you get an "Syntax error" message. But if you transofrm your equation to:
2/3 * X - (W - 77.2) = (2 / V) * 24.7 - (U + 5)
you can put this in the symbolic view of the app.

If you now go to the numeric view you get a screen where you can put in 3 of your values and save for the fourth. E.g. X=1, W=3, V=1 results in U=-30.4667

I hope this helps a bit.

Best
Find all posts by this user
Quote this message in a reply
02-27-2021, 09:45 AM (This post was last modified: 02-27-2021 12:39 PM by ramon_ea1gth.)
Post: #5
RE: Write an equation that contains several variables, and go immediately to solve them
I often use the HP 50g solver with MINIT, MITM and MSOLVR, working in a folder, but also the HP Prime, so I understand the feeling of this question.

My proposal for the HP-Prime would be this:
- Start the Solve app.
- From the Home screen, create the variables you need as app variables with this command: 0▶AVars({"PrXs_011","PreXs_053","PreTAM_034","LOCFm_01"})
- Press the Symb key and enter your equation. Your created variables are also available by pressing [Vars][Solve][Program]

This approach is also useful if you create new apps based on the Solve app, as you can store your variables as local app variables, avoiding clutter in the Home environment with global variables.

Edited: one more comment.
If you want to go one step further by programming, I propose to combine this approach with CSTMENU:
https://www.hpmuseum.org/forum/thread-16144.html
You can prepare a short program with a list of variables as input argument, to be initialised with AVars() as explained, but also to be used as soft keys to help at entering the equation.

Ramón
Valladolid, Spain
TI-50, Casio fx-180P, HP48GX, HP50g, HP Prime G2
Visit this user's website Find all posts by this user
Quote this message in a reply
02-27-2021, 11:19 PM
Post: #6
RE: Write an equation containing variables, and go immediately to solve them
(02-27-2021 07:24 AM)rawi Wrote:  Hi,
In the Solve App you can define an equation. If you use the names of your original equation you get an "Syntax error" message. But if you transofrm your equation to:
2/3 * X - (W - 77.2) = (2 / V) * 24.7 - (U + 5)
you can put this in the symbolic view of the app.
If you now go to the numeric view you get a screen where you can put in 3 of your values and save for the fourth. E.g. X=1, W=3, V=1 results in U=-30.4667
I hope this helps a bit.
Best


Thank you very much, rawi.
Not only it does help a bit; It helps me a lot!, since I am starting to use this calculator. Thank you very much!
In fact, that way that you propose ... is the one that I am using: on a separate piece of paper (yes, with paper and a pen) I write down the equivalences: PrXs_011 = X, PreXs_053 = W, etc. And I proceed to do what you have told me. It is very useful… and all the more useful if the name of the variables that we adopt is as long and as difficult to write as the examples I have put.

Having said all this, I suggest you also take a look at the good idea that ramon_ea1gth offers us above.

All the best.

Carlos
Madrid, Spain
Casio ClassPad II, HP17BII, HP48GX, HP50g, HP Prime G2
Find all posts by this user
Quote this message in a reply
02-28-2021, 01:00 AM (This post was last modified: 02-28-2021 01:38 AM by CharlieF.)
Post: #7
RE: Write an equation containing several variables, and go immediately to solve them
(02-27-2021 09:45 AM)ramon_ea1gth Wrote:  I often use the HP 50g solver with MINIT, MITM and MSOLVR, working in a folder...


So do I. Very often. And... that is: working in a 'particular folder'.
And I do it very often. Exaggerating a bit: 'I couldn't live without them'!

By the way: do you know what is the folder (= memory area) in which I do that work? In a sub-sub-folder called "Home .1 .11". I suppose you can already guess why to do all that work in such a particular folder (a sub sub folder of Home). I'll give you the answer (which I'm sure you can guess): I have in the CST menu of that Home sub sub folder, I have a key in it assigned to a program (very simple program, with just two instructions) that… automatically deletes all the variables created in that sub sub-folder of HOME; and so I can make it clear the 'blackboard', to go on to solve the next problem in chemistry or physics. 'I couldn't live without CST menu, MINIT, MITM, MSOLVR, etc.!



(02-27-2021 09:45 AM)ramon_ea1gth Wrote:  My proposal for the HP-Prime would be this:
- Start the Solve app.
- From the Home screen, create the variables you need as app variables with this command: 0▶AVars({"PrXs_011","PreXs_053","PreTAM_034","LOCFm_01"})
- Press the Symb key and enter your equation. Your created variables are also available by pressing [Vars][Solve][Program]
This approach is also useful if you create new apps based on the Solve app, as you can store your variables as local app variables, avoiding clutter in the Home environment with global variables.


Great!!!!, excellent!!!!, fantastic!!!!!! Thank you very much, Ramón!!!

And an absolute novice idea: do you think we could combine, in a single program (in order to get the calculator to do it all while we are sitting on the sofaWink,
- that AVars command
- with... this one that I just discovered: lname (syntax: lname (Expres)) I am not sure if the command is written lname or LNAME
Its description is this:
- list of variables in the expression
- example: lname (exp (x) * 2sin (y)) returns [x, y]


I've checked for an equation..., and it works too.
Example: LNAME (AB_01= exp (x) * 2/B_37) returns this list [AB_01, x, B_37]


Thank you in advance.

Carlos
Madrid, Spain
Casio ClassPad II, HP17BII, HP48GX, HP50g, HP Prime G2
Find all posts by this user
Quote this message in a reply
02-28-2021, 01:07 AM (This post was last modified: 02-28-2021 01:13 AM by CharlieF.)
Post: #8
RE: Write an equation containing several variables, and go immediately to solve them
(02-27-2021 09:45 AM)ramon_ea1gth Wrote:  ....so I understand the feeling of this question.

Edited: one more comment.
If you want to go one step further by programming, I propose to combine this approach with CSTMENU:
https://www.hpmuseum.org/forum/thread-16144.html
You can prepare a short program with a list of variables as input argument, to be initialised with AVars() as explained, but also to be used as soft keys to help at entering the equation.




Of course I do want to go one step further... to combine that great approach with CSTMENU!! That would be the final goal: to get a program to end up assigning it to a soft key (inside a CST Menu), or to a keyboard key.

... And thank you very much, Ramón, for taking your time to understand the feeling of all these questions.

Have a happy sunday! All the best.

Carlos
Madrid, Spain
Casio ClassPad II, HP17BII, HP48GX, HP50g, HP Prime G2
Find all posts by this user
Quote this message in a reply
03-06-2021, 08:06 PM (This post was last modified: 03-06-2021 08:22 PM by ramon_ea1gth.)
Post: #9
RE: Write an equation that contains several variables, and go immediately to solve them
Hi!
Quote:And an absolute novice idea: do you think we could combine, in a single program (in order to get the calculator to do it all while we are sitting on the sofaWink,
- that AVars command
- with... this one that I just discovered: lname (syntax: lname (Expres)) I am not sure if the command is written lname or LNAME
Its description is this:
- list of variables in the expression
- example: lname (exp (x) * 2sin (y)) returns [x, y]
At first glance, it looks as an interesting idea: to pass the equation to a program, extract the possible variables inside and create them afterwards with AVars().
However, you need the variables already defined with AVars() to be able to use LNAME().
So AVars() has to be used first.

Cheers!

Ramón
Valladolid, Spain
TI-50, Casio fx-180P, HP48GX, HP50g, HP Prime G2
Visit this user's website Find all posts by this user
Quote this message in a reply
03-07-2021, 08:37 PM
Post: #10
Write an equation that contains several variables, and go immediately to solve them
Not sure if this helps but, if you don't mind enclosing your equation in double quotes, this program:

PHP Code:
#pragma mode( separator(.,;) integer(h32) )
EXPORT makevars(is)
BEGIN
 local n
,stc,mtvs,sz;
 
local fy:={};
 
stc:="lname("+is+")";
 
mtvs:=CAS(eval(stc));
 
sz:=SIZE(mtvs);
 if 
sz then
  fy
:=MAKELIST(string(mtvs(n)),n,1,sz);
 
AVars(fy):=0;
 
END;
 
AVars;
END

will create any app variables that do not already exist and return a list.

DelAVars({"y","x"});
makevars("exp (x) * 2sin (y)");

returns: {"x","y"}

-road
Find all posts by this user
Quote this message in a reply
03-07-2021, 09:45 PM (This post was last modified: 03-11-2021 11:53 AM by essen.)
Post: #11
RE: Write an equation that contains several variables, and go immediately to solve them
(02-28-2021 01:00 AM)CharlieF Wrote:  
(02-27-2021 09:45 AM)ramon_ea1gth Wrote:  I often use the HP 50g solver with MINIT, MITM and MSOLVR, working in a folder...


So do I. Very often. And... that is: working in a 'particular folder'.
And I do it very often. Exaggerating a bit: 'I couldn't live without them'!

By the way: do you know what is the folder (= memory area) in which I do that work? In a sub-sub-folder called "Home .1 .11". I suppose you can already guess why to do all that work in such a particular folder (a sub sub folder of Home). I'll give you the answer (which I'm sure you can guess): I have in the CST menu of that Home sub sub folder, I have a key in it assigned to a program (very simple program, with just two instructions) that… automatically deletes all the variables created in that sub sub-folder of HOME; and so I can make it clear the 'blackboard', to go on to solve the next problem in chemistry or physics. 'I couldn't live without CST menu, MINIT, MITM, MSOLVR, etc.!



(02-27-2021 09:45 AM)ramon_ea1gth Wrote:  My proposal for the HP-Prime would be this:
- Start the Solve app.
- From the Home screen, create the variables you need as app variables with this command: 0▶AVars({"PrXs_011","PreXs_053","PreTAM_034","LOCFm_01"})
- Press the Symb key and enter your equation. Your created variables are also available by pressing [Vars][Solve][Program]
This approach is also useful if you create new apps based on the Solve app, as you can store your variables as local app variables, avoiding clutter in the Home environment with global variables.


Great!!!!, excellent!!!!, fantastic!!!!!! Thank you very much, Ramón!!!

And an absolute novice idea: do you think we could combine, in a single program (in order to get the calculator to do it all while we are sitting on the sofaWink,
- that AVars command
- with... this one that I just discovered: lname (syntax: lname (Expres)) I am not sure if the command is written lname or LNAME
Its description is this:
- list of variables in the expression
- example: lname (exp (x) * 2sin (y)) returns [x, y]


I've checked for an equation..., and it works too.
Example: LNAME (AB_01= exp (x) * 2/B_37) returns this list [AB_01, x, B_37]


Thank you in advance.


--------------------------------------------------------------------------------
Lname()

The "l" in lname stands for list.

Try this:

Set your Prime in CAS mode.

Save your variables like this:
{MyA1,MyD1,MyC1,MyB1}:={5.3,-41,13.9, 1}
It' s never mind if one of these values are an unknown value.
You can even set it "" if wanted.
You now can se these variables in CAS-memory having these given values.

Rearrange your equation as you showed us, but in a style like this.
'0=MyA1*MyD1+MyC1*(MyB1+MyD1)'

Save it like so:
EQMIN:='0=MyA1*MyD1+MyC1*(MyB1+MyD1)'
It is essentiel your remember to quote it with ' '
Because anytime you fetch your equation it wil evaluate if not quoted.
You can now find this equation in CAS-memory.

Now do this:
lname(quote(EQMIN))
Again you must use quote, otherwise lname() will not function.
This will show you a list of your equations variables.

{MyA1,MyD1,MyC1,MyB1}

You are allowed to do it conversely. That is, you could had started storing
the equation. Then used the lname. Then used the found variable list
to store your variables value as shown.

Now you want to solved for 3 known and a third one unknown.
Say, MyB1

You have 3 that all works:
solve(EQMIN,MyB1,1)
or this one
fsolve(EQMIN,MyB1,1)
or this one
solvec(EQMIN,MyB1,1), for complex roots.

The "1" in these are just guesses. It can be necessary to try more guess
if you just get an empty bracket like []. Try also negative. And you sure will
get an empty bracket half of your trials, because these Prime solvers er really
bad designed. There has never been alike trouble with HP HP - 50. Of course,
if you saved an unknown variable with "", then solve that first.

I now shown you the bread and butter to build with. Though, I would not use
these solvers myself. I will recommend you to read very carefully the Primes
input(). - That one are excellent. With this, it is possible making up a program
exactly like the HP 48 solver. Using the input() are easier than starting with
CSTMENU.

The Primes app solver are a real bogey. It is essential given variable meaningful
names, as you did. - Not one letter names. If storing names of multi-letters
first, the app solver accept them, but I could not yet get it working, no result
came.

es
Find all posts by this user
Quote this message in a reply
Post Reply 




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