logoalt Hacker News

notpushkinyesterday at 7:26 AM1 replyview on HN

Some trivial cases produce... interesting results.

For x in [−1.79e308, 1.79e308]:

Initial Program: 100.0% accurate, 1.0× speedup

  def code(x):
      return math.sqrt((x + 1.0))
Alternative 1: 67.5% accurate, 5.6× speedup

  def code(x):
      return 1.0

Replies

lifthrasiiryesterday at 7:44 AM

That does make sense, because a half of all available fp numbers are less than 1 in their magnitude. In particular there should be a plenty of numbers x such that |x| << 1 so x + 1 ~= 1; in fact, the proportion should be just shy of 50%.

show 3 replies