Average Error: 15.0 → 0.0
Time: 1.7m
Precision: 64
Internal Precision: 384
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -2.327396780585858 \cdot 10^{+40}:\\ \;\;\;\;\left(\frac{1}{{x}^{5}} + \frac{1}{x}\right) - \frac{1}{{x}^{3}}\\ \mathbf{if}\;x \le 4175421.3812397714:\\ \;\;\;\;\frac{x}{(\left(x \cdot x\right) \cdot \left(x \cdot x\right) + \left(-1\right))_*} \cdot \left(x \cdot x - 1\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{{x}^{5}} + \frac{1}{x}\right) - \frac{1}{{x}^{3}}\\ \end{array}\]

Error

Bits error versus x

Target

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

Derivation

  1. Split input into 2 regimes
  2. if x < -2.327396780585858e+40 or 4175421.3812397714 < x

    1. Initial program 32.4

      \[\frac{x}{x \cdot x + 1}\]
    2. Taylor expanded around inf 0.0

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

    if -2.327396780585858e+40 < x < 4175421.3812397714

    1. Initial program 0.0

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

      \[\leadsto \frac{x}{\color{blue}{\frac{\left(x \cdot x\right) \cdot \left(x \cdot x\right) - 1 \cdot 1}{x \cdot x - 1}}}\]
    4. Applied associate-/r/0.0

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

      \[\leadsto \color{blue}{\frac{x}{(\left(x \cdot x\right) \cdot \left(x \cdot x\right) + \left(-1\right))_*}} \cdot \left(x \cdot x - 1\right)\]
  3. Recombined 2 regimes into one program.
  4. Removed slow pow expressions.

Runtime

Time bar (total: 1.7m)Debug log

herbie shell --seed '#(1889797285 268396849 4100589100 2067516092 3019009300 3748763710)' +o rules:numerics
(FPCore (x)
  :name "x / (x^2 + 1)"

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

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