Question about CAS and Graphing
|
09-20-2014, 08:59 PM
Post: #1
|
|||
|
|||
Question about CAS and Graphing
I just purchased my HP Prime and I'm learning how to use it. I have a question about working between the Function app and CAS. I'll use an example to explain my question:
Let's say you perform the following integration in CAS, int(x,x). The result is 1/2 * x^2. Now, let's say you want to plot the result as a function, f(X) using the Function app. If I switch to the Function app, I can push the "Menu" button to get the result of my integration in CAS. However, I can't enter this equation because it uses a lower case 'x' instead of an upper case 'X'. To plot the equation you have to swap out the 'x' with a 'X'. This isn't very efficient for larger equations. What's the point of getting an equation from CAS if you can't use it? Maybe I'm missing something. Is there a better way to work between CAS and this app (or Home for that matter)? Thanks. |
|||
09-20-2014, 09:45 PM
(This post was last modified: 09-20-2014 09:52 PM by jebem.)
Post: #2
|
|||
|
|||
RE: Question about CAS and Graphing
The Home environment requires all variables to be declared before they can be used (CAS is another environment where you can reference the variables without declaring them in first place).
It happens that Home mode has a number of system global variables predefined (the ones in uppercase that you mention like "X"). Try to declare the lowercase variables in Home mode in first place, by storing 0 in them and see if this works for you. Jose Mesquita RadioMuseum.org member |
|||
09-21-2014, 03:19 AM
Post: #3
|
|||
|
|||
RE: Question about CAS and Graphing
Thanks, but no joy.
Declaring the variable in Home eliminates the syntax error, but setting it equal to some number results in a constant plot ... For example X = 0, results in 1/2 * x^2 always = 0 ... no parabolic curve. Too bad the app doesn't allow you to easily swap out a variable when bringing an equation over from CAS. I guess you just have to modify the equation for the app. |
|||
09-21-2014, 05:27 AM
(This post was last modified: 09-21-2014 05:32 AM by jebem.)
Post: #4
|
|||
|
|||
RE: Question about CAS and Graphing
(09-21-2014 03:19 AM)Mysilmaril Wrote: Thanks, but no joy. I don't have access to the calculator now, indeed it is strange. But when you use the uppercase X , check the actual value of it. Global predefined variables also have zero as contents. Edit: Peraphs there is a way: Try to use uppercase variable X in CAS to see if it woks. Jose Mesquita RadioMuseum.org member |
|||
09-24-2014, 10:14 PM
(This post was last modified: 09-25-2014 12:28 AM by Han.)
Post: #5
|
|||
|
|||
RE: Question about CAS and Graphing
In the CAS view, use:
f:=int(x,x); Now, load the geometry app, and in the [Symb] view enter: plotfunc(f), then hit [Plot]. Not exactly the most natural way, but works because the geometry app is built on the CAS so there is no issue with x vs X. EDIT: You can also skip using the geometry app if you are happy with a miniature plot. Just type plotfun(f) in the CAS view to get this tiny graph. Graph 3D | QPI | SolveSys |
|||
09-25-2014, 08:21 AM
Post: #6
|
|||
|
|||
RE: Question about CAS and Graphing
(09-24-2014 10:14 PM)Han Wrote: In the CAS view, use: Thank you, Han! Lateral thinking... excellent. You are very knowledgeable and helpful, as usual! Concerning your EDIT info on plotfun(f), yes, I tried that a couple of days ago after my previous posting, but I was not sure about if that could be a good answer to the OP, so I preferred to wait for someone with enough expertize on the Prime to add additional useful comments. Jose Mesquita RadioMuseum.org member |
|||
09-25-2014, 11:30 AM
(This post was last modified: 09-25-2014 11:34 AM by Angus.)
Post: #7
|
|||
|
|||
RE: Question about CAS and Graphing
Confusion, again...
plotfun() sound like plotting a function f:=int(x,x) is called an expression right? If I define f(x):=int(x,x) i.e. a function there is no graph. Yes plot(f(x)) works fine, but you should keep in mind that students not present in forums should find an intuitive way to use the tool. @HP: These issues are really, really important and essential for a calculator. Especially when thinking of usage at school. Please go for that topic! Seriously I have the feeling there has to be done something. There was a thread weeks ago about interchanging graph data to the function app I just don't find it to link it. I am surprised that most people seem to be happy with workarounds...? edit: I would suggest to use small letters by default in the geometry app to point out its realation to the cas. Mine plot big letters just like the function app. |
|||
09-25-2014, 01:35 PM
(This post was last modified: 09-25-2014 01:36 PM by Han.)
Post: #8
|
|||
|
|||
RE: Question about CAS and Graphing
(09-25-2014 11:30 AM)Angus Wrote: Confusion, again... Your function is not well defined. No matter what cas you use f(x):=int(x,x) does not appear to be well defined. Is f(3) to be 1/2*3^2 or int(3,3)? The plotfunc command requires an expression representing the function as an input and not an actual function object itself. And yes I agree -- this is merely a workaround. Graph 3D | QPI | SolveSys |
|||
09-26-2014, 07:37 PM
Post: #9
|
|||
|
|||
RE: Question about CAS and Graphing
(09-20-2014 08:59 PM)Mysilmaril Wrote: Let's say you perform the following integration in CAS, int(x,x). The result is 1/2 * x^2. Now, let's say you want to plot the result as a function, f(X) using the Function app. One way around the problem that hasn't been mentioned yet is the following. Suppose you have a potentially complicated function of x (or any other variable) on the CAS screen - call it f(x). Copy f(x) to the command line in CAS and use the "|" template with x='X' as the substitution. This replaces x with X; you can then copy the new expression from CAS into the graphing app with the "Menu" button as you describe above. There are a couple of points to note. First, the single quote marks around X are needed - without them x is replaced with the numerical value of X (and because X is a Home variable, it always has a numerical value; it is never undefined). Second, you can't use "Ans" instead of copying f(x) directly into the command line. I think that the substitution command carries out the substitution before evaluating its first argument, which is normally what you want. This fails when the first argument is Ans. The substitution is carried out on 'Ans', leaving it unchanged, and then Ans is evaluated giving the original expression back again. Ans needs to be treated with care! Nigel (UK) |
|||
11-22-2014, 03:01 AM
Post: #10
|
|||
|
|||
RE: Question about CAS and Graphing
If you define f as a function in the CAS
(for example, by entering "f(x):=1/2*x^2") then in the Function Symbolic View entering and checking F1(X)=f(X) should also bring up a parabola in the Function plot view. There is an issue with moving non-floating-point values from the CAS to the numeric (Function, Home, etc.) environment (this can be seen with the above example by going to the Function Numeric View). To ameliorate this issue you can uncheck the "Exact" setting in the CAS Settings screen. Plotting won't be as fast as F1(X)=1/2*X^2 due to the many round trips between the CAS and numeric environments. |
|||
11-22-2014, 10:30 AM
Post: #11
|
|||
|
|||
RE: Question about CAS and Graphing
I congratulate the previous posters on their ingenuity & knowledge of the machine to achieve better performance.
Exactly these efforts have convinced me to finally discontinue using the Prime. |
|||
11-22-2014, 02:16 PM
(This post was last modified: 11-22-2014 02:18 PM by Han.)
Post: #12
|
|||
|
|||
RE: Question about CAS and Graphing
(11-22-2014 10:30 AM)Gerald H Wrote: I congratulate the previous posters on their ingenuity & knowledge of the machine to achieve better performance. Speaking only for myself, the only efforts involved were reading up on the CAS documentation and trying stuff out on my own -- which is what I imagined anyone would do for any CAS. In fact, I still do that now when I work with Maple and Mathematica -- and these are CAS that I've used for over a decade. Specifically for the HP Prime, the separation of Home from CAS is a design choice that users must come to terms with before continuing to use the calculator. It's the same when switching from Maple to Mathematica and recognizing that functions in Mathematica are defined using square brackets -- which is often associated with vectors and matrices for users comfortable with Maple's design choices. One can simply choose to not use Mathematica since it would require relearning how to input expressions, or actually make an attempt to use it and take advantage of its capabilities. The answers I gave when I posted a while back were simply what came to mind (namely because I was tinkering with plotfunc() for other reasons). In retrospect, the answer I should have given (which seems obvious, now) is below: int(x,x); f(x):=<copy the result from above>; (easy to do on the calc) F1:=f; then go into the Plot app and simply plot. The plot app can and will convert x to X on the fly provided you feed F0-F9 an actual CAS function. In fact, the function f itself doesn't even have to be in terms of x; it can be in terms of any dummy variable and the calculator is smart enough to convert to X. For example: f(r):=1/2*r^2; F1:=f; F1 will correctly show 1/2*X^2. And even shorter is: int(x,x); F1:=(x)->copy result from above The problem with trying to do everything in one step is that there are conflicts with priority -- something that no CAS will be able to resolve on its own. For example, if one attempts to use: f(x):=int(x,x); then (from a programming point of view) how should f(3) be treated? Should f(3) be the result of evaluating int(x,x) first and then substituting in 3? Or should 3 be substituted first and then the integral evaluated (causing an error). Humans know the difference, but computers do not. Even Maple and Mathematica complain in this case. Graph 3D | QPI | SolveSys |
|||
11-22-2014, 02:31 PM
Post: #13
|
|||
|
|||
RE: Question about CAS and Graphing
(11-22-2014 03:01 AM)jte Wrote: If you define f as a function in the CAS This is unnecessary. In CAS, simply type: F1:=f('X'); which evaluates f at the symbolic value 'X' and properly provides a formula for F1. Graph 3D | QPI | SolveSys |
|||
11-22-2014, 07:01 PM
Post: #14
|
|||
|
|||
RE: Question about CAS and Graphing
(11-22-2014 02:16 PM)Han Wrote:(11-22-2014 10:30 AM)Gerald H Wrote: I congratulate the previous posters on their ingenuity & knowledge of the machine to achieve better performance. Maple & Mathematica have different syntax & conventions! Not really surprising, as they are different products, so the best you can demand is CONSISTENCY in the system, not between the competing products. I do not consider inconsistency between various environments in the one system an advantage - it could be viewed as quaint, but that's scarcely a compliment. |
|||
11-22-2014, 07:26 PM
(This post was last modified: 11-22-2014 07:32 PM by Han.)
Post: #15
|
|||
|
|||
RE: Question about CAS and Graphing
(11-22-2014 07:01 PM)Gerald H Wrote: Maple & Mathematica have different syntax & conventions! Not really surprising, as they are different products, so the best you can demand is CONSISTENCY in the system, not between the competing products. I'm not trying to defend the design choice and am simply noting that there are two environments. Once you familiarize yourself with each, it's not hard to work between them. The inconsistencies arise from trying to force one environment that has its own set of rules to behave like the other (which also has its own set of rules). Of course this will happen by the mere fact that they are two separate environments, each with their own set of rules. I think that if the Home environment was inconsistent within itself, then that would be disastrous. Likewise, if the CAS environment had inconsistencies within itself, then it too would be disastrous. However, I haven't heard any complaints about how Home is inconsistent with itself (nor similarly with the CAS). In a classroom that has various CAS software available, students must come to terms with the fact that if they use multiple CAS to solve a single problem, they have to deal with making these different CAS work together. There are tasks that Maple can do better than Mathematica, and vice versa. It's not too far-fetched to have real-world problems that make use of both. I don't see this as being really any different from having two separate environments. If the complaint is that there are even two environments to begin with (forcing you to have to remember that they behave differently), then that's a different discussion. If you really want to see inconsistency, look no further than the HP49G through HP50G that tried to put everything under one roof. https://groups.google.com/forum/#!search...2t49yjMC8J Various solving algorithms would ask to change certain flag settings which may or may not affect results on future calculations. One need only dig through comp.sys.hp48 to see myriad examples. Most of those issues were alleviated with a few of the HP50G's internal commands that handled all the flag settings for the user. Edit: I am sure you are aware that CAS programs are incredibly slow compared to their non-CAS counterparts when it comes to numerical computations. (This is true for any CAS system). The HP Prime gives you both. You can choose to ignore the CAS and do only numerical computations for a speed gain. Or you can use the CAS if your computations require mostly symbolic manipulation. I hardly think that this is quaint in an age where most technologies are judged by their computing power and speed. Graph 3D | QPI | SolveSys |
|||
11-23-2014, 07:54 AM
Post: #16
|
|||
|
|||
RE: Question about CAS and Graphing
(11-22-2014 07:26 PM)Han Wrote: Edit: I am sure you are aware that CAS programs are incredibly slow compared to their non-CAS counterparts when it comes to numerical computations. (This is true for any CAS system).This is true if the numeric data is handled exactly by the CAS, but it does not need to be slower if the data is handled numerically. Experience: uncheck Textbook mode display in Settings. Enter this in CAS: a:=ranm(100,100,0..1) This creates a 100x100 matrix with approx random coeff in 0..1 M0:=a 1/a in CAS takes about 1s 1/M0 in Home takes more time. |
|||
11-23-2014, 03:15 PM
Post: #17
|
|||
|
|||
RE: Question about CAS and Graphing
(11-22-2014 07:26 PM)Han Wrote:(11-22-2014 07:01 PM)Gerald H Wrote: Maple & Mathematica have different syntax & conventions! Not really surprising, as they are different products, so the best you can demand is CONSISTENCY in the system, not between the competing products. It may be a pleasure to bounce around between Mathematica & Maple in a world where both are freely available, unfortunately on my planet you have to pay cash for them. I pity the poor creatures having to use both M & M to solve their problems - do you imagine these beings will have the discipline to remember the system they're working in & come up with the right syntax everytime? |
|||
11-23-2014, 06:31 PM
(This post was last modified: 11-23-2014 06:32 PM by jte.)
Post: #18
|
|||
|
|||
RE: Question about CAS and Graphing
(11-22-2014 02:31 PM)Han Wrote:(11-22-2014 03:01 AM)jte Wrote: If you define f as a function in the CAS Excellent point. This can certainly result in an F1 that evaluates faster. With this approach some care should be taken though, at least when f contains CAS operations as F1 may be overly "simplified" (into an inequivalent expression — depending, apparently, on the value of X at the time of assignment, even with "Simplify" in the CAS settings unchecked). After trying a handful of examples I've also experienced some crashes when going to a Function plot view (crashes that didn't occur with F1 defined as f(X) in the Function Symbolic view — but only when f contained CAS operations). |
|||
11-23-2014, 08:41 PM
Post: #19
|
|||
|
|||
RE: Question about CAS and Graphing
(11-23-2014 03:15 PM)Gerald H Wrote: It may be a pleasure to bounce around between Mathematica & Maple in a world where both are freely available, unfortunately on my planet you have to pay cash for them. I don't see why cost is at all relevant to the initial discussion. If anything, the cost speaks favorably for the HP Prime (and its free CAS). At any rate, the target demographics for the Prime includes college students. At many universities, software packages such as Mathematica, Maple, Mathcad, etc. are all available to students. You can even get them at student pricing (if you want your own license) for $75. Quote:I pity the poor creatures having to use both M & M to solve their problems - do you imagine these beings will have the discipline to remember the system they're working in & come up with the right syntax everytime? Are you suggesting that we pity folks who choose to do research for which applications such as Mathematica and Maple are simultaneously useful? I wouldn't pity them for the same reason I wouldn't pity folks who strive to learn two languages and struggle to understand those who natively speak the two languages in a mixed fashion (I know plenty of folks who speak half a sentence in one language, and finish the second half in another). If anything, I think it's commendable that people make an effort to learn more than one language, CAS, operating system, what-have-you... Perhaps you meant we should pity the "creatures" who are given homework assignments that require multiple software applications to solve problems. While most typical class assignments will not require several CAS to solve, that doesn't mean that there aren't situations where the use of multiple software packages are necessary. I am sure you can find numerous engineers who not only have to program their own solutions, they probably even do it via multiple languages and/or CAS to check their work. In fact, I know a graduate student in engineering who was doing that just that this week -- and it was for a single homework assignment. Even among undergraduate students there will come times when they may rely on many different applications to solve a problem. For example, many undergraduates compete in the mathematical competition in modeling; the problems are often open-ended questions. As for whether they remember the syntax -- they try stuff out on their own, ask for help, and/or read the documentation and that seems to work out just fine. If you don't like the Mathematica and Maple analogy, then just look at any recent version of Maple itself. They have both "worksheets" and "documents" and you can even use a combination of both inside a single session. I cannot count the number of times I have had to explain to students the pitfalls mixing 2D and 1D math and when what they type is math input vs. plain text. Anyway, I hated the fact that the Prime had two environments when I first got one because the familiarity with the HP48G through HP50G calculators had been so deeply ingrained. Now, it doesn't bother me as much because I have gotten more familiar with how each work. Despite my love for the HP48GX, it just doesn't hold a candle to the power available on the Prime. Graph 3D | QPI | SolveSys |
|||
11-23-2014, 08:42 PM
Post: #20
|
|||
|
|||
RE: Question about CAS and Graphing
(11-23-2014 06:31 PM)jte Wrote: After trying a handful of examples I've also experienced some crashes when going to a Function plot view (crashes that didn't occur with F1 defined as f(X) in the Function Symbolic view — but only when f contained CAS operations). Could you provide some examples? Graph 3D | QPI | SolveSys |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 6 Guest(s)