Average Error: 19.6 → 0.4
Time: 16.2s
Precision: 64
Internal Precision: 128
\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
\[\frac{\frac{\frac{1}{\sqrt{x + 1} \cdot \sqrt{x}}}{\sqrt{\sqrt{x} + \sqrt{x + 1}}}}{\sqrt{\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.6
Target0.6
Herbie0.4
\[\frac{1}{\left(x + 1\right) \cdot \sqrt{x} + x \cdot \sqrt{x + 1}}\]

Derivation

  1. Initial program 19.6

    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
  2. Using strategy rm
  3. Applied frac-sub19.6

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

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

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

    \[\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 add-sqr-sqrt0.4

    \[\leadsto \frac{\frac{1}{\sqrt{x} \cdot \sqrt{x + 1}}}{\color{blue}{\sqrt{\sqrt{x + 1} + \sqrt{x}} \cdot \sqrt{\sqrt{x + 1} + \sqrt{x}}}}\]
  13. Applied associate-/r*0.4

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

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

Reproduce

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

sample150.0ms

Algorithm
intervals

simplify27.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune5.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 21.4b

localize24.0ms

Local error

Found 4 expressions with local error:

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

series78.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

39.0ms
(- (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1))))
15.0ms
(sqrt (+ x 1))
13.0ms
(/ 1 (sqrt (+ x 1)))
11.0ms
(/ 1 (sqrt x))

simplify324.0ms

Counts
42 → 83
Calls

42 calls. Slowest were:

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

prune804.0ms

Pruning

10 alts after pruning (10 fresh and 0 done)

Merged error: 20.9b

localize18.0ms

Local error

Found 4 expressions with local error:

3.3b
(- (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))

rewrite32.0ms

Algorithm
rewrite-expression-head
Counts
4 → 85
Calls

4 calls. Slowest were:

15.0ms
(/ (- (sqrt (+ x 1)) (sqrt x)) (* (sqrt x) (sqrt (+ x 1))))
8.0ms
(- (sqrt (+ x 1)) (sqrt x))
7.0ms
(* (sqrt x) (sqrt (+ x 1)))

series119.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

62.0ms
(/ (- (sqrt (+ x 1)) (sqrt x)) (* (sqrt x) (sqrt (+ x 1))))
25.0ms
(- (sqrt (+ x 1)) (sqrt x))
22.0ms
(* (sqrt x) (sqrt (+ x 1)))
11.0ms
(sqrt (+ x 1))

simplify927.0ms

Counts
65 → 97
Calls

65 calls. Slowest were:

236.0ms
(* (* (* (sqrt x) (sqrt x)) (sqrt x)) (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))))
84.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)))))
65.0ms
(- (+ (* 1/2 x) 1) (* 1/8 (pow x 2)))

prune885.0ms

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0.7b

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

rewrite67.0ms

Algorithm
rewrite-expression-head
Counts
4 → 91
Calls

4 calls. Slowest were:

30.0ms
(* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x)))
22.0ms
(/ 1 (* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x))))
9.0ms
(+ (sqrt (+ x 1)) (sqrt x))

series264.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

107.0ms
(/ 1 (* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x))))
91.0ms
(* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x)))
36.0ms
(* (sqrt x) (sqrt (+ x 1)))
31.0ms
(+ (sqrt (+ x 1)) (sqrt x))

simplify3.6s

Counts
66 → 103
Calls

66 calls. Slowest were:

404.0ms
(* (sqrt (- x 1)) (+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x)))))
388.0ms
(* (sqrt (+ (* x x) (- (* 1 1) (* x 1)))) (+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x)))))
352.0ms
(* (* (* (sqrt x) (sqrt x)) (sqrt x)) (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))))

prune993.0ms

Pruning

10 alts after pruning (10 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)))) (+ (sqrt (+ x 1)) (sqrt x)))
0.1b
(/ 1 (* (sqrt x) (sqrt (+ x 1))))
0.0b
(+ (sqrt (+ x 1)) (sqrt x))

rewrite41.0ms

Algorithm
rewrite-expression-head
Counts
4 → 106
Calls

4 calls. Slowest were:

13.0ms
(/ (/ 1 (* (sqrt x) (sqrt (+ x 1)))) (+ (sqrt (+ x 1)) (sqrt x)))
13.0ms
(+ (sqrt (+ x 1)) (sqrt x))
7.0ms
(/ 1 (* (sqrt x) (sqrt (+ x 1))))

series179.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

90.0ms
(/ (/ 1 (* (sqrt x) (sqrt (+ x 1)))) (+ (sqrt (+ x 1)) (sqrt x)))
37.0ms
(* (sqrt x) (sqrt (+ x 1)))
28.0ms
(/ 1 (* (sqrt x) (sqrt (+ x 1))))
23.0ms
(+ (sqrt (+ x 1)) (sqrt x))

simplify2.3s

Counts
97 → 118
Calls

97 calls. Slowest were:

265.0ms
(* (* (* (sqrt x) (sqrt x)) (sqrt x)) (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))))
124.0ms
(+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x))))
122.0ms
(- (+ (* 3/8 (/ 1 (pow x 3))) (/ 1 x)) (* 1/2 (/ 1 (pow x 2))))

prune1.0s

Pruning

9 alts after pruning (9 fresh and 0 done)

Merged error: 0.0b

regimes54.0ms

Accuracy

0% (0.4b remaining)

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

bsearch1.0ms

end0.0ms

sample3.4s

Algorithm
intervals