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

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.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 \sqrt{x + 1} + \left(x + 1\right) \cdot \sqrt{x}\right)}}^{1}}\]
  14. Final simplification0.6

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

Reproduce

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

sample92.0ms

Algorithm
intervals

simplify6.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune5.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 19.1b

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

rewrite17.0ms

Algorithm
rewrite-expression-head
Counts
4 → 71
Calls

4 calls. Slowest were:

11.0ms
(- (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1))))
2.0ms
(/ 1 (sqrt (+ x 1)))
1.0ms
(/ 1 (sqrt x))

series104.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

46.0ms
(- (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1))))
22.0ms
(/ 1 (sqrt (+ x 1)))
19.0ms
(/ 1 (sqrt x))
17.0ms
(sqrt (+ x 1))

simplify331.0ms

Counts
42 → 83
Calls

42 calls. Slowest were:

71.0ms
(- (+ (* 3/8 (pow x 2)) 1) (* 1/2 x))
47.0ms
(sqrt (+ (* x x) (- (* 1 1) (* x 1))))
47.0ms
(- (+ (* 1/2 x) 1) (* 1/8 (pow x 2)))

prune759.0ms

Pruning

11 alts after pruning (11 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))

rewrite36.0ms

Algorithm
rewrite-expression-head
Counts
4 → 85
Calls

4 calls. Slowest were:

19.0ms
(/ (- (sqrt (+ x 1)) (sqrt x)) (* (sqrt x) (sqrt (+ x 1))))
8.0ms
(* (sqrt x) (sqrt (+ x 1)))
8.0ms
(- (sqrt (+ x 1)) (sqrt x))

series136.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

82.0ms
(/ (- (sqrt (+ x 1)) (sqrt x)) (* (sqrt x) (sqrt (+ x 1))))
22.0ms
(- (sqrt (+ x 1)) (sqrt x))
21.0ms
(* (sqrt x) (sqrt (+ x 1)))
10.0ms
(sqrt (+ x 1))

simplify934.0ms

Counts
65 → 97
Calls

65 calls. Slowest were:

271.0ms
(* (* (* (sqrt x) (sqrt x)) (sqrt x)) (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))))
92.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)))))
75.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)))))

prune686.0ms

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

rewrite51.0ms

Algorithm
rewrite-expression-head
Counts
4 → 91
Calls

4 calls. Slowest were:

26.0ms
(* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x)))
15.0ms
(/ 1 (* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x))))
4.0ms
(+ (sqrt (+ x 1)) (sqrt x))

series224.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

94.0ms
(/ 1 (* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x))))
78.0ms
(* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x)))
28.0ms
(+ (sqrt (+ x 1)) (sqrt x))
24.0ms
(* (sqrt x) (sqrt (+ x 1)))

simplify2.9s

Counts
66 → 103
Calls

66 calls. Slowest were:

305.0ms
(* (sqrt (- x 1)) (+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x)))))
293.0ms
(* (sqrt (- x 1)) (+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x)))))
282.0ms
(* (sqrt (+ (* x x) (- (* 1 1) (* x 1)))) (+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x)))))

prune744.0ms

Pruning

9 alts after pruning (9 fresh and 0 done)

Merged error: 0.0b

localize13.0ms

Local error

Found 4 expressions with local error:

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

rewrite32.0ms

Algorithm
rewrite-expression-head
Counts
4 → 71
Calls

4 calls. Slowest were:

10.0ms
(/ 1 (pow (+ (* x (sqrt (+ x 1))) (* (+ x 1) (sqrt x))) 1))
10.0ms
(+ (* x (sqrt (+ x 1))) (* (+ x 1) (sqrt x)))
7.0ms
(* (+ x 1) (sqrt x))

series131.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

53.0ms
(/ 1 (pow (+ (* x (sqrt (+ x 1))) (* (+ x 1) (sqrt x))) 1))
40.0ms
(+ (* x (sqrt (+ x 1))) (* (+ x 1) (sqrt x)))
20.0ms
(* (+ x 1) (sqrt x))
18.0ms
(* x (sqrt (+ x 1)))

simplify2.3s

Counts
46 → 83
Calls

46 calls. Slowest were:

282.0ms
(+ (* (* x (sqrt (+ (pow x 3) (pow 1 3)))) (+ (* x x) (- (* 1 1) (* x 1)))) (* (sqrt (+ (* x x) (- (* 1 1) (* x 1)))) (* (+ (pow x 3) (pow 1 3)) (sqrt x))))
280.0ms
(* (* (* (+ x 1) (+ x 1)) (+ x 1)) (* (* (sqrt x) (sqrt x)) (sqrt x)))
274.0ms
(+ (* (* x (sqrt (- (* x x) (* 1 1)))) (+ (* x x) (- (* 1 1) (* x 1)))) (* (sqrt (- x 1)) (* (+ (pow x 3) (pow 1 3)) (sqrt x))))

prune530.0ms

Pruning

8 alts after pruning (7 fresh and 1 done)

Merged error: 0.0b

regimes38.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.6s

Algorithm
intervals