Average Error: 9.9 → 0.2
Time: 1.3m
Precision: 64
Internal Precision: 128
\[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
\[\frac{2}{{x}^{3} - x}\]

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 9.9

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

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

    \[\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. Simplified26.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. Simplified26.0

    \[\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 0 0.3

    \[\leadsto \frac{\color{blue}{2}}{(x \cdot x + x)_* \cdot \left(-1 + x\right)}\]
  8. Taylor expanded around inf 0.2

    \[\leadsto \frac{2}{\color{blue}{{x}^{3} - x}}\]
  9. Final simplification0.2

    \[\leadsto \frac{2}{{x}^{3} - x}\]

Reproduce

herbie shell --seed 2019008 +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: 1.3m)Debug log

sample101.0ms

Algorithm
intervals

simplify54.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune4.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 9.2b

localize398.0ms

Local error

Found 4 expressions with local error:

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

rewrite66.0ms

Algorithm
rewrite-expression-head
Counts
4 → 144
Calls

4 calls. Slowest were:

48.0ms
(+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1)))
11.0ms
(- (/ 1 (+ x 1)) (/ 2 x))
2.0ms
(/ 1 (+ x 1))

series105.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

67.0ms
(+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1)))
18.0ms
(- (/ 1 (+ x 1)) (/ 2 x))
12.0ms
(/ 1 (- x 1))
8.0ms
(/ 1 (+ x 1))

simplify10.4s

Counts
127 → 156
Calls

127 calls. Slowest were:

679.0ms
(+ (* (- (* 1 x) (* (+ x 1) 2)) (- x 1)) (* (* (+ x 1) x) 1))
654.0ms
(- (+ (* 2 x) (+ (* 2 (pow x 3)) (* 2 (/ 1 x)))))
470.0ms
(* (+ (/ 1 (+ x 1)) (/ 2 x)) (- x 1))

prune1.2s

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0.0b

localize19.0ms

Local error

Found 4 expressions with local error:

15.0b
(+ (- (/ (/ 1 (* (cbrt (+ x 1)) (cbrt (+ x 1)))) (cbrt (+ x 1))) (/ 2 x)) (/ 1 (- x 1)))
0.3b
(cbrt (+ x 1))
0.3b
(cbrt (+ x 1))
0.3b
(cbrt (+ x 1))

rewrite240.0ms

Algorithm
rewrite-expression-head
Counts
4 → 388
Calls

4 calls. Slowest were:

223.0ms
(+ (- (/ (/ 1 (* (cbrt (+ x 1)) (cbrt (+ x 1)))) (cbrt (+ x 1))) (/ 2 x)) (/ 1 (- x 1)))
1.0ms
(cbrt (+ x 1))
1.0ms
(cbrt (+ x 1))

series206.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

56.0ms
(cbrt (+ x 1))
55.0ms
(cbrt (+ x 1))
51.0ms
(+ (- (/ (/ 1 (* (cbrt (+ x 1)) (cbrt (+ x 1)))) (cbrt (+ x 1))) (/ 2 x)) (/ 1 (- x 1)))
43.0ms
(cbrt (+ x 1))

simplify59.1s

Counts
359 → 400
Calls

359 calls. Slowest were:

707.0ms
(fma (/ 1 (sqrt (cbrt (+ x 1)))) (/ (/ 1 (* (cbrt (+ x 1)) (cbrt (+ x 1)))) (sqrt (cbrt (+ x 1)))) (- (* (cbrt (/ 2 x)) (* (cbrt (/ 2 x)) (cbrt (/ 2 x))))))
688.0ms
(fma (/ 1 (sqrt (cbrt (+ x 1)))) (/ (/ 1 (* (cbrt (+ x 1)) (cbrt (+ x 1)))) (sqrt (cbrt (+ x 1)))) (- (* (cbrt (/ 2 x)) (* (cbrt (/ 2 x)) (cbrt (/ 2 x))))))
680.0ms
(fma (/ 1 (sqrt (cbrt (+ x 1)))) (/ (/ 1 (* (cbrt (+ x 1)) (cbrt (+ x 1)))) (sqrt (cbrt (+ x 1)))) (- (* (/ 1 x) 2)))

prune4.0s

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0.0b

localize25.0ms

Local error

Found 3 expressions with local error:

29.0b
(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))

rewrite5.0ms

Algorithm
rewrite-expression-head
Counts
3 → 46
Calls

3 calls. Slowest were:

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

series134.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

69.0ms
(fma (+ x (fma -2 x -2)) (+ x -1) (fma x x x))
44.0ms
(* (fma x x x) (+ -1 x))
21.0ms
(+ x (fma -2 x -2))

simplify239.0ms

Counts
21 → 55
Calls

21 calls. Slowest were:

86.0ms
(* (* (* (fma x x x) (fma x x x)) (fma x x x)) (* (* (+ -1 x) (+ -1 x)) (+ -1 x)))
56.0ms
(* (fma x x x) (+ -1 x))
34.0ms
(+ (* -1 -1) (- (* x x) (* -1 x)))

prune349.0ms

Pruning

4 alts after pruning (2 fresh and 2 done)

Merged error: 0.0b

localize3.0ms

Local error

Found 2 expressions with local error:

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

rewrite5.0ms

Algorithm
rewrite-expression-head
Counts
2 → 38
Calls

2 calls. Slowest were:

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

series72.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

43.0ms
(* (fma x x x) (+ -1 x))
29.0ms
(/ 2 (* (fma x x x) (+ -1 x)))

simplify1.0s

Counts
21 → 44
Calls

21 calls. Slowest were:

392.0ms
(- (+ (* 2 x) (+ (* 2 (pow x 3)) (* 2 (/ 1 x)))))
197.0ms
(+ (* 2 (/ 1 (pow x 7))) (+ (* 2 (/ 1 (pow x 3))) (* 2 (/ 1 (pow x 5)))))
195.0ms
(+ (* 2 (/ 1 (pow x 7))) (+ (* 2 (/ 1 (pow x 3))) (* 2 (/ 1 (pow x 5)))))

prune216.0ms

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0.0b

regimes19.0ms

Accuracy

0% (0.2b remaining)

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

bsearch0.0ms

end0.0ms

sample1.8s

Algorithm
intervals