Average Error: 14.9 → 0.0
Time: 13.1s
Precision: 64
Internal Precision: 128
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -59936.72473869073 \lor \neg \left(x \le 51139.341490639854\right):\\ \;\;\;\;\left(\frac{1}{x} + \frac{1}{{x}^{5}}\right) - \frac{1}{{x}^{3}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{(x \cdot x + 1)_*}\\ \end{array}\]

Error

Bits error versus x

Target

Original14.9
Target0.1
Herbie0.0
\[\frac{1}{x + \frac{1}{x}}\]

Derivation

  1. Split input into 2 regimes
  2. if x < -59936.72473869073 or 51139.341490639854 < x

    1. Initial program 30.1

      \[\frac{x}{x \cdot x + 1}\]
    2. Simplified30.1

      \[\leadsto \color{blue}{\frac{x}{(x \cdot x + 1)_*}}\]
    3. Taylor expanded around -inf 0.0

      \[\leadsto \color{blue}{\left(\frac{1}{{x}^{5}} + \frac{1}{x}\right) - \frac{1}{{x}^{3}}}\]

    if -59936.72473869073 < x < 51139.341490639854

    1. Initial program 0.0

      \[\frac{x}{x \cdot x + 1}\]
    2. Simplified0.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -59936.72473869073 \lor \neg \left(x \le 51139.341490639854\right):\\ \;\;\;\;\left(\frac{1}{x} + \frac{1}{{x}^{5}}\right) - \frac{1}{{x}^{3}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{(x \cdot x + 1)_*}\\ \end{array}\]

Reproduce

herbie shell --seed 2019004 +o rules:numerics
(FPCore (x)
  :name "x / (x^2 + 1)"

  :herbie-target
  (/ 1 (+ x (/ 1 x)))

  (/ x (+ (* x x) 1)))

Details

Time bar (total: 12.6s)Debug log

sample30.0ms

Algorithm
intervals

simplify5.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

5.0ms
(/ x (+ (* x x) 1))

prune12.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 17.8b

localize13.0ms

Local error

Found 1 expressions with local error:

17.8b
(/ x (fma x x 1))

rewrite1.0ms

Algorithm
rewrite-expression-head
Counts
1 → 15
Calls

1 calls. Slowest were:

1.0ms
(/ x (fma x x 1))

series48.0ms

Counts
1 → 3
Calls

1 calls. Slowest were:

47.0ms
(/ x (fma x x 1))

simplify171.0ms

Counts
6 → 18
Calls

6 calls. Slowest were:

60.0ms
(- (+ (/ 1 (pow x 5)) (/ 1 x)) (/ 1 (pow x 3)))
59.0ms
(- (+ (/ 1 (pow x 5)) (/ 1 x)) (/ 1 (pow x 3)))
43.0ms
(- (+ x (pow x 5)) (pow x 3))

prune130.0ms

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0.0b

localize39.0ms

Local error

Found 3 expressions with local error:

17.7b
(- (+ (/ 1 (pow x 5)) (/ 1 x)) (/ 1 (pow x 3)))
0.4b
(/ 1 (pow x 3))
0.1b
(/ 1 (pow x 5))

rewrite63.0ms

Algorithm
rewrite-expression-head
Counts
3 → 105
Calls

3 calls. Slowest were:

58.0ms
(- (+ (/ 1 (pow x 5)) (/ 1 x)) (/ 1 (pow x 3)))
1.0ms
(/ 1 (pow x 3))
1.0ms
(/ 1 (pow x 5))

series65.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

26.0ms
(- (+ (/ 1 (pow x 5)) (/ 1 x)) (/ 1 (pow x 3)))
19.0ms
(/ 1 (pow x 3))
19.0ms
(/ 1 (pow x 5))

simplify7.4s

Counts
97 → 114
Calls

97 calls. Slowest were:

403.0ms
(* (- (/ 1 (pow x 5)) (/ 1 x)) (pow x 3))
308.0ms
(- (* (+ (pow (/ 1 (pow x 5)) 3) (pow (/ 1 x) 3)) (pow x 3)) (* (+ (* (/ 1 (pow x 5)) (/ 1 (pow x 5))) (- (* (/ 1 x) (/ 1 x)) (* (/ 1 (pow x 5)) (/ 1 x)))) 1))
277.0ms
(- (* (+ (* 1 x) (* (pow x 5) 1)) (pow x 3)) (* (* (pow x 5) x) 1))

prune883.0ms

Pruning

3 alts after pruning (1 fresh and 2 done)

Merged error: 0.0b

localize11.0ms

Local error

Found 1 expressions with local error:

21.7b
(- (+ x (pow x 5)) (pow x 3))

rewrite13.0ms

Algorithm
rewrite-expression-head
Counts
1 → 35
Calls

1 calls. Slowest were:

12.0ms
(- (+ x (pow x 5)) (pow x 3))

series21.0ms

Counts
1 → 3
Calls

1 calls. Slowest were:

21.0ms
(- (+ x (pow x 5)) (pow x 3))

simplify2.2s

Counts
39 → 38
Calls

39 calls. Slowest were:

294.0ms
(fma (- (cbrt (pow x 3))) (* (cbrt (pow x 3)) (cbrt (pow x 3))) (* (cbrt (pow x 3)) (* (cbrt (pow x 3)) (cbrt (pow x 3)))))
229.0ms
(fma (- (cbrt (pow x 3))) (* (cbrt (pow x 3)) (cbrt (pow x 3))) (* (cbrt (pow x 3)) (* (cbrt (pow x 3)) (cbrt (pow x 3)))))
219.0ms
(fma (- (cbrt (pow x 3))) (* (cbrt (pow x 3)) (cbrt (pow x 3))) (* (cbrt (pow x 3)) (* (cbrt (pow x 3)) (cbrt (pow x 3)))))

prune317.0ms

Pruning

3 alts after pruning (0 fresh and 3 done)

Merged error: 0.0b

regimes58.0ms

Accuracy

100% (0.0b remaining)

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

bsearch126.0ms

end0.0ms

sample1.0s

Algorithm
intervals