Average Error: 14.2 → 0.4
Time: 19.4s
Precision: 64
Internal Precision: 896
\[\frac{1}{x + 1} - \frac{1}{x}\]
\[\begin{array}{l} \mathbf{if}\;(x \cdot x + x)_* \le 1.4203847663962692 \cdot 10^{+20}:\\ \;\;\;\;\frac{x - \left(1 + x\right)}{(x \cdot x + x)_*}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{-1}{\sqrt{(x \cdot x + x)_*}}}{\sqrt{(x \cdot x + x)_*}}\\ \end{array}\]

Error

Bits error versus x

Derivation

  1. Split input into 2 regimes
  2. if (fma x x x) < 1.4203847663962692e+20

    1. Initial program 0.5

      \[\frac{1}{x + 1} - \frac{1}{x}\]
    2. Using strategy rm
    3. Applied frac-sub0.0

      \[\leadsto \color{blue}{\frac{1 \cdot x - \left(x + 1\right) \cdot 1}{\left(x + 1\right) \cdot x}}\]
    4. Applied simplify0.0

      \[\leadsto \frac{\color{blue}{x - \left(x + 1\right)}}{\left(x + 1\right) \cdot x}\]
    5. Applied simplify0.0

      \[\leadsto \frac{x - \left(x + 1\right)}{\color{blue}{(x \cdot x + x)_*}}\]

    if 1.4203847663962692e+20 < (fma x x x)

    1. Initial program 28.9

      \[\frac{1}{x + 1} - \frac{1}{x}\]
    2. Using strategy rm
    3. Applied frac-sub28.1

      \[\leadsto \color{blue}{\frac{1 \cdot x - \left(x + 1\right) \cdot 1}{\left(x + 1\right) \cdot x}}\]
    4. Applied simplify28.1

      \[\leadsto \frac{\color{blue}{x - \left(x + 1\right)}}{\left(x + 1\right) \cdot x}\]
    5. Applied simplify28.1

      \[\leadsto \frac{x - \left(x + 1\right)}{\color{blue}{(x \cdot x + x)_*}}\]
    6. Using strategy rm
    7. Applied add-sqr-sqrt28.1

      \[\leadsto \frac{x - \left(x + 1\right)}{\color{blue}{\sqrt{(x \cdot x + x)_*} \cdot \sqrt{(x \cdot x + x)_*}}}\]
    8. Applied associate-/r*28.1

      \[\leadsto \color{blue}{\frac{\frac{x - \left(x + 1\right)}{\sqrt{(x \cdot x + x)_*}}}{\sqrt{(x \cdot x + x)_*}}}\]
    9. Applied simplify0.8

      \[\leadsto \frac{\color{blue}{\frac{0 - 1}{\sqrt{(x \cdot x + x)_*}}}}{\sqrt{(x \cdot x + x)_*}}\]
  3. Recombined 2 regimes into one program.
  4. Applied simplify0.4

    \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;(x \cdot x + x)_* \le 1.4203847663962692 \cdot 10^{+20}:\\ \;\;\;\;\frac{x - \left(1 + x\right)}{(x \cdot x + x)_*}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{-1}{\sqrt{(x \cdot x + x)_*}}}{\sqrt{(x \cdot x + x)_*}}\\ \end{array}}\]

Runtime

Time bar (total: 19.4s)Debug logProfile

herbie shell --seed '#(1064269945 2896236262 301053905 1701069080 1701464310 1614783279)' +o rules:numerics
(FPCore (x)
  :name "2frac (problem 3.3.1)"
  (- (/ 1 (+ x 1)) (/ 1 x)))