Average Error: 15.2 → 0.0
Time: 7.3s
Precision: 64
Internal Precision: 128
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -7.345940124114164 \cdot 10^{+23} \lor \neg \left(x \le 937904.7083747658\right):\\ \;\;\;\;\left(\frac{1}{x} + \frac{1}{{x}^{5}}\right) - \frac{1}{{x}^{3}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{1}{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

Original15.2
Target0.1
Herbie0.0
\[\frac{1}{x + \frac{1}{x}}\]

Derivation

  1. Split input into 2 regimes
  2. if x < -7.345940124114164e+23 or 937904.7083747658 < x

    1. Initial program 31.6

      \[\frac{x}{x \cdot x + 1}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity31.6

      \[\leadsto \frac{x}{\color{blue}{1 \cdot \left(x \cdot x + 1\right)}}\]
    4. Applied associate-/r*31.6

      \[\leadsto \color{blue}{\frac{\frac{x}{1}}{x \cdot x + 1}}\]
    5. Taylor expanded around inf 0.0

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

    if -7.345940124114164e+23 < x < 937904.7083747658

    1. Initial program 0.0

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

      \[\leadsto \frac{x}{\color{blue}{1 \cdot \left(x \cdot x + 1\right)}}\]
    4. Applied associate-/r*0.0

      \[\leadsto \color{blue}{\frac{\frac{x}{1}}{x \cdot x + 1}}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity0.0

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

      \[\leadsto \frac{\color{blue}{x \cdot \frac{1}{1}}}{1 \cdot \left(x \cdot x + 1\right)}\]
    8. Applied times-frac0.0

      \[\leadsto \color{blue}{\frac{x}{1} \cdot \frac{\frac{1}{1}}{x \cdot x + 1}}\]
    9. Simplified0.0

      \[\leadsto \color{blue}{x} \cdot \frac{\frac{1}{1}}{x \cdot x + 1}\]
    10. Simplified0.0

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -7.345940124114164 \cdot 10^{+23} \lor \neg \left(x \le 937904.7083747658\right):\\ \;\;\;\;\left(\frac{1}{x} + \frac{1}{{x}^{5}}\right) - \frac{1}{{x}^{3}}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \frac{1}{x \cdot x + 1}\\ \end{array}\]

Reproduce

herbie shell --seed 2019008 
(FPCore (x)
  :name "x / (x^2 + 1)"

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

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

Details

Time bar (total: 7.0s)Debug log

sample29.0ms

Algorithm
intervals

simplify3.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune4.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 13.8b

localize8.0ms

Local error

Found 1 expressions with local error:

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

rewrite1.0ms

Algorithm
rewrite-expression-head
Counts
1 → 15
Calls

1 calls. Slowest were:

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

series18.0ms

Counts
1 → 3
Calls

1 calls. Slowest were:

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

simplify396.0ms

Counts
8 → 18
Calls

8 calls. Slowest were:

261.0ms
(+ (* (* x x) (* x x)) (- (* 1 1) (* (* x x) 1)))
54.0ms
(- (+ (/ 1 (pow x 5)) (/ 1 x)) (/ 1 (pow x 3)))
30.0ms
(- (+ (/ 1 (pow x 5)) (/ 1 x)) (/ 1 (pow x 3)))

prune113.0ms

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0b

localize10.0ms

Local error

Found 1 expressions with local error:

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

rewrite10.0ms

Algorithm
rewrite-expression-head
Counts
1 → 34
Calls

1 calls. Slowest were:

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

series30.0ms

Counts
1 → 3
Calls

1 calls. Slowest were:

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

simplify1.1s

Counts
36 → 37
Calls

36 calls. Slowest were:

518.0ms
(/ (* (* (/ x 1) (/ x 1)) (/ x 1)) (* (* (+ (* x x) 1) (+ (* x x) 1)) (+ (* x x) 1)))
240.0ms
(+ (* (* x x) (* x x)) (- (* 1 1) (* (* x x) 1)))
43.0ms
(- (+ (/ 1 (pow x 5)) (/ 1 x)) (/ 1 (pow x 3)))

prune277.0ms

Pruning

3 alts after pruning (2 fresh and 1 done)

Merged error: 0b

localize8.0ms

Local error

Found 2 expressions with local error:

13.7b
(* x (/ 1 (+ (* x x) 1)))
0.1b
(/ 1 (+ (* x x) 1))

rewrite4.0ms

Algorithm
rewrite-expression-head
Counts
2 → 34
Calls

2 calls. Slowest were:

2.0ms
(/ 1 (+ (* x x) 1))
1.0ms
(* x (/ 1 (+ (* x x) 1)))

series33.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

18.0ms
(* x (/ 1 (+ (* x x) 1)))
15.0ms
(/ 1 (+ (* x x) 1))

simplify830.0ms

Counts
20 → 40
Calls

20 calls. Slowest were:

282.0ms
(+ (* (* x x) (* x x)) (- (* 1 1) (* (* x x) 1)))
250.0ms
(+ (* (* x x) (* x x)) (- (* 1 1) (* (* x x) 1)))
60.0ms
(- (+ (/ 1 (pow x 5)) (/ 1 x)) (/ 1 (pow x 3)))

prune232.0ms

Pruning

3 alts after pruning (1 fresh and 2 done)

Merged error: 0b

localize20.0ms

Local error

Found 4 expressions with local error:

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

rewrite41.0ms

Algorithm
rewrite-expression-head
Counts
4 → 80
Calls

4 calls. Slowest were:

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

series100.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

33.0ms
(+ (/ 1 (pow x 5)) (/ 1 x))
25.0ms
(/ 1 (pow x 5))
24.0ms
(/ 1 (pow x 3))
18.0ms
(- (+ (/ 1 (pow x 5)) (/ 1 x)) (/ 1 (pow x 3)))

simplify2.2s

Counts
49 → 92
Calls

49 calls. Slowest were:

356.0ms
(- (+ (/ 1 (pow x 5)) (/ 1 x)) (/ 1 (pow x 3)))
293.0ms
(* (- (/ 1 (pow x 5)) (/ 1 x)) (pow x 3))
214.0ms
(- (* (+ (* 1 x) (* (pow x 5) 1)) (pow x 3)) (* (* (pow x 5) x) 1))

prune748.0ms

Pruning

3 alts after pruning (0 fresh and 3 done)

Merged error: 0b

regimes34.0ms

Accuracy

100% (0.0b remaining)

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

bsearch82.0ms

end0.0ms

sample629.0ms

Algorithm
intervals