Author > Variable Value command
Use the Author > Variable Value command or press Ctrl+Alt+V to declare a variable and optionally assign it a value or clear an existing value. This command displays a dialog box with fields for entering a variable name and its value. After entering a name in the Variable Name field and an expression in the Variable Value field, click on OK to make the name an assigned variable having the unsimplified expression as its value. Leave the Variable Value field blank to make the name an unassigned variable.
Click on the pull-down menu button at the right end of the Variable Name field to display an alphabetical list of all the currently assigned variable names. If you click on one of the variable names, the current value of the variable is displayed in the Variable Value field.
While entering an expression in the Variable Value field, you can use all the line editing features normally provided by Derive (see Entering Mathematical ExpressionsEntering_Mathematical_Expressions). In particular, you can use the Greek and math symbol toolbars, and the F3 and F4 function keys to insert the highlighted expressions and subexpressions in the Variable Value field.
Declared variable names can be multi-character and of mixed case, no matter what the current Input Settings are (see the Options > Mode Settings > Input command1MJ.MVB).
The Author > Variable Value command over-rides any previous assignment or domain declarations of the variable name. Also it can turn the name of a user-defined function into a variable name. However, it cannot turn the name of one of the Built-in Functions and ConstantsBuilt_in_Functions_and_Constants into a variable name.
Use the File > Close command3LICX6 to clear all variable declarations and assignments, and close the active worksheet.
Instead of a Author > Variable Value command, you can use the Author > Expression commandFJQ5GW to declare a variable and optionally assign it a value or clear an existing value. On the expression entry line, enter: the variable name; the := assignment operator; and the variable's value, if it is to be an assigned variable. For example, entering
AreaCircle := pi·r^2
assigns the variable AreaCircle the value π·r². If an assignment is simplified, the assignment is returned with the right side simplified. (Note that in previous versions of Derive, just the simplified right side is returned.)
When an expression containing an assigned variable is simplified, all occurrences of the variable are replaced by its value. For example, if AreaCircle is assigned as above,
2·AreaCircle + 2·pi·h·r
simplifies to
2
2·π·h·r + 2·π·r
This expression gives the surface area of a cylinder of height h and radius r. In turn, it can be assigned as the value of the variable AreaCylinder by the assignment
AreaCylinder := 2·AreaCircle + 2·pi·h·r
Entering
AreaCircle :=
clears any value previously assigned to AreaCircle and makes it an unassigned variable.
When an assignment is entered without simplifying it, the unsimplified right operand of the := operator is assigned to the left operand. However, when an assignment is simplified, the right operand is first simplified and then the result assigned to the left operand. (Note that in previous versions of Derive, the right operand was not simplified before being assigned to the left operand.) For example, if you enter the assignment
Digit := RANDOM(10)
the variable Digit is assigned the value RANDOM(10). Thereafter, Digit will return a new random digit each time it is simplified. However, if you simplify the above assignment, RANDOM(10) is simplified and Digit is assigned the resulting digit. Thereafter, Digit will return this same digit each time it is simplified.
No matter whether an assignment is simplified or not, the left operand of the := operator is not simplified. Thus the left operand of the := operator must be the actual variable to be assigned a value. Use the ASSIGN function if you need to simplify an expression to determine the variable to be assigned a value (see Procedural ProgrammingProcedural_Programming).
#n where n is an expression label number can be used like a variable name on the expression entry line or when Derive commands prompt for an expression. Also previous expressions and subexpressions can be referenced by highlighting. For these reasons variable assignments are often unnecessary when using Derive.
On the other hand, variable assignments are convenient to reference an expression after it scrolls off the screen or to assign a descriptive name to an expression that is of special significance.
Variable assignments that you forget about can lead to surprising or incorrect results. Thus using multi-character names for assigned variables is recommended since it reduces the chance of name conflicts with unassigned variables.
Derive repeatedly applies variable assignments until a constant or unassigned variable is reached. For example, if r is assigned the value s², then s is assigned the value 5, then r will simplify to 25 rather than s².
The following utility files provide good examples of the use of assigned variables:
• English Units ConversionA31Q0Q
• Metric Units ConversionD6IIVI
• Physical Constants1TR3BWS
Other Author commandsAuthor_commands
Created with the Personal Edition of HelpNDoc: Write eBooks for the Kindle