# Reduction rules for MathObject Formulas

When substituting randomly chosen values into an expression, it is possible to obtain situations like `1 x^2 + -3 x + 0`, which do not look good when displayed as part of the text shown to a student. To help remedy this situation, the MathObjects library can reduce Formula objects according to a set of reduction rules that try to eliminate such visual problems. The main reduction rules are shown below.

Sometimes these rules don't improve the look of your formulas, however. In particular, many are designed to try to factor out negatives so that they can be canceled, but this does not always lead to better looking equations when the negatives don't cancel. For this reason, you can turn off individual reduction rules so that they will be skipped. See the Reduction Rules section of the Introduction to Contexts for details on how to control the reduction rules.

You can disable one or more reduction rules using a command like the following examples:

```   Context()->noreduce('(-x)-y');
Context()->noreduce('(-x)-y','(-x)+y');
```

It is possible for MathObject extensions to add more reduction rules for the MathObjects they define. See the documentation for the extensions you are using to see if that is the case.

### The Reduction Rules and their Actions

Rule Reduction Description
`0+x` `x` Anything plus zero is itself.
`x+0` `x` Anything plus zero is itself.
`0-x` `-x` Subtracting from zero gives negative.
`x-0` `x` Anything minus zero is itself.
`0*x` `0` Zero times anything is zero (or zero vector, etc.).
`x*0` `0` Zero times anything is zero (or zero vector, etc.).
`1*x` `x` One times anything is itself.
`x*1` `x` Anything times one is itself.
`x*n` `n*x` Move constants to be in front of formulas.
`0/x` `0` Zero divided by anything is zero (since division by zero is already not allowed).
`x/1` `x` Anything over one is itself.
`x^1` `x` Anything to the first power is itself.
`x^0` `1` Anything to the zero power is one.
`x^(-a)` `1/x^a` Negative power is reciprocal.
`1^x` `1` One to any power is one.
`0.x` `0` Zero vector dot any vector is zero.
`x.0` `0` Any vector dot zero vector is zero.
`0><x` `0` Cross product with a zero vector produces a zero vector.
`x><0` `0` Cross product with a zero vector produces a zero vector.
`-n` `-(n)` Factor out negatives from real number constants.
`-a-bi` `-(a+bi)` Factor out negatives from complex constants.
`(-x)+y` `y-x` Reverse order to remove initial negative.
`x+(-y)` `x-y` Turn plus-a-negative into minus.
`(-x)-y` `-(x+y)` Turn negative-minus-positive to negation of addition.
`x-(-y)` `x+y` Turn minus-a-negative to addition.
`(-x)*y` `-(x*y)` Factor negation out of multiplication.
`x*(-y)` `-(x*y)` Factor negation out of multiplication.
`(-x)/y` `-(x/y)` Factor negation out of division.
`x/(-y)` `-(x/y)` Factor negation out of division.
`(-x).y` `-(x.y)` Factor negative out of dot product.
`x.(-y)` `-(x.y)` Factor negative out of dot product.
`(-x)><y` `-(x><y)` Factor negative out of cross product.
`x><(-y)` `-(x><y)` Factor negative out of cross product.
`-(-x)` `x` Cancel double negatives.
`+x` `x` Remove unneeded unary plus.
`-x=n` `x=-n` Multiply equality by [math]-1[/math] when equal to a constant.
`-x=-y` `x=y` Multiply equality by [math]-1[/math] when both sides are negative.
`fn*x` `x*fn` Move function calls to the right.
`V_n` [math]n[/math]-th item of `V`. Extract a coordinate from a vector or point.