# Normalize and expand rules¶

This section will cover the rules that are applied when normalizing and/or expanding functions. But before we start on that, take a look at the example below which explains shortly how functions are handled internally within MUMIE.

Example:
Take the following function: $x^4 \cdot (3 + 2)$. To input the function into MUMIE, you would type the following: x^4*(3+2), which in turn could be graphically displayed as the image below.

MUMIE uses the following terminoligy regarding the tree you see above.
• node: referring to a box in the tree
• operation: every node, together with its children, can be referred to as an operation. The example above consists of the following operations, Multiplication Operation (or simply MultiplicationOp), PowerOp, AddOp, VariableOp and NumberOp. Operations can be combined together to make more complex operations. The formula used above can therefor also be referred to as an operation.
Every node has the following properties:
• factor
• exponent
and based on the type, possibly a:
• base (if it is a NumberOp)
• identifier (if it is a VariableOp)

Keeping this in our mind, we can take a look at the rules being applied when normalizing and/or expanding functions. When normalizing/expanding, all rules will be applied until a stable state of the function has been reached, resulting in a normalized/expanded function. The rules for normalization and expanding are shown below (showing the Class name of the Java-code in brackets), along with several examples for each rule.

## Rules for normalizing functions¶

### Collapse factors of a variable (NormalizeMultRule)¶

\begin{align}
3 \cdot 5 \cdot x + 2 \cdot 4 \cdot y + 2 \cdot 3 \quad &\Rightarrow \quad 15x+8y+2 \cdot 3
\end{align}

### Collapse multiplications and additions (CollapseEqualOpsRule)¶

\begin{align}
\end{align}

For multiplication:
\begin{align}
3 \cdot (4 \cdot 9 \cdot x) \quad & \Rightarrow \quad 3 \cdot 4 \cdot 9 \cdot x \\
\frac{3}{\frac{1}{4} \cdot x} \quad & \Rightarrow \quad \frac{3 \cdot 4}{x \cdot 1}
\end{align}

\begin{align}
\end{align}

\begin{align}
\end{align}

\begin{align}
\end{align}

\begin{align}
\end{align}

\begin{align}
\end{align}

### Collapse equal children belonging to multiplication operations (SummarizeEqualMultChildrenRule)¶

\begin{align}
y \cdot x^2 \cdot z \cdot x^{-1} \quad &\Rightarrow \quad y \cdot x \cdot z
\end{align}

### Remove neutral elements (RemoveNeutralElementRule)¶

Only handles the following three cases
\begin{align}
\end{align}

### Collapse powers (CollapsePowerRule)¶

Implements the following two rules:
\begin{align}
\end{align}

### Collapse powers when rational (CollapseRationalPowerRule)¶

If the node is a PowerOp with a rational exponent and the denominator of the exponent is n != 1. An n-th root node will be added as parent and the child will get the numerator as exponent.

\begin{align}
\end{align}

### Simplify constants of single nodes (NormalizeConstantRule)¶

Sets exponent to $1$ and factor to $+/- 1$ and calculates its base.
\begin{align}
\end{align}

### Collapse function nodes that have their inverse function as child (CollapseInverseFunctionRule)¶

This rule only works on functions that have an inverse function defined.
\begin{align}
\end{align}

### Collapse function nodes for powers and n-roots (CollapseNrtRule)¶

This is a special case of the above rule.
\begin{align}
\end{align}

### Symmetry of elementary functions (HandleFunctionSymmetryRule)¶

Currently only applies to the following functions: abs, acos, asin, atan, cos, cosh, n-root (for uneven n), sinh, sin and tan. The rule is dependent on whether the function is symmetric or antisymmetric.
\begin{align}
\end{align}

\begin{align}
\end{align}

## Rules for expanding functions¶

### Distributive law (ExpandProductRule)¶

\begin{align}
4 \cdot (-b-3) \quad &\Rightarrow \quad 4 \cdot (-b) + 4 \cdot (-3)
\end{align}

\begin{align}
\end{align}

\begin{align}