Average Error: 10.1 → 0.2
Time: 25.2s
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

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

Derivation

  1. Initial program 10.1

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

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

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

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

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

sample92.0ms

Algorithm
intervals
Results
35.0ms66×body640valid
18.0ms133×body80valid
16.0ms35×body320valid
7.0ms12×body1280valid
3.0ms11×body160valid

simplify62.0ms

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

prune8.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 12.0b

localize52.0ms

Local error

Found 4 expressions with local error:

2.2b
(+ (- (/ 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))

rewrite41.0ms

Algorithm
rewrite-expression-head
Rules
48×prod-diff
45×*-un-lft-identity
32×add-sqr-sqrt
30×div-inv
28×add-cube-cbrt
26×associate-+l+
22×associate-/r/
11×add-log-exp
11×flip-+
11×flip3-+
distribute-lft-out--
distribute-lft-out
add-exp-log
fma-neg
fma-def
associate-/r*
pow1
log1p-expm1-u
add-cbrt-cube
expm1-log1p-u
flip--
frac-add
flip3--
difference-of-squares
inv-pow
pow-flip
frac-sub
diff-log
frac-2neg
sub-neg
sum-log
clear-num
rec-exp
associate-+l-
+-commutative
Counts
4 → 144
Calls
4 calls:
Slowest
25.0ms
(+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1)))
10.0ms
(- (/ 1 (+ x 1)) (/ 2 x))
1.0ms
(/ 1 (+ x 1))
1.0ms
(/ 1 (- x 1))

series77.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
43.0ms
(+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1)))
12.0ms
(- (/ 1 (+ x 1)) (/ 2 x))
11.0ms
(/ 1 (+ x 1))
10.0ms
(/ 1 (- x 1))

simplify10.3s

Counts
127 → 156
Calls
127 calls:
Slowest
613.0ms
(+ (* (- (* 1 x) (* (+ x 1) 2)) (- x 1)) (* (* (+ x 1) x) 1))
521.0ms
(- (+ (* 2 x) (+ (* 2 (pow x 3)) (* 2 (/ 1 x)))))
457.0ms
(fma (/ 1 (+ (pow x 3) (pow 1 3))) (+ (* x x) (- (* 1 1) (* x 1))) (- (* (sqrt (/ 2 x)) (sqrt (/ 2 x)))))
440.0ms
(fma (/ 1 (+ (pow x 3) (pow 1 3))) (+ (* x x) (- (* 1 1) (* x 1))) (- (* (cbrt (/ 2 x)) (* (cbrt (/ 2 x)) (cbrt (/ 2 x))))))
439.0ms
(fma (/ 1 (+ (pow x 3) (pow 1 3))) (+ (* x x) (- (* 1 1) (* x 1))) (- (* (cbrt (/ 2 x)) (* (cbrt (/ 2 x)) (cbrt (/ 2 x))))))

prune1.1s

Pruning

5 alts after pruning (5 fresh and 0 done)

Merged error: 0.1b

localize44.0ms

Local error

Found 4 expressions with local error:

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

rewrite18.0ms

Algorithm
rewrite-expression-head
Rules
11×add-exp-log
11×add-cbrt-cube
add-cube-cbrt
*-un-lft-identity
add-sqr-sqrt
pow1
add-log-exp
log1p-expm1-u
associate-*r/
expm1-log1p-u
associate-/l*
flip-+
associate-*l*
associate-*r*
times-frac
flip3-+
fma-udef
cbrt-unprod
associate-/r/
prod-exp
div-exp
cbrt-undiv
div-inv
*-commutative
pow-prod-down
distribute-lft-in
frac-2neg
associate-/r*
clear-num
associate-+r+
+-commutative
distribute-rgt-in
Counts
4 → 71
Calls
4 calls:
Slowest
9.0ms
(/ (fma (+ x (fma -2 x -2)) (+ x -1) (fma x x x)) (* (fma x x x) (+ -1 x)))
6.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))

series301.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
101.0ms
(fma (+ x (fma -2 x -2)) (+ x -1) (fma x x x))
101.0ms
(/ (fma (+ x (fma -2 x -2)) (+ x -1) (fma x x x)) (* (fma x x x) (+ -1 x)))
75.0ms
(* (fma x x x) (+ -1 x))
24.0ms
(+ x (fma -2 x -2))

simplify3.4s

Counts
39 → 83
Calls
39 calls:
Slowest
582.0ms
(- (+ (* 2 x) (+ (* 2 (pow x 3)) (* 2 (/ 1 x)))))
309.0ms
(+ (* 2 (/ 1 (pow x 7))) (+ (* 2 (/ 1 (pow x 3))) (* 2 (/ 1 (pow x 5)))))
308.0ms
(- (log (fma (+ x (fma -2 x -2)) (+ x -1) (fma x x x))) (log (* (fma x x x) (+ -1 x))))
284.0ms
(+ (* 2 (/ 1 (pow x 7))) (+ (* 2 (/ 1 (pow x 3))) (* 2 (/ 1 (pow x 5)))))
249.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) (+ -1 x)) (* (fma x x x) (+ -1 x))) (* (fma x x x) (+ -1 x))))

prune743.0ms

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0.0b

localize4.0ms

Local error

Found 2 expressions with local error:

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

rewrite5.0ms

Algorithm
rewrite-expression-head
Rules
add-cube-cbrt
add-exp-log
associate-*r/
add-cbrt-cube
*-un-lft-identity
pow1
add-sqr-sqrt
associate-*l*
associate-*r*
add-log-exp
log1p-expm1-u
flip-+
associate-/r/
flip3-+
expm1-log1p-u
div-inv
cbrt-unprod
*-commutative
prod-exp
pow-prod-down
distribute-lft-in
frac-2neg
associate-/r*
clear-num
distribute-rgt-in
Counts
2 → 38
Calls
2 calls:
Slowest
4.0ms
(* (fma x x x) (+ -1 x))
1.0ms
(/ 2 (* (fma x x x) (+ -1 x)))

series82.0ms

Counts
2 → 6
Calls
2 calls:
Slowest
46.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
467.0ms
(- (+ (* 2 x) (+ (* 2 (pow x 3)) (* 2 (/ 1 x)))))
297.0ms
(+ (* 2 (/ 1 (pow x 7))) (+ (* 2 (/ 1 (pow x 3))) (* 2 (/ 1 (pow x 5)))))
249.0ms
(+ (* 2 (/ 1 (pow x 7))) (+ (* 2 (/ 1 (pow x 3))) (* 2 (/ 1 (pow x 5)))))
149.0ms
(* (* (* (fma x x x) (fma x x x)) (fma x x x)) (* (* (+ -1 x) (+ -1 x)) (+ -1 x)))
88.0ms
(* (fma x x x) (+ -1 x))

prune283.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.0b

localize6.0ms

Local error

Found 2 expressions with local error:

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

rewrite4.0ms

Algorithm
rewrite-expression-head
Rules
12×add-cube-cbrt
12×times-frac
12×*-un-lft-identity
12×add-sqr-sqrt
div-inv
associate-/r*
associate-/l*
add-exp-log
add-cbrt-cube
add-log-exp
log1p-expm1-u
associate-/r/
frac-2neg
clear-num
pow1
expm1-log1p-u
associate-/l/
flip-+
div-exp
flip3-+
cbrt-undiv
Counts
2 → 51
Calls
2 calls:
Slowest
3.0ms
(/ (/ 2 (fma x x x)) (+ -1 x))
1.0ms
(/ 2 (fma x x x))

series55.0ms

Counts
2 → 6
Calls
2 calls:
Slowest
44.0ms
(/ (/ 2 (fma x x x)) (+ -1 x))
11.0ms
(/ 2 (fma x x x))

simplify3.9s

Counts
42 → 57
Calls
42 calls:
Slowest
896.0ms
(- (+ (* 2 (/ 1 (pow x 4))) (* 2 (/ 1 (pow x 2)))) (* 2 (/ 1 (pow x 3))))
682.0ms
(- (+ (* 2 (/ 1 (pow x 4))) (* 2 (/ 1 (pow x 2)))) (* 2 (/ 1 (pow x 3))))
478.0ms
(- (+ (* 2 x) (+ (* 2 (pow x 3)) (* 2 (/ 1 x)))))
283.0ms
(+ (* 2 (/ 1 (pow x 7))) (+ (* 2 (/ 1 (pow x 3))) (* 2 (/ 1 (pow x 5)))))
217.0ms
(+ (* 2 (/ 1 (pow x 7))) (+ (* 2 (/ 1 (pow x 3))) (* 2 (/ 1 (pow x 5)))))

prune411.0ms

Pruning

5 alts after pruning (5 fresh and 0 done)

Merged error: 0.0b

regimes26.0ms

Accuracy

0% (0.2b remaining)

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

bsearch1.0ms

end0.0ms

sample2.4s

Algorithm
intervals
Results
1.1s1856×body640valid
433.0ms4179×body80valid
314.0ms953×body320valid
282.0ms540×body1280valid
106.0ms477×body160valid