function bisect(f,a,b,fa,fb,tol,n,dir) local c=(a+b)/2 if c==a or c==b or (b-a)