Average Error: 10.0 → 0.1
Time: 31.5s
Precision: 64
Internal Precision: 128
\[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -121.73154097949735 \lor \neg \left(x \le 121.7231247325857\right):\\ \;\;\;\;\frac{2}{{x}^{5}} + \left(\frac{\frac{2}{x}}{x \cdot x} + \frac{2}{{x}^{7}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{(\left((-2 \cdot x + -2)_* + x\right) \cdot \left(-1 + x\right) + \left((x \cdot x + x)_*\right))_*}{\left(-1 + x\right) \cdot (x \cdot x + x)_*}\\ \end{array}\]

Error

Bits error versus x

Target

Original10.0
Target0.2
Herbie0.1
\[\frac{2}{x \cdot \left(x \cdot x - 1\right)}\]

Derivation

  1. Split input into 2 regimes
  2. if x < -121.73154097949735 or 121.7231247325857 < x

    1. Initial program 19.8

      \[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
    2. Taylor expanded around inf 0.4

      \[\leadsto \color{blue}{2 \cdot \frac{1}{{x}^{7}} + \left(2 \cdot \frac{1}{{x}^{3}} + 2 \cdot \frac{1}{{x}^{5}}\right)}\]
    3. Simplified0.1

      \[\leadsto \color{blue}{\left(\frac{\frac{2}{x}}{x \cdot x} + \frac{2}{{x}^{7}}\right) + \frac{2}{{x}^{5}}}\]

    if -121.73154097949735 < x < 121.7231247325857

    1. Initial program 0.0

      \[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
    2. Using strategy rm
    3. Applied frac-sub0.1

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -121.73154097949735 \lor \neg \left(x \le 121.7231247325857\right):\\ \;\;\;\;\frac{2}{{x}^{5}} + \left(\frac{\frac{2}{x}}{x \cdot x} + \frac{2}{{x}^{7}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{(\left((-2 \cdot x + -2)_* + x\right) \cdot \left(-1 + x\right) + \left((x \cdot x + x)_*\right))_*}{\left(-1 + x\right) \cdot (x \cdot x + x)_*}\\ \end{array}\]

Runtime

Time bar (total: 31.5s)Debug logProfile

BaselineHerbieOracleSpan%
Regimes31.50.10.131.499.9%
herbie shell --seed 2018353 +o rules:numerics
(FPCore (x)
  :name "3frac (problem 3.3.3)"

  :herbie-target
  (/ 2 (* x (- (* x x) 1)))

  (+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1))))