)set messages interponly off Sturm(p:POLY(FRAC(INT))):List(POLY(FRAC(INT)))== local V,x,S if p=0 then error("The polynomial must not be 0") else if totalDegree(p)=0 then [p] else V:=variables(p) if #(V)>1 then error("The polynomial must be univariate") x:=V.1 q:=p/gcd(p,D(p,x)) q1:???:=q q2:???:=D(q,x) S:=[q1,q2] repeat ??? ... ??? S --Input: -- L.....a list of rationals. --Output: -- The number of sign variations in L. variation(L:List(FRAC(INT))):NNI== local v if L=[] then 0 else v:=0 p:=L.1 for n in L repeat if n~=0 then if p~=0 and sign(p)~=sign(n) then v:=v+1 p:=n v --Input: -- p.......a polynomial with rational coefficients. -- a,b.....rational numbers. --Output: -- The number of real roots of p in [a,b). --Checks: -- If p is not univariate or a>b then an error is signalled by the code. rootsCount(p:POLY(FRAC(INT)),a:FRAC(INT),b:FRAC(INT)):Union(NNI,String)== local V,x,S if a>b then error("The first endpoint of the interval cannot be strictly larger than the second.") V:=variables(p) if #(V)>1 then error("The polynomial must be univariate") else if p=0 then "infinite" else if #(V)=1 then x:=V.1 S:=Sturm(p) variation(eval(S,x=a))-variation(eval(S,x=b)) -------------------------------------------------------------------- -- Put the rest of your code below here. --------------------------------------------------------------------