Average Error: 19.9 → 0.4
Time: 15.6s
Precision: 64
Internal Precision: 128
\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
\[\frac{1}{\sqrt{x + 1} \cdot \sqrt{x}} \cdot \frac{1}{\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.9
Target0.6
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 frac-sub19.9

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

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

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

    \[\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. Using strategy rm
  12. Applied div-inv0.4

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

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

Reproduce

herbie shell --seed 2019005 
(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.0s)Debug log

sample124.0ms

Algorithm
intervals

simplify11.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune32.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 20.2b

localize35.0ms

Local error

Found 4 expressions with local error:

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

rewrite11.0ms

Algorithm
rewrite-expression-head
Counts
4 → 71
Calls

4 calls. Slowest were:

7.0ms
(- (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1))))
1.0ms
(/ 1 (sqrt (+ x 1)))
1.0ms
(/ 1 (sqrt x))

series75.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

31.0ms
(- (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1))))
17.0ms
(/ 1 (sqrt x))
14.0ms
(sqrt (+ x 1))
13.0ms
(/ 1 (sqrt (+ x 1)))

simplify412.0ms

Counts
42 → 83
Calls

42 calls. Slowest were:

79.0ms
(- (+ (* 1/2 x) 1) (* 1/8 (pow x 2)))
45.0ms
(sqrt (+ (* x x) (- (* 1 1) (* x 1))))
37.0ms
(- (+ (* 3/8 (pow x 2)) 1) (* 1/2 x))

prune755.0ms

Pruning

12 alts after pruning (12 fresh and 0 done)

Merged error: 19.6b

localize9.0ms

Local error

Found 4 expressions with local error:

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

rewrite40.0ms

Algorithm
rewrite-expression-head
Counts
4 → 85
Calls

4 calls. Slowest were:

25.0ms
(/ (- (sqrt (+ x 1)) (sqrt x)) (* (sqrt x) (sqrt (+ x 1))))
8.0ms
(- (sqrt (+ x 1)) (sqrt x))
4.0ms
(* (sqrt x) (sqrt (+ x 1)))

series147.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

77.0ms
(/ (- (sqrt (+ x 1)) (sqrt x)) (* (sqrt x) (sqrt (+ x 1))))
38.0ms
(- (sqrt (+ x 1)) (sqrt x))
22.0ms
(* (sqrt x) (sqrt (+ x 1)))
10.0ms
(sqrt (+ x 1))

simplify1.0s

Counts
65 → 97
Calls

65 calls. Slowest were:

330.0ms
(* (* (* (sqrt x) (sqrt x)) (sqrt x)) (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))))
99.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)))))
83.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)))))

prune844.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.6b

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

rewrite87.0ms

Algorithm
rewrite-expression-head
Counts
4 → 91
Calls

4 calls. Slowest were:

37.0ms
(* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x)))
31.0ms
(/ 1 (* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x))))
9.0ms
(+ (sqrt (+ x 1)) (sqrt x))

series271.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

105.0ms
(/ 1 (* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x))))
91.0ms
(* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x)))
38.0ms
(* (sqrt x) (sqrt (+ x 1)))
37.0ms
(+ (sqrt (+ x 1)) (sqrt x))

simplify3.9s

Counts
66 → 103
Calls

66 calls. Slowest were:

652.0ms
(* (sqrt (- x 1)) (+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x)))))
359.0ms
(* (sqrt (- x 1)) (+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x)))))
333.0ms
(* (sqrt (+ (* x x) (- (* 1 1) (* x 1)))) (+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x)))))

prune1.0s

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

rewrite50.0ms

Algorithm
rewrite-expression-head
Counts
4 → 106
Calls

4 calls. Slowest were:

25.0ms
(/ (/ 1 (* (sqrt x) (sqrt (+ x 1)))) (+ (sqrt (+ x 1)) (sqrt x)))
9.0ms
(* (sqrt x) (sqrt (+ x 1)))
7.0ms
(/ 1 (* (sqrt x) (sqrt (+ x 1))))

series164.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

90.0ms
(/ (/ 1 (* (sqrt x) (sqrt (+ x 1)))) (+ (sqrt (+ x 1)) (sqrt x)))
27.0ms
(+ (sqrt (+ x 1)) (sqrt x))
25.0ms
(/ 1 (* (sqrt x) (sqrt (+ x 1))))
21.0ms
(* (sqrt x) (sqrt (+ x 1)))

simplify1.8s

Counts
97 → 118
Calls

97 calls. Slowest were:

232.0ms
(* (* (* (sqrt x) (sqrt x)) (sqrt x)) (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))))
104.0ms
(- (+ (* 3/8 (/ 1 (pow x 3))) (/ 1 x)) (* 1/2 (/ 1 (pow x 2))))
102.0ms
(+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x))))

prune939.0ms

Pruning

7 alts after pruning (7 fresh and 0 done)

Merged error: 0.0b

regimes44.0ms

Accuracy

0% (0.4b remaining)

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

bsearch2.0ms

end0.0ms

sample3.2s

Algorithm
intervals