Average Error: 15.1 → 0.1
Time: 15.4s
Precision: 64
Internal Precision: 128
\[\frac{1}{x + 1} - \frac{1}{x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -12259.563905676921 \lor \neg \left(x \le 12260.049492977074\right):\\ \;\;\;\;\frac{1}{{x}^{3}} - \left({x}^{-2} + \frac{1}{{x}^{4}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{1 + x} - \frac{1}{x}\\ \end{array}\]

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if x < -12259.563905676921 or 12260.049492977074 < x

    1. Initial program 29.9

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

      \[\leadsto \color{blue}{\frac{1}{{x}^{3}} - \left(\frac{1}{{x}^{4}} + \frac{1}{{x}^{2}}\right)}\]
    3. Using strategy rm
    4. Applied pow-flip0.0

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

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

    if -12259.563905676921 < x < 12260.049492977074

    1. Initial program 0.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -12259.563905676921 \lor \neg \left(x \le 12260.049492977074\right):\\ \;\;\;\;\frac{1}{{x}^{3}} - \left({x}^{-2} + \frac{1}{{x}^{4}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{1 + x} - \frac{1}{x}\\ \end{array}\]

Reproduce

herbie shell --seed 1137770271 
(FPCore (x)
  :name "2frac (problem 3.3.1)"
  (- (/ 1 (+ x 1)) (/ 1 x)))

Details

Time bar (total: 14.8s)Debug log

sample135.0ms

Algorithm
intervals
Results
55×47.0ms(body real 640)
144×30.0ms(body real 80)
38×24.0ms(body real 320)
256×8.0ms(pre true 80)
19×8.0ms(body real 160)

simplify12.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
12.0ms
(- (/ 1 (+ x 1)) (/ 1 x))

prune11.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 12.1b

localize35.0ms

Local error

Found 1 expressions with local error:

2.6b
(- (/ 1 (+ x 1)) (/ 1 x))

rewrite13.0ms

Algorithm
rewrite-expression-head
Rules
*-un-lft-identity
distribute-lft-out--
div-inv
add-log-exp
add-sqr-sqrt
difference-of-squares
flip--
add-cube-cbrt
frac-sub
add-exp-log
diff-log
add-cbrt-cube
flip3--
sub-neg
pow1
Counts
1 → 18
Calls
1 calls:
Slowest
12.0ms
(- (/ 1 (+ x 1)) (/ 1 x))

series33.0ms

Counts
1 → 3
Calls
1 calls:
Slowest
33.0ms
(- (/ 1 (+ x 1)) (/ 1 x))

simplify884.0ms

Counts
12 → 21
Calls
12 calls:
Slowest
524.0ms
(- 1 (+ x (/ 1 x)))
94.0ms
(- (/ 1 (pow x 3)) (+ (/ 1 (pow x 4)) (/ 1 (pow x 2))))
91.0ms
(- (/ 1 (pow x 3)) (+ (/ 1 (pow x 4)) (/ 1 (pow x 2))))
50.0ms
(- (* 1 x) (* (+ x 1) 1))
34.0ms
(/ (exp (/ 1 (+ x 1))) (exp (/ 1 x)))

prune274.0ms

Pruning

2 alts after pruning (1 fresh and 1 done)

Merged error: 0.8b

localize110.0ms

Local error

Found 4 expressions with local error:

11.5b
(- (/ 1 (pow x 3)) (+ (/ 1 (pow x 4)) (/ 1 (pow x 2))))
0.9b
(/ 1 (pow x 2))
0.5b
(/ 1 (pow x 4))
0.3b
(/ 1 (pow x 3))

rewrite76.0ms

Algorithm
rewrite-expression-head
Rules
22×*-un-lft-identity
16×div-inv
12×associate-/r*
10×distribute-lft-out--
add-log-exp
add-sqr-sqrt
distribute-lft-out
add-cube-cbrt
add-exp-log
rec-exp
add-cbrt-cube
pow1
inv-pow
pow-flip
frac-sub
frac-2neg
clear-num
pow-to-exp
diff-log
difference-of-squares
unpow2
associate--r+
flip--
flip-+
frac-add
unpow3
flip3--
flip3-+
sub-neg
sum-log
cube-mult
Counts
4 → 82
Calls
4 calls:
Slowest
63.0ms
(- (/ 1 (pow x 3)) (+ (/ 1 (pow x 4)) (/ 1 (pow x 2))))
4.0ms
(/ 1 (pow x 2))
4.0ms
(/ 1 (pow x 4))
3.0ms
(/ 1 (pow x 3))

series141.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
45.0ms
(- (/ 1 (pow x 3)) (+ (/ 1 (pow x 4)) (/ 1 (pow x 2))))
40.0ms
(/ 1 (pow x 3))
32.0ms
(/ 1 (pow x 4))
24.0ms
(/ 1 (pow x 2))

simplify4.5s

Counts
46 → 94
Calls
46 calls:
Slowest
886.0ms
(* (pow x 3) (- (/ 1 (pow x 4)) (/ 1 (pow x 2))))
690.0ms
(- (* 1 (- (/ 1 (pow x 4)) (/ 1 (pow x 2)))) (* (pow x 3) (- (* (/ 1 (pow x 4)) (/ 1 (pow x 4))) (* (/ 1 (pow x 2)) (/ 1 (pow x 2))))))
637.0ms
(* (pow x 3) (+ (* (/ 1 (pow x 4)) (/ 1 (pow x 4))) (- (* (/ 1 (pow x 2)) (/ 1 (pow x 2))) (* (/ 1 (pow x 4)) (/ 1 (pow x 2))))))
388.0ms
(- (* 1 (* (pow x 4) (pow x 2))) (* (pow x 3) (+ (* 1 (pow x 2)) (* (pow x 4) 1))))
294.0ms
(- (* 1 (+ (* (/ 1 (pow x 4)) (/ 1 (pow x 4))) (- (* (/ 1 (pow x 2)) (/ 1 (pow x 2))) (* (/ 1 (pow x 4)) (/ 1 (pow x 2)))))) (* (pow x 3) (+ (pow (/ 1 (pow x 4)) 3) (pow (/ 1 (pow x 2)) 3))))

prune1.7s

Pruning

2 alts after pruning (1 fresh and 1 done)

Merged error: 0b

localize30.0ms

Local error

Found 4 expressions with local error:

11.5b
(- (/ 1 (pow x 3)) (+ (/ 1 (pow x 4)) (pow x -2)))
0.5b
(/ 1 (pow x 4))
0.3b
(/ 1 (pow x 3))
0.0b
(+ (/ 1 (pow x 4)) (pow x -2))

rewrite45.0ms

Algorithm
rewrite-expression-head
Rules
20×*-un-lft-identity
11×add-log-exp
div-inv
associate-/r*
add-sqr-sqrt
distribute-lft-out--
distribute-lft-out
add-cube-cbrt
add-exp-log
add-cbrt-cube
rec-exp
pow1
inv-pow
pow-flip
flip-+
frac-sub
diff-log
flip3-+
frac-2neg
sum-log
clear-num
pow-to-exp
difference-of-squares
associate--r+
flip--
unpow3
flip3--
sub-neg
+-commutative
cube-mult
Counts
4 → 72
Calls
4 calls:
Slowest
29.0ms
(- (/ 1 (pow x 3)) (+ (/ 1 (pow x 4)) (pow x -2)))
11.0ms
(+ (/ 1 (pow x 4)) (pow x -2))
2.0ms
(/ 1 (pow x 4))
2.0ms
(/ 1 (pow x 3))

series161.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
77.0ms
(+ (/ 1 (pow x 4)) (pow x -2))
30.0ms
(/ 1 (pow x 3))
28.0ms
(- (/ 1 (pow x 3)) (+ (/ 1 (pow x 4)) (pow x -2)))
26.0ms
(/ 1 (pow x 4))

simplify2.2s

Counts
39 → 84
Calls
39 calls:
Slowest
378.0ms
(- (* 1 (- (/ 1 (pow x 4)) (pow x -2))) (* (pow x 3) (- (* (/ 1 (pow x 4)) (/ 1 (pow x 4))) (* (pow x -2) (pow x -2)))))
300.0ms
(* (pow x 3) (+ (* (/ 1 (pow x 4)) (/ 1 (pow x 4))) (- (* (pow x -2) (pow x -2)) (* (/ 1 (pow x 4)) (pow x -2)))))
258.0ms
(* (pow x 3) (- (/ 1 (pow x 4)) (pow x -2)))
165.0ms
(- (* 1 (+ (* (/ 1 (pow x 4)) (/ 1 (pow x 4))) (- (* (pow x -2) (pow x -2)) (* (/ 1 (pow x 4)) (pow x -2))))) (* (pow x 3) (+ (pow (/ 1 (pow x 4)) 3) (pow (pow x -2) 3))))
102.0ms
(/ (exp (/ 1 (pow x 3))) (exp (+ (/ 1 (pow x 4)) (pow x -2))))

prune1.5s

Pruning

2 alts after pruning (0 fresh and 2 done)

Merged error: 0b

regimes110.0ms

Accuracy

100% (0.0b remaining)

Error of 0.1b against oracle of 0.1b and baseline of 15.1b

bsearch195.0ms

end0.0ms

sample2.7s

Algorithm
intervals
Results
1903×1.0s(body real 640)
4159×600.0ms(body real 80)
1286×542.0ms(body real 320)
656×221.0ms(body real 160)
8004×198.0ms(pre true 80)