Average Error: 19.9 → 0.4
Time: 30.0s
Precision: 64
Internal Precision: 128
\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
\[\frac{\frac{1}{x + 1}}{\frac{x}{\sqrt{x}} + \frac{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.9
Target0.7
Herbie0.4
\[\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. Using strategy rm
  3. Applied flip--20.0

    \[\leadsto \color{blue}{\frac{\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}}\]
  4. Using strategy rm
  5. Applied frac-times25.0

    \[\leadsto \frac{\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1 \cdot 1}{\sqrt{x + 1} \cdot \sqrt{x + 1}}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}\]
  6. Applied frac-times20.1

    \[\leadsto \frac{\color{blue}{\frac{1 \cdot 1}{\sqrt{x} \cdot \sqrt{x}}} - \frac{1 \cdot 1}{\sqrt{x + 1} \cdot \sqrt{x + 1}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}\]
  7. Applied frac-sub19.8

    \[\leadsto \frac{\color{blue}{\frac{\left(1 \cdot 1\right) \cdot \left(\sqrt{x + 1} \cdot \sqrt{x + 1}\right) - \left(\sqrt{x} \cdot \sqrt{x}\right) \cdot \left(1 \cdot 1\right)}{\left(\sqrt{x} \cdot \sqrt{x}\right) \cdot \left(\sqrt{x + 1} \cdot \sqrt{x + 1}\right)}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}\]
  8. Simplified5.9

    \[\leadsto \frac{\frac{\color{blue}{1}}{\left(\sqrt{x} \cdot \sqrt{x}\right) \cdot \left(\sqrt{x + 1} \cdot \sqrt{x + 1}\right)}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}\]
  9. Simplified5.7

    \[\leadsto \frac{\frac{1}{\color{blue}{x \cdot x + x}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}\]
  10. Using strategy rm
  11. Applied div-inv5.7

    \[\leadsto \frac{\frac{1}{x \cdot x + x}}{\frac{1}{\sqrt{x}} + \color{blue}{1 \cdot \frac{1}{\sqrt{x + 1}}}}\]
  12. Applied div-inv5.7

    \[\leadsto \frac{\frac{1}{x \cdot x + x}}{\color{blue}{1 \cdot \frac{1}{\sqrt{x}}} + 1 \cdot \frac{1}{\sqrt{x + 1}}}\]
  13. Applied distribute-lft-out5.7

    \[\leadsto \frac{\frac{1}{x \cdot x + x}}{\color{blue}{1 \cdot \left(\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}\right)}}\]
  14. Applied *-un-lft-identity5.7

    \[\leadsto \frac{\color{blue}{1 \cdot \frac{1}{x \cdot x + x}}}{1 \cdot \left(\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}\right)}\]
  15. Applied times-frac5.7

    \[\leadsto \color{blue}{\frac{1}{1} \cdot \frac{\frac{1}{x \cdot x + x}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}}\]
  16. Simplified5.7

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

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

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

Reproduce

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

sample114.0ms

Algorithm
intervals

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: 19.2b

localize29.0ms

Local error

Found 4 expressions with local error:

3.3b
(- (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1))))
0.3b
(/ 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))

series95.0ms

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

simplify319.0ms

Counts
42 → 83
Calls
42 calls:
Slowest
64.0ms
(- (+ (* 3/8 (pow x 2)) 1) (* 1/2 x))
61.0ms
(- (+ (* 1/2 x) 1) (* 1/8 (pow x 2)))
37.0ms
(/ (exp (/ 1 (sqrt x))) (exp (/ 1 (sqrt (+ x 1)))))
30.0ms
(- (* 1 (sqrt (+ x 1))) (* (sqrt x) 1))
23.0ms
(sqrt (+ (* x x) (- (* 1 1) (* x 1))))

prune652.0ms

Pruning

10 alts after pruning (10 fresh and 0 done)

Merged error: 18.6b

localize30.0ms

Local error

Found 4 expressions with local error:

3.3b
(- (* (/ 1 (sqrt x)) (/ 1 (sqrt x))) (* (/ 1 (sqrt (+ x 1))) (/ 1 (sqrt (+ x 1)))))
0.5b
(* (/ 1 (sqrt x)) (/ 1 (sqrt x)))
0.3b
(/ (- (* (/ 1 (sqrt x)) (/ 1 (sqrt x))) (* (/ 1 (sqrt (+ x 1))) (/ 1 (sqrt (+ x 1))))) (+ (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1)))))
0.3b
(/ 1 (sqrt x))

rewrite75.0ms

Algorithm
rewrite-expression-head
Rules
40×*-un-lft-identity
32×frac-sub
28×times-frac
24×div-inv
20×distribute-lft-out
20×add-cube-cbrt
20×add-sqr-sqrt
18×associate-/l/
17×un-div-inv
17×associate-*r/
17×associate-*l/
17×frac-times
16×pow1
15×add-exp-log
12×pow-flip
10×associate-/r*
difference-of-squares
add-cbrt-cube
inv-pow
add-log-exp
pow-prod-up
pow1/2
rec-exp
associate-/l*
prod-exp
pow-prod-down
associate-*l*
associate-*r*
associate-/r/
flip--
flip3--
frac-2neg
clear-num
flip-+
cbrt-unprod
*-commutative
frac-add
div-exp
div-sub
diff-log
pow-plus
flip3-+
sub-neg
cbrt-undiv
pow2
Counts
4 → 156
Calls
4 calls:
Slowest
43.0ms
(/ (- (* (/ 1 (sqrt x)) (/ 1 (sqrt x))) (* (/ 1 (sqrt (+ x 1))) (/ 1 (sqrt (+ x 1))))) (+ (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1)))))
18.0ms
(- (* (/ 1 (sqrt x)) (/ 1 (sqrt x))) (* (/ 1 (sqrt (+ x 1))) (/ 1 (sqrt (+ x 1)))))
9.0ms
(* (/ 1 (sqrt x)) (/ 1 (sqrt x)))
1.0ms
(/ 1 (sqrt x))

series107.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
57.0ms
(/ (- (* (/ 1 (sqrt x)) (/ 1 (sqrt x))) (* (/ 1 (sqrt (+ x 1))) (/ 1 (sqrt (+ x 1))))) (+ (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1)))))
27.0ms
(- (* (/ 1 (sqrt x)) (/ 1 (sqrt x))) (* (/ 1 (sqrt (+ x 1))) (/ 1 (sqrt (+ x 1)))))
11.0ms
(/ 1 (sqrt x))
11.0ms
(* (/ 1 (sqrt x)) (/ 1 (sqrt x)))

simplify15.0s

Counts
176 → 168
Calls
176 calls:
Slowest
611.0ms
(/ (sqrt (- (* (/ 1 (sqrt x)) (/ 1 (sqrt x))) (* (/ 1 (sqrt (+ x 1))) (/ 1 (sqrt (+ x 1)))))) (sqrt (+ (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1))))))
408.0ms
(/ (- (* (/ 1 (sqrt x)) (/ 1 (sqrt x))) (* (/ 1 (sqrt (+ x 1))) (/ 1 (sqrt (+ x 1))))) (+ (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1)))))
389.0ms
(/ (- (* (/ 1 (sqrt x)) (/ 1 (sqrt x))) (* (/ 1 (sqrt (+ x 1))) (/ 1 (sqrt (+ x 1))))) (+ (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1)))))
388.0ms
(/ (- (* (/ 1 (sqrt x)) (/ 1 (sqrt x))) (* (/ 1 (sqrt (+ x 1))) (/ 1 (sqrt (+ x 1))))) (+ (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1)))))
373.0ms
(/ (- (* (/ 1 (sqrt x)) (/ 1 (sqrt x))) (* (/ 1 (sqrt (+ x 1))) (/ 1 (sqrt (+ x 1))))) (+ (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1)))))

prune1.0s

Pruning

5 alts after pruning (5 fresh and 0 done)

Merged error: 4.7b

localize10.0ms

Local error

Found 4 expressions with local error:

4.6b
(/ (/ 1 (+ (* x x) x)) (+ (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1)))))
0.3b
(/ 1 (+ (* x x) x))
0.3b
(/ 1 (sqrt x))
0.1b
(/ 1 (sqrt (+ x 1)))

rewrite15.0ms

Algorithm
rewrite-expression-head
Rules
51×*-un-lft-identity
42×times-frac
40×div-inv
28×distribute-lft-out
23×add-cube-cbrt
23×associate-/r/
23×add-sqr-sqrt
20×associate-/r*
11×flip-+
11×add-exp-log
11×flip3-+
pow1
associate-/l*
add-cbrt-cube
pow-flip
add-log-exp
frac-2neg
clear-num
rec-exp
inv-pow
sqrt-prod
div-exp
sqrt-div
pow1/2
associate-/l/
frac-add
distribute-lft1-in
cbrt-undiv
Counts
4 → 130
Calls
4 calls:
Slowest
10.0ms
(/ (/ 1 (+ (* x x) x)) (+ (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1)))))
2.0ms
(/ 1 (+ (* x x) x))
1.0ms
(/ 1 (sqrt (+ x 1)))
1.0ms
(/ 1 (sqrt x))

series86.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
54.0ms
(/ (/ 1 (+ (* x x) x)) (+ (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1)))))
12.0ms
(/ 1 (sqrt (+ x 1)))
11.0ms
(/ 1 (sqrt x))
9.0ms
(/ 1 (+ (* x x) x))

simplify5.4s

Counts
134 → 142
Calls
134 calls:
Slowest
324.0ms
(+ (* (* x x) (* x x)) (- (* x x) (* (* x x) x)))
212.0ms
(/ (/ 1 (- (* (* x x) (* x x)) (* x x))) 1)
210.0ms
(/ (/ 1 (- (* (* x x) (* x x)) (* x x))) 1)
209.0ms
(/ (/ 1 (- (* (* x x) (* x x)) (* x x))) 1)
209.0ms
(/ (/ 1 (- (* (* x x) (* x x)) (* x x))) 1)

prune867.0ms

Pruning

8 alts after pruning (8 fresh and 0 done)

Merged error: 0.0b

localize15.0ms

Local error

Found 4 expressions with local error:

0.5b
(/ x (sqrt x))
0.3b
(/ (/ 1 (+ x 1)) (+ (/ x (sqrt x)) (/ x (sqrt (+ x 1)))))
0.2b
(/ x (sqrt (+ x 1)))
0.0b
(+ (/ x (sqrt x)) (/ x (sqrt (+ x 1))))

rewrite16.0ms

Algorithm
rewrite-expression-head
Rules
36×*-un-lft-identity
30×times-frac
25×div-inv
20×add-cube-cbrt
20×add-sqr-sqrt
17×associate-/r/
16×distribute-lft-out
14×associate-/r*
flip-+
flip3-+
add-exp-log
add-log-exp
associate-/l*
add-cbrt-cube
pow1
sqrt-prod
frac-2neg
clear-num
frac-add
div-exp
sqrt-div
associate-/l/
sum-log
rec-exp
+-commutative
cbrt-undiv
Counts
4 → 103
Calls
4 calls:
Slowest
9.0ms
(/ (/ 1 (+ x 1)) (+ (/ x (sqrt x)) (/ x (sqrt (+ x 1)))))
5.0ms
(+ (/ x (sqrt x)) (/ x (sqrt (+ x 1))))
1.0ms
(/ x (sqrt (+ x 1)))
1.0ms
(/ x (sqrt x))

series133.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
58.0ms
(/ (/ 1 (+ x 1)) (+ (/ x (sqrt x)) (/ x (sqrt (+ x 1)))))
37.0ms
(+ (/ x (sqrt x)) (/ x (sqrt (+ x 1))))
21.0ms
(/ x (sqrt (+ x 1)))
18.0ms
(/ x (sqrt x))

simplify2.5s

Counts
103 → 115
Calls
103 calls:
Slowest
172.0ms
(+ (* (/ x (sqrt x)) (/ x (sqrt x))) (- (* (/ x (sqrt (+ x 1))) (/ x (sqrt (+ x 1)))) (* (/ x (sqrt x)) (/ x (sqrt (+ x 1))))))
168.0ms
(/ (/ 1 (+ x 1)) (+ (/ x (sqrt x)) (/ x (sqrt (+ x 1)))))
167.0ms
(/ (/ 1 (+ x 1)) (+ (/ x (sqrt x)) (/ x (sqrt (+ x 1)))))
167.0ms
(/ (/ 1 (+ x 1)) (+ (/ x (sqrt x)) (/ x (sqrt (+ x 1)))))
165.0ms
(/ (/ 1 (+ x 1)) (+ (/ x (sqrt x)) (/ x (sqrt (+ x 1)))))

prune644.0ms

Pruning

9 alts after pruning (8 fresh and 1 done)

Merged error: 0b

regimes40.0ms

Accuracy

0% (0.3b remaining)

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

bsearch1.0ms

end0.0ms

sample2.3s

Algorithm
intervals