Question: i want to just modify my code so that it performs multivariate polynomial division, the main problem is in ig in while loop, its infinite:

i want to just modify my code so that it performs multivariate polynomial division, the main problem is in ig in while loop, its infinite: from sympy import symbols, degree, LC, expand
def fun(f, g, var = symbols('x y'), Order='lex'):
x, y = var
r = f
q =0
while degree(r, gen=x)>= degree(g, gen=x) and degree(r, gen=y)>= degree(g, gen=y):
LT_r_xy = LC(r, x, y)
LT_g_xy = LC(g, x, y)
TempQ = LT_r_xy / LT_g_xy * x**(degree(r, gen=x)- degree(g, gen=x))* y**(degree(r, gen=y)- degree(g, gen=y))
q += TempQ
r =(r - TempQ * g).expand()
return q, r
x, y = symbols('x y')
f = x**2+ y**2+3*x*y -1
g = x + y
quotient, remainder = fun(f, g,(x, y))
print(f"Quotient: {quotient}")
print(f"Remainder: {remainder}")

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!