Average Error: 14.5 → 0.0
Time: 5.8s
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

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

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. 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. Using strategy rm
    3. Applied add-sqr-sqrt0.1

      \[\leadsto \frac{x}{\color{blue}{\sqrt{x \cdot x + 1} \cdot \sqrt{x \cdot x + 1}}}\]
    4. 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 
(FPCore (x)
  :name "x / (x^2 + 1)"

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

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

Details

Time bar (total: 5.5s)Debug log

sample15.0ms

Algorithm
intervals

simplify2.0ms

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

prune4.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 12.7b

localize11.0ms

Local error

Found 1 expressions with local error:

12.7b
(/ x (+ (* x x) 1))

rewrite2.0ms

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

series21.0ms

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

simplify397.0ms

Counts
8 → 18
Calls
8 calls:
Slowest
240.0ms
(+ (* (* x x) (* x x)) (- (* 1 1) (* (* x x) 1)))
56.0ms
(- (+ (/ 1 (pow x 5)) (/ 1 x)) (/ 1 (pow x 3)))
46.0ms
(- (+ (/ 1 (pow x 5)) (/ 1 x)) (/ 1 (pow x 3)))
21.0ms
(- (+ x (pow x 5)) (pow x 3))
13.0ms
(- (* x x) 1)

prune122.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 (+ (* x x) 1))
12.6b
(sqrt (+ (* x x) 1))

rewrite4.0ms

Algorithm
rewrite-expression-head
Rules
sqrt-prod
add-sqr-sqrt
add-cube-cbrt
sqrt-div
*-un-lft-identity
add-log-exp
flip-+
add-exp-log
pow1/2
add-cbrt-cube
flip3-+
rem-sqrt-square
pow1
Counts
2 → 28
Calls
2 calls:
Slowest
2.0ms
(sqrt (+ (* x x) 1))
2.0ms
(sqrt (+ (* x x) 1))

series37.0ms

Counts
2 → 6
Calls
2 calls:
Slowest
21.0ms
(sqrt (+ (* x x) 1))
16.0ms
(sqrt (+ (* x x) 1))

simplify908.0ms

Counts
18 → 34
Calls
18 calls:
Slowest
168.0ms
(- (+ x (* 1/2 (/ 1 x))) (* 1/8 (/ 1 (pow x 3))))
154.0ms
(- (* 1/8 (/ 1 (pow x 3))) (+ x (* 1/2 (/ 1 x))))
116.0ms
(- (* 1/8 (/ 1 (pow x 3))) (+ x (* 1/2 (/ 1 x))))
111.0ms
(- (+ x (* 1/2 (/ 1 x))) (* 1/8 (/ 1 (pow x 3))))
101.0ms
(sqrt (- (* (* x x) (* x x)) (* 1 1)))

prune272.0ms

Pruning

2 alts after pruning (1 fresh and 1 done)

Merged error: 0b

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

rewrite57.0ms

Algorithm
rewrite-expression-head
Rules
20×*-un-lft-identity
15×div-inv
10×distribute-lft-out--
add-log-exp
distribute-lft-out
associate-/r*
add-sqr-sqrt
add-cube-cbrt
add-exp-log
rec-exp
frac-sub
add-cbrt-cube
pow1
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 → 64
Calls
3 calls:
Slowest
53.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
27.0ms
(- (+ (/ 1 (pow x 5)) (/ 1 x)) (/ 1 (pow x 3)))
26.0ms
(/ 1 (pow x 5))
22.0ms
(/ 1 (pow x 3))

simplify2.0s

Counts
39 → 73
Calls
39 calls:
Slowest
332.0ms
(* (- (/ 1 (pow x 5)) (/ 1 x)) (pow x 3))
238.0ms
(- (* (- (* (/ 1 (pow x 5)) (/ 1 (pow x 5))) (* (/ 1 x) (/ 1 x))) (pow x 3)) (* (- (/ 1 (pow x 5)) (/ 1 x)) 1))
209.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))
203.0ms
(- (* (+ (* 1 x) (* (pow x 5) 1)) (pow x 3)) (* (* (pow x 5) x) 1))
135.0ms
(* (+ (* (/ 1 (pow x 5)) (/ 1 (pow x 5))) (- (* (/ 1 x) (/ 1 x)) (* (/ 1 (pow x 5)) (/ 1 x)))) (pow x 3))

prune727.0ms

Pruning

2 alts after pruning (0 fresh and 2 done)

Merged error: 0b

regimes28.0ms

Accuracy

100% (0.0b remaining)

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

bsearch141.0ms

end0.0ms

sample607.0ms

Algorithm
intervals