Average Error: 9.8 → 0.1
Time: 36.0s
Precision: 64
Internal Precision: 128
\[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -115.27580035964922 \lor \neg \left(x \le 105.7634957037421\right):\\ \;\;\;\;\frac{\frac{2}{x}}{x \cdot x} + \left(\frac{2}{{x}^{7}} + \frac{2}{{x}^{5}}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{1 + x} - \frac{2}{x}\right) + \frac{1}{x - 1}\\ \end{array}\]

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Split input into 2 regimes
  2. if x < -115.27580035964922 or 105.7634957037421 < x

    1. Initial program 19.6

      \[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity19.6

      \[\leadsto \left(\frac{1}{x + 1} - \color{blue}{1 \cdot \frac{2}{x}}\right) + \frac{1}{x - 1}\]
    4. Applied div-inv19.6

      \[\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--19.6

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

      \[\leadsto \color{blue}{2 \cdot \frac{1}{{x}^{7}} + \left(2 \cdot \frac{1}{{x}^{3}} + 2 \cdot \frac{1}{{x}^{5}}\right)}\]
    7. Simplified0.1

      \[\leadsto \color{blue}{\left(\frac{2}{{x}^{7}} + \frac{2}{{x}^{5}}\right) + \frac{\frac{2}{x}}{x \cdot x}}\]

    if -115.27580035964922 < x < 105.7634957037421

    1. Initial program 0.0

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

      \[\leadsto \left(\frac{1}{x + 1} - \color{blue}{1 \cdot \frac{2}{x}}\right) + \frac{1}{x - 1}\]
    4. Applied div-inv0.0

      \[\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--0.0

      \[\leadsto \color{blue}{1 \cdot \left(\frac{1}{x + 1} - \frac{2}{x}\right)} + \frac{1}{x - 1}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -115.27580035964922 \lor \neg \left(x \le 105.7634957037421\right):\\ \;\;\;\;\frac{\frac{2}{x}}{x \cdot x} + \left(\frac{2}{{x}^{7}} + \frac{2}{{x}^{5}}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{1 + x} - \frac{2}{x}\right) + \frac{1}{x - 1}\\ \end{array}\]

Reproduce

herbie shell --seed 2019004 
(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: 35.7s)Debug log

sample110.0ms

Algorithm
intervals

simplify58.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune4.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 10.5b

localize18.0ms

Local error

Found 4 expressions with local error:

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

rewrite47.0ms

Algorithm
rewrite-expression-head
Counts
4 → 76
Calls

4 calls. Slowest were:

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

series71.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

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

simplify3.4s

Counts
48 → 88
Calls

48 calls. Slowest were:

508.0ms
(* (+ (/ 1 (+ x 1)) (/ 2 x)) (- x 1))
413.0ms
(- (+ (* 2 x) (+ (* 2 (pow x 3)) (* 2 (/ 1 x)))))
332.0ms
(+ (* (- (* 1 x) (* (+ x 1) 2)) (- x 1)) (* (* (+ x 1) x) 1))

prune533.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.1b

localize5.0ms

Local error

Found 4 expressions with local error:

2.7b
(+ (* 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))

rewrite27.0ms

Algorithm
rewrite-expression-head
Counts
4 → 72
Calls

4 calls. Slowest were:

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

series89.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

48.0ms
(+ (* 1 (- (/ 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))

simplify3.2s

Counts
44 → 84
Calls

44 calls. Slowest were:

493.0ms
(* (+ (/ 1 (+ x 1)) (/ 2 x)) (- x 1))
437.0ms
(- (+ (* 2 x) (+ (* 2 (pow x 3)) (* 2 (/ 1 x)))))
293.0ms
(+ (* (* 1 (- (* 1 x) (* (+ x 1) 2))) (- x 1)) (* (* (+ x 1) x) 1))

prune723.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0.1b

localize59.0ms

Local error

Found 4 expressions with local error:

14.2b
(/ (* (+ (/ 2 x) (/ 1 (+ x 1))) (+ 1 (+ (* (+ -1 x) (/ -2 x)) (/ (+ -1 x) (+ x 1))))) (* (+ (/ 1 (+ x 1)) (/ 2 x)) (- x 1)))
7.1b
(+ 1 (+ (* (+ -1 x) (/ -2 x)) (/ (+ -1 x) (+ x 1))))
0.2b
(+ (/ 2 x) (/ 1 (+ x 1)))
0.2b
(+ (/ 1 (+ x 1)) (/ 2 x))

rewrite74.0ms

Algorithm
rewrite-expression-head
Counts
4 → 82
Calls

4 calls. Slowest were:

44.0ms
(/ (* (+ (/ 2 x) (/ 1 (+ x 1))) (+ 1 (+ (* (+ -1 x) (/ -2 x)) (/ (+ -1 x) (+ x 1))))) (* (+ (/ 1 (+ x 1)) (/ 2 x)) (- x 1)))
12.0ms
(+ 1 (+ (* (+ -1 x) (/ -2 x)) (/ (+ -1 x) (+ x 1))))
9.0ms
(+ (/ 1 (+ x 1)) (/ 2 x))

series545.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

424.0ms
(+ 1 (+ (* (+ -1 x) (/ -2 x)) (/ (+ -1 x) (+ x 1))))
98.0ms
(/ (* (+ (/ 2 x) (/ 1 (+ x 1))) (+ 1 (+ (* (+ -1 x) (/ -2 x)) (/ (+ -1 x) (+ x 1))))) (* (+ (/ 1 (+ x 1)) (/ 2 x)) (- x 1)))
12.0ms
(+ (/ 2 x) (/ 1 (+ x 1)))
11.0ms
(+ (/ 1 (+ x 1)) (/ 2 x))

simplify8.6s

Counts
57 → 94
Calls

57 calls. Slowest were:

905.0ms
(/ (* (* (* (+ (/ 2 x) (/ 1 (+ x 1))) (+ 1 (+ (* (+ -1 x) (/ -2 x)) (/ (+ -1 x) (+ x 1))))) (* (+ (/ 2 x) (/ 1 (+ x 1))) (+ 1 (+ (* (+ -1 x) (/ -2 x)) (/ (+ -1 x) (+ x 1)))))) (* (+ (/ 2 x) (/ 1 (+ x 1))) (+ 1 (+ (* (+ -1 x) (/ -2 x)) (/ (+ -1 x) (+ x 1)))))) (* (* (* (+ (/ 1 (+ x 1)) (/ 2 x)) (+ (/ 1 (+ x 1)) (/ 2 x))) (+ (/ 1 (+ x 1)) (/ 2 x))) (* (* (- x 1) (- x 1)) (- x 1))))
695.0ms
(/ (* (* (* (+ (/ 2 x) (/ 1 (+ x 1))) (+ 1 (+ (* (+ -1 x) (/ -2 x)) (/ (+ -1 x) (+ x 1))))) (* (+ (/ 2 x) (/ 1 (+ x 1))) (+ 1 (+ (* (+ -1 x) (/ -2 x)) (/ (+ -1 x) (+ x 1)))))) (* (+ (/ 2 x) (/ 1 (+ x 1))) (+ 1 (+ (* (+ -1 x) (/ -2 x)) (/ (+ -1 x) (+ x 1)))))) (* (* (* (+ (/ 1 (+ x 1)) (/ 2 x)) (- x 1)) (* (+ (/ 1 (+ x 1)) (/ 2 x)) (- x 1))) (* (+ (/ 1 (+ x 1)) (/ 2 x)) (- x 1))))
666.0ms
(* (+ (pow (/ 2 x) 3) (pow (/ 1 (+ x 1)) 3)) (+ 1 (+ (* (+ -1 x) (/ -2 x)) (/ (+ -1 x) (+ x 1)))))

prune1.1s

Pruning

5 alts after pruning (3 fresh and 2 done)

Merged error: 0.0b

localize49.0ms

Local error

Found 4 expressions with local error:

7.2b
(- (/ 2 (pow x 4)) (- (/ (/ 2 x) (* x x)) (/ (/ 2 x) x)))
5.8b
(- (/ (/ 2 x) (* x x)) (/ (/ 2 x) x))
1.4b
(/ (* (+ (/ 2 x) (/ 1 (+ x 1))) (- (/ 2 (pow x 4)) (- (/ (/ 2 x) (* x x)) (/ (/ 2 x) x)))) (* (+ (/ 1 (+ x 1)) (/ 2 x)) (- x 1)))
0.3b
(/ 2 (pow x 4))

rewrite70.0ms

Algorithm
rewrite-expression-head
Counts
4 → 109
Calls

4 calls. Slowest were:

32.0ms
(/ (* (+ (/ 2 x) (/ 1 (+ x 1))) (- (/ 2 (pow x 4)) (- (/ (/ 2 x) (* x x)) (/ (/ 2 x) x)))) (* (+ (/ 1 (+ x 1)) (/ 2 x)) (- x 1)))
28.0ms
(- (/ 2 (pow x 4)) (- (/ (/ 2 x) (* x x)) (/ (/ 2 x) x)))
7.0ms
(- (/ (/ 2 x) (* x x)) (/ (/ 2 x) x))

series109.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

40.0ms
(/ (* (+ (/ 2 x) (/ 1 (+ x 1))) (- (/ 2 (pow x 4)) (- (/ (/ 2 x) (* x x)) (/ (/ 2 x) x)))) (* (+ (/ 1 (+ x 1)) (/ 2 x)) (- x 1)))
38.0ms
(- (/ (/ 2 x) (* x x)) (/ (/ 2 x) x))
16.0ms
(/ 2 (pow x 4))
15.0ms
(- (/ 2 (pow x 4)) (- (/ (/ 2 x) (* x x)) (/ (/ 2 x) x)))

simplify13.8s

Counts
90 → 121
Calls

90 calls. Slowest were:

707.0ms
(/ (* (* (* (+ (/ 2 x) (/ 1 (+ x 1))) (+ (/ 2 x) (/ 1 (+ x 1)))) (+ (/ 2 x) (/ 1 (+ x 1)))) (* (* (- (/ 2 (pow x 4)) (- (/ (/ 2 x) (* x x)) (/ (/ 2 x) x))) (- (/ 2 (pow x 4)) (- (/ (/ 2 x) (* x x)) (/ (/ 2 x) x)))) (- (/ 2 (pow x 4)) (- (/ (/ 2 x) (* x x)) (/ (/ 2 x) x))))) (* (* (* (+ (/ 1 (+ x 1)) (/ 2 x)) (- x 1)) (* (+ (/ 1 (+ x 1)) (/ 2 x)) (- x 1))) (* (+ (/ 1 (+ x 1)) (/ 2 x)) (- x 1))))
673.0ms
(- (+ (log (+ (/ 2 x) (/ 1 (+ x 1)))) (log (- (/ 2 (pow x 4)) (- (/ (/ 2 x) (* x x)) (/ (/ 2 x) x))))) (+ (log (+ (/ 1 (+ x 1)) (/ 2 x))) (log (- x 1))))
663.0ms
(/ (* (* (* (+ (/ 2 x) (/ 1 (+ x 1))) (+ (/ 2 x) (/ 1 (+ x 1)))) (+ (/ 2 x) (/ 1 (+ x 1)))) (* (* (- (/ 2 (pow x 4)) (- (/ (/ 2 x) (* x x)) (/ (/ 2 x) x))) (- (/ 2 (pow x 4)) (- (/ (/ 2 x) (* x x)) (/ (/ 2 x) x)))) (- (/ 2 (pow x 4)) (- (/ (/ 2 x) (* x x)) (/ (/ 2 x) x))))) (* (* (* (+ (/ 1 (+ x 1)) (/ 2 x)) (+ (/ 1 (+ x 1)) (/ 2 x))) (+ (/ 1 (+ x 1)) (/ 2 x))) (* (* (- x 1) (- x 1)) (- x 1))))

prune1.0s

Pruning

6 alts after pruning (4 fresh and 2 done)

Merged error: 0b

regimes44.0ms

Accuracy

99.5% (0.1b remaining)

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

bsearch119.0ms

end0.0ms

sample1.8s

Algorithm
intervals