| 1 |
-- Seperates the various binary operations into their own files for readability |
| 2 |
|
| 3 |
--- Automatic simplification of difference expressions. |
| 4 |
--- @return BinaryOperation |
| 5 |
function BinaryOperation:simplifydifference() |
| 6 |
local term1 = self.expressions[1] |
| 7 |
local term2 = self.expressions[2] |
| 8 |
|
| 9 |
if not term2 then |
| 10 |
return BinaryOperation(BinaryOperation.MUL, {Integer(-1), term1}):autosimplify() |
| 11 |
end |
| 12 |
|
| 13 |
return BinaryOperation(BinaryOperation.ADD, {term1, BinaryOperation(BinaryOperation.MUL, {Integer(-1), term2}):autosimplify()}):autosimplify() |
| 14 |
end |