Average Error: 14.5 → 0.0
Time: 11.6s
Precision: 64
Internal Precision: 128
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.357340002977744 \cdot 10^{+154} \lor \neg \left(x \le 15474336.42221833\right):\\ \;\;\;\;\left(\frac{1}{x} + \frac{1}{{x}^{5}}\right) - \frac{1}{{x}^{3}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x}{\sqrt{(x \cdot x + 1)_*}}}{\sqrt{(x \cdot x + 1)_*}}\\ \end{array}\]

Error

Bits error versus x

Target

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

Derivation

  1. Split input into 2 regimes
  2. if x < -1.357340002977744e+154 or 15474336.42221833 < x

    1. Initial program 39.6

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

      \[\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 -1.357340002977744e+154 < x < 15474336.42221833

    1. Initial program 0.1

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

      \[\leadsto \color{blue}{\frac{x}{(x \cdot x + 1)_*}}\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt0.1

      \[\leadsto \frac{x}{\color{blue}{\sqrt{(x \cdot x + 1)_*} \cdot \sqrt{(x \cdot x + 1)_*}}}\]
    5. Applied associate-/r*0.0

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

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

Reproduce

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

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

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

Details

Time bar (total: 11.2s)Debug log

sample34.0ms

Algorithm
intervals

simplify5.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
5.0ms
(/ x (+ (* x x) 1))

prune12.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 12.7b

localize14.0ms

Local error

Found 1 expressions with local error:

12.7b
(/ x (fma x x 1))

rewrite1.0ms

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

series38.0ms

Counts
1 → 3
Calls
1 calls:
Slowest
38.0ms
(/ x (fma x x 1))

simplify178.0ms

Counts
6 → 18
Calls
6 calls:
Slowest
64.0ms
(- (+ (/ 1 (pow x 5)) (/ 1 x)) (/ 1 (pow x 3)))
63.0ms
(- (+ (/ 1 (pow x 5)) (/ 1 x)) (/ 1 (pow x 3)))
42.0ms
(- (+ x (pow x 5)) (pow x 3))
3.0ms
(sqrt (fma x x 1))
3.0ms
(cbrt (fma x x 1))

prune108.0ms

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 0b

localize8.0ms

Local error

Found 2 expressions with local error:

12.6b
(sqrt (fma x x 1))
12.6b
(sqrt (fma x x 1))

rewrite2.0ms

Algorithm
rewrite-expression-head
Rules
sqrt-prod
add-sqr-sqrt
add-cube-cbrt
*-un-lft-identity
add-log-exp
log1p-expm1-u
add-exp-log
pow1/2
add-cbrt-cube
rem-sqrt-square
pow1
expm1-log1p-u
Counts
2 → 28
Calls
2 calls:
Slowest
1.0ms
(sqrt (fma x x 1))
1.0ms
(sqrt (fma x x 1))

series47.0ms

Counts
2 → 6
Calls
2 calls:
Slowest
25.0ms
(sqrt (fma x x 1))
21.0ms
(sqrt (fma x x 1))

simplify838.0ms

Counts
14 → 34
Calls
14 calls:
Slowest
195.0ms
(- (+ x (* 1/2 (/ 1 x))) (* 1/8 (/ 1 (pow x 3))))
181.0ms
(- (* 1/8 (/ 1 (pow x 3))) (+ x (* 1/2 (/ 1 x))))
163.0ms
(- (* 1/8 (/ 1 (pow x 3))) (+ x (* 1/2 (/ 1 x))))
155.0ms
(- (+ x (* 1/2 (/ 1 x))) (* 1/8 (/ 1 (pow x 3))))
50.0ms
(- (+ (* 1/2 (pow x 2)) 1) (* 1/8 (pow x 4)))

prune256.0ms

Pruning

2 alts after pruning (1 fresh and 1 done)

Merged error: 0b

localize21.0ms

Local error

Found 3 expressions with local error:

19.8b
(- (+ (/ 1 (pow x 5)) (/ 1 x)) (/ 1 (pow x 3)))
0.2b
(/ 1 (pow x 3))
0.0b
(/ 1 (pow x 5))

rewrite32.0ms

Algorithm
rewrite-expression-head
Rules
52×*-un-lft-identity
42×div-inv
28×distribute-lft-out
28×prod-diff
19×add-sqr-sqrt
17×add-cube-cbrt
10×distribute-lft-out--
add-log-exp
associate-/r*
fma-neg
add-exp-log
rec-exp
log1p-expm1-u
frac-sub
add-cbrt-cube
pow1
expm1-log1p-u
inv-pow
pow-flip
diff-log
frac-2neg
clear-num
pow-to-exp
difference-of-squares
flip--
flip-+
associate--l+
frac-add
unpow3
flip3--
flip3-+
sub-neg
sum-log
cube-mult
Counts
3 → 105
Calls
3 calls:
Slowest
29.0ms
(- (+ (/ 1 (pow x 5)) (/ 1 x)) (/ 1 (pow x 3)))
1.0ms
(/ 1 (pow x 3))
1.0ms
(/ 1 (pow x 5))

series75.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
33.0ms
(/ 1 (pow x 5))
22.0ms
(/ 1 (pow x 3))
19.0ms
(- (+ (/ 1 (pow x 5)) (/ 1 x)) (/ 1 (pow x 3)))

simplify7.7s

Counts
97 → 114
Calls
97 calls:
Slowest
341.0ms
(* (- (/ 1 (pow x 5)) (/ 1 x)) (pow x 3))
318.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))
276.0ms
(- (* (- (* (/ 1 (pow x 5)) (/ 1 (pow x 5))) (* (/ 1 x) (/ 1 x))) (pow x 3)) (* (- (/ 1 (pow x 5)) (/ 1 x)) 1))
254.0ms
(- (* (+ (* 1 x) (* (pow x 5) 1)) (pow x 3)) (* (* (pow x 5) x) 1))
215.0ms
(fma 1 (+ (/ 1 (pow x 5)) (/ 1 x)) (- (* (/ 1 (pow x 3)) 1)))

prune936.0ms

Pruning

2 alts after pruning (0 fresh and 2 done)

Merged error: 0b

regimes47.0ms

Accuracy

100% (0.0b remaining)

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

bsearch95.0ms

end0.0ms

sample677.0ms

Algorithm
intervals