let sturm_chain =
let rec f = function
(p1, p2) -> (* p2 is assumed to be the derivative of p1 *)
if degree (p2) = 0
then cons_list (p1, cons_list (p2, empty_list ()))
else
let
p = mod_poly (p1, p2)
in
let
q = rat_times_poly (cons_rat ("-1", "1"), p)
in
cons_list (p1, f (p2, q))
in
function p -> f (p, deriv_poly (p))