Post Reply 
Variable use between CAS and Home.
07-09-2017, 08:04 PM
Post: #1
Variable use between CAS and Home.
I wrote the following equation into the CAS:

solve(X^3-5*X^2-2*X+24) and got the result I was expecting ... [-2, 3, 4]

I then wanted to enter the same equation into the Function App to plot it.
I copied the expression within the CAS and pasted in into the Smyb of the Function App. I then deleted solve() so I was left with only X^3-5*X^2-2*X+24. I then pressed Enter.

I got an error which I realized was because in the CAS the 'x' variable was lower case (which was copied over to the Function App). So, I had to change the copied lower case 'x' to upper case 'X' to be able use it in the Function App and plot it.

Is there a better way to do this?
Find all posts by this user
Quote this message in a reply
07-11-2017, 02:13 AM
Post: #2
RE: Variable use between CAS and Home.
Anyone have any ideas on how to use variables between Home and CAS?
I just ran into the same issue in reverse (took me 20 minutes to figure out what was wrong).

I put the following expression into the Function Symb:
X^2+4*X-5

Then I plotted it ... all is well.

Now, I want to factor it so I do the following:

1. Highlight X^2+4*X-5 and copy
2. Go to CAS
3. Select Toolbox > Algebra > Factor

paste expression into factor and get this result:
−8.58601465676

Ah, what's going on? what did I do wrong??? This is the answer I want:
(x-1)*(x+5)

As it turns out, the 'X' from Home is upper case and CAS wants lower case 'x'.

Do I really have to manually change all the x's between Home and CAS?

Thanks,
Jim
Find all posts by this user
Quote this message in a reply
07-11-2017, 03:39 AM
Post: #3
RE: Variable use between CAS and Home.
Have you tried subst?

For example, in CAS
subst('X ...', 'X'=x) should do the conversion for you.
Find all posts by this user
Quote this message in a reply
07-11-2017, 11:29 PM (This post was last modified: 07-11-2017 11:33 PM by Skyblues.)
Post: #4
RE: Variable use between CAS and Home.
I actually tried that and couldn't get it to work.

In another post (where I was facing a similar issue), Joe suggested purge (X) and restart but neither solved the problem here.

This time, I am copying to and from Home <-> CAS.

I am still new to the Prime and going through examples, the Quick Start Guide and Users Manual.

There is an advertised feature where one can use the Menu button to "Get From Home" or "Get From CAS".

I am surprised that a calculator this powerful wouldn't have a relatively easy way to change the variables case needed when copied from/to Home/CAS.


From the Quick Start Guide:

"You can also copy an item from CAS history to an expression you are entering in Home view. Press Menu and select Get from CAS. The CAS view opens. Tap the item you want, and it is copied directly to the cursor position in Home view. Likewise, you can insert an item from Home view history into an expression you are entering in CAS view. Just press Menu and select Get from Home. Home view opens. Tap the item you want and it is copied directly to the cursor position in CAS view."

It doesn't mention that an expression with upper case 'X' copied from Home cannot be used in the CAS that needs a lower case 'x' to give symbolic answers.

I figure I must be missing something.
Find all posts by this user
Quote this message in a reply
07-12-2017, 12:45 AM (This post was last modified: 07-12-2017 12:47 AM by Han.)
Post: #5
RE: Variable use between CAS and Home.
From Home to CAS:

Suppose you have a formula entered in F1 (using Plot app). So if F1 is defined as X^2+4*X-5, then in the CAS, you can simply do:

purge(x);
f:=F1(x);
factor(f);

This creates an expression named f with dummy variable x; i.e. f is the same as x^2+4*x-5 (in lower case). The right hand side is an evaluation of the function F1 at x. You can then work with the expression using f in its place rather than having to copy/paste or type out the expression.

From CAS to Home:

Suppose you have x^2+4*x-5 on your screen at some point. To quickly apply this formula to F1, type:

F1:=x->

and with the cursor sitting after the > symbol in the command line, use your touchscreen to copy the formula to complete the command as:

F1:=x->x^2+4*x-5;

This creates a function objection with dummy variable x and formula x^2+4*x-5; the calculator will "automagically" convert lower case x to upper case X for you.

Notes:

You could have also created a function f using f:=F1. To then obtain an expression, you can then use functional notation to evaluate f at the variable x by typing: f(x).

Thus f:=F1; followed by factor(f(x)); would also have worked for the Home to CAS case.

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
07-12-2017, 03:01 AM
Post: #6
RE: Variable use between CAS and Home.
Han,

Wow, thank you, that's exactly what I needed! I knew I was missing something.

Thanks,
Jim
Find all posts by this user
Quote this message in a reply
07-14-2017, 08:50 AM
Post: #7
RE: Variable use between CAS and Home.
Han, I was reading this post out of curiosity and tried your F1 example.
On CAS I tried to factor x^2+4*x-5
Then, I went to the home screen and did what you suggested and typed:
F1:=x->
...and copied the quadratic from CAS to get:
F1:=x->x^2+4*x-5
...and it gives me Error:Syntax Error
What am I doing wrong here?
Thx
-Donald
Find all posts by this user
Quote this message in a reply
07-15-2017, 01:08 PM
Post: #8
RE: Variable use between CAS and Home.
(07-14-2017 08:50 AM)webmasterpdx Wrote:  Han, I was reading this post out of curiosity and tried your F1 example.
On CAS I tried to factor x^2+4*x-5
Then, I went to the home screen and did what you suggested and typed:
F1:=x->
...and copied the quadratic from CAS to get:
F1:=x->x^2+4*x-5
...and it gives me Error:Syntax Error
What am I doing wrong here?
Thx
-Donald

You need to do that in the CAS view, not in the Home view.

Graph 3D | QPI | SolveSys
Find all posts by this user
Quote this message in a reply
08-08-2017, 04:19 PM
Post: #9
RE: Variable use between CAS and Home.
I have written a user defined function. It change little x to great X.
------------------------------------------------------
I have defined the Name of the function in the follow:
CHANGE x to X
CH x 2 X
------------------------------------------------------
#cas
CHx2X(cmd):=
BEGIN
return subst(cmd,x = ('X'));
END;
#end

Examples (In Mode CAS):


1. CHx2X(2*x+5*x²-5) ==> 2*X+5*X²-5

2. F1:= CHx2X(2*x+5*x²-5) ==> X-> (2*X+5*X²-5)
Find all posts by this user
Quote this message in a reply
08-08-2017, 11:11 PM
Post: #10
RE: Variable use between CAS and Home.
(08-08-2017 04:19 PM)Rudi Wrote:  I have written a user defined function. It change little x to great X.
------------------------------------------------------
I have defined the Name of the function in the follow:
CHANGE x to X
CH x 2 X
------------------------------------------------------
#cas
CHx2X(cmd):=
BEGIN
return subst(cmd,x = ('X'));
END;
#end

Examples (In Mode CAS):


1. CHx2X(2*x+5*x²-5) ==> 2*X+5*X²-5

2. F1:= CHx2X(2*x+5*x²-5) ==> X-> (2*X+5*X²-5)

This looks very nice and may be a good solution to a problem I always encounter.

Any idea how to add an EXPORT statement so the program will present the user with ...

CHx2X()

on the input?

I tried a few options and couldn't get it to work. I'm a total beginner on programming the Prime.
Find all posts by this user
Quote this message in a reply
08-11-2017, 01:08 PM
Post: #11
RE: Variable use between CAS and Home.
In fact, I think you can try replace("2*X+5*X^2-5","X","x") then copy the content without ' " '. That's what I do.
Find all posts by this user
Quote this message in a reply
08-27-2017, 08:02 PM
Post: #12
RE: Variable use between CAS and Home.
Variable use between CAS and Home.
I have written a new user defined function. It change lowercase x, y, z variables to uppercase X, Y, Z variables.
I have defined the Name of the function in the follow:
CHANGE xyz to XYZ
CH xyz 2 XYZ

Code:
#cas
// To use Variables between CAS and Home
// Writen by Rudi Steeger
// Input an Formular with Lowercase x, y, z Variables
// Output Uppercase X, Y, Z Variables
// Important Use the Program only in CAS View!
CHxyz2XYZ(cmd):=
BEGIN
RETURN subst(cmd,([x,y,z]) = (trn([['X'],['Y'],['Z']])));
END;
#end


// Examples (Only in CAS View):
// CHxyz2XYZ(2*x*y^2*z+5*x^2-5*y+3*z)
// ==> 2*X*Y^2*Z+5*X^2-5*Y+3*Z

// f:=2*x*y^2*z+5*x^2-5*y+3*z
// ==> 2*x*y^2*z+5*x^2-5*y+3*z

// CHxyz2XYZ(f)
// ==> 2*X*Y^2*Z+5*X^2-5*Y+3*Z

// CHxyz2XYZ(2*x+5*x^2-5)
// ==> 5*X^2+2*X-5

// F1:=CHxyz2XYZ(2*x+5*x^2-5)
// ==> (X)->2*X+5*X^2-5
Find all posts by this user
Quote this message in a reply
08-28-2017, 09:13 AM
Post: #13
RE: Variable use between CAS and Home.
(08-11-2017 01:08 PM)wangchong01 Wrote:  replace("2*X+5*X^2-5","X","x") then copy the content without ' " '.
Just another dumb question: How could I get rid of the quotation marks?
The mark on the right hand cannot be deleted, deleting the mark on the left deletes the whole string.
And a possible even dumber question: where in the documentation(s) may I find described this (getting rid of the marks, not the use of the "replace" command)?

Thanks

Hans
Find all posts by this user
Quote this message in a reply
08-29-2017, 05:05 AM
Post: #14
RE: Variable use between CAS and Home.
Hello,

Programatically, you can use the expr command.
in the edit line, you can only delete the whole string at once :-(

cyrille

Although I work for the HP calculator group, the views and opinions I post here are my own. I do not speak for HP.
Find all posts by this user
Quote this message in a reply
08-29-2017, 05:15 AM (This post was last modified: 08-29-2017 05:15 AM by Anders.)
Post: #15
RE: Variable use between CAS and Home.
(08-29-2017 05:05 AM)cyrille de brébisson Wrote:  Hello,

Programatically, you can use the expr command.
in the edit line, you can only delete the whole string at once :-(

cyrille

Yes, I have also noticed that you are only left with delete whole string option. Super irritating :-(
Find all posts by this user
Quote this message in a reply
08-29-2017, 05:38 AM (This post was last modified: 08-29-2017 05:39 AM by Tim Wessman.)
Post: #16
RE: Variable use between CAS and Home.
The issue is 2D display. Strings HAVE to be grouped together and you can't allow them individually. It is ridiculously (maybe impossible) difficult to re flow text perfectly between 2d/1d when you mix strings.

Think about it, the instant you stick in a " singly, you need to go through and reflow the rest of the text. Then when you close it... go back and reflow everything after back into 2D without losing any formatting or making any changes.

It just isn't compatible with 2D. Any 2D editor I've ever seen that allows strings in the input behaves the same way that I've seen.

TW

Although I work for HP, the views and opinions I post here are my own.
Find all posts by this user
Quote this message in a reply
08-29-2017, 06:34 AM
Post: #17
RE: Variable use between CAS and Home.
(08-29-2017 05:38 AM)Tim Wessman Wrote:  The issue is 2D display. Strings HAVE to be grouped together and you can't allow them individually. It is ridiculously (maybe impossible) difficult to re flow text perfectly between 2d/1d when you mix strings.

I understand. Meanwhile I found a way (so I believe) to isolate, say the >>3+x<<, out of "3+x". Copy and paste (via "Begin" and "End") did so.

Do I use the system correctly or is this just another example of the impossibility to design idiot-proof systems (because idiots are so creative)?

Thank you for your patience,
Hans
Find all posts by this user
Quote this message in a reply
08-29-2017, 03:48 PM
Post: #18
RE: Variable use between CAS and Home.
Yes, that will work. You can also long hold-drag to select. However, I need to add in little handles still to let you adjust the selection still.

TW

Although I work for HP, the views and opinions I post here are my own.
Find all posts by this user
Quote this message in a reply
08-30-2017, 04:49 AM
Post: #19
RE: Variable use between CAS and Home.
(08-29-2017 03:48 PM)Tim Wessman Wrote:  Yes, that will work. You can also long hold-drag to select. However, I need to add in little handles still to let you adjust the selection still.

Thank You Tim for the enlightenment,

Hans
Find all posts by this user
Quote this message in a reply
09-04-2017, 12:53 PM
Post: #20
RE: Variable use between CAS and Home.
Typing on the prime is not too much fun, so I decided to store some help funktions for cas<->home interchange on my user keys handling.

If I try: "f(x):=Function.F1(x)" as a returned user key and assign, say X^2 to F1 in the function app.

I get (x)->F1(x).

evaluating f(2) gives 4, so things -seem- to be ok. How do I get the expression for F1(x) instead? On the first hand I'd like to see it und second I don't know if f(x) would behave differently if F1(X) was changed....

Tried EVAL("f(x):=Function.F1(x)") as a result. Doesn't help.

Thank you so much.
Find all posts by this user
Quote this message in a reply
Post Reply 




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