rem roots of polynomials - newton's method cls print print "Roots of Polynomials - Newton's Method" print "input the degree, and then the coefficients" print "given the form F(x)=A0+A1*x+A2*x^2+...+AN*x^N" dim a(11) dim b(11) for i=1 to 11 a(i)=0 b(i)=0 next i print input "degree of equation: ";n$ if n$="q" then end n=val(n$) print for i=1 to n+1 print "coefficent of A(";i-1;")= "; input a$ if a$="q" then end a=val(a$) a(i)=a next i for i=1 to 10 b(i)=a(i+1)*i next i [again] print input "Best guess (press q to quit)? ";x$ if x$="q" then end x=val(x$) q=0 [leap] s=1 f1=0 f0=0 q=q+1 for i=1 to n+1 f0=f0+a(i)*s f1=f1+b(i)*s s=s*x next i if f1=0 then print print "derivative = 0 at x= ";x print goto [again] end if s=x-f0/f1 if x=s then print print "Root = ";x print "Error= ";f0 print "Derivative= ";f1 goto [again] end if x=s if q>1000 then print print "1000 iterations completed with no clear solution" print "x= ";x print "f(x)= ";f0 print [jump] input "More iterations (i), new guess (g), quit (q)? ";w$ if w$="i" then goto [leap] if w$="g" then goto [again] if w$="q" then end goto [jump] end if goto [leap]