Question: modified regular falsi method

hy 
need help 
i made this code but i can not get the answer ,help me to find out where i did wrong.

thanx in advance




restart;
f:=x->(x^3+3*x^2-1);
n:=30;
tol:=1e-9;
a[0]:=0;
b[0]:=10;
Digits :=15;

 

printf("No root F(x) abs(x[i+1]-x[i])\n");

for i from 1 to n do
t[i-1] :=evalf( (b[i-1]-a[i-1])/(f(b[i-1])-f(a[i-1])));
c[i-1] := evalf((a[i-1]*f(b[i-1])-b[i-1]*f(a[i-1]))/(f(b[i-1])-f(a[i-1])));
x[i] :=evalf( x[i-1]-t[i-1]*f(x[i-1])^2/(f(x[i-1])-f(c[i-1])));

printf("%d %10.15f %10.15f %10.15e \n",i,x[i],f(x[i]),abs(x[i]-x[i-1]));
if f(a[i-1])*f(c[i-1])<0 then
a[i]:=a[i-1];
b[i]:=c[i-1];
else
a[i]:=c[i-1];
b[i]:=b[i-1];
if abs(f(x[i]))<tol then
print("approximate solution"= x[i]);
print("No of iterations"= i);
break;
end if;
end if;
end do:

Please Wait...