| ![]() |
|||||||||||||||||||||||||||||||||||||||||||||||||
|
Controlling EvaluationOne of the characteristics of Mathematica and other computer algebra systems that educators sometimes find frustrating is the fact that these systems generate results without showing intermediate steps. Leibniz addresses this problem by giving the user very fine control over just what part of an expression gets modified and how drastically the expression gets modified in a single step. By selecting only a portion of an expression to work on, or by dragging and dropping within a larger expression, the user gets to focus the calculation. Leibniz supports this focusing behavior by sending just the relevant part of an expression to the kernel. When the result comes back, its gets swapped into place in the larger expression it came from, and that expression is then formatted and displayed. Even with this focusing behavior, special care is needed to avoid unwanted evaluation. Consider our seemingly innocent example of a rule for moving a term from one side of an equation to the other. This seems straightforward enough, but what happens when, say, This solves the problem of the unwanted evaluation, but then causes the expression to fail to evaluate correctly when the
user wants it to. For example, if The lack of control offered by the standard evaluation mechanisms and the The first element of this strategy is to force every expression that the system works with to be a purely symbolic expression.
This is done by replacing all conventional mathematical functions such as With a little bit of care, we can do pattern matching with these new expressions just as easily as we could with more conventional
expressions. For example, by giving the function Because none of these new functions come with evaluation rules, everything gets held by default. To release the implicit hold,
Thus, the This solves both of the problems described earlier. If The second evaluation mechanism used is a complete evaluation mechanism, which converts every function in an expression from
its LZ form to its conventional form. This mechanism is implemented via a function called The This hold and release mechanism provides other benefits, as well. Because we get the incorrect result If we remember to use Copyright © 2002 Wolfram Media, Inc. All rights reserved. |