4. Using Variables

PEMDAS Widget has support for variables. You can assign the result of any equation to a variable.

Defining a Variable

You can set a variable using the equals operator; anything to the left of the equals is the variable, to the right of the variable is what the variable is assigned. So typing:

myVariable=3+5

myVariable = 8

will set the variable *myVariable* to 8. You can then use *myVariable* in any equation as follows:

myVariable*2

= 16

All variables you define will show up in the "Defined" section of the variable list in the equation history view.

Auto-Defined Variables

If you calculate an equation, and you do not assign the result to a variable, PEMDAS will automatically assign the result to a variable.

All the auto-defined variables are named ans1, ans2, ans3, etc., and will show up in the variable list located in the History view. Note that If assign a variable "ans3" to a number before PEMDAS is at "ans3", PEMDAS will skip over it and go to the next available variable name in the auto-cache format.

The "ans" Variable

The "ans" variable contains the result of the most recent calculation. For example, if you calculate:

3+2

= 5

PEMDAS Widget will automatically assign the result of 5 to an auto-cached variable (in this case, assume it's 'ans1'). In addition, the result will be assigned to the 'ans' variable, so the next equation you calculate, typing something like ans*2 is exactly equivalent to typing ans1*2.

This feature will also work when assigning a variable. So if you calculated:

myVariable=7*5

= 35

Now typing ans*3 would be equivalent to typing myVariable*3.

Variable Names

Variable names are case sensitive, must be alphanumeric (A-Z, a-z, 0-9), and cannot start with numbers.

Locked Variables

Some variables, like 'ans' and 'pi', are locked, so you can't assign them anything. All function names (sin, exp, etc.) are also locked.

Variable Quick Look

To use Variable Quick Look, which will enable you to see the value of a variable in the current equation simply hold the shift key while moving your mouse over a variable in the equation.

Previous: Supported Functions | Index | Next: Equation History View |