Average Error: 9.7 → 0.1
Time: 21.0s
Precision: 64
Internal Precision: 1088
\[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -99.99527790347257 \lor \neg \left(x \le 100.82262386676551\right):\\ \;\;\;\;\frac{2}{{x}^{5}} + \left(\frac{\frac{2}{x}}{x \cdot x} + \frac{2}{{x}^{7}}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{1 + x} - \frac{2}{x}\right) + \frac{1}{x - 1}\\ \end{array}\]

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Split input into 2 regimes
  2. if x < -99.99527790347257 or 100.82262386676551 < x

    1. Initial program 19.5

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

      \[\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}}}\]
    4. Taylor expanded around inf 0.1

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

    if -99.99527790347257 < x < 100.82262386676551

    1. Initial program 0.0

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

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

Runtime

Time bar (total: 21.0s)Debug logProfile

BaselineHerbieOracleSpan%
Regimes9.70.10.09.699.5%
herbie shell --seed 2018274 +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))))