[Request] for renaming variables - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: HP Prime (/forum-5.html) +--- Thread: [Request] for renaming variables (/thread-1440.html) |
[Request] for renaming variables - Tugdual - 05-28-2014 08:58 PM to translate lower case to upper case variable names and vice versa in between CAS and Home? This is something that I was really expecting with the new firmware. Say you do some CAS work and then want to see a graph? Sounds like the normal thing to do to me but remains cumbersome due to variables renaming. RE: [Request] for renaming variables - Joe Horn - 05-28-2014 11:21 PM (05-28-2014 08:58 PM)Tugdual Wrote: to translate lower case to upper case variable names and vice versa in between CAS and Home? This is something that I was really expecting with the new firmware. Say you do some CAS work and then want to see a graph? Sounds like the normal thing to do to me but remains cumbersome due to variables renaming. Not sure what you mean. No variables get renamed when switching between Home and CAS. Although the default for ALPHA in Home is uppercase, and the default ALPHA in CAS is lowercase, you can create variables in both modes using either case, or mixed case, whatever you want (as long as it doesn't conflict with reserved names, obviously). Example: Home: AA:=11; bb:=22; Cc:=33 CAS: DD:=44; ee:=55; Ff:=66 All are legal, and all retain their values (and names!) in both modes, with the first three remaining Home vars, and the other three remaining CAS vars, as can be seen by pressing the Vars key, or via the Memory Manager. If I'm missing your point, please elucidate. Thanks! RE: [Request] for renaming variables - CR Haeger - 05-28-2014 11:49 PM If I understand, it may be related to doing work in CAS with say lower case f(x) then wanting to just copy/paste or use this in Function App. The app requires upper case Xs and there seems to be non obvious workarounds like: f(x):=sin(x) // define CAS variable program with lower case x's Function.F1:=f // defines F1 as f(x) and converts to upper case X when opened in Function app Now Function app F1 shows sin(X) RE: [Request] for renaming variables - Tugdual - 05-29-2014 12:35 AM Yes you totally understood my question, sorry if I was not clear. Thanks for sharing this very nice workaround. Note: I noticed it is possible to enter f(X) straight into the Function app screen for example. RE: [Request] for renaming variables - cyrille de brébisson - 05-29-2014 06:15 AM Hello, FYI: in cas, you can do: f(x):=x+1 and then do F1:=f This WILL assign X+1 (note the uppercase) to F1. and without copy/paste. note, you could also do g(a):=a+1 and F1:=g it will also work. cyrille RE: [Request] for renaming variables - Tugdual - 05-29-2014 07:39 AM (05-29-2014 06:15 AM)cyrille de brébisson Wrote: Hello,Thanks for mentioning this, very helpful and the beauty of this is that you can on the fly change f(x) and see the plot updated. Also the 'STO >' key works (no need to enter ':' and '='). Hmmmmm looks like the Prime starts becoming sexy after all. Edit: it is also possible to define g(x):=df(x)/dx (btw F1:=df(X)/dX doesn't work) and plot f(X) and g(X) all together. Then later you can change f(x) and see both graphs updated. This is actually much more powerful than copy/pasting from cas to Apps. Edit: well there is a major drawback with this solution: speed. I didn't notice it when trying on the emulator but when I did the same on the real prime I could notice that the poor little things was on its knees. Just enter f(x):=sin(x) then F1:=f(X) and F2:=2*sin(X) and you'll see how dramatically faster F2 is compared to F1. RE: [Request] for renaming variables - Angus - 05-29-2014 09:28 AM I tried it the other way around if you want, i.e. I defined F1 in the function app as F1(X)=SIN(X)/X. Then I decided to do some cas work on that. Question 1: picking F1 from the vars menu App->Function->Symbolic->F1 places F1 on the cas. It is the same if I typed only F1. Whats the difference between Function.F1:=f and only F1? Why do you see the Function.F1:=f typing and why did CR Haeger use it? Question 2: I found that either dF1/dx nor dF1/dX worked as Tungdual noticed aswell... Is it explainable? I thought F1 was implied to be a function of some variable X. Or x in the cas? why does dF1(x)/dx do the job? Are all variables converted from upper to lower case when using an APP function (not only restricted to function app) in the case and vice versa? I'd love to see hands on materials with deeper explanation and many examples, soon! edit: the fact that dF1(x)/dx works seems to be logical after some thinking. Is it that the cas works with the function F1(X), replaces the -in the cas mode- X with the symbolical 'x' and therefore can calculate the differentiation? But why would the cas not work with capital X on the other hand? I think JoeHorn stated that in the cas all Variables are cas Variables no matter how they are typed in. So an 'X' should be symbolic just as 'x' is so that replacing the X in F1 with the cas 'X' should work? I'm getting confused again... RE: [Request] for renaming variables - CR Haeger - 05-29-2014 10:19 AM It was suggested to me earlier to use Function.F1:=f versus just F1:=f. This seems to allow the definition of F1 even if the FUNCTION app is not ACTIVE. I use this and f(x):= frequently enough that I created USER keys for both of them - to save keystrokes. I usually use Function.F2:=f' to define F2 as the first derivative of f. RE: [Request] for renaming variables - Tim Wessman - 05-29-2014 01:27 PM Quote:edit: the fact that dF1(x)/dx works seems to be logical after some thinking. Is it that the cas works with the function F1(X), replaces the -in the cas mode- X with When you use the X, it is evaluating the real variable after. eg COS(X) <try to get a real value, can't so evalute the symbolic> -> COS(<current_num_in_variable>) To evaluate a numerical derivative at a point, the syntax is d<fnc>/d<var>=<var>. eg: dF1(X)/(dX=X) RE: [Request] for renaming variables - Angus - 05-29-2014 03:46 PM I refer to Joe Horn's post Quote:All are legal, and all retain their values (and names!) in both modes, with the first three remaining Home vars, and the other three remaining CAS vars, as can be seen by pressing the Vars key, or via the Memory Manager. Doesn't that mean, that if I define a variable X in the cas it does NOT coexist with a home variable X??? So a single letter variable in capital letter refers to the home variable, althogh it it used/created in the cas? Man I thought I got it.... RE: [Request] for renaming variables - cyrille de brébisson - 05-30-2014 07:08 AM Hello, >There is a major drawback with this solution: speed. f(x):=sin(x) then F1:=f(X) and F2:=2*sin(X) and you'll see how dramatically faster F2 is compared to F1. Yep, it is because F1 will be f(x) and not sin(X). As a result, EVERY call to evaluate F1 will be a call to the CAS instead of a numerical call and there is a high cost to call the CAS from the numerical world (which is where the function app resides)... > Difference between Function.F1:=f and only F1? Why do you see the Function.F1:=f typing and why did CR Haeger use it? You would use Function.F1:= when F1 by itself is ambiguous.. As a general rules, varaibles are contextual. so you would not be able to access an app variable directly unless it is the current app OR you provide the namespace information by doing namespace.variable Now, in the case of F1 (and a few others), if no F1 is found in the system, it will use the Function.F1 even if Function is not the current application (to make things easy for non strict people). This does lead to confusion for the rest of us.. Nevertheless... you would use Function.F1 if Function is NOT the current app (and you wanted to be strict), if you had another F1 defined, or if the current app was a function app, but not the one called Function. cyrille RE: [Request] for renaming variables - Joe Horn - 05-30-2014 10:47 AM (05-29-2014 09:28 AM)Angus Wrote: I think JoeHorn stated that in the cas all Variables are cas Variables no matter how they are typed in. So an 'X' should be symbolic just as 'x' is so that replacing the X in F1 with the cas 'X' should work? I'm getting confused again... You can't create a variable that already exists. So you can't create a CAS variable called 'X' because 'X' already exists as a permanently-existing Home variable. RE: [Request] for renaming variables - Joe Horn - 05-30-2014 10:57 AM (05-29-2014 03:46 PM)Angus Wrote: I refer to Joe Horn's postQuote:All are legal, and all retain their values (and names!) in both modes, with the first three remaining Home vars, and the other three remaining CAS vars, as can be seen by pressing the Vars key, or via the Memory Manager. You can't define a variable X in CAS. Creating two variables with the same name, one in Home, and one in CAS, is impossible to do. If you're in CAS, and you store a number into X, then it gets stored into the Home variable X. Related factoid: Since Home numeric (real, floating-point) variables are 12-digit BCD, and CAS numeric variables are 48-bit binary, this can cause surprising changes to values. Example: In CAS: X:=1/3. (include the decimal point to force numeric approximation) X-1/3. --> not zero, because 1/3. in Home <> 1/3. in CAS. I hope that didn't make it even more confusing. RE: [Request] for renaming variables - Tugdual - 05-30-2014 12:05 PM (05-30-2014 07:08 AM)cyrille de brébisson Wrote: >There is a major drawback with this solution: speed. f(x):=sin(x) then F1:=f(X) and F2:=2*sin(X) and you'll see how dramatically faster F2 is compared to F1.Hi, understood but then the fun of exploration with touch screen is totally gone considering the time it takes to refresh. I see two options: 1. Improve the redraw algorithm to iterate redraw from rough to detailed (a bit like jpeg) so that we can have a preview and immediately zoom or scroll the drawing, possibly interrupting the ongoing refine process. 2. Implement a copy paste with renaming of x -> X to leverage the native numericall features. |