REDUCE

8.2 The Expression Workspace

Several mechanisms are available for saving and retrieving previously evaluated expressions. The simplest of these refers to the last algebraic expression simplified. When an assignment of an algebraic expression is made, or an expression is evaluated at the top level, (i.e., not inside a compound statement or procedure) the results of the evaluation are automatically saved in a variable ws that we shall refer to as the workspace. (More precisely, the expression is assigned to the variable ws that is then available for further manipulation.)

Example:

If we evaluate the expression (x+y)^2 at the top level and next wish to differentiate it with respect to y, we can simply say

        df(ws,y);

to get the desired answer.

If the user wishes to assign the workspace to a variable or expression for later use, the saveasstatement can be used. It has the syntax

saveas \(\langle \)expression\(\rangle \)

For example, after the differentiation in the last example, the workspace holds the expression 2*x+2*y. If we wish to assign this to the variable z we can now say

        saveas z;

If the user wishes to save the expression in a form that allows him to use some of its variables as arbitrary parameters, the for all command can be used.

Example:

        for all x saveas h(x);

with the above expression would mean that h(z) evaluates to 2*y+2*z.

A further method for referencing more than the last expression is described in chapter 13 on interactive use of REDUCE.


Hosted by Download REDUCE Powered by MathJax