mathsteps: Better break-up fraction
I have no idea how to go about this in a general way, but currently break-up fraction isn’t very smart.
For example, (2x+3)/(2x+2)
simplifies to 2 x / (2 x + 2) + 3 / (2 x + 2)
, which is arguable more complex. Instead, it might be better if it did: (2x+3)/(2x+2)
-> (2x+2 + 1)/(2x+2)
-> (2x+2)/(2x+2) + 1/(2x+2)
-> 1 + 1/(2x+2)
.
Thoughts?
About this issue
- Original URL
- State: open
- Created 7 years ago
- Comments: 18 (12 by maintainers)
Commits related to this issue
- Issue #76 - Better break-up fraction. This is only solves the initial case posed of (2x+3)/(2x+2). The output is now (2x+2)/(2x+2) + (1)/(2x+2). — committed to eltonlaw/mathsteps by eltonlaw 7 years ago
- Issue #76 - Better break-up fraction Almost completely covers all cases of (ax^1 + b) / (cx^1 + d). The only current holes in this function are for cases where 1) Constant and polynomial term are not... — committed to eltonlaw/mathsteps by eltonlaw 7 years ago
@aliang8 Yeah right now it’s super fragile, it only works on 2 term cases of the form (ax^1 +b)/(cx^1 +d). I figured we could focus on the easier scenarios and discuss the methods before going into the more complicated stuff. With the breakUpNumerator step, for now I think I’m going to keep it, everything still fits okay, it’s not an unnecessary constraint or anything.
Oh yeah, I just made a PR, let me know what you guys think. I added some more tests and made the checks/simplifying function a bit more robust, it’s also more in tune with your specifications (I think) @evykassirer.
Hi everyone, I found a really cool approach to long polynomial division that I would like to share with the two of you. It’s super intuitive, pedagogical, just like how we would normally do long division.
The pseudocode is here: https://rosettacode.org/wiki/Polynomial_long_division#Python
Basically, it represents the polynomials as vectors such that the i^th element keeps the coefficient of x^i e.g [-42 0 -12 1] => x^3 - 12 x^2 + 0x - 42 and multiplication by a monomial is a shift of the vector’s element to the right e.g [-42 0 -12 1] * x^2 => [0 0 -42 0 -12 1] It uses a simple recursive loop to find all the coefficients of the quotient polynomial by applying the two concepts above. Highly suggest taking a look at it since it covers most if not all of the edge cases. Let me know what yall think of it 👍
agreed! that’d be sweet.
we could start with a rule that handles only this case, where the denominator can be found in the numerator
so here you’d check if an x term is in the numerator and if a constant term is in the numerator, and then split it up into 2x + 2 and the rest of the numerator.
I think we should keep the current break-up fraction functionality, but add this as a more specific check before we do the general one, so we do the better one instead if it’s possible.
How’s that sound?