Variable Multiply

The Variable Multiplication rule restates x^b * x^d as x^(b + d) which has the effect of isolating the exponents attached to the variables, so they can be combined.

Note

This rule can only be applied when the nodes have matching variable bases. This means that x * y cannot be combined, but x * x can be.

Transformations

Both implicit and explicit variable powers are recognized in this transformation.

Help Wanted

The current variable multiply rule leaves out a case where there is a power raised to another power, they can be combined by multiplying the exponents together.

For example: x^(2^2) = x^4

If you would like to help out with by updating this rule open an issue here

Explicit powers

In the simplest case both variables have explicit exponents.

Examples: x^b * x^d = x^(b+d)

  • 42x^2 * x^3 becomes 42x^(2 + 3)
  • x^1 * x^7 becomes x^(1 + 8)
            *
           / \
          /   \          ^
         /     \    =   / \
        ^       ^      x   +
       / \     / \        / \
      x   b   x   d      b   d

Implicit powers

When not explicitly stated, a variable has an implicit power of being raised to the 1, and this form is identified.

Examples: x * x^d = x^(1 + d)

  • 42x * x^3 becomes 42x^(1 + 3)
  • x * x becomes x^(1 + 1)
            *
           / \
          /   \          ^
         /     \    =   / \
        x       ^      x   +
               / \        / \
              x   d      1   d

Examples

Info

All the examples shown below are drawn from the mathy test suite that verifies the expected input/output combinations for rule transformations.

Input Output Valid
x * x x^(1 + 1)
(36c^6 * u^3) * 7u^3 36c^6 * 7u^(3 + 3)
4x * 2p^2 * 2p^3 * 12x^2 4x * 2 * 2 * p^(2 + 3) * 12x^2
324u * u 324u^(1 + 1)
17k * 23k 17 * 23k^(1 + 1)
p * p * 12 p^(1 + 1) * 12
4x * p^2 * p^3 * 12x^2 4x * p^(2 + 3) * 12x^2
4 * p * p^3 * 12x^2 4 * p^(1 + 3) * 12x^2
4 * p * p * 12x^2 4 * p^(1 + 1) * 12x^2
4 * p * p * 12 4 * p^(1 + 1) * 12
x * x^3 x^(1 + 3)
y^11 * y y^(11 + 1)
x^2 * x^7 x^(2 + 7)
(8y * 4y) 8 * 4y^(1 + 1)
x * z --- ---
x * y^2 --- ---
2x * 1y^3 --- ---