Average Error: 29.6 → 0.2
Time: 13.2s
Precision: 64
Internal Precision: 128
\[\sqrt{x + 1} - \sqrt{x}\]
\[\frac{1}{\sqrt{x + 1} + \sqrt{x}}\]

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original29.6
Target0.2
Herbie0.2
\[\frac{1}{\sqrt{x + 1} + \sqrt{x}}\]

Derivation

  1. Initial program 29.6

    \[\sqrt{x + 1} - \sqrt{x}\]
  2. Using strategy rm
  3. Applied flip--29.4

    \[\leadsto \color{blue}{\frac{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x + 1} + \sqrt{x}}}\]
  4. Taylor expanded around inf 0.2

    \[\leadsto \frac{\color{blue}{1}}{\sqrt{x + 1} + \sqrt{x}}\]
  5. Final simplification0.2

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

Reproduce

herbie shell --seed 2019016 
(FPCore (x)
  :name "2sqrt (example 3.1)"

  :herbie-target
  (/ 1 (+ (sqrt (+ x 1)) (sqrt x)))

  (- (sqrt (+ x 1)) (sqrt x)))

Details

Time bar (total: 12.3s)Debug log

sample87.0ms

Algorithm
intervals
Results
573×(pre true 80)
316×(body nan 80)
138×(body real 80)
60×(body real 1280)
39×(body real 640)
12×(body real 320)
(body real 160)

simplify8.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
8.0ms
(- (sqrt (+ x 1)) (sqrt x))

prune9.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 28.5b

localize21.0ms

Local error

Found 2 expressions with local error:

2.4b
(- (sqrt (+ x 1)) (sqrt x))
0.0b
(sqrt (+ x 1))

rewrite13.0ms

Algorithm
rewrite-expression-head
Rules
add-sqr-sqrt
*-un-lft-identity
add-log-exp
sqrt-prod
add-cube-cbrt
difference-of-squares
add-exp-log
sqrt-div
add-cbrt-cube
pow1
distribute-lft-out--
flip--
flip-+
diff-log
pow1/2
flip3--
flip3-+
sub-neg
rem-sqrt-square
Counts
2 → 29
Calls
2 calls:
Slowest
11.0ms
(- (sqrt (+ x 1)) (sqrt x))
1.0ms
(sqrt (+ x 1))

series36.0ms

Counts
2 → 6
Calls
2 calls:
Slowest
26.0ms
(- (sqrt (+ x 1)) (sqrt x))
10.0ms
(sqrt (+ x 1))

simplify118.0ms

Counts
18 → 35
Calls
18 calls:
Slowest
52.0ms
(- (+ (* 1/2 x) 1) (* 1/8 (pow x 2)))
19.0ms
(/ (exp (sqrt (+ x 1))) (exp (sqrt x)))
14.0ms
(sqrt (- (* x x) (* 1 1)))
4.0ms
(- (sqrt (sqrt (+ x 1))) (sqrt (sqrt x)))
4.0ms
(- (sqrt (sqrt (+ x 1))) (sqrt (sqrt x)))

prune342.0ms

Pruning

12 alts after pruning (12 fresh and 0 done)

Merged error: 27.8b

localize31.0ms

Local error

Found 4 expressions with local error:

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

rewrite80.0ms

Algorithm
rewrite-expression-head
Rules
30×*-un-lft-identity
20×add-cube-cbrt
20×add-sqr-sqrt
16×times-frac
14×pow1
12×sqrt-div
10×add-exp-log
10×add-cbrt-cube
associate-*l*
associate-*r*
pow1/2
flip-+
flip3-+
difference-of-squares
add-log-exp
sqrt-prod
distribute-lft-out
associate-/l*
pow-prod-up
pow-prod-down
associate-/r*
frac-times
associate-/l/
flip--
cbrt-unprod
*-commutative
associate-/r/
associate-*r/
prod-exp
associate-*l/
sqrt-unprod
flip3--
pow-plus
rem-square-sqrt
pow2
div-inv
div-exp
div-sub
diff-log
frac-2neg
sub-neg
clear-num
cbrt-undiv
Counts
4 → 116
Calls
4 calls:
Slowest
41.0ms
(/ (- (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt x) (sqrt x))) (+ (sqrt (+ x 1)) (sqrt x)))
19.0ms
(- (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt x) (sqrt x)))
10.0ms
(* (sqrt (+ x 1)) (sqrt (+ x 1)))
7.0ms
(* (sqrt x) (sqrt x))

series76.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
36.0ms
(/ (- (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt x) (sqrt x))) (+ (sqrt (+ x 1)) (sqrt x)))
15.0ms
(* (sqrt (+ x 1)) (sqrt (+ x 1)))
12.0ms
(* (sqrt x) (sqrt x))
12.0ms
(- (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt x) (sqrt x)))

simplify2.4s

Counts
108 → 128
Calls
108 calls:
Slowest
472.0ms
(- (pow (* (sqrt (+ x 1)) (sqrt (+ x 1))) 3) (pow (* (sqrt x) (sqrt x)) 3))
416.0ms
(- (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt (+ x 1)) (sqrt (+ x 1)))) (* (* (sqrt x) (sqrt x)) (* (sqrt x) (sqrt x))))
178.0ms
(* (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))) (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))))
98.0ms
(+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x))))
82.0ms
(/ (* (* (- (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt x) (sqrt x))) (- (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt x) (sqrt x)))) (- (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt x) (sqrt x)))) (* (* (+ (sqrt (+ x 1)) (sqrt x)) (+ (sqrt (+ x 1)) (sqrt x))) (+ (sqrt (+ x 1)) (sqrt x))))

prune1.2s

Pruning

7 alts after pruning (7 fresh and 0 done)

Merged error: 0.1b

localize3.0ms

Local error

Found 3 expressions with local error:

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

rewrite12.0ms

Algorithm
rewrite-expression-head
Rules
*-un-lft-identity
add-sqr-sqrt
add-log-exp
add-cube-cbrt
add-exp-log
associate-/r*
pow1
flip-+
sqrt-prod
add-cbrt-cube
flip3-+
distribute-lft-out
associate-/r/
sqrt-div
inv-pow
pow-flip
div-inv
pow1/2
frac-2neg
sum-log
clear-num
rec-exp
rem-sqrt-square
+-commutative
Counts
3 → 45
Calls
3 calls:
Slowest
5.0ms
(/ 1 (+ (sqrt (+ x 1)) (sqrt x)))
5.0ms
(+ (sqrt (+ x 1)) (sqrt x))
1.0ms
(sqrt (+ x 1))

series72.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
42.0ms
(/ 1 (+ (sqrt (+ x 1)) (sqrt x)))
20.0ms
(+ (sqrt (+ x 1)) (sqrt x))
10.0ms
(sqrt (+ x 1))

simplify317.0ms

Counts
24 → 54
Calls
24 calls:
Slowest
150.0ms
(+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x))))
81.0ms
(- (+ (* 1/2 x) 1) (* 1/8 (pow x 2)))
29.0ms
(sqrt (- (* x x) (* 1 1)))
10.0ms
(* (exp (sqrt (+ x 1))) (exp (sqrt x)))
8.0ms
(- (sqrt (+ x 1)) (sqrt x))

prune450.0ms

Pruning

9 alts after pruning (8 fresh and 1 done)

Merged error: 0.1b

localize17.0ms

Local error

Found 4 expressions with local error:

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

rewrite50.0ms

Algorithm
rewrite-expression-head
Rules
50×*-un-lft-identity
42×times-frac
40×sqrt-prod
32×add-sqr-sqrt
30×add-cube-cbrt
24×sqrt-div
20×associate-/r/
14×associate-/r*
12×flip-+
12×flip3-+
10×distribute-lft-out
10×div-inv
add-exp-log
pow1
associate-/l*
add-cbrt-cube
pow1/2
add-log-exp
pow-flip
pow-div
inv-pow
div-exp
frac-2neg
clear-num
rec-exp
rem-sqrt-square
associate-/l/
cbrt-undiv
Counts
4 → 127
Calls
4 calls:
Slowest
20.0ms
(/ (/ 1 (sqrt (+ (sqrt (+ x 1)) (sqrt x)))) (sqrt (+ (sqrt (+ x 1)) (sqrt x))))
10.0ms
(sqrt (+ (sqrt (+ x 1)) (sqrt x)))
10.0ms
(sqrt (+ (sqrt (+ x 1)) (sqrt x)))
8.0ms
(/ 1 (sqrt (+ (sqrt (+ x 1)) (sqrt x))))

series229.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
75.0ms
(/ 1 (sqrt (+ (sqrt (+ x 1)) (sqrt x))))
57.0ms
(sqrt (+ (sqrt (+ x 1)) (sqrt x)))
48.0ms
(sqrt (+ (sqrt (+ x 1)) (sqrt x)))
48.0ms
(/ (/ 1 (sqrt (+ (sqrt (+ x 1)) (sqrt x)))) (sqrt (+ (sqrt (+ x 1)) (sqrt x))))

simplify2.7s

Counts
143 → 139
Calls
143 calls:
Slowest
456.0ms
(/ (* (* (/ 1 (sqrt (+ (sqrt (+ x 1)) (sqrt x)))) (/ 1 (sqrt (+ (sqrt (+ x 1)) (sqrt x))))) (/ 1 (sqrt (+ (sqrt (+ x 1)) (sqrt x))))) (* (* (sqrt (+ (sqrt (+ x 1)) (sqrt x))) (sqrt (+ (sqrt (+ x 1)) (sqrt x)))) (sqrt (+ (sqrt (+ x 1)) (sqrt x)))))
163.0ms
(/ (sqrt (+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x))))) (sqrt (+ (sqrt (+ x 1)) (sqrt x))))
135.0ms
(/ (sqrt (+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x))))) (sqrt (+ (sqrt (+ x 1)) (sqrt x))))
130.0ms
(/ (sqrt (+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x))))) (cbrt (sqrt (+ (sqrt (+ x 1)) (sqrt x)))))
128.0ms
(/ (sqrt (+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x))))) (sqrt (+ (sqrt (+ x 1)) (sqrt x))))

prune1.3s

Pruning

9 alts after pruning (8 fresh and 1 done)

Merged error: 0.0b

regimes74.0ms

Accuracy

0% (0.1b remaining)

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

bsearch1.0ms

end0.0ms

sample2.5s

Algorithm
intervals
Results
16094×(pre true 80)
8093×(body nan 80)
4126×(body real 80)
1738×(body real 1280)
1214×(body real 640)
608×(body real 320)
315×(body real 160)