- Macro-based fronted to the MathObjects system.

From WeBWorK

Jump to: navigation

NAME - Macro-based fronted to the MathObjects system.




The main way to get a MathObject Formula object (an equation that depends on one or more variables).


        Compute("formula"[, var=>value, ...]);

Compute the value of a formula and return a MathObject appropriate to its value. Set the object so that the correct answer will be shown as in the given string rather than by its usual stringification. (I.e., the stringified version of the formula when reduceConstants, reduceConstantFunctions, and showExtraParens are set to 0 is used.)

If the value is a Formula and any var=>value pairs are specified, then the formula will be evaluated using the given variable values. E.g.,

        $x = Compute("x+3",x=>2)

will produce the equivalent of $x = Real(5). In this case, the original parsed formula will be saved in the object's original_formula field, and can be obtained by


if needed later in the problem.

If the formula is contstant-valued, Compute() will return the value of the formula rather than the formula itself. Again, in this case, the original can be obtained from the original_formula property.



Set or get the current context. When a name is given, the context with that name is selected as the current context. When a context reference is provided, that context is set as the current one. In all three cases, the current context (after setting) is returned.