Average Error: 30.0 → 0.2
Time: 10.9s
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

Original30.0
Target0.2
Herbie0.2
\[\frac{1}{\sqrt{x + 1} + \sqrt{x}}\]

Derivation

  1. Initial program 30.0

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

    \[\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 2019022 +o rules:numerics
(FPCore (x)
  :name "2sqrt (example 3.1)"

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

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

Details

Time bar (total: 9.8s)Debug log

sample57.0ms

Algorithm
intervals
Results
13.0ms270×body80nan
12.0ms50×body1280valid
8.0ms43×body640valid
7.0ms126×body80valid
4.0ms22×body320valid
2.0ms15×body160valid

simplify4.0ms

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

prune5.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 30.5b

localize11.0ms

Local error

Found 1 expressions with local error:

4.0b
(- (sqrt (+ x 1)) (sqrt x))

rewrite6.0ms

Algorithm
rewrite-expression-head
Rules
19×add-sqr-sqrt
18×prod-diff
17×*-un-lft-identity
15×add-cube-cbrt
13×sqrt-prod
fma-neg
add-log-exp
difference-of-squares
distribute-lft-out--
flip--
log1p-expm1-u
add-exp-log
diff-log
add-cbrt-cube
flip3--
sub-neg
pow1
expm1-log1p-u
Counts
1 → 41
Calls
1 calls:
Slowest
6.0ms
(- (sqrt (+ x 1)) (sqrt x))

series40.0ms

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

simplify693.0ms

Counts
50 → 44
Calls
50 calls:
Slowest
42.0ms
(fma (sqrt (sqrt (+ x 1))) (sqrt (sqrt (+ x 1))) (- (* (sqrt (sqrt x)) (sqrt (sqrt x)))))
29.0ms
(fma (- (cbrt (sqrt x))) (* (cbrt (sqrt x)) (cbrt (sqrt x))) (* (cbrt (sqrt x)) (* (cbrt (sqrt x)) (cbrt (sqrt x)))))
29.0ms
(fma (- (cbrt (sqrt x))) (* (cbrt (sqrt x)) (cbrt (sqrt x))) (* (cbrt (sqrt x)) (* (cbrt (sqrt x)) (cbrt (sqrt x)))))
29.0ms
(fma (- (cbrt (sqrt x))) (* (cbrt (sqrt x)) (cbrt (sqrt x))) (* (cbrt (sqrt x)) (* (cbrt (sqrt x)) (cbrt (sqrt x)))))
27.0ms
(fma (sqrt (* (cbrt (+ x 1)) (cbrt (+ x 1)))) (sqrt (cbrt (+ x 1))) (- (* (sqrt x) 1)))

prune357.0ms

Pruning

7 alts after pruning (7 fresh and 0 done)

Merged error: 29.5b

localize26.0ms

Local error

Found 4 expressions with local error:

2.9b
(- (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt x) (sqrt x)))
0.5b
(* (sqrt x) (sqrt x))
0.2b
(* (sqrt (+ x 1)) (sqrt (+ x 1)))
0.0b
(/ (- (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt x) (sqrt x))) (+ (sqrt (+ x 1)) (sqrt x)))

rewrite48.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*
log1p-expm1-u
pow-prod-up
pow-prod-down
associate-/r*
frac-times
expm1-log1p-u
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
prod-diff
div-exp
div-sub
diff-log
fma-neg
frac-2neg
sub-neg
clear-num
cbrt-undiv
Counts
4 → 126
Calls
4 calls:
Slowest
28.0ms
(/ (- (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt x) (sqrt x))) (+ (sqrt (+ x 1)) (sqrt x)))
10.0ms
(- (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt x) (sqrt x)))
5.0ms
(* (sqrt (+ x 1)) (sqrt (+ x 1)))
3.0ms
(* (sqrt x) (sqrt x))

series82.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
52.0ms
(/ (- (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt x) (sqrt x))) (+ (sqrt (+ x 1)) (sqrt x)))
11.0ms
(* (sqrt x) (sqrt x))
10.0ms
(- (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt x) (sqrt x)))
9.0ms
(* (sqrt (+ x 1)) (sqrt (+ x 1)))

simplify3.0s

Counts
111 → 138
Calls
111 calls:
Slowest
648.0ms
(- (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt (+ x 1)) (sqrt (+ x 1)))) (* (* (sqrt x) (sqrt x)) (* (sqrt x) (sqrt x))))
226.0ms
(* (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))) (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))))
186.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))))
140.0ms
(- (pow (* (sqrt (+ x 1)) (sqrt (+ x 1))) 3) (pow (* (sqrt x) (sqrt x)) 3))
100.0ms
(+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x))))

prune1.2s

Pruning

6 alts after pruning (6 fresh and 0 done)

Merged error: 0.0b

localize6.0ms

Local error

Found 2 expressions with local error:

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

rewrite18.0ms

Algorithm
rewrite-expression-head
Rules
*-un-lft-identity
fma-def
add-cube-cbrt
add-sqr-sqrt
add-log-exp
associate-/r*
sqrt-prod
add-exp-log
pow1
distribute-lft-out
log1p-expm1-u
flip-+
associate-/r/
add-cbrt-cube
flip3-+
expm1-log1p-u
inv-pow
pow-flip
div-inv
frac-2neg
sum-log
clear-num
rec-exp
+-commutative
Counts
2 → 41
Calls
2 calls:
Slowest
9.0ms
(+ (sqrt (+ x 1)) (sqrt x))
8.0ms
(/ 1 (+ (sqrt (+ x 1)) (sqrt x)))

series78.0ms

Counts
2 → 6
Calls
2 calls:
Slowest
44.0ms
(/ 1 (+ (sqrt (+ x 1)) (sqrt x)))
33.0ms
(+ (sqrt (+ x 1)) (sqrt x))

simplify130.0ms

Counts
20 → 47
Calls
20 calls:
Slowest
92.0ms
(+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x))))
5.0ms
(* (exp (sqrt (+ x 1))) (exp (sqrt x)))
4.0ms
(- (sqrt (+ x 1)) (sqrt x))
3.0ms
(sqrt (+ (sqrt (+ x 1)) (sqrt x)))
3.0ms
(+ (sqrt (+ x 1)) (sqrt x))

prune346.0ms

Pruning

8 alts after pruning (7 fresh and 1 done)

Merged error: 0.0b

localize10.0ms

Local error

Found 4 expressions with local error:

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

rewrite28.0ms

Algorithm
rewrite-expression-head
Rules
18×sqrt-prod
15×*-un-lft-identity
12×add-sqr-sqrt
11×add-cube-cbrt
11×pow1
10×associate-/r/
associate-*l*
associate-*r*
add-exp-log
associate-/r*
add-cbrt-cube
div-inv
flip-+
sqrt-div
pow1/2
flip3-+
add-log-exp
log1p-expm1-u
expm1-log1p-u
inv-pow
distribute-lft-out
pow-flip
pow-prod-up
pow-prod-down
frac-2neg
clear-num
rec-exp
cbrt-unprod
*-commutative
associate-*r/
prod-exp
associate-*l/
sqrt-unprod
pow-plus
rem-square-sqrt
rem-sqrt-square
frac-times
pow2
Counts
4 → 101
Calls
4 calls:
Slowest
10.0ms
(* (sqrt (/ 1 (+ (sqrt (+ x 1)) (sqrt x)))) (sqrt (/ 1 (+ (sqrt (+ x 1)) (sqrt x)))))
7.0ms
(/ 1 (+ (sqrt (+ x 1)) (sqrt x)))
6.0ms
(/ 1 (+ (sqrt (+ x 1)) (sqrt x)))
3.0ms
(sqrt (/ 1 (+ (sqrt (+ x 1)) (sqrt x))))

series130.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
45.0ms
(sqrt (/ 1 (+ (sqrt (+ x 1)) (sqrt x))))
30.0ms
(* (sqrt (/ 1 (+ (sqrt (+ x 1)) (sqrt x)))) (sqrt (/ 1 (+ (sqrt (+ x 1)) (sqrt x)))))
29.0ms
(/ 1 (+ (sqrt (+ x 1)) (sqrt x)))
26.0ms
(/ 1 (+ (sqrt (+ x 1)) (sqrt x)))

simplify646.0ms

Counts
66 → 113
Calls
66 calls:
Slowest
101.0ms
(+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x))))
91.0ms
(+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x))))
74.0ms
(sqrt (+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x)))))
66.0ms
(* (* (* (sqrt (/ 1 (+ (sqrt (+ x 1)) (sqrt x)))) (sqrt (/ 1 (+ (sqrt (+ x 1)) (sqrt x))))) (sqrt (/ 1 (+ (sqrt (+ x 1)) (sqrt x))))) (* (* (sqrt (/ 1 (+ (sqrt (+ x 1)) (sqrt x)))) (sqrt (/ 1 (+ (sqrt (+ x 1)) (sqrt x))))) (sqrt (/ 1 (+ (sqrt (+ x 1)) (sqrt x))))))
48.0ms
(sqrt (/ 1 (+ (pow (sqrt (+ x 1)) 3) (pow (sqrt x) 3))))

prune864.0ms

Pruning

5 alts after pruning (3 fresh and 2 done)

Merged error: 0.0b

regimes36.0ms

Accuracy

0% (0.1b remaining)

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

bsearch1.0ms

end0.0ms

sample2.0s

Algorithm
intervals
Results
581.0ms8004×body80nan
492.0ms1717×body1280valid
354.0ms1216×body640valid
219.0ms4066×body80valid
103.0ms658×body320valid
65.0ms343×body160valid