Plot equation in Home view (e.g Function plot) using result from CAS view
07-19-2019, 07:37 AM
Post: #1
 teerasak Member Posts: 63 Joined: Jun 2019
Plot equation in Home view (e.g Function plot) using result from CAS view
In many cases, I have got analysis result in CAS view with x (lower-case x) as a variable. I then need to draw the graph of this equation in Home view. However, in Home view, it accepts X (upper-case x) as a variable. What I'm doing is to change from x to X manually.

Is there any better way to allow me to have result from CAS to plot in Home view directly without manually changing it.
07-19-2019, 02:11 PM (This post was last modified: 07-19-2019 02:14 PM by toshk.)
Post: #2
 toshk Member Posts: 194 Joined: Feb 2015
RE: Plot equation in Home view (e.g Function plot) using result from CAS view
Make sure you are on Function App.
On cas screen type F1(x):=your cas equation
Or
Just use cas function. plotfunc()
07-19-2019, 02:13 PM
Post: #3 Han Senior Member Posts: 1,881 Joined: Dec 2013
RE: Plot equation in Home view (e.g Function plot) using result from CAS view
(07-19-2019 07:37 AM)teerasak Wrote:  In many cases, I have got analysis result in CAS view with x (lower-case x) as a variable. I then need to draw the graph of this equation in Home view. However, in Home view, it accepts X (upper-case x) as a variable. What I'm doing is to change from x to X manually.

Is there any better way to allow me to have result from CAS to plot in Home view directly without manually changing it.

F0 through F9 are the global variables for functions to be plotted. You can use these within the CAS environment and define, for example, F1 to be a function to plot. In CAS view, functions take the form similar to: (x)->(x^2+2*x-3). So you can do something like:

F1:=x->x^2-4;

Notice that the calculator will automatically convert to upper case and return: (X)->(X^2-4). Since the variables of functions are just placeholders, you could really use whatever variable you want. However, the system variables F0 through F9 only accept X as their placeholder variable (hence the auto-conversion).

Here's a short example of how you can use this in your calculations:

g1:=x^3-4*x^2+2*x-1;
g2:=diff(g1,x);
F1:=unapply(g2,x);

In this example, diff() computes the derivative, and unapply() turns the expression (in this case, g2) into a function whose placeholder variable is 'x'. Since we are saving the result into F1, it will auto-convert for us.

Graph 3D | QPI | SolveSys
07-19-2019, 09:38 PM
Post: #4
 victorvbc Member Posts: 73 Joined: Jun 2019
RE: Plot equation in Home view (e.g Function plot) using result from CAS view
(07-19-2019 02:13 PM)Han Wrote:
(07-19-2019 07:37 AM)teerasak Wrote:  In many cases, I have got analysis result in CAS view with x (lower-case x) as a variable. I then need to draw the graph of this equation in Home view. However, in Home view, it accepts X (upper-case x) as a variable. What I'm doing is to change from x to X manually.

Is there any better way to allow me to have result from CAS to plot in Home view directly without manually changing it.

F0 through F9 are the global variables for functions to be plotted. You can use these within the CAS environment and define, for example, F1 to be a function to plot. In CAS view, functions take the form similar to: (x)->(x^2+2*x-3). So you can do something like:

F1:=x->x^2-4;

Notice that the calculator will automatically convert to upper case and return: (X)->(X^2-4). Since the variables of functions are just placeholders, you could really use whatever variable you want. However, the system variables F0 through F9 only accept X as their placeholder variable (hence the auto-conversion).

Here's a short example of how you can use this in your calculations:

g1:=x^3-4*x^2+2*x-1;
g2:=diff(g1,x);
F1:=unapply(g2,x);

In this example, diff() computes the derivative, and unapply() turns the expression (in this case, g2) into a function whose placeholder variable is 'x'. Since we are saving the result into F1, it will auto-convert for us.

Hello,

I was making a script for my control systems class and needed to plot some resulting expressions in the function app using "F1:=...". It works perfectly from the CAS environment, but doing it in a #cas function simply attributes the name of the variable that contained the expression to F1 in my case.

An example:
Code:
 #cas test(myPoly):= BEGIN LOCAL fcn; fcn:=poly2symb(myPoly,x); F1:=unapply(fcn,x); RETURN fcn; END; #end

Am I doing something wrong?

Attached File(s) Thumbnail(s)  07-20-2019, 12:25 AM (This post was last modified: 07-20-2019 12:41 AM by toshk.)
Post: #5
 toshk Member Posts: 194 Joined: Feb 2015
RE: Plot equation in Home view (e.g Function plot) using result from CAS view
Try this;
#cas
test(myPoly):=
BEGIN
L0:=myPoly //myPoly pass straight up to my Poly2symb cause your error; but saving it to L0 forces it to list
STARTAPP(Function); //F1 is not only reserved Var for Function App but also Spreadsheet
F1:=unapply(poly2symb(L0,x),x);
RETURN F1(x);
END;
#end

Also Function App can straight up take some built in function:
F1 type in poly2symb({1,2,3},X)
07-21-2019, 03:27 PM
Post: #6
 teerasak Member Posts: 63 Joined: Jun 2019
RE: Plot equation in Home view (e.g Function plot) using result from CAS view
Thank you all for your help. That works!
 « Next Oldest | Next Newest »

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