Average Error: 10.0 → 0.1
Time: 26.9s
Precision: 64
Internal Precision: 128
\[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
\[\frac{\frac{2}{(x \cdot x + x)_*}}{x + -1}\]

Error

Bits error versus x

Target

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

Derivation

  1. Initial program 10.0

    \[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
  2. Using strategy rm
  3. Applied frac-sub26.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-add25.3

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

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

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

    \[\leadsto \frac{\color{blue}{2}}{(x \cdot x + x)_* \cdot \left(-1 + x\right)}\]
  8. Using strategy rm
  9. Applied associate-/r*0.1

    \[\leadsto \color{blue}{\frac{\frac{2}{(x \cdot x + x)_*}}{-1 + x}}\]
  10. Final simplification0.1

    \[\leadsto \frac{\frac{2}{(x \cdot x + x)_*}}{x + -1}\]

Reproduce

herbie shell --seed 2019005 +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))))

Details

Time bar (total: 26.4s)Debug log

sample104.0ms

Algorithm
intervals

simplify33.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune9.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 9.7b

localize49.0ms

Local error

Found 4 expressions with local error:

2.4b
(+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1)))
0.0b
(- (/ 1 (+ x 1)) (/ 2 x))
0.0b
(/ 1 (+ x 1))
0.0b
(/ 1 (- x 1))

rewrite67.0ms

Algorithm
rewrite-expression-head
Counts
4 → 144
Calls

4 calls. Slowest were:

49.0ms
(+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1)))
11.0ms
(- (/ 1 (+ x 1)) (/ 2 x))
1.0ms
(/ 1 (+ x 1))

series105.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

59.0ms
(+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1)))
23.0ms
(- (/ 1 (+ x 1)) (/ 2 x))
11.0ms
(/ 1 (- x 1))
11.0ms
(/ 1 (+ x 1))

simplify10.8s

Counts
127 → 156
Calls

127 calls. Slowest were:

651.0ms
(+ (* (- (* 1 x) (* (+ x 1) 2)) (- x 1)) (* (* (+ x 1) x) 1))
612.0ms
(- (+ (* 2 x) (+ (* 2 (pow x 3)) (* 2 (/ 1 x)))))
525.0ms
(fma (/ 1 (+ (pow x 3) (pow 1 3))) (+ (* x x) (- (* 1 1) (* x 1))) (- (* (/ 2 x) 1)))

prune1.2s

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0.1b

localize37.0ms

Local error

Found 4 expressions with local error:

30.3b
(fma (+ x (fma -2 x -2)) (+ x -1) (fma x x x))
0.1b
(* (fma x x x) (+ -1 x))
0.0b
(+ x (fma -2 x -2))
0.0b
(/ (fma (+ x (fma -2 x -2)) (+ x -1) (fma x x x)) (* (fma x x x) (+ -1 x)))

rewrite11.0ms

Algorithm
rewrite-expression-head
Counts
4 → 71
Calls

4 calls. Slowest were:

5.0ms
(/ (fma (+ x (fma -2 x -2)) (+ x -1) (fma x x x)) (* (fma x x x) (+ -1 x)))
4.0ms
(* (fma x x x) (+ -1 x))
1.0ms
(+ x (fma -2 x -2))

series278.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

104.0ms
(/ (fma (+ x (fma -2 x -2)) (+ x -1) (fma x x x)) (* (fma x x x) (+ -1 x)))
81.0ms
(fma (+ x (fma -2 x -2)) (+ x -1) (fma x x x))
59.0ms
(* (fma x x x) (+ -1 x))
33.0ms
(+ x (fma -2 x -2))

simplify3.5s

Counts
39 → 83
Calls

39 calls. Slowest were:

568.0ms
(- (+ (* 2 x) (+ (* 2 (pow x 3)) (* 2 (/ 1 x)))))
306.0ms
(/ (* (* (fma (+ x (fma -2 x -2)) (+ x -1) (fma x x x)) (fma (+ x (fma -2 x -2)) (+ x -1) (fma x x x))) (fma (+ x (fma -2 x -2)) (+ x -1) (fma x x x))) (* (* (* (fma x x x) (fma x x x)) (fma x x x)) (* (* (+ -1 x) (+ -1 x)) (+ -1 x))))
305.0ms
(- (log (fma (+ x (fma -2 x -2)) (+ x -1) (fma x x x))) (log (* (fma x x x) (+ -1 x))))

prune801.0ms

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0.0b

localize3.0ms

Local error

Found 2 expressions with local error:

0.1b
(/ 2 (* (fma x x x) (+ -1 x)))
0.1b
(* (fma x x x) (+ -1 x))

rewrite8.0ms

Algorithm
rewrite-expression-head
Counts
2 → 38
Calls

2 calls. Slowest were:

4.0ms
(* (fma x x x) (+ -1 x))
3.0ms
(/ 2 (* (fma x x x) (+ -1 x)))

series105.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

68.0ms
(* (fma x x x) (+ -1 x))
36.0ms
(/ 2 (* (fma x x x) (+ -1 x)))

simplify1.5s

Counts
21 → 44
Calls

21 calls. Slowest were:

513.0ms
(- (+ (* 2 x) (+ (* 2 (pow x 3)) (* 2 (/ 1 x)))))
284.0ms
(+ (* 2 (/ 1 (pow x 7))) (+ (* 2 (/ 1 (pow x 3))) (* 2 (/ 1 (pow x 5)))))
267.0ms
(+ (* 2 (/ 1 (pow x 7))) (+ (* 2 (/ 1 (pow x 3))) (* 2 (/ 1 (pow x 5)))))

prune340.0ms

Pruning

5 alts after pruning (5 fresh and 0 done)

Merged error: 0b

localize6.0ms

Local error

Found 2 expressions with local error:

0.2b
(/ 2 (fma x x x))
0.0b
(/ (/ 2 (fma x x x)) (+ -1 x))

rewrite4.0ms

Algorithm
rewrite-expression-head
Counts
2 → 51
Calls

2 calls. Slowest were:

3.0ms
(/ (/ 2 (fma x x x)) (+ -1 x))
1.0ms
(/ 2 (fma x x x))

series43.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

32.0ms
(/ (/ 2 (fma x x x)) (+ -1 x))
11.0ms
(/ 2 (fma x x x))

simplify4.3s

Counts
42 → 57
Calls

42 calls. Slowest were:

892.0ms
(- (+ (* 2 (/ 1 (pow x 4))) (* 2 (/ 1 (pow x 2)))) (* 2 (/ 1 (pow x 3))))
816.0ms
(- (+ (* 2 (/ 1 (pow x 4))) (* 2 (/ 1 (pow x 2)))) (* 2 (/ 1 (pow x 3))))
587.0ms
(- (+ (* 2 x) (+ (* 2 (pow x 3)) (* 2 (/ 1 x)))))

prune447.0ms

Pruning

5 alts after pruning (4 fresh and 1 done)

Merged error: 0b

regimes53.0ms

Accuracy

0% (0.1b remaining)

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

bsearch2.0ms

end0.0ms

sample2.7s

Algorithm
intervals