Average Error: 9.5 → 0.2
Time: 1.4m
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 *-un-lft-identity9.5

    \[\leadsto \left(\frac{1}{x + 1} - \color{blue}{1 \cdot \frac{2}{x}}\right) + \frac{1}{x - 1}\]
  4. Applied *-un-lft-identity9.5

    \[\leadsto \left(\color{blue}{1 \cdot \frac{1}{x + 1}} - 1 \cdot \frac{2}{x}\right) + \frac{1}{x - 1}\]
  5. Applied distribute-lft-out--9.5

    \[\leadsto \color{blue}{1 \cdot \left(\frac{1}{x + 1} - \frac{2}{x}\right)} + \frac{1}{x - 1}\]
  6. Using strategy rm
  7. Applied frac-sub26.0

    \[\leadsto 1 \cdot \color{blue}{\frac{1 \cdot x - \left(x + 1\right) \cdot 2}{\left(x + 1\right) \cdot x}} + \frac{1}{x - 1}\]
  8. Applied associate-*r/26.0

    \[\leadsto \color{blue}{\frac{1 \cdot \left(1 \cdot x - \left(x + 1\right) \cdot 2\right)}{\left(x + 1\right) \cdot x}} + \frac{1}{x - 1}\]
  9. Applied frac-add25.2

    \[\leadsto \color{blue}{\frac{\left(1 \cdot \left(1 \cdot x - \left(x + 1\right) \cdot 2\right)\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)}}\]
  10. Simplified25.3

    \[\leadsto \frac{\color{blue}{x \cdot \left(\left(x + 1\right) + \left(x + -1\right)\right) + \left(\left(x + -1\right) \cdot \left(-1 - x\right)\right) \cdot 2}}{\left(\left(x + 1\right) \cdot x\right) \cdot \left(x - 1\right)}\]
  11. Taylor expanded around 0 0.3

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

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

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

Reproduce

herbie shell --seed 2018362 
(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

start110.0ms

Algorithm
intervals

setup73.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 6.1b

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

rewrite26.0ms

Algorithm
rewrite-expression-head
Counts
4 → 76
Calls

4 calls. Slowest were:

19.0ms
(+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1)))
4.0ms
(- (/ 1 (+ x 1)) (/ 2 x))
1.0ms
(/ 1 (- x 1))

series70.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

45.0ms
(+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1)))
12.0ms
(- (/ 1 (+ x 1)) (/ 2 x))
7.0ms
(/ 1 (- x 1))
6.0ms
(/ 1 (+ x 1))

simplify3.2s

Counts
48 → 88
Calls

48 calls. Slowest were:

436.0ms
(* (+ (/ 1 (+ x 1)) (/ 2 x)) (- x 1))
384.0ms
(- (+ (* 2 x) (+ (* 2 (pow x 3)) (* 2 (/ 1 x)))))
348.0ms
(+ (* (- (* 1 x) (* (+ x 1) 2)) (- x 1)) (* (* (+ x 1) x) 1))

prune654.0ms

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0.0b

localize11.0ms

Local error

Found 4 expressions with local error:

1.4b
(+ (* 1 (- (/ 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))

rewrite29.0ms

Algorithm
rewrite-expression-head
Counts
4 → 72
Calls

4 calls. Slowest were:

13.0ms
(+ (* 1 (- (/ 1 (+ x 1)) (/ 2 x))) (/ 1 (- x 1)))
9.0ms
(- (/ 1 (+ x 1)) (/ 2 x))
5.0ms
(/ 1 (- x 1))

series90.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

55.0ms
(+ (* 1 (- (/ 1 (+ x 1)) (/ 2 x))) (/ 1 (- x 1)))
17.0ms
(- (/ 1 (+ x 1)) (/ 2 x))
10.0ms
(/ 1 (- x 1))
7.0ms
(/ 1 (+ x 1))

simplify2.5s

Counts
44 → 84
Calls

44 calls. Slowest were:

327.0ms
(* (+ (/ 1 (+ x 1)) (/ 2 x)) (- x 1))
324.0ms
(- (+ (* 2 x) (+ (* 2 (pow x 3)) (* 2 (/ 1 x)))))
210.0ms
(+ (* (* 1 (- (* 1 x) (* (+ x 1) 2))) (- x 1)) (* (* (+ x 1) x) 1))

prune744.0ms

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0.0b

localize52.0ms

Local error

Found 4 expressions with local error:

14.3b
(+ (* x (+ (+ x 1) (+ x -1))) (* (* (+ x -1) (- -1 x)) 2))
4.8b
(+ (+ x 1) (+ x -1))
0.0b
(* (* (+ x 1) x) (- x 1))
0.0b
(/ (+ (* x (+ (+ x 1) (+ x -1))) (* (* (+ x -1) (- -1 x)) 2)) (* (* (+ x 1) x) (- x 1)))

rewrite96.0ms

Algorithm
rewrite-expression-head
Counts
4 → 185
Calls

4 calls. Slowest were:

48.0ms
(/ (+ (* x (+ (+ x 1) (+ x -1))) (* (* (+ x -1) (- -1 x)) 2)) (* (* (+ x 1) x) (- x 1)))
20.0ms
(* (* (+ x 1) x) (- x 1))
17.0ms
(+ (* x (+ (+ x 1) (+ x -1))) (* (* (+ x -1) (- -1 x)) 2))

series109.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

58.0ms
(* (* (+ x 1) x) (- x 1))
39.0ms
(/ (+ (* x (+ (+ x 1) (+ x -1))) (* (* (+ x -1) (- -1 x)) 2)) (* (* (+ x 1) x) (- x 1)))
10.0ms
(+ (+ x 1) (+ x -1))
2.0ms
(+ (* x (+ (+ x 1) (+ x -1))) (* (* (+ x -1) (- -1 x)) 2))

simplify1.1m

Counts
215 → 197
Calls

215 calls. Slowest were:

1.6s
(+ (* (* x (+ (* (- (* x x) (* 1 1)) (- x -1)) (* (- x 1) (- (* x x) (* -1 -1))))) (+ -1 x)) (* (* (- x 1) (- x -1)) (* (* (+ x -1) (- (* -1 -1) (* x x))) 2)))
1.5s
(+ (* (* x (+ (* (- (* x x) (* 1 1)) (- x -1)) (* (- x 1) (- (* x x) (* -1 -1))))) (+ -1 x)) (* (* (- x 1) (- x -1)) (* (* (+ x -1) (- (* -1 -1) (* x x))) 2)))
1.3s
(* (+ (* (+ x 1) (+ x 1)) (- (* (+ x -1) (+ x -1)) (* (+ x 1) (+ x -1)))) (- x -1))

prune2.6s

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0.0b

localize3.0ms

Local error

Found 3 expressions with local error:

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

rewrite12.0ms

Algorithm
rewrite-expression-head
Counts
3 → 59
Calls

3 calls. Slowest were:

7.0ms
(* (* (+ x 1) x) (- x 1))
2.0ms
(/ 2 (* (* (+ x 1) x) (- x 1)))
2.0ms
(* (+ x 1) x)

series76.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

36.0ms
(* (* (+ x 1) x) (- x 1))
22.0ms
(/ 2 (* (* (+ x 1) x) (- x 1)))
17.0ms
(* (+ x 1) x)

simplify3.2s

Counts
45 → 68
Calls

45 calls. Slowest were:

337.0ms
(* (* (- (* x x) (* 1 1)) x) (- (pow x 3) (pow 1 3)))
274.0ms
(- (+ (* 2 x) (+ (* 2 (pow x 3)) (* 2 (/ 1 x)))))
234.0ms
(* (* (- (* x x) (* 1 1)) x) (- x 1))

prune418.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0b

regimes25.0ms

Accuracy

0% (0.2b remaining)

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

bsearch0.0ms