Average Error: 19.7 → 0.4
Time: 14.7s
Precision: 64
Internal Precision: 128
\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
\[\frac{\frac{1}{\sqrt{x + 1} \cdot \sqrt{x}}}{\sqrt{x} + \sqrt{x + 1}}\]

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original19.7
Target0.6
Herbie0.4
\[\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.7

    \[\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. Final simplification0.4

    \[\leadsto \frac{\frac{1}{\sqrt{x + 1} \cdot \sqrt{x}}}{\sqrt{x} + \sqrt{x + 1}}\]

Reproduce

herbie shell --seed 2019018 
(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: 13.9s)Debug log

sample92.0ms

Algorithm
intervals
Results
18.0ms63×body640valid
14.0ms284×body80nan
9.0ms29×body1280valid
8.0ms126×body80valid
5.0ms26×body320valid
2.0ms13×body160valid

simplify12.0ms

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

prune10.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 23.1b

localize23.0ms

Local error

Found 4 expressions with local error:

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

rewrite8.0ms

Algorithm
rewrite-expression-head
Rules
12×*-un-lft-identity
11×add-sqr-sqrt
associate-/r*
add-cube-cbrt
add-log-exp
div-inv
sqrt-prod
add-exp-log
pow1
distribute-lft-out--
pow-flip
sqrt-div
add-cbrt-cube
pow1/2
inv-pow
flip-+
associate-/r/
flip3-+
frac-2neg
clear-num
rec-exp
difference-of-squares
flip--
frac-sub
diff-log
flip3--
sub-neg
rem-sqrt-square
Counts
4 → 71
Calls
4 calls:
Slowest
5.0ms
(- (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1))))
1.0ms
(/ 1 (sqrt (+ x 1)))
1.0ms
(/ 1 (sqrt x))
1.0ms
(sqrt (+ x 1))

series104.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
41.0ms
(- (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1))))
27.0ms
(/ 1 (sqrt (+ x 1)))
19.0ms
(/ 1 (sqrt x))
17.0ms
(sqrt (+ x 1))

simplify328.0ms

Counts
42 → 83
Calls
42 calls:
Slowest
63.0ms
(- (+ (* 1/2 x) 1) (* 1/8 (pow x 2)))
36.0ms
(- (+ (* 3/8 (pow x 2)) 1) (* 1/2 x))
33.0ms
(sqrt (+ (* x x) (- (* 1 1) (* x 1))))
29.0ms
(- (* 1 (sqrt (+ x 1))) (* (sqrt x) 1))
29.0ms
(/ (exp (/ 1 (sqrt x))) (exp (/ 1 (sqrt (+ x 1)))))

prune727.0ms

Pruning

12 alts after pruning (12 fresh and 0 done)

Merged error: 22.4b

localize19.0ms

Local error

Found 4 expressions with local error:

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

rewrite41.0ms

Algorithm
rewrite-expression-head
Rules
23×add-sqr-sqrt
16×*-un-lft-identity
11×add-exp-log
11×add-cbrt-cube
10×add-cube-cbrt
sqrt-prod
difference-of-squares
add-log-exp
associate-/l*
associate-*r*
sqrt-div
times-frac
pow1
associate-*r/
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 → 85
Calls
4 calls:
Slowest
22.0ms
(/ (- (sqrt (+ x 1)) (sqrt x)) (* (sqrt x) (sqrt (+ x 1))))
10.0ms
(- (sqrt (+ x 1)) (sqrt x))
8.0ms
(* (sqrt x) (sqrt (+ x 1)))
1.0ms
(sqrt (+ x 1))

series165.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
92.0ms
(/ (- (sqrt (+ x 1)) (sqrt x)) (* (sqrt x) (sqrt (+ x 1))))
34.0ms
(* (sqrt x) (sqrt (+ x 1)))
23.0ms
(- (sqrt (+ x 1)) (sqrt x))
17.0ms
(sqrt (+ x 1))

simplify979.0ms

Counts
65 → 97
Calls
65 calls:
Slowest
287.0ms
(* (* (* (sqrt x) (sqrt x)) (sqrt x)) (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))))
98.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)))))
54.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)))))
54.0ms
(- (+ (* 1/2 x) 1) (* 1/8 (pow x 2)))
40.0ms
(- (log (- (sqrt (+ x 1)) (sqrt x))) (log (* (sqrt x) (sqrt (+ x 1)))))

prune922.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.9b

localize15.0ms

Local error

Found 4 expressions with local error:

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

rewrite68.0ms

Algorithm
rewrite-expression-head
Rules
18×associate-*r/
17×add-exp-log
17×pow1
14×flip-+
14×sqrt-div
14×flip3-+
12×*-un-lft-identity
11×add-cbrt-cube
10×associate-*r*
add-cube-cbrt
associate-/r/
pow-prod-down
frac-times
add-sqr-sqrt
prod-exp
add-log-exp
cbrt-unprod
associate-*l/
associate-*l*
pow-flip
sqrt-prod
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 → 91
Calls
4 calls:
Slowest
31.0ms
(/ 1 (* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x))))
22.0ms
(* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x)))
8.0ms
(* (sqrt x) (sqrt (+ x 1)))
4.0ms
(+ (sqrt (+ x 1)) (sqrt x))

series264.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
114.0ms
(/ 1 (* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x))))
84.0ms
(* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x)))
36.0ms
(* (sqrt x) (sqrt (+ x 1)))
30.0ms
(+ (sqrt (+ x 1)) (sqrt x))

simplify3.4s

Counts
66 → 103
Calls
66 calls:
Slowest
372.0ms
(* (sqrt (- x 1)) (+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x)))))
323.0ms
(* (sqrt (- x 1)) (+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x)))))
281.0ms
(* (sqrt (+ (* x x) (- (* 1 1) (* x 1)))) (+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x)))))
275.0ms
(* (* (* (sqrt x) (sqrt x)) (sqrt x)) (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))))
243.0ms
(* (sqrt (+ (* x x) (- (* 1 1) (* x 1)))) (+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x)))))

prune829.0ms

Pruning

10 alts after pruning (10 fresh and 0 done)

Merged error: 0.0b

localize12.0ms

Local error

Found 4 expressions with local error:

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

rewrite58.0ms

Algorithm
rewrite-expression-head
Rules
35×*-un-lft-identity
24×times-frac
19×add-cube-cbrt
19×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*
associate-*r*
associate-/r*
pow-prod-down
pow1/2
rec-exp
pow-flip
sqrt-prod
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 → 106
Calls
4 calls:
Slowest
25.0ms
(/ (/ 1 (* (sqrt x) (sqrt (+ x 1)))) (+ (sqrt (+ x 1)) (sqrt x)))
12.0ms
(/ 1 (* (sqrt x) (sqrt (+ x 1))))
9.0ms
(+ (sqrt (+ x 1)) (sqrt x))
9.0ms
(* (sqrt x) (sqrt (+ x 1)))

series187.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
86.0ms
(/ (/ 1 (* (sqrt x) (sqrt (+ x 1)))) (+ (sqrt (+ x 1)) (sqrt x)))
36.0ms
(/ 1 (* (sqrt x) (sqrt (+ x 1))))
35.0ms
(+ (sqrt (+ x 1)) (sqrt x))
31.0ms
(* (sqrt x) (sqrt (+ x 1)))

simplify2.3s

Counts
97 → 118
Calls
97 calls:
Slowest
301.0ms
(* (exp (sqrt (+ x 1))) (exp (sqrt x)))
298.0ms
(* (* (* (sqrt x) (sqrt x)) (sqrt x)) (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))))
112.0ms
(- (log (/ 1 (* (sqrt x) (sqrt (+ x 1))))) (log (+ (sqrt (+ x 1)) (sqrt x))))
107.0ms
(+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x))))
88.0ms
(/ (/ 1 (* (sqrt x) (sqrt (- (* x x) (* 1 1))))) (* (cbrt (+ (sqrt (+ x 1)) (sqrt x))) (cbrt (+ (sqrt (+ x 1)) (sqrt x)))))

prune939.0ms

Pruning

10 alts after pruning (9 fresh and 1 done)

Merged error: 0b

regimes74.0ms

Accuracy

0% (0.4b remaining)

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

bsearch1.0ms

end0.0ms

sample2.3s

Algorithm
intervals
Results
706.0ms1091×body1280valid
535.0ms1780×body640valid
486.0ms8053×body80nan
280.0ms4176×body80valid
141.0ms648×body320valid
80.0ms306×body160valid