Average Error: 9.5 → 0.2
Time: 28.6s
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.5
Target0.3
Herbie0.2
\[\frac{2}{x \cdot \left(x \cdot x - 1\right)}\]

Derivation

  1. Initial program 9.5

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

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

    \[\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 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 2018362 +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: 21.8s)Debug log

start109.0ms

Algorithm
intervals

setup51.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 6.1b

localize38.0ms

Local error

Found 4 expressions with local error:

1.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))

rewrite38.0ms

Algorithm
rewrite-expression-head
Counts
4 → 144
Calls

4 calls. Slowest were:

23.0ms
(+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1)))
9.0ms
(- (/ 1 (+ x 1)) (/ 2 x))
2.0ms
(/ 1 (- x 1))

series107.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

66.0ms
(+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1)))
18.0ms
(- (/ 1 (+ x 1)) (/ 2 x))
11.0ms
(/ 1 (+ x 1))
11.0ms
(/ 1 (- x 1))

simplify11.6s

Counts
127 → 156
Calls

127 calls. Slowest were:

946.0ms
(+ (* (- (* 1 x) (* (+ x 1) 2)) (- x 1)) (* (* (+ x 1) x) 1))
803.0ms
(- (+ (* 2 x) (+ (* 2 (pow x 3)) (* 2 (/ 1 x)))))
475.0ms
(fma (/ 1 (+ (pow x 3) (pow 1 3))) (+ (* x x) (- (* 1 1) (* x 1))) (- (* (sqrt (/ 2 x)) (sqrt (/ 2 x)))))

prune1.6s

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0.0b

localize51.0ms

Local error

Found 4 expressions with local error:

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

rewrite20.0ms

Algorithm
rewrite-expression-head
Counts
4 → 71
Calls

4 calls. Slowest were:

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

series327.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

147.0ms
(/ (fma (+ x (fma -2 x -2)) (+ x -1) (fma x x x)) (* (fma x x x) (+ -1 x)))
98.0ms
(fma (+ x (fma -2 x -2)) (+ x -1) (fma x x x))
44.0ms
(* (fma x x x) (+ -1 x))
38.0ms
(+ x (fma -2 x -2))

simplify3.3s

Counts
39 → 83
Calls

39 calls. Slowest were:

643.0ms
(- (+ (* 2 x) (+ (* 2 (pow x 3)) (* 2 (/ 1 x)))))
393.0ms
(- (log (fma (+ x (fma -2 x -2)) (+ x -1) (fma x x x))) (log (* (fma x x x) (+ -1 x))))
289.0ms
(+ (* 2 (/ 1 (pow x 7))) (+ (* 2 (/ 1 (pow x 3))) (* 2 (/ 1 (pow x 5)))))

prune663.0ms

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0.0b

localize3.0ms

Local error

Found 2 expressions with local error:

0.0b
(/ 2 (* (fma x x x) (+ -1 x)))
0.0b
(* (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)))

series73.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

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

simplify1.2s

Counts
21 → 44
Calls

21 calls. Slowest were:

439.0ms
(- (+ (* 2 x) (+ (* 2 (pow x 3)) (* 2 (/ 1 x)))))
262.0ms
(+ (* 2 (/ 1 (pow x 7))) (+ (* 2 (/ 1 (pow x 3))) (* 2 (/ 1 (pow x 5)))))
230.0ms
(+ (* 2 (/ 1 (pow x 7))) (+ (* 2 (/ 1 (pow x 3))) (* 2 (/ 1 (pow x 5)))))

prune335.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0b

localize8.0ms

Local error

Found 2 expressions with local error:

0.0b
(/ 2 (- (pow x 3) x))
0.0b
(- (pow x 3) x)

rewrite5.0ms

Algorithm
rewrite-expression-head
Counts
2 → 35
Calls

2 calls. Slowest were:

3.0ms
(- (pow x 3) x)
2.0ms
(/ 2 (- (pow x 3) x))

series47.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

29.0ms
(- (pow x 3) x)
18.0ms
(/ 2 (- (pow x 3) x))

simplify1.8s

Counts
14 → 41
Calls

14 calls. Slowest were:

576.0ms
(+ (* (pow x 3) (pow x 3)) (+ (* x x) (* (pow x 3) x)))
555.0ms
(- (+ (* 2 x) (+ (* 2 (pow x 3)) (* 2 (/ 1 x)))))
365.0ms
(+ (* 2 (/ 1 (pow x 7))) (+ (* 2 (/ 1 (pow x 3))) (* 2 (/ 1 (pow x 5)))))

prune368.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0b

regimes51.0ms

Accuracy

0% (0.2b remaining)

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

bsearch1.0ms