# This procedure checks if the polynomial p is unimodal unimodal := proc (p) local inc, oldcoeff, i; # Test to see if the polynomial p is unimodal # Returns 1 if unimodal, 0 else inc := 1: # Signifies that it is still increasing oldcoeff := 0: for i from 0 to degree(p) do if (abs(coeff(p,t,i)) <= oldcoeff) then # We are decreasing # Not increasing any more inc := 0; # This must be the peak else # we are increasing then, problem if inc == 0 if (inc = 0) then printf ("NOT UNIMODAL(counterexample)\n"); return (0); end if; end if; oldcoeff := abs(coeff(p,t,i)); end do; printf ("UNIMODAL\n"); return (1); end proc;