Proper way(s) to substitute X for x in a CAS expression
|
12-20-2013, 05:53 PM
(This post was last modified: 12-20-2013 05:55 PM by Han.)
Post: #6
|
|||
|
|||
RE: Proper way(s) to substitute X for x in a CAS expression
As much as I like the HP Prime, I must say that the way programs interact with the CAS at the moment feels a lot like "hacking" -- as in, there really isn't a straightforward way to do it and it looks like a bunch of tricks to get things to play nicely.
That said, a symbolic object on the HP Prime is surrounded by quotes. However, the Home view and CAS view treat symbolic objects differently as they have different parsing methods. For the time being, you must always assume that you are working in the Home view when you create any program. So one of the issues you will run into is the inability to use undefined variables in the Home view. This is why 'x^2-1' will produce an error (despite being an algebraic object) whereas as soon as you define lower case x, then the errors go away. The reason is because in the Home view, all objects can can be evaluated must return a real value when evaluated. So 'X^2-1' always works since capital X is always defined. So just how does one pass an expression so that it can be handled in CAS properly? For now, I would suggest strings. Use a combination of STRING(), EXPR(), and CAS() in addition to CAS.function() where possible. Below are some examples: Code:
The three examples above illustrate the following:
So, do what you need to do with strings, then pass the final result to the CAS() command. Here's an example of how to use symbolics inside a matrix: Code:
Convoluted, but if you study it carefully, it follows the scheme I outlined earlier. Now, to really muddy up the waters, certain CAS commands actually behave normally in the Home view (likely because their Home execution falls back on the CAS rules -.- *sigh*). In particular, the diff() command could be used with CAS.diff() or even just as diff() provided you use single quotes! But I'll save that for another day to discuss. (12-20-2013 02:32 PM)CR Haeger Wrote:(12-20-2013 09:07 AM)cyrille de brébisson Wrote: try using QUOTE (or '') as in: Specifically for built-in variables which take "formulas" for input, you can even get away with a string. For example: Code:
works just fine provided the string properly parses (i.e. if you were to type the formula in with double quotes, it must be a proper expression). Graph 3D | QPI | SolveSys |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
Proper way(s) to substitute X for x in a CAS expression - CR Haeger - 12-17-2013, 12:32 AM
RE: Proper way(s) to substitute X for x in a CAS expression - Helge Gabert - 12-17-2013, 03:23 AM
RE: Proper way(s) to substitute X for x in a CAS expression - CR Haeger - 12-17-2013, 05:15 PM
RE: Proper way(s) to substitute X for x in a CAS expression - cyrille de brébisson - 12-20-2013, 09:07 AM
RE: Proper way(s) to substitute X for x in a CAS expression - CR Haeger - 12-20-2013, 02:32 PM
RE: Proper way(s) to substitute X for x in a CAS expression - Han - 12-20-2013 05:53 PM
RE: Proper way(s) to substitute X for x in a CAS expression - John P - 12-20-2013, 08:13 PM
|
User(s) browsing this thread: 2 Guest(s)