Open eki opened 4 years ago
This happens when the exponent is unknown. For example, (x + 1)^y
, there really isn't anyway to expand that into our existing immediate models. But, leaving this as an Expression
feels wrong... we need some way to represent this form as an immediate. We should also attempt to make this same immediate representation work with large exponents.
The bottom line is, we need to be able to reduce things like: (x + 1)^(2y) / (x + 1)^y
=> (x + 1)^y
and (x + 1)^9999 / (x + 1)^9998
=> x + 1
.
One solution to remaining immediate would be to put the sum in a term. We don't normally so this, of course, because we'd normally like to expand sums.
It looks like Term.new can already accept a sum as one of the unknowns. It also looks like term behaves correctly with a sum as one of the factors. We would likely need rules for when to re-expand into a sum, though.
Sum#**
can return anExpression
. Is it okay to incorporate a lazy model on the immediate side of things?https://github.com/eki/mathcraft/blob/master/lib/mathcraft/sum.rb#L106
Considerations:
(x + 1)^1000
we probably don't want to expand the entire thing. Not expanding would seem to indicate that we should use a lazy representation in some cases. But, will anything break? Add tests!