Polynomial Long Division with Variable Coefficients
I want to divide the following polynomial (in terms of t) with coefficients in terms of λ.
(λ6−5λ4+6λ2−1)t5+(λ5−4λ3+3λ2)t6
by λt2−λ2t+λ
The resulting quotient will include a fractional component (the numerator's degree will be strictly less than the denominator's degree).
This is what a quotient and remainder, added together, might look like:
t(2λ8−9λ6+2λ5+6λ4−4λ2λ)+t3(2λ6−9λ4+3λ3+6λ2−1λ)+t(λ4−2λ)+(λ3−4λ2)λt2−λ2t+λ
I have tried the following thus far Any suggestions? The code below "does not work", because it outputs a quotient whose degree is greater than the degree of the dividend. Here y takes the place of λ and x takes the place of t.
The quotient is:
-2*x^8 - x^4*y^4 + 2.0*x^6 - 3.0*x^5 - 1.0*x^4 - (2*x^5 + x^3)*y^3 + (-2*x^6 + 2.0*x^4 - x^2)*y^2 + (-2*x^7 +
4.0*x^5 + 1.0*x^3 - x)*y - 1
The remainder is:
-x^5 + (2*x^10 + 3.0*x^7 - 1.0*x^6 + 3.0*x^5 + 1.0*x^4 + x^2 + 1)*y
The code:
from sympy import Function, rsolve_poly, Symbol, rsolve, rsolve_hyper, oo
from sympy.abc import n
x = var('x')
y = var('y')
P.<x,y> = PolynomialRing(CC)
f = (y**5 - 4*y**3 + 3*y**2)*x**6 + (y**6 - 5*y**4 + 6*y**2 - 1)*x**5
g = y*x**2 - y**2*x + y
def division(dividend, divisor):
return (dividend._maxima_().divide(divisor).sage())
a = division(f,g)
print("The quotient is: \n")
print(a[0])
print("The remainder is: \n")
print(a[1])