saveme.fox
{Laura Chapin's Root Finding program for only one root using Newton's Method}
begin;
variable x 80;
variable f 80;
variable L 80;
function f y;
{enter function here}
f:=y^3-4+y^2-63;
endfunction;
function d x;
{This takes the derivative}
d:=(f(x+.0000000010000000000)-f(x))/.0000000010000000000;
endfunction;
read 5 x;
x:=-abs(x);
{this checks accounts for the method checking roots from negative to positive}
if d(x)=0;
{This checks to make sure the derivative isn't zero at the guess-point}
x:=x+10;
endif;
while L<10000;
{This prevents an infinite loop in case the function doesn't have a root}
L:=L+1;
if abs(f(x))>0.0000000100000000;
x := x - f(x)/d(x); {You can replace d(x) with the derivative}
elseif 1=1;
L:=10000;
write 6 x;
endif;
endwhile;
if abs(f(x))>0.000000010000000;{displays message if no root is found}
write 6 'no root found';
endif;
end;