'**************************************************** '* ROOT TESTING PROGRAM FOR POLYNOMIALS * '* ------------------------------------------------ * '* Reference: BASIC Scientific Subroutines, Vol. II * '* By F.R. Ruckdeschel, BYTE/McGRAWW-HILL, 1981 [1].* '* * '**************************************************** defint i-n defdbl a-h,o-z cls print print " This program will help you determine" print " where to look for roots of a polynomial." print input " What is the degree of the polynomial: ", n dim A(n) print print " Input the polynomial coefficients as prompted:" print for i=0 to n print " A(";i;") = "; : input A(i) next i print print print " There are ";n;" roots." print 'Find the maximum value of root aa=A(n-1)*A(n-1)-2*A(n-2) if aa>0 then goto 100 print " There are at least two complex roots." goto 500 100 aa=sqr(aa) print print " The magnitude of the largest root is <= "; aa print aa=-1 if INT(n/2)=n/2 then aa=-aa aa=A(0)/aa 'b will flag a negative root b=0 if aa>0 then goto 200 print " There is at least one negative real root." b=1 200 print 'Test for Descartes rule nø 1 c=0 for i=1 to n if A(i-1)*A(i)<0 then c=c+1 next i if c=1 then print " There is at most one positive "; if c>1 then print " There are at most ";c;" positive "; if c=1 then print "real root." if c>1 then print "real roots." print 'Test for Descartes rule nø 2 d=0 for i=1 to n if A(i-1)*A(i)>0 then d=d+1 next i if d=1 then print " There is at most one negative "; if d>1 then print " There are at most ";d;" negative "; if d=1 then print "real root." if d>1 then print "real roots." print if INT(c/2)=c/2 then goto 300 print " There is at least one positive real root." 300 if INT(d/2)=d/2 then goto 500 print " There is at least one negative real root." 500 print end 'End of file roottest.bas