eki / mathcraft

A mathtastic computer algebra system.
0 stars 0 forks source link

Sum#** can produce an Expression #2

Open eki opened 4 years ago

eki commented 4 years ago

Sum#** can return an Expression. 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:

eki commented 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.

eki commented 4 years ago

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.