Average Error: 19.5 → 0.3
Time: 16.6s
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. Using strategy rm
  3. Applied frac-sub19.5

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

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

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

    \[\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 associate-/r*0.4

    \[\leadsto \color{blue}{\frac{\frac{1}{\sqrt{x} \cdot \sqrt{x + 1}}}{\sqrt{x + 1} + \sqrt{x}}}\]
  11. Using strategy rm
  12. 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)}}\]
  13. 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)}\]
  14. 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}}}\]
  15. Simplified0.4

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

sample129.0ms

Algorithm
intervals
Results
573×(pre true 80)
316×(body nan 80)
137×(body real 80)
60×(body real 640)
39×(body real 1280)
12×(body real 320)
(body real 160)

simplify6.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
6.0ms
(- (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1))))

prune5.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 17.1b

localize15.0ms

Local error

Found 4 expressions with local error:

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

rewrite11.0ms

Algorithm
rewrite-expression-head
Rules
24×prod-diff
23×*-un-lft-identity
22×add-sqr-sqrt
19×add-cube-cbrt
17×div-inv
12×sqrt-div
10×associate-/r/
associate-/r*
add-log-exp
flip-+
sqrt-prod
add-exp-log
flip3-+
pow1
distribute-lft-out--
pow-flip
log1p-expm1-u
fma-neg
add-cbrt-cube
expm1-log1p-u
pow1/2
inv-pow
frac-2neg
clear-num
rec-exp
difference-of-squares
flip--
frac-sub
diff-log
flip3--
sub-neg
rem-sqrt-square
Counts
4 → 107
Calls
4 calls:
Slowest
7.0ms
(- (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1))))
1.0ms
(/ 1 (sqrt (+ x 1)))
1.0ms
(/ 1 (sqrt x))
1.0ms
(sqrt (+ x 1))

series68.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
35.0ms
(- (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1))))
13.0ms
(/ 1 (sqrt (+ x 1)))
11.0ms
(/ 1 (sqrt x))
10.0ms
(sqrt (+ x 1))

simplify3.3s

Counts
92 → 119
Calls
92 calls:
Slowest
189.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))))))
174.0ms
(fma (- (sqrt (- x 1))) (/ 1 (sqrt (- (* x x) (* 1 1)))) (* (sqrt (- x 1)) (/ 1 (sqrt (- (* x x) (* 1 1))))))
161.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))))))
158.0ms
(fma (- (sqrt (- x 1))) (/ 1 (sqrt (- (* x x) (* 1 1)))) (* (sqrt (- x 1)) (/ 1 (sqrt (- (* x x) (* 1 1))))))
150.0ms
(fma 1 (/ 1 (sqrt x)) (- (* (sqrt (+ (* x x) (- (* 1 1) (* x 1)))) (/ 1 (sqrt (+ (pow x 3) (pow 1 3)))))))

prune730.0ms

Pruning

9 alts after pruning (9 fresh and 0 done)

Merged error: 16.6b

localize8.0ms

Local error

Found 4 expressions with local error:

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

rewrite38.0ms

Algorithm
rewrite-expression-head
Rules
37×add-sqr-sqrt
30×*-un-lft-identity
24×add-cube-cbrt
21×sqrt-prod
18×prod-diff
11×add-exp-log
11×add-cbrt-cube
difference-of-squares
add-log-exp
associate-/l*
associate-*r*
sqrt-div
fma-neg
times-frac
pow1
log1p-expm1-u
associate-*r/
expm1-log1p-u
distribute-lft-out--
flip-+
associate-*l*
pow1/2
flip3-+
associate-/l/
flip--
cbrt-unprod
associate-/r/
prod-exp
pow-prod-down
div-exp
flip3--
cbrt-undiv
div-inv
*-commutative
div-sub
diff-log
sqrt-unprod
frac-2neg
sub-neg
associate-/r*
clear-num
rem-sqrt-square
Counts
4 → 117
Calls
4 calls:
Slowest
19.0ms
(/ (- (sqrt (+ x 1)) (sqrt x)) (* (sqrt x) (sqrt (+ x 1))))
9.0ms
(- (sqrt (+ x 1)) (sqrt x))
9.0ms
(* (sqrt x) (sqrt (+ x 1)))
1.0ms
(sqrt (+ x 1))

series137.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
79.0ms
(/ (- (sqrt (+ x 1)) (sqrt x)) (* (sqrt x) (sqrt (+ x 1))))
25.0ms
(* (sqrt x) (sqrt (+ x 1)))
22.0ms
(- (sqrt (+ x 1)) (sqrt x))
11.0ms
(sqrt (+ x 1))

simplify1.7s

Counts
106 → 129
Calls
106 calls:
Slowest
502.0ms
(* (* (* (sqrt x) (sqrt x)) (sqrt x)) (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))))
78.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)))))
67.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)))))
58.0ms
(- (+ x 1/2) (* 1/8 (/ 1 x)))
50.0ms
(- (+ (* 1/2 x) 1) (* 1/8 (pow x 2)))

prune946.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.9b

localize8.0ms

Local error

Found 4 expressions with local error:

1.0b
(/ 1 (* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x))))
0.3b
(* (sqrt x) (sqrt (+ x 1)))
0.1b
(* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x)))
0.0b
(+ (sqrt (+ x 1)) (sqrt x))

rewrite47.0ms

Algorithm
rewrite-expression-head
Rules
18×associate-*r/
17×add-exp-log
17×pow1
14×flip-+
14×sqrt-div
14×flip3-+
14×*-un-lft-identity
11×add-cbrt-cube
10×add-cube-cbrt
10×associate-*r*
10×add-sqr-sqrt
associate-/r/
pow-prod-down
frac-times
prod-exp
add-log-exp
sqrt-prod
fma-def
log1p-expm1-u
cbrt-unprod
associate-*l/
associate-*l*
expm1-log1p-u
pow-flip
rec-exp
distribute-lft-out
*-commutative
pow1/2
inv-pow
div-inv
sqrt-unprod
distribute-lft-in
frac-2neg
sum-log
associate-/r*
clear-num
+-commutative
distribute-rgt-in
Counts
4 → 105
Calls
4 calls:
Slowest
18.0ms
(* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x)))
16.0ms
(/ 1 (* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x))))
7.0ms
(+ (sqrt (+ x 1)) (sqrt x))
4.0ms
(* (sqrt x) (sqrt (+ x 1)))

series193.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
81.0ms
(/ 1 (* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x))))
65.0ms
(* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x)))
24.0ms
(+ (sqrt (+ x 1)) (sqrt x))
23.0ms
(* (sqrt x) (sqrt (+ x 1)))

simplify2.9s

Counts
71 → 117
Calls
71 calls:
Slowest
417.0ms
(* (* (sqrt x) (sqrt (- (* x x) (* 1 1)))) (+ (pow (sqrt (+ x 1)) 3) (pow (sqrt x) 3)))
376.0ms
(* (* (* (sqrt x) (sqrt x)) (sqrt x)) (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))))
161.0ms
(* (* (sqrt x) (sqrt (+ (pow x 3) (pow 1 3)))) (+ (pow (sqrt (+ x 1)) 3) (pow (sqrt x) 3)))
149.0ms
(* (sqrt (+ (* x x) (- (* 1 1) (* x 1)))) (+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x)))))
143.0ms
(* (* (* (* (sqrt x) (sqrt x)) (sqrt x)) (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1)))) (* (* (+ (sqrt (+ x 1)) (sqrt x)) (+ (sqrt (+ x 1)) (sqrt x))) (+ (sqrt (+ x 1)) (sqrt x))))

prune685.0ms

Pruning

7 alts after pruning (7 fresh and 0 done)

Merged error: 0.0b

localize6.0ms

Local error

Found 4 expressions with local error:

0.3b
(* (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))

rewrite28.0ms

Algorithm
rewrite-expression-head
Rules
37×*-un-lft-identity
24×times-frac
21×add-cube-cbrt
21×add-sqr-sqrt
16×add-exp-log
14×associate-/r/
14×associate-*r/
14×sqrt-div
flip-+
flip3-+
pow1
distribute-lft-out
add-cbrt-cube
div-inv
add-log-exp
associate-/l*
sqrt-prod
associate-*r*
fma-def
associate-/r*
log1p-expm1-u
pow-prod-down
pow1/2
rec-exp
expm1-log1p-u
pow-flip
prod-exp
associate-*l*
div-exp
frac-2neg
clear-num
associate-/l/
inv-pow
cbrt-unprod
*-commutative
sqrt-unprod
sum-log
+-commutative
cbrt-undiv
Counts
4 → 120
Calls
4 calls:
Slowest
13.0ms
(/ (/ 1 (* (sqrt x) (sqrt (+ x 1)))) (+ (sqrt (+ x 1)) (sqrt x)))
5.0ms
(+ (sqrt (+ x 1)) (sqrt x))
4.0ms
(* (sqrt x) (sqrt (+ x 1)))
4.0ms
(/ 1 (* (sqrt x) (sqrt (+ x 1))))

series131.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
67.0ms
(/ (/ 1 (* (sqrt x) (sqrt (+ x 1)))) (+ (sqrt (+ x 1)) (sqrt x)))
23.0ms
(* (sqrt x) (sqrt (+ x 1)))
22.0ms
(/ 1 (* (sqrt x) (sqrt (+ x 1))))
19.0ms
(+ (sqrt (+ x 1)) (sqrt x))

simplify1.8s

Counts
102 → 132
Calls
102 calls:
Slowest
369.0ms
(* (* (* (sqrt x) (sqrt x)) (sqrt x)) (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))))
114.0ms
(- (+ (* 3/8 (/ 1 (pow x 3))) (/ 1 x)) (* 1/2 (/ 1 (pow x 2))))
72.0ms
(- (log (/ 1 (* (sqrt x) (sqrt (+ x 1))))) (log (+ (sqrt (+ x 1)) (sqrt x))))
70.0ms
(+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x))))
67.0ms
(/ (* (* (/ 1 (* (sqrt x) (sqrt (+ x 1)))) (/ 1 (* (sqrt x) (sqrt (+ x 1))))) (/ 1 (* (sqrt x) (sqrt (+ x 1))))) (* (* (+ (sqrt (+ x 1)) (sqrt x)) (+ (sqrt (+ x 1)) (sqrt x))) (+ (sqrt (+ x 1)) (sqrt x))))

prune746.0ms

Pruning

7 alts after pruning (7 fresh and 0 done)

Merged error: 0b

regimes32.0ms

Accuracy

0% (0.3b remaining)

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

bsearch1.0ms

end0.0ms

sample2.4s

Algorithm
intervals
Results
16094×(pre true 80)
8093×(body nan 80)
4119×(body real 80)
1835×(body real 640)
1120×(body real 1280)
614×(body real 320)
313×(body real 160)