Average Error: 19.8 → 0.4
Time: 16.4s
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.8
Target0.6
Herbie0.4
\[\frac{1}{\left(x + 1\right) \cdot \sqrt{x} + x \cdot \sqrt{x + 1}}\]

Derivation

  1. Initial program 19.8

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

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

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

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

    \[\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 2019002 
(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.5s)Debug log

sample135.0ms

Algorithm
intervals

simplify12.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune10.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 21.3b

localize32.0ms

Local error

Found 3 expressions with local error:

3.3b
(- (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1))))
0.2b
(/ 1 (sqrt x))
0.1b
(/ 1 (sqrt (+ x 1)))

rewrite16.0ms

Algorithm
rewrite-expression-head
Counts
3 → 57
Calls

3 calls. Slowest were:

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

series95.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

55.0ms
(- (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1))))
21.0ms
(/ 1 (sqrt (+ x 1)))
19.0ms
(/ 1 (sqrt x))

simplify239.0ms

Counts
33 → 66
Calls

33 calls. Slowest were:

45.0ms
(- (+ (* 3/8 (pow x 2)) 1) (* 1/2 x))
35.0ms
(- (* 1 (sqrt (+ x 1))) (* (sqrt x) 1))
32.0ms
(/ (exp (/ 1 (sqrt x))) (exp (/ 1 (sqrt (+ x 1)))))

prune569.0ms

Pruning

12 alts after pruning (12 fresh and 0 done)

Merged error: 20.7b

localize8.0ms

Local error

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

rewrite31.0ms

Algorithm
rewrite-expression-head
Counts
3 → 71
Calls

3 calls. Slowest were:

20.0ms
(/ (- (sqrt (+ x 1)) (sqrt x)) (* (sqrt x) (sqrt (+ x 1))))
5.0ms
(- (sqrt (+ x 1)) (sqrt x))
4.0ms
(* (sqrt x) (sqrt (+ x 1)))

series140.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

78.0ms
(/ (- (sqrt (+ x 1)) (sqrt x)) (* (sqrt x) (sqrt (+ x 1))))
36.0ms
(* (sqrt x) (sqrt (+ x 1)))
26.0ms
(- (sqrt (+ x 1)) (sqrt x))

simplify995.0ms

Counts
56 → 80
Calls

56 calls. Slowest were:

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

prune719.0ms

Pruning

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

rewrite60.0ms

Algorithm
rewrite-expression-head
Counts
4 → 91
Calls

4 calls. Slowest were:

31.0ms
(/ 1 (* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x))))
17.0ms
(* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x)))
6.0ms
(* (sqrt x) (sqrt (+ x 1)))

series231.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

96.0ms
(/ 1 (* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x))))
75.0ms
(* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x)))
33.0ms
(* (sqrt x) (sqrt (+ x 1)))
26.0ms
(+ (sqrt (+ x 1)) (sqrt x))

simplify3.8s

Counts
66 → 103
Calls

66 calls. Slowest were:

393.0ms
(* (sqrt (- x 1)) (+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x)))))
381.0ms
(* (sqrt (- x 1)) (+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x)))))
360.0ms
(* (sqrt (+ (* x x) (- (* 1 1) (* x 1)))) (+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x)))))

prune1.1s

Pruning

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

rewrite29.0ms

Algorithm
rewrite-expression-head
Counts
4 → 106
Calls

4 calls. Slowest were:

12.0ms
(/ (/ 1 (* (sqrt x) (sqrt (+ x 1)))) (+ (sqrt (+ x 1)) (sqrt x)))
7.0ms
(* (sqrt x) (sqrt (+ x 1)))
4.0ms
(+ (sqrt (+ x 1)) (sqrt x))

series218.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

122.0ms
(/ (/ 1 (* (sqrt x) (sqrt (+ x 1)))) (+ (sqrt (+ x 1)) (sqrt x)))
38.0ms
(/ 1 (* (sqrt x) (sqrt (+ x 1))))
34.0ms
(* (sqrt x) (sqrt (+ x 1)))
24.0ms
(+ (sqrt (+ x 1)) (sqrt x))

simplify2.5s

Counts
97 → 118
Calls

97 calls. Slowest were:

318.0ms
(/ (sqrt (/ 1 (* (sqrt x) (sqrt (+ x 1))))) (* (cbrt (+ (sqrt (+ x 1)) (sqrt x))) (cbrt (+ (sqrt (+ x 1)) (sqrt x)))))
267.0ms
(* (* (* (sqrt x) (sqrt x)) (sqrt x)) (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))))
162.0ms
(- (+ (* 3/8 (/ 1 (pow x 3))) (/ 1 x)) (* 1/2 (/ 1 (pow x 2))))

prune1.1s

Pruning

10 alts after pruning (10 fresh and 0 done)

Merged error: 0b

regimes65.0ms

Accuracy

0% (0.4b remaining)

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

bsearch3.0ms

end0.0ms

sample3.3s

Algorithm
intervals