I'm looking for al algorithm to try to implement simplification of a fraction of two multivariate polynomials. Here's an example of one:
$$\frac{(3xy^2+x^2y^2+7yx^2+21xy+2y^2+12x^2+14y+36x+24) }{(4xy^2+x^2y^2+6yx^2+24xy+3y^2+8x^2+18y+32x+24)}$$
This can be simplified to:
$$\frac{(xy+3x+2y+6) }{(xy+2x+3y+6)}$$
Because the shared factors of the numerator and denominator in the example are $(x+1)$ and $(y+4)$, in other words the gcd is $(xy + y + 4x + 4)$.
So the numerator and denominoator can both be divided through $(xy + y + 4x + 4)$ to get the above simplified form.
Of course I constructed this example myself by on purpose multiplying $(x+1)$, $(y+4)$ and other such factors together to create the numerator and denominator with the shared factors in there on purpose. But I'd like to find the simplification for arbitrary multivariate polynomials with an algorithm.
This is just an example, I'd also like it to support more variables, higher powers than the 2 in this example, etc..., any random polynomials you could type, if they happen to have a gcd, simplify it. Also, the coefficients can be any complex numbers, doesn't have to be restricted to integers.
But to implement this as an algorithm requires two things:
find the $\gcd$ of two multivariate polynomials
implement division (with remainder that's know to be zero, so we don't need to support getting the remainder) of the numerator, and denominator, through this gcd, to get the simplified result.
When I search for how to do the $\gcd$ and especially division of multivariate polynomials, the answer points to using groebner basis, but I've not found anything that says how to actually do the division of two multivariate polynomials with groebner basis.
If I try it in wolfram alpha, and if I type in there the two involved polynomials of the example:
groebnerbasis[{3*x*y^2+x^2*y^2+7*y*x^2+21*x*y+2*y^2+12*x^2+14*y+36*x+24,4*x*y^2+x^2*y^2+6*y*x^2+24*x*y+3*y^2+8*x^2+18*y+32*x+24},{x,y}]
It outputs:
{x y^3 + 9 x y^2 + 26 x y + 24 x + y^3 + 9 y^2 + 26 y + 24, x^2 y + 4 x^2 - x y^2 - 3 x y + 4 x - y^2 - 4 y}
So it outputs two polynomials:
$xy^3 + 9xy^2 + 26xy + 24x + y^3 + 9y^2 + 26y + 24$
$x^2y + 4x^2 - xy^2 - 3xy + 4x - y^2 - 4y$
And neither of these two polynomials looks either like the gcd $(xy + y + 4x + 4)$, nor like the simplified result of $(xy+3x+2y+6) / (xy+2x+3y+6)$.
So how can I use this groebner basis for the desired purpose? Does this bring one any closer to the desired solution of simplifying the two input polynomials? Is there an algorithm that operates on this groebner basis result?
What's the correct algorithm to look for (with or without groebner basis) to do the gcd, and divisions with known remainder zero, to do what I want?
Also, separate from that, I have a few questions about groebner basis too:
most examples involving polynomial division and groebner basis (including other questions here on stackoverflow, and wikipedia), is dividing a polynomial through multiple polynomials at the same time. Why this focus on dividing through multiple polynomials? That seems to be for a different application than my simplification example above, why is dividing though multiple polynomials so common and dividing through a single one not findable in any examples?
the term "ideal" and "generator" come up all the time in information about the groebner basis. In my example above with the two big polynomials getting divided and simplified, what are the ideal and generator there exactly, or is this not relevant here?
I saw some explanation on groebner basis that said there'd always be one polynomial in them with only one variable. Is that correct? In the wolfram alpha above, both have x and y in it. What could have gone wrong here?
Thanks!