Average Error: 15.4 → 0.1
Time: 14.1s
Precision: 64
Internal Precision: 128
\[\frac{x}{x \cdot x + 1}\]
\[\begin{array}{l} \mathbf{if}\;x \le -5.315332958531357 \cdot 10^{+47} \lor \neg \left(x \le 536.2819961347985\right):\\ \;\;\;\;\left(\frac{1}{x} + \frac{1}{{x}^{5}}\right) - \frac{1}{{x}^{3}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{(x \cdot x + 1)_*}{x}}\\ \end{array}\]

Error

Bits error versus x

Target

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

Derivation

  1. Split input into 2 regimes
  2. if x < -5.315332958531357e+47 or 536.2819961347985 < x

    1. Initial program 33.4

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

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

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

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

    if -5.315332958531357e+47 < x < 536.2819961347985

    1. Initial program 0.0

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

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

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

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

Reproduce

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

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

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

Details

Time bar (total: 13.5s)Debug log

sample30.0ms

Algorithm
intervals

simplify5.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune12.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 17.0b

localize14.0ms

Local error

Found 1 expressions with local error:

17.0b
(/ 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))

series31.0ms

Counts
1 → 3
Calls

1 calls. Slowest were:

31.0ms
(/ x (fma x x 1))

simplify114.0ms

Counts
6 → 18
Calls

6 calls. Slowest were:

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

prune112.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.0b

localize9.0ms

Local error

Found 2 expressions with local error:

17.0b
(/ (fma x x 1) x)
0.1b
(/ 1 (/ (fma x x 1) x))

rewrite4.0ms

Algorithm
rewrite-expression-head
Counts
2 → 35
Calls

2 calls. Slowest were:

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

series91.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

54.0ms
(/ (fma x x 1) x)
37.0ms
(/ 1 (/ (fma x x 1) x))

simplify135.0ms

Counts
13 → 41
Calls

13 calls. Slowest were:

41.0ms
(- (+ (/ 1 (pow x 5)) (/ 1 x)) (/ 1 (pow x 3)))
33.0ms
(- (+ (/ 1 (pow x 5)) (/ 1 x)) (/ 1 (pow x 3)))
32.0ms
(- (+ x (pow x 5)) (pow x 3))

prune272.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 0.0b

localize24.0ms

Local error

Found 1 expressions with local error:

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

rewrite14.0ms

Algorithm
rewrite-expression-head
Counts
1 → 35
Calls

1 calls. Slowest were:

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

series35.0ms

Counts
1 → 3
Calls

1 calls. Slowest were:

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

simplify2.5s

Counts
39 → 38
Calls

39 calls. Slowest were:

333.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)))))
272.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)))))
241.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)))))

prune267.0ms

Pruning

4 alts after pruning (2 fresh and 2 done)

Merged error: 0.0b

localize30.0ms

Local error

Found 4 expressions with local error:

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

rewrite74.0ms

Algorithm
rewrite-expression-head
Counts
4 → 127
Calls

4 calls. Slowest were:

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

series132.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

46.0ms
(+ (/ 1 (pow x 5)) (/ 1 x))
34.0ms
(/ 1 (pow x 5))
28.0ms
(- (+ (/ 1 (pow x 5)) (/ 1 x)) (/ 1 (pow x 3)))
24.0ms
(/ 1 (pow x 3))

simplify7.2s

Counts
109 → 139
Calls

109 calls. Slowest were:

386.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))
330.0ms
(* (- (/ 1 (pow x 5)) (/ 1 x)) (pow x 3))
235.0ms
(* (+ (* (/ 1 (pow x 5)) (/ 1 (pow x 5))) (- (* (/ 1 x) (/ 1 x)) (* (/ 1 (pow x 5)) (/ 1 x)))) (pow x 3))

prune1.4s

Pruning

4 alts after pruning (1 fresh and 3 done)

Merged error: 0.0b

regimes41.0ms

Accuracy

99.4% (0.1b remaining)

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

bsearch139.0ms

end0.0ms

sample839.0ms

Algorithm
intervals