Average Error: 19.9 → 0.3
Time: 22.5s
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.9
Target0.7
Herbie0.3
\[\frac{1}{\left(x + 1\right) \cdot \sqrt{x} + x \cdot \sqrt{x + 1}}\]

Derivation

  1. Initial program 19.9

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

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

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

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

    \[\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.7

    \[\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}}}{\color{blue}{1 \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)}}\]
  14. Applied div-inv0.4

    \[\leadsto \frac{\color{blue}{1 \cdot \frac{1}{\sqrt{x} \cdot \sqrt{x + 1}}}}{1 \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)}\]
  15. 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}}}\]
  16. Simplified0.4

    \[\leadsto \color{blue}{1} \cdot \frac{\frac{1}{\sqrt{x} \cdot \sqrt{x + 1}}}{\sqrt{x + 1} + \sqrt{x}}\]
  17. 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))_*}}\]
  18. 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 2018362 +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: 17.0s)Debug log

start222.0ms

Algorithm
intervals

setup14.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 18.1b

localize25.0ms

Local error

Found 4 expressions with local error:

1.6b
(- (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1))))
0.3b
(/ 1 (sqrt x))
0.2b
(/ 1 (sqrt (+ x 1)))
0.0b
(sqrt (+ x 1))

rewrite10.0ms

Algorithm
rewrite-expression-head
Counts
4 → 107
Calls

4 calls. Slowest were:

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

series103.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

39.0ms
(- (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1))))
22.0ms
(/ 1 (sqrt (+ x 1)))
16.0ms
(/ 1 (sqrt x))
14.0ms
(sqrt (+ x 1))

simplify3.8s

Counts
92 → 119
Calls

92 calls. Slowest were:

191.0ms
(fma (- (sqrt (+ (* x x) (- (* 1 1) (* x 1))))) (/ 1 (sqrt (+ (pow x 3) (pow 1 3)))) (* (sqrt (+ (* x x) (- (* 1 1) (* x 1)))) (/ 1 (sqrt (+ (pow x 3) (pow 1 3))))))
190.0ms
(fma (- (sqrt (+ (* x x) (- (* 1 1) (* x 1))))) (/ 1 (sqrt (+ (pow x 3) (pow 1 3)))) (* (sqrt (+ (* x x) (- (* 1 1) (* x 1)))) (/ 1 (sqrt (+ (pow x 3) (pow 1 3))))))
185.0ms
(fma 1 (/ 1 (sqrt x)) (- (* (sqrt (+ (* x x) (- (* 1 1) (* x 1)))) (/ 1 (sqrt (+ (pow x 3) (pow 1 3)))))))

prune1.2s

Pruning

9 alts after pruning (9 fresh and 0 done)

Merged error: 17.7b

localize16.0ms

Local error

Found 4 expressions with local error:

1.6b
(- (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))

rewrite27.0ms

Algorithm
rewrite-expression-head
Counts
4 → 117
Calls

4 calls. Slowest were:

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

series166.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

85.0ms
(/ (- (sqrt (+ x 1)) (sqrt x)) (* (sqrt x) (sqrt (+ x 1))))
38.0ms
(* (sqrt x) (sqrt (+ x 1)))
33.0ms
(- (sqrt (+ x 1)) (sqrt x))
10.0ms
(sqrt (+ x 1))

simplify2.4s

Counts
106 → 129
Calls

106 calls. Slowest were:

755.0ms
(* (* (* (sqrt x) (sqrt x)) (sqrt x)) (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))))
120.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)))))
102.0ms
(- (+ x 1/2) (* 1/8 (/ 1 x)))

prune1.2s

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.5b

localize8.0ms

Local error

Found 4 expressions with local error:

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

rewrite56.0ms

Algorithm
rewrite-expression-head
Counts
4 → 105
Calls

4 calls. Slowest were:

22.0ms
(* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x)))
15.0ms
(/ 1 (* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x))))
9.0ms
(+ (sqrt (+ x 1)) (sqrt x))

series232.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

106.0ms
(/ 1 (* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x))))
71.0ms
(* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x)))
31.0ms
(* (sqrt x) (sqrt (+ x 1)))
24.0ms
(+ (sqrt (+ x 1)) (sqrt x))

simplify3.4s

Counts
71 → 117
Calls

71 calls. Slowest were:

520.0ms
(* (* (* (sqrt x) (sqrt x)) (sqrt x)) (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))))
215.0ms
(* (* (sqrt x) (sqrt (- (* x x) (* 1 1)))) (+ (pow (sqrt (+ x 1)) 3) (pow (sqrt x) 3)))
209.0ms
(* (sqrt (- x 1)) (+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x)))))

prune870.0ms

Pruning

12 alts after pruning (11 fresh and 1 done)

Merged error: 0.0b

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

rewrite30.0ms

Algorithm
rewrite-expression-head
Counts
4 → 120
Calls

4 calls. Slowest were:

13.0ms
(/ (/ 1 (* (sqrt x) (sqrt (+ x 1)))) (+ (sqrt (+ x 1)) (sqrt x)))
7.0ms
(/ 1 (* (sqrt x) (sqrt (+ x 1))))
5.0ms
(+ (sqrt (+ x 1)) (sqrt x))

series136.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

71.0ms
(/ (/ 1 (* (sqrt x) (sqrt (+ x 1)))) (+ (sqrt (+ x 1)) (sqrt x)))
23.0ms
(/ 1 (* (sqrt x) (sqrt (+ x 1))))
21.0ms
(* (sqrt x) (sqrt (+ x 1)))
21.0ms
(+ (sqrt (+ x 1)) (sqrt x))

simplify2.1s

Counts
102 → 132
Calls

102 calls. Slowest were:

438.0ms
(* (* (* (sqrt x) (sqrt x)) (sqrt x)) (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))))
132.0ms
(- (+ (* 3/8 (/ 1 (pow x 3))) (/ 1 x)) (* 1/2 (/ 1 (pow x 2))))
81.0ms
(- (log (/ 1 (* (sqrt x) (sqrt (+ x 1))))) (log (+ (sqrt (+ x 1)) (sqrt x))))

prune917.0ms

Pruning

11 alts after pruning (11 fresh and 0 done)

Merged error: 0.0b

regimes52.0ms

Accuracy

0% (0.3b remaining)

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

bsearch1.0ms