I am new to Maple and trying to implement the gcd of 2 polynomials using euclide's algorithm.
I was quite sure of my code, but i am getting weird fractional results
with(Algebraic);
euclide:=proc(a, b)
local r0, r1, tmp, q;
r0 := a;
r1 := b;
while (degree(r0) > degree(r1)) and (r1 <> 0) do
q := Quotient(r0, r1, x);
tmp := r0 - q * r1;
r0 := r1;
r1 := tmp;
r0 := expand(r0);
r1 := expand(r1);
od;
return expand(r0);
end;
When running my algorithm on random polynomials, The result I get is a very weird fractional result, while the gcd function in Maple gives output 1. I don't understand the bug in my program.