Average Error: 14.6 → 0.0
Time: 13.7s
Precision: 64
Internal Precision: 128
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -6.5099531673261085 \cdot 10^{+31}:\\ \;\;\;\;\frac{1}{x} + \left(\frac{1}{{x}^{5}} - \frac{\log \left(e^{\frac{\frac{1}{x}}{x}}\right)}{x}\right)\\ \mathbf{elif}\;x \le 1578867.6400496326:\\ \;\;\;\;x \cdot \frac{1}{(x \cdot x + 1)_*}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x} + \left(\frac{1}{{x}^{5}} - \frac{\log \left(e^{\frac{\frac{1}{x}}{x}}\right)}{x}\right)\\ \end{array}\]

Error

Bits error versus x

Target

Original14.6
Target0.1
Herbie0.0
\[\frac{1}{x + \frac{1}{x}}\]

Derivation

  1. Split input into 2 regimes
  2. if x < -6.5099531673261085e+31 or 1578867.6400496326 < x

    1. Initial program 31.8

      \[\frac{x}{x \cdot x + 1}\]
    2. Simplified31.8

      \[\leadsto \color{blue}{\frac{x}{(x \cdot x + 1)_*}}\]
    3. Using strategy rm
    4. Applied div-inv31.9

      \[\leadsto \color{blue}{x \cdot \frac{1}{(x \cdot x + 1)_*}}\]
    5. Taylor expanded around -inf 0.0

      \[\leadsto \color{blue}{\left(\frac{1}{{x}^{5}} + \frac{1}{x}\right) - \frac{1}{{x}^{3}}}\]
    6. Simplified0.0

      \[\leadsto \color{blue}{\left(\frac{1}{{x}^{5}} - \frac{\frac{\frac{1}{x}}{x}}{x}\right) + \frac{1}{x}}\]
    7. Using strategy rm
    8. Applied add-log-exp0.0

      \[\leadsto \left(\frac{1}{{x}^{5}} - \frac{\color{blue}{\log \left(e^{\frac{\frac{1}{x}}{x}}\right)}}{x}\right) + \frac{1}{x}\]

    if -6.5099531673261085e+31 < x < 1578867.6400496326

    1. Initial program 0.0

      \[\frac{x}{x \cdot x + 1}\]
    2. Simplified0.0

      \[\leadsto \color{blue}{\frac{x}{(x \cdot x + 1)_*}}\]
    3. Using strategy rm
    4. Applied div-inv0.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -6.5099531673261085 \cdot 10^{+31}:\\ \;\;\;\;\frac{1}{x} + \left(\frac{1}{{x}^{5}} - \frac{\log \left(e^{\frac{\frac{1}{x}}{x}}\right)}{x}\right)\\ \mathbf{elif}\;x \le 1578867.6400496326:\\ \;\;\;\;x \cdot \frac{1}{(x \cdot x + 1)_*}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x} + \left(\frac{1}{{x}^{5}} - \frac{\log \left(e^{\frac{\frac{1}{x}}{x}}\right)}{x}\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019093 +o rules:numerics
(FPCore (x)
  :name "x / (x^2 + 1)"

  :herbie-target
  (/ 1 (+ x (/ 1 x)))

  (/ x (+ (* x x) 1)))