Average Error: 10.5 → 0.1
Time: 2.7m
Precision: 64
Internal Precision: 128
\[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
\[\frac{\frac{2}{\left(x + 1\right) \cdot x}}{x - 1}\]

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 10.5

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

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

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

    \[\leadsto \color{blue}{\frac{\frac{2}{\left(x + 1\right) \cdot x}}{x - 1}}\]
  8. Final simplification0.1

    \[\leadsto \frac{\frac{2}{\left(x + 1\right) \cdot x}}{x - 1}\]

Reproduce

herbie shell --seed 1137770271 
(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: 2.7m)Debug log

sample125.0ms

Algorithm
intervals
Results
63×48.0ms(body real 640)
144×28.0ms(body real 80)
26×14.0ms(body real 320)
11×11.0ms(body real 1280)
256×6.0ms(pre true 80)
12×5.0ms(body real 160)

simplify81.0ms

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

prune10.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 8.7b

localize52.0ms

Local error

Found 2 expressions with local error:

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

rewrite64.0ms

Algorithm
rewrite-expression-head
Rules
16×*-un-lft-identity
add-log-exp
distribute-lft-out--
distribute-lft-out
div-inv
add-sqr-sqrt
frac-add
flip--
add-cube-cbrt
frac-sub
add-exp-log
diff-log
add-cbrt-cube
flip3--
sub-neg
sum-log
associate-+l+
pow1
difference-of-squares
flip-+
associate-+l-
flip3-+
+-commutative
Counts
2 → 40
Calls
2 calls:
Slowest
51.0ms
(+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1)))
12.0ms
(- (/ 1 (+ x 1)) (/ 2 x))

series102.0ms

Counts
2 → 6
Calls
2 calls:
Slowest
80.0ms
(+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1)))
22.0ms
(- (/ 1 (+ x 1)) (/ 2 x))

simplify4.3s

Counts
30 → 46
Calls
30 calls:
Slowest
609.0ms
(* (+ (/ 1 (+ x 1)) (/ 2 x)) (- x 1))
564.0ms
(- (+ (* 2 x) (+ (* 2 (pow x 3)) (* 2 (/ 1 x)))))
471.0ms
(+ (* (- (* 1 x) (* (+ x 1) 2)) (- x 1)) (* (* (+ x 1) x) 1))
384.0ms
(* (* (+ x 1) x) (- x 1))
355.0ms
(* (+ (* (/ 1 (+ x 1)) (/ 1 (+ x 1))) (+ (* (/ 2 x) (/ 2 x)) (* (/ 1 (+ x 1)) (/ 2 x)))) (- x 1))

prune602.0ms

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0.1b

localize45.0ms

Local error

Found 4 expressions with local error:

16.0b
(/ (- (* (- (/ 1 (+ x 1)) (/ 2 x)) (- (/ 1 (+ x 1)) (/ 2 x))) (* (/ 1 (- x 1)) (/ 1 (- x 1)))) (- (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1))))
1.7b
(- (* (- (/ 1 (+ x 1)) (/ 2 x)) (- (/ 1 (+ x 1)) (/ 2 x))) (* (/ 1 (- x 1)) (/ 1 (- x 1))))
0.3b
(* (- (/ 1 (+ x 1)) (/ 2 x)) (- (/ 1 (+ x 1)) (/ 2 x)))
0.1b
(* (/ 1 (- x 1)) (/ 1 (- x 1)))

rewrite250.0ms

Algorithm
rewrite-expression-head
Rules
196×frac-sub
112×frac-times
85×*-un-lft-identity
78×flip--
78×flip3--
62×associate-/l/
58×associate-*r/
58×associate-*l/
54×distribute-lft-out--
40×times-frac
38×add-sqr-sqrt
31×un-div-inv
30×div-inv
24×add-cube-cbrt
20×pow1
19×difference-of-squares
16×add-exp-log
12×associate-*l*
12×associate-*r*
10×add-cbrt-cube
10×associate-/r*
associate-/r/
add-log-exp
inv-pow
pow-flip
pow-prod-up
prod-exp
sub-neg
associate-/l*
associate--l+
pow-prod-down
distribute-lft-in
rec-exp
distribute-rgt-in
cbrt-unprod
*-commutative
pow-plus
pow2
div-exp
div-sub
diff-log
frac-2neg
clear-num
cbrt-undiv
Counts
4 → 295
Calls
4 calls:
Slowest
143.0ms
(/ (- (* (- (/ 1 (+ x 1)) (/ 2 x)) (- (/ 1 (+ x 1)) (/ 2 x))) (* (/ 1 (- x 1)) (/ 1 (- x 1)))) (- (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1))))
42.0ms
(* (- (/ 1 (+ x 1)) (/ 2 x)) (- (/ 1 (+ x 1)) (/ 2 x)))
40.0ms
(- (* (- (/ 1 (+ x 1)) (/ 2 x)) (- (/ 1 (+ x 1)) (/ 2 x))) (* (/ 1 (- x 1)) (/ 1 (- x 1))))
11.0ms
(* (/ 1 (- x 1)) (/ 1 (- x 1)))

series360.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
225.0ms
(/ (- (* (- (/ 1 (+ x 1)) (/ 2 x)) (- (/ 1 (+ x 1)) (/ 2 x))) (* (/ 1 (- x 1)) (/ 1 (- x 1)))) (- (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1))))
89.0ms
(- (* (- (/ 1 (+ x 1)) (/ 2 x)) (- (/ 1 (+ x 1)) (/ 2 x))) (* (/ 1 (- x 1)) (/ 1 (- x 1))))
28.0ms
(* (- (/ 1 (+ x 1)) (/ 2 x)) (- (/ 1 (+ x 1)) (/ 2 x)))
17.0ms
(* (/ 1 (- x 1)) (/ 1 (- x 1)))

simplify1.8m

Counts
380 → 307
Calls
380 calls:
Slowest
1.3s
(- (* (* (- (* 1 x) (* (+ x 1) 2)) (- (/ 1 (+ x 1)) (/ 2 x))) (- x 1)) (* (* (+ x 1) x) (* 1 (/ 1 (- x 1)))))
1.1s
(* (* (* (+ x 1) x) (* (+ x 1) x)) (* (- x 1) (- x 1)))
1.0s
(* (* (+ (/ 1 (+ x 1)) (/ 2 x)) (+ (/ 1 (+ x 1)) (/ 2 x))) (* (- x 1) (- x 1)))
988.0ms
(- (* (* (- (/ 1 (+ x 1)) (/ 2 x)) (- (* 1 x) (* (+ x 1) 2))) (* (- x 1) (- x 1))) (* (* (+ x 1) x) (* 1 1)))
968.0ms
(- (* (* (- (* 1 x) (* (+ x 1) 2)) (- (/ 1 (+ x 1)) (/ 2 x))) (* (- x 1) (- x 1))) (* (* (+ x 1) x) (* 1 1)))

prune5.8s

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0.1b

localize68.0ms

Local error

Found 4 expressions with local error:

17.9b
(+ (* (- (* 1 x) (* (+ x 1) 2)) (- x 1)) (* (* (+ x 1) x) 1))
0.2b
(- (* 1 x) (* (+ x 1) 2))
0.0b
(* (* (+ x 1) x) (- x 1))
0.0b
(* (- (* 1 x) (* (+ x 1) 2)) (- x 1))

rewrite70.0ms

Algorithm
rewrite-expression-head
Rules
46×associate-*l/
22×flip--
22×flip3--
16×frac-add
16×frac-times
12×flip-+
12×flip3-+
add-log-exp
add-exp-log
associate-*r/
add-cbrt-cube
pow1
add-cube-cbrt
*-un-lft-identity
sub-neg
add-sqr-sqrt
associate-*r*
distribute-lft-in
distribute-rgt-in
associate-*l*
associate-+l+
cbrt-unprod
*-commutative
prod-exp
pow-prod-down
diff-log
sum-log
+-commutative
Counts
4 → 99
Calls
4 calls:
Slowest
27.0ms
(+ (* (- (* 1 x) (* (+ x 1) 2)) (- x 1)) (* (* (+ x 1) x) 1))
19.0ms
(* (* (+ x 1) x) (- x 1))
15.0ms
(* (- (* 1 x) (* (+ x 1) 2)) (- x 1))
5.0ms
(- (* 1 x) (* (+ x 1) 2))

series122.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
75.0ms
(* (* (+ x 1) x) (- x 1))
22.0ms
(- (* 1 x) (* (+ x 1) 2))
21.0ms
(* (- (* 1 x) (* (+ x 1) 2)) (- x 1))
4.0ms
(+ (* (- (* 1 x) (* (+ x 1) 2)) (- x 1)) (* (* (+ x 1) x) 1))

simplify26.4s

Counts
97 → 111
Calls
97 calls:
Slowest
1.4s
(+ (* (* (- (pow (* 1 x) 3) (pow (* (+ x 1) 2) 3)) (- (pow x 3) (pow 1 3))) (+ (* x x) (- (* 1 1) (* x 1)))) (* (* (+ (* (* 1 x) (* 1 x)) (+ (* (* (+ x 1) 2) (* (+ x 1) 2)) (* (* 1 x) (* (+ x 1) 2)))) (+ (* x x) (+ (* 1 1) (* x 1)))) (* (* (+ (pow x 3) (pow 1 3)) x) 1)))
1.0s
(+ (* (* (- (pow (* 1 x) 3) (pow (* (+ x 1) 2) 3)) (- (pow x 3) (pow 1 3))) (- x 1)) (* (* (+ (* (* 1 x) (* 1 x)) (+ (* (* (+ x 1) 2) (* (+ x 1) 2)) (* (* 1 x) (* (+ x 1) 2)))) (+ (* x x) (+ (* 1 1) (* x 1)))) (* (* (- (* x x) (* 1 1)) x) 1)))
1.0s
(* (- (* (* 1 x) (* 1 x)) (* (* (+ x 1) 2) (* (+ x 1) 2))) (- (pow x 3) (pow 1 3)))
864.0ms
(* (+ (* 1 x) (* (+ x 1) 2)) (+ (* x x) (+ (* 1 1) (* x 1))))
818.0ms
(+ (* (* (- (* (* 1 x) (* 1 x)) (* (* (+ x 1) 2) (* (+ x 1) 2))) (- (pow x 3) (pow 1 3))) (+ (* x x) (- (* 1 1) (* x 1)))) (* (* (+ (* 1 x) (* (+ x 1) 2)) (+ (* x x) (+ (* 1 1) (* x 1)))) (* (* (+ (pow x 3) (pow 1 3)) x) 1)))

prune1.9s

Pruning

5 alts after pruning (3 fresh and 2 done)

Merged error: 0.0b

localize9.0ms

Local error

Found 3 expressions with local error:

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

rewrite32.0ms

Algorithm
rewrite-expression-head
Rules
18×associate-*l/
associate-/r/
frac-times
flip-+
flip3-+
flip--
flip3--
add-cube-cbrt
add-exp-log
add-cbrt-cube
*-un-lft-identity
pow1
add-sqr-sqrt
associate-*r/
associate-*l*
add-log-exp
associate-*r*
*-commutative
distribute-lft-in
sub-neg
distribute-rgt-in
div-inv
cbrt-unprod
prod-exp
pow-prod-down
frac-2neg
associate-/r*
clear-num
Counts
3 → 59
Calls
3 calls:
Slowest
19.0ms
(* (* (+ x 1) x) (- x 1))
6.0ms
(/ 2 (* (* (+ x 1) x) (- x 1)))
6.0ms
(* (+ x 1) x)

series167.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
79.0ms
(* (* (+ x 1) x) (- x 1))
48.0ms
(/ 2 (* (* (+ x 1) x) (- x 1)))
39.0ms
(* (+ x 1) x)

simplify6.8s

Counts
45 → 68
Calls
45 calls:
Slowest
656.0ms
(* (* (- (* x x) (* 1 1)) x) (- (pow x 3) (pow 1 3)))
598.0ms
(- (+ (* 2 x) (+ (* 2 (pow x 3)) (* 2 (/ 1 x)))))
526.0ms
(* (* (- (* x x) (* 1 1)) x) (- x 1))
447.0ms
(* (* (+ (pow x 3) (pow 1 3)) x) (- (* x x) (* 1 1)))
397.0ms
(* (* (+ (pow x 3) (pow 1 3)) x) (- (pow x 3) (pow 1 3)))

prune860.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0b

regimes64.0ms

Accuracy

0% (0.1b remaining)

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

bsearch5.0ms

end0.0ms

sample4.6s

Algorithm
intervals
Results
1961×2.1s(body real 640)
4102×801.0ms(body real 80)
936×612.0ms(body real 320)
531×501.0ms(body real 1280)
8004×201.0ms(pre true 80)
474×180.0ms(body real 160)