restart;Digits:=16;sec2_1_2:=x->3*(x+1)*(x-1/2)*(x-1);bisection:=proc(f,left,right,Tol)
local N,Count,RootFound,a,b,m,x:
N:=floor(ln((right-left)/Tol)/ln(2)):
Count:=1:
RootFound:=false:
a:=evalf(left):
b:=evalf(right):
print(a,b);
while ( (RootFound=false) and (Count<=N) ) do
m := evalf(a+(b-a)/2):
if (evalf(f(m))=0) then
RootFound:=true:
x:=m:
else
if sign(evalf(f(m)))=sign(evalf(f(a))) then
a:=m:
else
b:=m:
end if:
x:=evalf(a+(b-a)/2):
end if:
Count:=Count+1:
print(a,b,x);
end do:
end:bisection(sec2_1_2,-2.0,1.5,0.01);bisection(sec2_1_2,-1.25,2.5,0.01);