Polynomial Root Solver

A polynomial equation solver that finds roots of equations up to degree 9. Takes coefficients as input and searches for roots in the range -100 to 100 by checking sign changes and function direction.

Source Code:

uses crt;

type tkoeff = record
     a,b,c,d,e,f,g,h,i,k,l:integer;
     end;
     tfsost = (down,up,non);
var

koeff: tkoeff;
fsost: tfsost;
x:integer;

const prec=0.01;

function pow(arg:real;step:integer):real;
var iter:real;
begin
     iter:=arg;
     while not (step=0) do begin
     iter:=arg*iter;
     dec(step);
     end;
pow:=iter;
end;

{N+}

function uravn(x:real):extended;
var y:extended;
begin
with koeff do begin
if not (a=0) then y:=a;
if not (b=0) then y:=y+b*pow(x,1);
if not (c=0) then y:=y+c*pow(x,2);
if not (d=0) then y:=y+d*pow(x,3);
if not (e=0) then y:=y+e*pow(x,4);
if not (f=0) then y:=y+f*pow(x,5);
if not (g=0) then y:=y+g*pow(x,6);
if not (h=0) then y:=y+h*pow(x,7);
if not (k=0) then y:=y+k*pow(x,8);
if not (l=0) then y:=y+l*pow(x,9);
end;
uravn:=y;
end;

procedure input;
begin
writeln('¢¢¥¤¨â¥...');
with koeff do begin
write('a='); readln(a);
write('b='); readln(b);
write('c='); readln(c);
write('d='); readln(d);
write('e='); readln(e);
write('f='); readln(f);
write('g='); readln(g);
write('h='); readln(h);
write('i='); readln(i);
write('k='); readln(k);
write('l='); readln(l);
end;
end;

function sost(x:real):tfsost;
begin
if (uravn(x)-uravn(x+prec) > 0) then sost:=down else sost:=up;
end;


begin
input;
for x:=-100 to 100 do begin
if (uravn(x)>0) and (uravn(x+1)<0) and (sost(x)=down) then writeln(x);
if (uravn(x)<0) and (uravn(x+1)>0) and (sost(x)=up) then writeln(x);
end;
end.