| 1 |
-- Seperates the various binary operations into their own files for readability |
| 2 |
|
| 3 |
-- Automatic simplification of quotient expressions. |
| 4 |
--- @return BinaryOperation |
| 5 |
function BinaryOperation:simplifyquotient() |
| 6 |
local numerator = self.expressions[1] |
| 7 |
local denominator = self.expressions[2] |
| 8 |
|
| 9 |
if numerator:isconstant() and denominator:isconstant() then |
| 10 |
return self:evaluate() |
| 11 |
end |
| 12 |
|
| 13 |
return BinaryOperation(BinaryOperation.MUL, {numerator, BinaryOperation(BinaryOperation.POW, {denominator, Integer(-1)}):autosimplify()}):autosimplify() |
| 14 |
end |