Euclindean algorithm for polynomials



Sheldon Newhouse wrote:
> Hello,
>  Is there a routine which performs the Euclidean algotithm for polynomials.
>
> I.e.,  p, q are polynomials with degree(p) = d > degree(q) =s,
> I want to obtain
>
>     p = k*q + r
>  where k, r are polynomials and degree(r) < s.
>
>   
Will divide do what you want?

divide(x^3+x^2+x+1, x^2+2) -> [x+1, -x-1]

expand([%[1]*(x^2+2)+%[2]) -> x^3+x^2+x+1

Ray