Average Error: 9.9 → 0.2
Time: 32.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 -1.0059583860097894:\\ \;\;\;\;\frac{2}{{x}^{5}} + \left(\frac{2}{{x}^{3}} + \frac{2}{{x}^{7}}\right)\\ \mathbf{elif}\;x \le 114.41236533389507:\\ \;\;\;\;\left(\sqrt{\frac{1}{1 + x}} \cdot \sqrt{\frac{1}{1 + x}} - \frac{2}{x}\right) + \frac{1}{x - 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{{x}^{5}} + \left(\frac{2}{{x}^{7}} + \frac{\frac{2}{x}}{x \cdot x}\right)\\ \end{array}\]

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Split input into 3 regimes
  2. if x < -1.0059583860097894

    1. Initial program 19.6

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

      \[\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.3

      \[\leadsto \color{blue}{\left(\frac{\frac{2}{x}}{x \cdot x} + \frac{2}{{x}^{7}}\right) + \frac{2}{{x}^{5}}}\]
    4. Using strategy rm
    5. Applied associate-/r*0.3

      \[\leadsto \left(\color{blue}{\frac{\frac{\frac{2}{x}}{x}}{x}} + \frac{2}{{x}^{7}}\right) + \frac{2}{{x}^{5}}\]
    6. Taylor expanded around -inf 0.7

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

    if -1.0059583860097894 < x < 114.41236533389507

    1. Initial program 0.0

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

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

    if 114.41236533389507 < x

    1. Initial program 19.6

      \[\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}}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.0059583860097894:\\ \;\;\;\;\frac{2}{{x}^{5}} + \left(\frac{2}{{x}^{3}} + \frac{2}{{x}^{7}}\right)\\ \mathbf{elif}\;x \le 114.41236533389507:\\ \;\;\;\;\left(\sqrt{\frac{1}{1 + x}} \cdot \sqrt{\frac{1}{1 + x}} - \frac{2}{x}\right) + \frac{1}{x - 1}\\ \mathbf{else}:\\ \;\;\;\;\frac{2}{{x}^{5}} + \left(\frac{2}{{x}^{7}} + \frac{\frac{2}{x}}{x \cdot x}\right)\\ \end{array}\]

Runtime

Time bar (total: 32.5s)Debug logProfile

BaselineHerbieOracleSpan%
Regimes25.70.20.125.699.4%
herbie shell --seed 2018351 +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))))