complementary function to unapply()
|
03-31-2015, 06:09 AM
Post: #1
|
|||
|
|||
complementary function to unapply()
I need to 'extract' a function's underlying expression. If you want the complementary function to unapply(). When an Expression is given I can convert it into a function with unapply(expr, var1, var2 ,...). I would I do that vice versa?
I did try to extract the Expression from the function Definition, but in order to use mid() or other string related functions I need a string first. If I have fun(x,y):=x*y it is represented as (x,y)->x*y. STRING(fun(x,y)) works and evaluates into "x*y" but entering the variables is cumbersome and error-prone so I would very much prefer STRING(fun). How do you do it? Or is there a built in function related to unapply wich does the Job? |
|||
03-31-2015, 06:26 AM
Post: #2
|
|||
|
|||
RE: complementary function to unapply()
If your function is algebraically defined (no stream control instructions), you can simply call it with free variables as arguments.
For example f:=unapply(sin(x^2),x), then f(x) |
|||
03-31-2015, 06:45 AM
Post: #3
|
|||
|
|||
RE: complementary function to unapply()
hello parisse! The thing is I already have a function f(x). What I want to achieve is to extract the expression under the function. I do not want to call all parameters.
If f(a,b,c,d,e):=a*b*c*d*e then a*b*c*d*e should be isolated. Adding a,b,c,d,e to any call is annoying. I hope it got clear what I mean and try to achieve. |
|||
03-31-2015, 12:35 PM
Post: #4
|
|||
|
|||
RE: complementary function to unapply()
(03-31-2015 06:45 AM)leprechaun Wrote: hello parisse! The thing is I already have a function f(x). What I want to achieve is to extract the expression under the function. I do not want to call all parameters. In CAS view, type string(f) (in lower case) and you will get the expression as a string. Then just use the substring starting from the character after the first ">" Graph 3D | QPI | SolveSys |
|||
03-31-2015, 12:51 PM
Post: #5
|
|||
|
|||
RE: complementary function to unapply()
Darn!
I string'ed for hours but just didn't try string().... Did I overlook that one? I hunted the help System for related commands like mad. The conversion only works in a #cas #end program as a result, I guess? Seriously I'm close to giving up with the prime - the fun gets lost atm. :-((( Thank you, Han! You seem to be a rock solid instance about the prime. Do you belong to the HP group? Why sooo complicated and bizarre? |
|||
03-31-2015, 01:11 PM
Post: #6
|
|||
|
|||
RE: complementary function to unapply()
(03-31-2015 12:51 PM)leprechaun Wrote: Darn! You can also use CAS.string() in Home view. Quote:Seriously I'm close to giving up with the prime - the fun gets lost atm. :-((( I was equally frustrated when I first started. Then as I used it more, I started to understand the nuances and I have tried to share what I have learned on the forums here. Quote:Thank you, Han! You seem to be a rock solid instance about the prime. Do you belong to the HP group? If you are asking whether I am one of the developers, then the answer is: no, I'm just a user. Quote:Why sooo complicated and bizarre? This is mere speculation, but the HP Prime is likely a continuation of the HP39GII. This older calculator was truly targeted at the education market. If you take the HP Prime and removed the CAS, then you would essentially have an HP39GII but with slightly updated hardware. The Prime added a CAS and a "test" mode. The idea was that the CAS and other features could be disabled during exams, and thus make it permissible on standard exams. This is likely one of the major reasons why there is a Home view and a CAS view, each with their nuanced ways of operating (e.g. CAS generally uses lower-case commands whereas Home uses upper-case). Graph 3D | QPI | SolveSys |
|||
03-31-2015, 02:03 PM
(This post was last modified: 03-31-2015 02:54 PM by DrD.)
Post: #7
|
|||
|
|||
RE: complementary function to unapply()
(03-31-2015 12:51 PM)leprechaun Wrote: Why sooo complicated and bizarre? Leprechaun; [Rainbow] "Simple" is the understandable. "Complicated" is a collection of the simple. "Bizarre" is a point on the learning curve, where understanding diverges from simple, to complicated. [Pot of Gold] There are products less complicated and bizarre. While the Prime has much to offer, it's still evolving. For the cost of entry, its a great value. [Lucky Charm] Given the Prime, an investment in time, ... your results may be a harbinger; For your effort this rhyme, attempts to remind, ... the "Tool does not make the Carpenter." ©-Dale- 20150331 |
|||
03-31-2015, 06:33 PM
Post: #8
|
|||
|
|||
RE: complementary function to unapply()
leprechaun, if say f(x):=sin(x^2), in Xcas you can access to the expression with f[3] (for any symbolic f, f[0] returns the top-level operator/command, f[1], f[2], etc. the arguments, a function is a symbolic with top-level command 'program'). I did not check on the Prime, it might work as well but probably with an index shift, i.e. with f[4].
|
|||
03-31-2015, 06:37 PM
Post: #9
|
|||
|
|||
RE: complementary function to unapply()
(03-31-2015 06:33 PM)parisse Wrote: leprechaun, if say f(x):=sin(x^2), in Xcas you can access to the expression with f[3] (for any symbolic f, f[0] returns the top-level operator/command, f[1], f[2], etc. the arguments, a function is a symbolic with top-level command 'program'). I did not check on the Prime, it might work as well but probably with an index shift, i.e. with f[4]. Just verified that it is indeed "shifted by 1". Very cool to have such a simple way of accessing parts of a function! Graph 3D | QPI | SolveSys |
|||
04-01-2015, 05:42 AM
Post: #10
|
|||
|
|||
RE: complementary function to unapply()
Yes, very cool! Thanks for the Information.
I could get Expression() finished in a first pre-alpha version. :-) Code:
Is it a good advice to create a cas program? I would prefer to find Expression in the Toolbox menu but it can only show normal programs. func[2] is also a Beauty as far as it seems to be the Parameter vector of the function! What I would like to achieve next is a function Information program. Namely an Input form that lists all used variables with their content. I hope that Input can be used for global variables - so you would get a nice overview if all variables have their correct value before you calculate the function with them. INPUT() is a beast that has to be tamed....[/code] |
|||
04-01-2015, 05:47 AM
Post: #11
|
|||
|
|||
RE: complementary function to unapply()
Also, you may want to read up on the XCas documentation since that is the engine for the CAS on the HP Prime. Just google xcas/giac and you'll find plenty of useful information.
Graph 3D | QPI | SolveSys |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 3 Guest(s)