def f(p1,q1,n1) return p1+q1*n1*Math.log(n1,2.0) end def f2(p1,q1,l,r,d) if d>127 then return (l+r)/2.0 else m=(l+r)/2.0 t1=f(p1,q1,m) t2=m*m if t1==t2 then return m elsif t1