Post Reply 
CAS: overriding HOME variables, bug or feature? (for me, a feature!)
07-11-2021, 10:17 PM (This post was last modified: 07-12-2021 12:09 PM by ramon_ea1gth.)
Post: #3
RE: CAS: overriding HOME variables, bug or feature? (for me, a feature!)
Dear Albert

As usual, your post is worth each line. So I would like to remark this, as I share it:
Quote:However, I would advise against doing this. With Undefined Behavior, Anything is Possible
(by the way, I like the image with the unicorn and the stuff around: you can feel the crazyness).

Said this, I will continue being naughty. I was thinking about a workflow to ‘properly’ use this ‘feature’ (unicorn flying around). My goal: doing some symbolic manipulations and afterwards, obtaining a numeric result. So this would be my way:
  • Use always single quoted ‘ ‘ expressions to avoid evaluation.
  • Apply Select&Simplify, by selecting the quoted expression and pressing the soft-key [simplify].
  • When symbolic operations are finished, initialize all the required variables with := and use the ‘overriding’ feature.

Example:
Code:

CAS> ‘Z = Z0 * exp(i*β*z)’                                // Example with quotation marks
Ans: Z = Z0 * exp(i*β*z)                                   // Output is not evaluated
CAS> ‘subst(Z = Z0 * exp(i*β*z),β=2*π/λeff)’    // Example of symbolic manipulation with quotation marks.
Ans: subst(Z = Z0 * exp(i*β*z),β=2*π/λeff)       // Output is not evaluated
CAS> simplify(‘subst(Z = Z0 * exp(i*β*z)),β=2*π/λeff’)            // Entered after Select&Simplify
Ans: Z = Z0 * exp(2*i*π*z/λeff)                        // Symbolic operation done. Now ready to give numbers
CAS> simplify('[Z, Z0] := [0, 100]')  // Initialize & override HOME variables
Ans: [0, 100]
CAS> Z := 'Z0 * exp(2*i*π*z/λeff)'      // Save Z with unevaluated contents
Ans: Z0 * exp(2*i*π*z/λeff)
CAS> [λeff, v, z, f, c] := [v/f, 0.66*c, 1, 1e9, 3e8]  // Initialize the rest of the variables as usual
Ans: [v/f, 0.66*c, 1, 1e9, 3e8]
CAS> Z                                        // Let's evaluate Z to obtain the numeric result we were looking for
Ans: 95.01+31.20*i

Now I feel like stealing some chocolates from the cupboard while the HP Prime parents are away. I will try to put an innocent face when they come back and ask ‘what were you doing??’ :-)

Quote: It would be nice if HP Prime truly separate HOME and CAS variables.

I agree. Let's hope it is in the roadmap to avoid these unicorns.

Edited. This line in the code:
CAS> Z := 'Z0 * exp(2*i*π*z/λeff)' // Save Z with unevaluated contents
was originally this way, but it was too much feature abuse:
CAS> simplify('Z := Z0 * exp(2*i*π*z/λeff)') // Save Z with unevaluated contents

Ramón
Valladolid, Spain
TI-50, Casio fx-180P, HP48GX, HP50g, HP Prime G2
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: CAS: overriding HOME variables, bug or feature? (for me, a feature!) - ramon_ea1gth - 07-11-2021 10:17 PM



User(s) browsing this thread: