Average Error: 9.8 → 0.1
Time: 36.8s
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 -105.3708612428674 \lor \neg \left(x \le 102.08531486087007\right):\\ \;\;\;\;\frac{2}{{x}^{5}} + \left(\frac{\frac{\frac{2}{x}}{x}}{x} + \frac{2}{{x}^{7}}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{1 + x} - \frac{2}{x}\right) + \left(\sqrt[3]{\frac{1}{x - 1}} \cdot \sqrt[3]{\frac{1}{x - 1}}\right) \cdot \sqrt[3]{\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 < -105.3708612428674 or 102.08531486087007 < x

    1. Initial program 19.6

      \[\left(\frac{1}{x + 1} - \frac{2}{x}\right) + \frac{1}{x - 1}\]
    2. 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)}\]
    3. Simplified0.1

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

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

    if -105.3708612428674 < x < 102.08531486087007

    1. Initial program 0.0

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

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

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

Reproduce

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

sample100.0ms

Algorithm
intervals

simplify70.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune5.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 10.5b

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

rewrite71.0ms

Algorithm
rewrite-expression-head
Counts
4 → 144
Calls

4 calls. Slowest were:

47.0ms
(+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1)))
12.0ms
(- (/ 1 (+ x 1)) (/ 2 x))
2.0ms
(/ 1 (- x 1))

series102.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

61.0ms
(+ (- (/ 1 (+ x 1)) (/ 2 x)) (/ 1 (- x 1)))
18.0ms
(- (/ 1 (+ x 1)) (/ 2 x))
12.0ms
(/ 1 (- x 1))
11.0ms
(/ 1 (+ x 1))

simplify11.2s

Counts
127 → 156
Calls

127 calls. Slowest were:

790.0ms
(fma (/ 1 (+ (pow x 3) (pow 1 3))) (+ (* x x) (- (* 1 1) (* x 1))) (- (* (cbrt (/ 2 x)) (* (cbrt (/ 2 x)) (cbrt (/ 2 x))))))
681.0ms
(- (+ (* 2 x) (+ (* 2 (pow x 3)) (* 2 (/ 1 x)))))
657.0ms
(+ (* (- (* 1 x) (* (+ x 1) 2)) (- x 1)) (* (* (+ x 1) x) 1))

prune1.2s

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0.1b

localize24.0ms

Local error

Found 4 expressions with local error:

21.5b
(+ (- (/ 1 (+ x 1)) (/ 2 x)) (* (* (cbrt (/ 1 (- x 1))) (cbrt (/ 1 (- x 1)))) (cbrt (/ 1 (- x 1)))))
0.4b
(cbrt (/ 1 (- x 1)))
0.4b
(cbrt (/ 1 (- x 1)))
0.4b
(cbrt (/ 1 (- x 1)))

rewrite59.0ms

Algorithm
rewrite-expression-head
Counts
4 → 119
Calls

4 calls. Slowest were:

55.0ms
(+ (- (/ 1 (+ x 1)) (/ 2 x)) (* (* (cbrt (/ 1 (- x 1))) (cbrt (/ 1 (- x 1)))) (cbrt (/ 1 (- x 1)))))
1.0ms
(cbrt (/ 1 (- x 1)))
1.0ms
(cbrt (/ 1 (- x 1)))

series247.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

102.0ms
(+ (- (/ 1 (+ x 1)) (/ 2 x)) (* (* (cbrt (/ 1 (- x 1))) (cbrt (/ 1 (- x 1)))) (cbrt (/ 1 (- x 1)))))
58.0ms
(cbrt (/ 1 (- x 1)))
45.0ms
(cbrt (/ 1 (- x 1)))
42.0ms
(cbrt (/ 1 (- x 1)))

simplify15.2s

Counts
107 → 131
Calls

107 calls. Slowest were:

629.0ms
(- (+ (* 2 x) (+ (* 2 (pow x 3)) (* 2 (/ 1 x)))))
518.0ms
(+ (* (- (* 1 x) (* (+ x 1) 2)) (* (* (cbrt (- x 1)) (cbrt (- x 1))) (cbrt (- x 1)))) (* (* (+ x 1) x) (* (* (cbrt 1) (cbrt 1)) (cbrt 1))))
444.0ms
(fma (/ 1 (+ (pow x 3) (pow 1 3))) (+ (* x x) (- (* 1 1) (* x 1))) (- (* (sqrt (/ 2 x)) (sqrt (/ 2 x)))))

prune1.5s

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0.1b

localize41.0ms

Local error

Found 4 expressions with local error:

0.1b
(/ (/ 2 x) (* x x))
0.1b
(/ 2 (pow x 5))
0.1b
(/ 2 (pow x 7))
0.0b
(+ (/ (/ 2 x) (* x x)) (/ 2 (pow x 7)))

rewrite28.0ms

Algorithm
rewrite-expression-head
Counts
4 → 77
Calls

4 calls. Slowest were:

18.0ms
(+ (/ (/ 2 x) (* x x)) (/ 2 (pow x 7)))
7.0ms
(/ (/ 2 x) (* x x))
1.0ms
(/ 2 (pow x 5))

series162.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

81.0ms
(+ (/ (/ 2 x) (* x x)) (/ 2 (pow x 7)))
38.0ms
(/ 2 (pow x 7))
23.0ms
(/ (/ 2 x) (* x x))
19.0ms
(/ 2 (pow x 5))

simplify1.0s

Counts
41 → 89
Calls

41 calls. Slowest were:

548.0ms
(/ (* (* (/ 2 x) (/ 2 x)) (/ 2 x)) (* (* (* x x) (* x x)) (* x x)))
113.0ms
(+ (* 2 (/ 1 (pow x 7))) (* 2 (/ 1 (pow x 3))))
111.0ms
(+ (* 2 (/ 1 (pow x 7))) (* 2 (/ 1 (pow x 3))))

prune1.0s

Pruning

6 alts after pruning (5 fresh and 1 done)

Merged error: 0b

localize22.0ms

Local error

Found 4 expressions with local error:

0.1b
(/ 2 (pow x 5))
0.1b
(/ (/ 2 x) x)
0.1b
(/ 2 (pow x 7))
0.1b
(/ (/ (/ 2 x) x) x)

rewrite17.0ms

Algorithm
rewrite-expression-head
Counts
4 → 64
Calls

4 calls. Slowest were:

9.0ms
(/ (/ (/ 2 x) x) x)
5.0ms
(/ (/ 2 x) x)
1.0ms
(/ 2 (pow x 5))

series97.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

37.0ms
(/ 2 (pow x 7))
26.0ms
(/ 2 (pow x 5))
20.0ms
(/ (/ (/ 2 x) x) x)
13.0ms
(/ (/ 2 x) x)

simplify59.0ms

Counts
24 → 76
Calls

24 calls. Slowest were:

8.0ms
(/ 2 (pow x 3))
8.0ms
(/ 2 (pow x 3))
8.0ms
(/ 2 (pow x 3))

prune898.0ms

Pruning

6 alts after pruning (4 fresh and 2 done)

Merged error: 0b

regimes92.0ms

Accuracy

99.8% (0.1b remaining)

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

bsearch239.0ms

end0.0ms

sample2.6s

Algorithm
intervals