Average Error: 19.5 → 0.3
Time: 24.0s
Precision: 64
Internal Precision: 128
\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
\[\frac{\frac{1}{\sqrt{x}}}{(\left(\sqrt{x}\right) \cdot \left(\sqrt{x + 1}\right) + \left(x + 1\right))_*}\]

Error

Bits error versus x

Target

Original19.5
Target0.7
Herbie0.3
\[\frac{1}{\left(x + 1\right) \cdot \sqrt{x} + x \cdot \sqrt{x + 1}}\]

Derivation

  1. Initial program 19.5

    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
  2. Initial simplification19.5

    \[\leadsto \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
  3. Using strategy rm
  4. Applied frac-sub19.5

    \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}}\]
  5. Simplified19.5

    \[\leadsto \frac{\color{blue}{\sqrt{x + 1} - \sqrt{x}}}{\sqrt{x} \cdot \sqrt{x + 1}}\]
  6. Using strategy rm
  7. Applied flip--19.4

    \[\leadsto \frac{\color{blue}{\frac{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x + 1} + \sqrt{x}}}}{\sqrt{x} \cdot \sqrt{x + 1}}\]
  8. Applied associate-/l/19.4

    \[\leadsto \color{blue}{\frac{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}{\left(\sqrt{x} \cdot \sqrt{x + 1}\right) \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)}}\]
  9. Simplified0.8

    \[\leadsto \frac{\color{blue}{1}}{\left(\sqrt{x} \cdot \sqrt{x + 1}\right) \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)}\]
  10. Using strategy rm
  11. Applied associate-/r*0.4

    \[\leadsto \color{blue}{\frac{\frac{1}{\sqrt{x} \cdot \sqrt{x + 1}}}{\sqrt{x + 1} + \sqrt{x}}}\]
  12. Using strategy rm
  13. Applied *-un-lft-identity0.4

    \[\leadsto \frac{\frac{1}{\sqrt{x} \cdot \sqrt{x + 1}}}{\sqrt{x + 1} + \color{blue}{1 \cdot \sqrt{x}}}\]
  14. Applied *-un-lft-identity0.4

    \[\leadsto \frac{\frac{1}{\sqrt{x} \cdot \sqrt{x + 1}}}{\color{blue}{1 \cdot \sqrt{x + 1}} + 1 \cdot \sqrt{x}}\]
  15. Applied distribute-lft-out0.4

    \[\leadsto \frac{\frac{1}{\sqrt{x} \cdot \sqrt{x + 1}}}{\color{blue}{1 \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)}}\]
  16. Applied *-un-lft-identity0.4

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

    \[\leadsto \color{blue}{\frac{1}{1} \cdot \frac{\frac{1}{\sqrt{x} \cdot \sqrt{x + 1}}}{\sqrt{x + 1} + \sqrt{x}}}\]
  18. Simplified0.4

    \[\leadsto \color{blue}{1} \cdot \frac{\frac{1}{\sqrt{x} \cdot \sqrt{x + 1}}}{\sqrt{x + 1} + \sqrt{x}}\]
  19. Simplified0.3

    \[\leadsto 1 \cdot \color{blue}{\frac{\frac{1}{\sqrt{x}}}{(\left(\sqrt{x}\right) \cdot \left(\sqrt{x + 1}\right) + \left(x + 1\right))_*}}\]
  20. Final simplification0.3

    \[\leadsto \frac{\frac{1}{\sqrt{x}}}{(\left(\sqrt{x}\right) \cdot \left(\sqrt{x + 1}\right) + \left(x + 1\right))_*}\]

Reproduce

herbie shell --seed 2018360 +o rules:numerics
(FPCore (x)
  :name "2isqrt (example 3.6)"

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

  (- (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1)))))

Details

Time bar (total: 18.3s)Debug log

start213.0ms

Algorithm
intervals

setup28.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 18.7b

localize47.0ms

Local error

Found 4 expressions with local error:

2.7b
(- (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1))))
0.3b
(/ 1 (sqrt x))
0.1b
(/ 1 (sqrt (+ x 1)))
0.0b
(sqrt (+ x 1))

rewrite14.0ms

Algorithm
rewrite-expression-head
Counts
4 → 107
Calls

4 calls. Slowest were:

7.0ms
(- (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1))))
2.0ms
(/ 1 (sqrt (+ x 1)))
1.0ms
(/ 1 (sqrt x))

series85.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

42.0ms
(- (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1))))
18.0ms
(sqrt (+ x 1))
13.0ms
(/ 1 (sqrt x))
12.0ms
(/ 1 (sqrt (+ x 1)))

simplify3.0s

Counts
92 → 119
Calls

92 calls. Slowest were:

163.0ms
(fma 1 (/ 1 (sqrt x)) (- (* (sqrt (- x 1)) (/ 1 (sqrt (- (* x x) (* 1 1)))))))
148.0ms
(fma (* (cbrt (/ 1 (sqrt x))) (cbrt (/ 1 (sqrt x)))) (cbrt (/ 1 (sqrt x))) (- (* (sqrt (- x 1)) (/ 1 (sqrt (- (* x x) (* 1 1)))))))
129.0ms
(fma (- (sqrt (- x 1))) (/ 1 (sqrt (- (* x x) (* 1 1)))) (* (sqrt (- x 1)) (/ 1 (sqrt (- (* x x) (* 1 1))))))

prune1.2s

Pruning

11 alts after pruning (11 fresh and 0 done)

Merged error: 18.2b

localize8.0ms

Local error

Found 4 expressions with local error:

2.7b
(- (sqrt (+ x 1)) (sqrt x))
0.2b
(* (sqrt x) (sqrt (+ x 1)))
0.1b
(/ (- (sqrt (+ x 1)) (sqrt x)) (* (sqrt x) (sqrt (+ x 1))))
0.0b
(sqrt (+ x 1))

rewrite33.0ms

Algorithm
rewrite-expression-head
Counts
4 → 117
Calls

4 calls. Slowest were:

18.0ms
(/ (- (sqrt (+ x 1)) (sqrt x)) (* (sqrt x) (sqrt (+ x 1))))
6.0ms
(- (sqrt (+ x 1)) (sqrt x))
4.0ms
(* (sqrt x) (sqrt (+ x 1)))

series147.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

74.0ms
(/ (- (sqrt (+ x 1)) (sqrt x)) (* (sqrt x) (sqrt (+ x 1))))
33.0ms
(* (sqrt x) (sqrt (+ x 1)))
29.0ms
(- (sqrt (+ x 1)) (sqrt x))
10.0ms
(sqrt (+ x 1))

simplify2.3s

Counts
106 → 129
Calls

106 calls. Slowest were:

778.0ms
(* (* (* (sqrt x) (sqrt x)) (sqrt x)) (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))))
80.0ms
(/ (* (* (- (sqrt (+ x 1)) (sqrt x)) (- (sqrt (+ x 1)) (sqrt x))) (- (sqrt (+ x 1)) (sqrt x))) (* (* (* (sqrt x) (sqrt (+ x 1))) (* (sqrt x) (sqrt (+ x 1)))) (* (sqrt x) (sqrt (+ x 1)))))
76.0ms
(/ (* (* (- (sqrt (+ x 1)) (sqrt x)) (- (sqrt (+ x 1)) (sqrt x))) (- (sqrt (+ x 1)) (sqrt x))) (* (* (* (sqrt x) (sqrt x)) (sqrt x)) (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1)))))

prune1.3s

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0.7b

localize17.0ms

Local error

Found 4 expressions with local error:

0.8b
(/ 1 (* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x))))
0.2b
(* (sqrt x) (sqrt (+ x 1)))
0.1b
(* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x)))
0.0b
(+ (sqrt (+ x 1)) (sqrt x))

rewrite63.0ms

Algorithm
rewrite-expression-head
Counts
4 → 105
Calls

4 calls. Slowest were:

32.0ms
(/ 1 (* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x))))
17.0ms
(* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x)))
7.0ms
(+ (sqrt (+ x 1)) (sqrt x))

series229.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

91.0ms
(/ 1 (* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x))))
85.0ms
(* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x)))
32.0ms
(* (sqrt x) (sqrt (+ x 1)))
21.0ms
(+ (sqrt (+ x 1)) (sqrt x))

simplify5.0s

Counts
71 → 117
Calls

71 calls. Slowest were:

530.0ms
(* (sqrt (+ (* x x) (- (* 1 1) (* x 1)))) (+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x)))))
500.0ms
(* (sqrt (- x 1)) (+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x)))))
483.0ms
(* (* (sqrt x) (sqrt (- (* x x) (* 1 1)))) (+ (pow (sqrt (+ x 1)) 3) (pow (sqrt x) 3)))

prune1.3s

Pruning

12 alts after pruning (12 fresh and 0 done)

Merged error: 0.0b

localize10.0ms

Local error

Found 4 expressions with local error:

0.2b
(* (sqrt x) (sqrt (+ x 1)))
0.1b
(/ 1 (* (sqrt x) (sqrt (+ x 1))))
0.1b
(/ (/ 1 (* (sqrt x) (sqrt (+ x 1)))) (+ (sqrt (+ x 1)) (sqrt x)))
0.0b
(+ (sqrt (+ x 1)) (sqrt x))

rewrite48.0ms

Algorithm
rewrite-expression-head
Counts
4 → 120
Calls

4 calls. Slowest were:

22.0ms
(/ (/ 1 (* (sqrt x) (sqrt (+ x 1)))) (+ (sqrt (+ x 1)) (sqrt x)))
8.0ms
(+ (sqrt (+ x 1)) (sqrt x))
7.0ms
(* (sqrt x) (sqrt (+ x 1)))

series227.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

121.0ms
(/ (/ 1 (* (sqrt x) (sqrt (+ x 1)))) (+ (sqrt (+ x 1)) (sqrt x)))
38.0ms
(/ 1 (* (sqrt x) (sqrt (+ x 1))))
37.0ms
(* (sqrt x) (sqrt (+ x 1)))
32.0ms
(+ (sqrt (+ x 1)) (sqrt x))

simplify2.1s

Counts
102 → 132
Calls

102 calls. Slowest were:

349.0ms
(* (* (* (sqrt x) (sqrt x)) (sqrt x)) (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))))
141.0ms
(+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x))))
106.0ms
(- (log (/ 1 (* (sqrt x) (sqrt (+ x 1))))) (log (+ (sqrt (+ x 1)) (sqrt x))))

prune1.0s

Pruning

7 alts after pruning (7 fresh and 0 done)

Merged error: 0.0b

regimes41.0ms

Accuracy

0% (0.2b remaining)

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

bsearch1.0ms