Commit fa97ae38 authored by Taddeüs Kroes's avatar Taddeüs Kroes

Made combine_groups a high-priority rule.

parent c3a2ee8a
......@@ -48,6 +48,10 @@ HIGH = [
add_numerics,
multiply_numerics,
negated_factor,
# Combine occurences before doing other stuff to prevent duplicate
# calculations
combine_groups,
]
......@@ -74,7 +78,7 @@ RELATIVE = [
# Combine groups before expanding them
# Expand 'single' before 'double' to avoid unnessecary complexity
(combine_groups, expand_single, expand_double),
(expand_single, expand_double),
(factor_out_exponent_important, raise_numerics),
......
......@@ -46,22 +46,22 @@ class TestLeidenOefenopgave(TestCase):
'(xx + x + 1x + 1 * 1)(x + 1)',
'(xx + x + x + 1 * 1)(x + 1)',
'(xx + x + x + 1)(x + 1)',
'(x ^ (1 + 1) + x + x + 1)(x + 1)',
'(x ^ 2 + x + x + 1)(x + 1)',
'(x ^ 2 + (1 + 1)x + 1)(x + 1)',
'(xx + (1 + 1)x + 1)(x + 1)',
'(xx + 2x + 1)(x + 1)',
'(x ^ (1 + 1) + 2x + 1)(x + 1)',
'(x ^ 2 + 2x + 1)(x + 1)',
'x ^ 2 * x + x ^ 2 * 1 + 2xx + 2x * 1 + 1x + 1 * 1',
'x ^ 2 * x + x ^ 2 + 2xx + 2x * 1 + 1x + 1 * 1',
'x ^ 2 * x + x ^ 2 + 2xx + 2x + 1x + 1 * 1',
'x ^ 2 * x + x ^ 2 + 2xx + 2x + x + 1 * 1',
'x ^ 2 * x + x ^ 2 + 2xx + 2x + x + 1',
'x ^ (2 + 1) + x ^ 2 + 2xx + 2x + x + 1',
'x ^ 3 + x ^ 2 + 2xx + 2x + x + 1',
'x ^ 3 + x ^ 2 + 2x ^ (1 + 1) + 2x + x + 1',
'x ^ 3 + x ^ 2 + 2x ^ 2 + 2x + x + 1',
'x ^ 3 + (1 + 2)x ^ 2 + 2x + x + 1',
'x ^ 3 + 3x ^ 2 + 2x + x + 1',
'x ^ 3 + 3x ^ 2 + (2 + 1)x + 1',
'x ^ 2 * x + x ^ 2 + 2xx + (2 + 1)x + 1',
'x ^ 2 * x + x ^ 2 + 2xx + 3x + 1',
'x ^ (2 + 1) + x ^ 2 + 2xx + 3x + 1',
'x ^ 3 + x ^ 2 + 2xx + 3x + 1',
'x ^ 3 + x ^ 2 + 2x ^ (1 + 1) + 3x + 1',
'x ^ 3 + x ^ 2 + 2x ^ 2 + 3x + 1',
'x ^ 3 + (1 + 2)x ^ 2 + 3x + 1',
'x ^ 3 + 3x ^ 2 + 3x + 1',
])
......@@ -74,9 +74,9 @@ class TestLeidenOefenopgave(TestCase):
'xx + x + 1x + 1 * 1',
'xx + x + x + 1 * 1',
'xx + x + x + 1',
'x ^ (1 + 1) + x + x + 1',
'x ^ 2 + x + x + 1',
'x ^ 2 + (1 + 1)x + 1',
'xx + (1 + 1)x + 1',
'xx + 2x + 1',
'x ^ (1 + 1) + 2x + 1',
'x ^ 2 + 2x + 1',
])
......@@ -92,10 +92,10 @@ class TestLeidenOefenopgave(TestCase):
'xx - x + (-1)x + 1',
'xx - x - 1x + 1',
'xx - x - x + 1',
'x ^ (1 + 1) - x - x + 1',
'x ^ 2 - x - x + 1',
'x ^ 2 + (1 + 1) * -x + 1',
'x ^ 2 + 2 * -x + 1',
'xx + (1 + 1) * -x + 1',
'xx + 2 * -x + 1',
'xx - 2x + 1',
'x ^ (1 + 1) - 2x + 1',
'x ^ 2 - 2x + 1',
])
......@@ -153,11 +153,11 @@ class TestLeidenOefenopgave(TestCase):
'-(20x + (-16)xx + 25 + (-20)x)',
'-(20x - 16xx + 25 + (-20)x)',
'-(20x - 16xx + 25 - 20x)',
'-(20x - 16x ^ (1 + 1) + 25 - 20x)',
'-(20x - 16x ^ 2 + 25 - 20x)',
'-((1 - 1)20x - 16x ^ 2 + 25)',
'-(0 * 20x - 16x ^ 2 + 25)',
'-(0 - 16x ^ 2 + 25)',
'-((1 - 1)20x - 16xx + 25)',
'-(0 * 20x - 16xx + 25)',
'-(0 - 16xx + 25)',
'-(-16xx + 25)',
'-(-16x ^ (1 + 1) + 25)',
'-(-16x ^ 2 + 25)',
'--16x ^ 2 - 25',
'16x ^ 2 - 25',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment