From: Yusuke ENDOH Date: 2011-07-17T09:59:42+09:00 Subject: [ruby-core:38116] Re: [Ruby 1.9 - Feature #4766] Range#bsearch > How is this useful? It's basically "find minimum" value, right? What difference does it make that it uses a binary search? > > If binary searching is important, then why not have a #beach --which can then be used to extrapolate any variety of other methods. Maybe I'm not sure your point. It finds minimum value by using binary search. Does the name `bsearch' matter? Is `beach' really suitable? I add a practical example of Range#bsearch for Float domain. The following code obtains the interior radius between 3 circles of radii a,b,c that are circumscribed each other, by using law of cosines three times: (0.0 .. [a,b,c].min).bsearch do |t| u, v = (t+a+b)*t, a*b s = Math.acos((u - v) / (u + v)) u, v = (t+b+c)*t, b*c s += Math.acos((u - v) / (u + v)) u, v = (t+c+a)*t, c*a s += Math.acos((u - v) / (u + v)) s <= Math::PI * 2 end -- Yusuke Endoh