6.5 Simplification Modes

The current simplification mode controls how numbers and formulas are “normalized” when being taken from or pushed onto the stack. Some normalizations are unavoidable, such as rounding floating-point results to the current precision, and reducing fractions to simplest form. Others, such as simplifying a formula like ‘a+a’ (or ‘2+3’), are done automatically but can be turned off when necessary.

When you press a key like + when ‘2’ and ‘3’ are on the stack, Calc pops these numbers, normalizes them, creates the formula ‘2+3’, normalizes it, and pushes the result. Of course the standard rules for normalizing ‘2+3’ will produce the result ‘5’.

Simplification mode commands consist of the lower-case m prefix key followed by a shifted letter.

The m O (calc-no-simplify-mode) command turns off all optional simplifications. These would leave a formula like ‘2+3’ alone. In fact, nothing except simple numbers are ever affected by normalization in this mode. Explicit simplification commands, such as = or a s, can still be given to simplify any formulas. See Programming with Formulas, for a sample use of No-Simplification mode.

The m N (calc-num-simplify-mode) command turns off simplification of any formulas except those for which all arguments are constants. For example, ‘1+2’ is simplified to ‘3’, and ‘a+(2-2)’ is simplified to ‘a+0’ but no further, since one argument of the sum is not a constant. Unfortunately, ‘(a+2)-2’ is not simplified because the top-level ‘-’ operator’s arguments are not both constant numbers (one of them is the formula ‘a+2’). A constant is a number or other numeric object (such as a constant error form or modulo form), or a vector all of whose elements are constant.

The m I (calc-basic-simplify-mode) command does some basic simplifications for all formulas. This includes many easy and fast algebraic simplifications such as ‘a+0’ to ‘a’, and ‘a + 2 a’ to ‘3 a’, as well as evaluating functions like ‘deriv(x^2, x)’ to ‘2 x’.

The m B (calc-bin-simplify-mode) mode applies the basic simplifications to a result and then, if the result is an integer, uses the b c (calc-clip) command to clip the integer according to the current binary word size. See Binary Number Functions. Real numbers are rounded to the nearest integer and then clipped; other kinds of results (after the basic simplifications) are left alone.

The m A (calc-alg-simplify-mode) mode does standard algebraic simplifications. See Algebraic Simplifications.

The m E (calc-ext-simplify-mode) mode does “extended”, or “unsafe”, algebraic simplification. See “Unsafe” Simplifications.

The m U (calc-units-simplify-mode) mode does units simplification. See Simplification of Units. These include the algebraic simplifications, plus variable names which are identifiable as unit names (like ‘mm’ for “millimeters”) are simplified with their unit definitions in mind.

A common technique is to set the simplification mode down to the lowest amount of simplification you will allow to be applied automatically, then use manual commands like a s and c c (calc-clean) to perform higher types of simplifications on demand.