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

Error

Bits error versus x

Target

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

Derivation

  1. Initial program 19.7

    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
  2. Using strategy rm
  3. Applied frac-sub19.7

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

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

    \[\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}}\]
  7. Applied associate-/l/19.5

    \[\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)}}\]
  8. Simplified0.8

    \[\leadsto \frac{\color{blue}{1}}{\left(\sqrt{x} \cdot \sqrt{x + 1}\right) \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)}\]
  9. Using strategy rm
  10. Applied pow10.8

    \[\leadsto \frac{1}{\left(\sqrt{x} \cdot \sqrt{x + 1}\right) \cdot \color{blue}{{\left(\sqrt{x + 1} + \sqrt{x}\right)}^{1}}}\]
  11. Applied pow10.8

    \[\leadsto \frac{1}{\color{blue}{{\left(\sqrt{x} \cdot \sqrt{x + 1}\right)}^{1}} \cdot {\left(\sqrt{x + 1} + \sqrt{x}\right)}^{1}}\]
  12. Applied pow-prod-down0.8

    \[\leadsto \frac{1}{\color{blue}{{\left(\left(\sqrt{x} \cdot \sqrt{x + 1}\right) \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)\right)}^{1}}}\]
  13. Simplified0.6

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

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

Reproduce

herbie shell --seed 2019008 +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: 16.5s)Debug log

sample137.0ms

Algorithm
intervals

simplify6.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune19.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 19.1b

localize16.0ms

Local error

Found 4 expressions with local error:

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

rewrite12.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
(sqrt (+ x 1))

series98.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

42.0ms
(- (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1))))
20.0ms
(/ 1 (sqrt (+ x 1)))
19.0ms
(/ 1 (sqrt x))
18.0ms
(sqrt (+ x 1))

simplify3.7s

Counts
92 → 119
Calls

92 calls. Slowest were:

205.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))))))
186.0ms
(fma (- (sqrt (- x 1))) (/ 1 (sqrt (- (* x x) (* 1 1)))) (* (sqrt (- x 1)) (/ 1 (sqrt (- (* x x) (* 1 1))))))
177.0ms
(fma (sqrt (/ 1 (sqrt x))) (sqrt (/ 1 (sqrt x))) (- (* (sqrt (+ (* x x) (- (* 1 1) (* x 1)))) (/ 1 (sqrt (+ (pow x 3) (pow 1 3)))))))

prune975.0ms

Pruning

10 alts after pruning (10 fresh and 0 done)

Merged error: 18.6b

localize8.0ms

Local error

Found 4 expressions with local error:

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

rewrite40.0ms

Algorithm
rewrite-expression-head
Counts
4 → 117
Calls

4 calls. Slowest were:

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

series152.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

65.0ms
(/ (- (sqrt (+ x 1)) (sqrt x)) (* (sqrt x) (sqrt (+ x 1))))
38.0ms
(- (sqrt (+ x 1)) (sqrt x))
36.0ms
(* (sqrt x) (sqrt (+ x 1)))
13.0ms
(sqrt (+ x 1))

simplify2.2s

Counts
106 → 129
Calls

106 calls. Slowest were:

638.0ms
(* (* (* (sqrt x) (sqrt x)) (sqrt x)) (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))))
85.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)))))
83.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)))))

prune1.1s

Pruning

2 alts after pruning (2 fresh and 0 done)

Merged error: 0.3b

localize8.0ms

Local error

Found 4 expressions with local error:

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

rewrite54.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)))
21.0ms
(/ 1 (* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x))))
5.0ms
(+ (sqrt (+ x 1)) (sqrt x))

series213.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

87.0ms
(/ 1 (* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x))))
76.0ms
(* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x)))
28.0ms
(+ (sqrt (+ x 1)) (sqrt x))
21.0ms
(* (sqrt x) (sqrt (+ x 1)))

simplify3.4s

Counts
71 → 117
Calls

71 calls. Slowest were:

590.0ms
(* (* (* (sqrt x) (sqrt x)) (sqrt x)) (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))))
204.0ms
(* (sqrt (+ (* x x) (- (* 1 1) (* x 1)))) (+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x)))))
202.0ms
(* (* (sqrt x) (sqrt (+ (pow x 3) (pow 1 3)))) (+ (pow (sqrt (+ x 1)) 3) (pow (sqrt x) 3)))

prune911.0ms

Pruning

10 alts after pruning (10 fresh and 0 done)

Merged error: 0.0b

localize17.0ms

Local error

Found 4 expressions with local error:

0.2b
(/ 1 (pow (fma x (sqrt (+ x 1)) (fma (sqrt x) x (sqrt x))) 1))
0.1b
(fma (sqrt x) x (sqrt x))
0.0b
(fma x (sqrt (+ x 1)) (fma (sqrt x) x (sqrt x)))
0.0b
(sqrt (+ x 1))

rewrite3.0ms

Algorithm
rewrite-expression-head
Counts
4 → 59
Calls

4 calls. Slowest were:

1.0ms
(/ 1 (pow (fma x (sqrt (+ x 1)) (fma (sqrt x) x (sqrt x))) 1))
1.0ms
(sqrt (+ x 1))
0.0ms
(fma (sqrt x) x (sqrt x))

series159.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

62.0ms
(/ 1 (pow (fma x (sqrt (+ x 1)) (fma (sqrt x) x (sqrt x))) 1))
54.0ms
(fma x (sqrt (+ x 1)) (fma (sqrt x) x (sqrt x)))
31.0ms
(fma (sqrt x) x (sqrt x))
12.0ms
(sqrt (+ x 1))

simplify263.0ms

Counts
25 → 71
Calls

25 calls. Slowest were:

58.0ms
(- (+ (* 1/2 x) 1) (* 1/8 (pow x 2)))
43.0ms
(pow (sqrt (fma x (sqrt (+ x 1)) (fma (sqrt x) x (sqrt x)))) 1)
28.0ms
(cbrt (pow (fma x (sqrt (+ x 1)) (fma (sqrt x) x (sqrt x))) 1))

prune546.0ms

Pruning

8 alts after pruning (7 fresh and 1 done)

Merged error: 0.0b

regimes70.0ms

Accuracy

0% (0.6b remaining)

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

bsearch1.0ms

end0.0ms

sample2.4s

Algorithm
intervals