Difference between revisions of "Reduction rules for MathObject Formulas"
(Fix rules for x^1 and x^0) 
m (Typo: turn of > turn off) 

Line 1:  Line 1:  
When substituting randomly chosen values into an expression, it is possible to obtain situations like <code>1 x^2 + 3 x + 0</code>, 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. 
When substituting randomly chosen values into an expression, it is possible to obtain situations like <code>1 x^2 + 3 x + 0</code>, 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 
+  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 [[Introduction to Contexts#Reduction RulesReduction 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: 
You can disable one or more reduction rules using a command like the following examples: 
Revision as of 00:38, 29 January 2018
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. 
0x

x

Subtracting from zero gives negative. 
x0

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

0

Anything to the first power is itself. 
x^0

1

Anything to the zero power is one. 
x^(1)

1/x

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. 
abi

(a+bi)

Factor out negatives from complex constants. 
(x)+y

yx

Reverse order to remove initial negative. 
x+(y)

xy

Turn plusanegative into minus. 
(x)y

(x+y)

Turn negativeminuspositive to negation of addition. 
x(y)

x+y

Turn minusanegative 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. 