Average Error: 19.5 → 0.4
Time: 23.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.5
Target0.6
Herbie0.4
\[\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.4

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

    \[\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 +-commutative0.4

    \[\leadsto \frac{\frac{1}{\sqrt{x} \cdot \sqrt{x + 1}}}{\color{blue}{\sqrt{x} + \sqrt{x + 1}}}\]
  13. Final simplification0.4

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

Reproduce

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

sample175.0ms

Algorithm
intervals
Results
39.0ms62×body640valid
35.0ms277×body80nan
31.0ms38×body1280valid
20.0ms127×body80valid
11.0ms24×body320valid
2.0msbody160valid

simplify12.0ms

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

prune12.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 21.0b

localize63.0ms

Local error

Found 3 expressions with local error:

2.7b
(- (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1))))
0.3b
(/ 1 (sqrt x))
0.2b
(/ 1 (sqrt (+ x 1)))

rewrite19.0ms

Algorithm
rewrite-expression-head
Rules
10×*-un-lft-identity
associate-/r*
add-sqr-sqrt
div-inv
add-cube-cbrt
add-log-exp
add-exp-log
pow1
distribute-lft-out--
pow-flip
sqrt-prod
add-cbrt-cube
inv-pow
associate-/r/
sqrt-div
pow1/2
frac-2neg
clear-num
rec-exp
difference-of-squares
flip--
flip-+
frac-sub
diff-log
flip3--
flip3-+
sub-neg
Counts
3 → 57
Calls
3 calls:
Slowest
13.0ms
(- (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1))))
3.0ms
(/ 1 (sqrt (+ x 1)))
2.0ms
(/ 1 (sqrt x))

series104.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
54.0ms
(- (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1))))
26.0ms
(/ 1 (sqrt (+ x 1)))
24.0ms
(/ 1 (sqrt x))

simplify329.0ms

Counts
33 → 66
Calls
33 calls:
Slowest
78.0ms
(- (+ (* 3/8 (pow x 2)) 1) (* 1/2 x))
51.0ms
(sqrt (+ (* x x) (- (* 1 1) (* x 1))))
39.0ms
(/ (exp (/ 1 (sqrt x))) (exp (/ 1 (sqrt (+ x 1)))))
37.0ms
(- (* 1 (sqrt (+ x 1))) (* (sqrt x) 1))
13.0ms
(- (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1))))

prune913.0ms

Pruning

12 alts after pruning (12 fresh and 0 done)

Merged error: 20.5b

localize22.0ms

Local error

Found 3 expressions with local error:

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

rewrite58.0ms

Algorithm
rewrite-expression-head
Rules
20×add-sqr-sqrt
14×*-un-lft-identity
10×add-exp-log
10×add-cbrt-cube
add-cube-cbrt
difference-of-squares
associate-/l*
sqrt-prod
associate-*r*
times-frac
add-log-exp
pow1
associate-*r/
sqrt-div
distribute-lft-out--
associate-*l*
associate-/l/
flip--
flip-+
cbrt-unprod
associate-/r/
prod-exp
pow-prod-down
div-exp
pow1/2
flip3--
flip3-+
cbrt-undiv
div-inv
*-commutative
div-sub
diff-log
sqrt-unprod
frac-2neg
sub-neg
associate-/r*
clear-num
Counts
3 → 71
Calls
3 calls:
Slowest
33.0ms
(/ (- (sqrt (+ x 1)) (sqrt x)) (* (sqrt x) (sqrt (+ x 1))))
13.0ms
(- (sqrt (+ x 1)) (sqrt x))
10.0ms
(* (sqrt x) (sqrt (+ x 1)))

series230.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
137.0ms
(/ (- (sqrt (+ x 1)) (sqrt x)) (* (sqrt x) (sqrt (+ x 1))))
47.0ms
(* (sqrt x) (sqrt (+ x 1)))
46.0ms
(- (sqrt (+ x 1)) (sqrt x))

simplify1.4s

Counts
56 → 80
Calls
56 calls:
Slowest
418.0ms
(* (* (* (sqrt x) (sqrt x)) (sqrt x)) (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))))
137.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)))))
119.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)))))
75.0ms
(- (+ x 1/2) (* 1/8 (/ 1 x)))
66.0ms
(- (log (- (sqrt (+ x 1)) (sqrt x))) (+ (log (sqrt x)) (log (sqrt (+ x 1)))))

prune1.1s

Pruning

5 alts after pruning (5 fresh and 0 done)

Merged error: 0.7b

localize22.0ms

Local error

Found 4 expressions with local error:

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

rewrite101.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
40.0ms
(* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x)))
37.0ms
(/ 1 (* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x))))
11.0ms
(+ (sqrt (+ x 1)) (sqrt x))
10.0ms
(* (sqrt x) (sqrt (+ x 1)))

series368.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
151.0ms
(/ 1 (* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x))))
129.0ms
(* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x)))
44.0ms
(+ (sqrt (+ x 1)) (sqrt x))
44.0ms
(* (sqrt x) (sqrt (+ x 1)))

simplify5.1s

Counts
66 → 103
Calls
66 calls:
Slowest
520.0ms
(* (sqrt (- x 1)) (+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x)))))
517.0ms
(* (sqrt (- x 1)) (+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x)))))
442.0ms
(* (sqrt (+ (* x x) (- (* 1 1) (* x 1)))) (+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x)))))
435.0ms
(* (sqrt (+ (* x x) (- (* 1 1) (* x 1)))) (+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x)))))
421.0ms
(* (* (* (sqrt x) (sqrt x)) (sqrt x)) (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))))

prune1.5s

Pruning

9 alts after pruning (9 fresh and 0 done)

Merged error: 0.0b

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

rewrite64.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
30.0ms
(/ (/ 1 (* (sqrt x) (sqrt (+ x 1)))) (+ (sqrt (+ x 1)) (sqrt x)))
11.0ms
(+ (sqrt (+ x 1)) (sqrt x))
10.0ms
(* (sqrt x) (sqrt (+ x 1)))
9.0ms
(/ 1 (* (sqrt x) (sqrt (+ x 1))))

series287.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
150.0ms
(/ (/ 1 (* (sqrt x) (sqrt (+ x 1)))) (+ (sqrt (+ x 1)) (sqrt x)))
48.0ms
(/ 1 (* (sqrt x) (sqrt (+ x 1))))
45.0ms
(* (sqrt x) (sqrt (+ x 1)))
43.0ms
(+ (sqrt (+ x 1)) (sqrt x))

simplify3.3s

Counts
97 → 118
Calls
97 calls:
Slowest
419.0ms
(* (* (* (sqrt x) (sqrt x)) (sqrt x)) (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))))
176.0ms
(- (+ (* 3/8 (/ 1 (pow x 3))) (/ 1 x)) (* 1/2 (/ 1 (pow x 2))))
163.0ms
(+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x))))
161.0ms
(- (log (/ 1 (* (sqrt x) (sqrt (+ x 1))))) (log (+ (sqrt (+ x 1)) (sqrt x))))
147.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))))

prune1.7s

Pruning

7 alts after pruning (7 fresh and 0 done)

Merged error: 0b

regimes81.0ms

Accuracy

0% (0.3b remaining)

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

bsearch3.0ms

end0.0ms

sample5.3s

Algorithm
intervals
Results
1.7s1903×body640valid
1.1s8083×body80nan
1.1s1151×body1280valid
704.0ms4065×body80valid
366.0ms592×body320valid
91.0ms289×body160valid