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 \quad &\Rightarrow \quad 15x \\
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)

For addition:
\begin{align}
4+(3-4) \quad &\Rightarrow \quad 4+3-4 \\
3-(-4+x) \quad &\Rightarrow \quad 3+4-x \\
\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}

Collapse powers of i (CollapsePowerOfIRule)

\begin{align}
i^2 \quad &\Rightarrow \quad -1 \\
i^8 \quad &\Rightarrow \quad 1 \\
i^{-7} \quad &\Rightarrow \quad i
\end{align}

Evaluate expressions involving only numbers (PropagateConstantsRule)

\begin{align}
12.0+2.0^{3.0} \cdot 3 \quad &\Rightarrow \quad 36
\end{align}

Evaluate expressions having zero as a factor (RemoveZeroMultRule)

\begin{align}
0 \cdot 3 \quad &\Rightarrow \quad 0 \\
0 \cdot x \quad &\Rightarrow \quad 0
\end{align}

Evaluate powers with zero as exponent (RemoveZeroExponentRule)

\begin{align}
2x^{0} \quad &\Rightarrow \quad 2 \cdot 1
\end{align}

Collapse equal children belonging to addition operations (SummarizeEqualAddChildrenRule)

\begin{align}
y+2x + z - x \quad &\Rightarrow \quad y+x+z
\end{align}

Collapse equal children belonging to multiplication operations (SummarizeEqualMultChildrenRule)

\begin{align}
x \cdot y \cdot x \quad &\Rightarrow \quad x^2 \cdot y\\
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}
x \cdot 1 \quad &\Rightarrow \quad x \\
x \cdot -1 \quad &\Rightarrow \quad -x \\
x + 0 \quad &\Rightarrow \quad x
\end{align}

Collapse powers (CollapsePowerRule)

Implements the following two rules:
\begin{align}
(a^b)^c \quad &\Rightarrow \quad a^{bc} \\
e^x \quad &\Rightarrow \quad \exp(x)
\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}
x^{\frac{3}{2}} \quad &\Rightarrow \quad \sqrt{x^3}
\end{align}

Simplify constants of single nodes (NormalizeConstantRule)

Sets exponent to $1$ and factor to $+/- 1$ and calculates its base.
\begin{align}
(-2)^3 \quad &\Rightarrow \quad -8
\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}
\cos(\arccos(x)) \quad &\Rightarrow \quad x\\
\ln(\exp(x)) \quad &\Rightarrow \quad x
\end{align}

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

This is a special case of the above rule.
\begin{align}
\sqrt{x^2} \quad &\Rightarrow \quad |x|
\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}
\sin(-x) \quad &\Rightarrow \quad -\sin(x)\\ |-x| \quad &\Rightarrow \quad |x|
\end{align}

Distributive law (NormalizeAddRule)

\begin{align}
3 \cdot (-x + 4) \quad &\Rightarrow \quad -3x + 12
\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}

Expand data in single node (ExpandInternalDataRule)

\begin{align}
-x^6 \quad &\Rightarrow \quad -1 \cdot x^6
\end{align}

Expands a power of products (ExpandPowerRule)

\begin{align}
(2 \cdot x)^4 \quad &\Rightarrow \quad 2^4 \cdot x^4
\end{align}

Expands a power of sums (ExpandPowerOfSumRule)

\begin{align}
(2+x)^4 \quad &\Rightarrow \quad (2+x) \cdot (2+x) \cdot (2+x) \cdot (2+x)
\end{align}

operation_tree.png (27.4 KB) Robert van Kints, 12/08/2014 04:03 PM

Operation_tree
Add picture from clipboard (Maximum size: 500 MB)