my code can only do for one variable,

how to make divisible checking for multivariable cases with the ordering such as plex

IsDivisible(LP(h, t), LP(g[i], t), x)

it is not only x when multivariable

f:=LP(y^2*x,plex(x, y))[2];

g:=LP(y*x-y,plex(x, y))[2];

Remainder(f, g, gcd(f,g));

degree(Remainder(f, g, x),x);

degree(g, x);

remainder has error expect its 3rd argument x, to be of type or but received y*x

how to do if have ordering

do it need to check whether both f and g have variable x using indets and then apply remainder?

do it need to check each variable starting from the first variable in the ordering?

how about if f has variable x but g do not have variable x, or f do not have variable x and g have variable x

if so, i try to replace below code in the bottom code, it has error

Error, (in FindDivisble) cannot determine if this expression is true or false: 0 < Search(x, {x, y})

FindDivisble := proc(g, h, t)

with(ListTools):

result := 0;

for i from 1 to nops(g) do

mainvariable := 0;

for j from 1 to nops(t) do

mainvariable := op(j, t);

if mainvariable <> 0 then

if Search(mainvariable, indets(h)) > 0 and Search(mainvariable, indets(g[i])) > 0 then

if IsDivisible(LP(h,t), LP(g[i],t), mainvariable) = 0 then

return i;

else

result := 0;

end if:

end if:

end if:

od:

od:

return result;

end proc:

with(Groebner):

LP := proc(f, t)

return LeadingTerm(f, t)/LeadingCoefficient(f, t);

end proc:

IsDivisible := proc(f, g, x)

with(Algebraic):

if Remainder(f, g, x) = 0 or degree(Remainder(f, g, x),x) < degree(g, x) then

return 0;

else

return 1;

end if:

end proc:

FindDivisble := proc(g, h, t)

result := 0;

for i from 1 to nops(g) do

if IsDivisible(LP(h, t), LP(g[i], t), x) = 0 then

return i;

else

result := 0;

end if:

od:

return result;

end proc:

MD := proc(f, g, t)

r := 0;

u := Matrix(nops(g), 1);

for j from 1 to nops(g) do

u[j] := 0;

od:

h := f;

while h <> 0 do

i := FindDivisble(g, h, t);

if i > 0 then

u[i] := u[i] + LeadingTerm(h, t)/LeadingTerm(f[i], t);

h := h - LeadingTerm(h, t)/LeadingTerm(f[i], t)*f[i];

else

r := r + LeadingTerm(h, t);

h := h - LeadingTerm(h, t);

end if:

od:

end proc:

f:=y^2*x;

f1 := y*x-y;

f2 := y^2-x;

MD(f,[f1,f2],plex(x, y));