Average Error: 29.4 → 0.2
Time: 11.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.4
Target0.2
Herbie0.2
\[\frac{1}{\sqrt{x + 1} + \sqrt{x}}\]

Derivation

  1. Initial program 29.4

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

    \[\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 2019021 
(FPCore (x)
  :name "2sqrt (example 3.1)"

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

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

Details

Time bar (total: 10.2s)Debug log

sample82.0ms

Algorithm
intervals
Results
15.0ms263×body80nan
15.0ms49×body1280valid
11.0ms42×body640valid
9.0ms138×body80valid
4.0ms22×body320valid
1.0msbody160valid

simplify4.0ms

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

prune4.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 28.6b

localize9.0ms

Local error

Found 2 expressions with local error:

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

rewrite6.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
5.0ms
(- (sqrt (+ x 1)) (sqrt x))
1.0ms
(sqrt (+ x 1))

series52.0ms

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

simplify181.0ms

Counts
18 → 35
Calls
18 calls:
Slowest
81.0ms
(- (+ (* 1/2 x) 1) (* 1/8 (pow x 2)))
35.0ms
(/ (exp (sqrt (+ x 1))) (exp (sqrt x)))
22.0ms
(sqrt (- (* x x) (* 1 1)))
9.0ms
(- (sqrt (sqrt (+ x 1))) (sqrt (sqrt x)))
5.0ms
(+ (sqrt (sqrt (+ x 1))) (sqrt (sqrt x)))

prune263.0ms

Pruning

8 alts after pruning (8 fresh and 0 done)

Merged error: 27.7b

localize13.0ms

Local error

Found 4 expressions with local error:

1.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.1b
(/ (- (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt x) (sqrt x))) (+ (sqrt (+ x 1)) (sqrt x)))

rewrite49.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
23.0ms
(/ (- (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt x) (sqrt x))) (+ (sqrt (+ x 1)) (sqrt x)))
12.0ms
(- (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt x) (sqrt x)))
10.0ms
(* (sqrt (+ x 1)) (sqrt (+ x 1)))
4.0ms
(* (sqrt x) (sqrt x))

series65.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)))
12.0ms
(* (sqrt (+ x 1)) (sqrt (+ x 1)))
10.0ms
(* (sqrt x) (sqrt x))
7.0ms
(- (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt x) (sqrt x)))

simplify2.6s

Counts
108 → 128
Calls
108 calls:
Slowest
503.0ms
(- (pow (* (sqrt (+ x 1)) (sqrt (+ x 1))) 3) (pow (* (sqrt x) (sqrt x)) 3))
411.0ms
(- (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt (+ x 1)) (sqrt (+ x 1)))) (* (* (sqrt x) (sqrt x)) (* (sqrt x) (sqrt x))))
166.0ms
(* (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))) (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))))
156.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))))
125.0ms
(+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x))))

prune1.2s

Pruning

7 alts after pruning (7 fresh and 0 done)

Merged error: 0.0b

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

rewrite11.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
6.0ms
(+ (sqrt (+ x 1)) (sqrt x))
4.0ms
(/ 1 (+ (sqrt (+ x 1)) (sqrt x)))
1.0ms
(sqrt (+ x 1))

series73.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
34.0ms
(/ 1 (+ (sqrt (+ x 1)) (sqrt x)))
23.0ms
(+ (sqrt (+ x 1)) (sqrt x))
16.0ms
(sqrt (+ x 1))

simplify266.0ms

Counts
24 → 54
Calls
24 calls:
Slowest
124.0ms
(+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x))))
69.0ms
(- (+ (* 1/2 x) 1) (* 1/8 (pow x 2)))
14.0ms
(sqrt (- (* x x) (* 1 1)))
12.0ms
(* (exp (sqrt (+ x 1))) (exp (sqrt x)))
8.0ms
(- (sqrt (+ x 1)) (sqrt x))

prune420.0ms

Pruning

8 alts after pruning (7 fresh and 1 done)

Merged error: 0.0b

localize25.0ms

Local error

Found 4 expressions with local error:

0.2b
(cbrt (+ x 1))
0.2b
(cbrt (+ 1 x))
0.2b
(* (fabs (cbrt (+ 1 x))) (sqrt (cbrt (+ x 1))))
0.2b
(/ 1 (+ (* (fabs (cbrt (+ 1 x))) (sqrt (cbrt (+ x 1)))) (sqrt x)))

rewrite24.0ms

Algorithm
rewrite-expression-head
Rules
11×add-cube-cbrt
11×*-un-lft-identity
11×add-sqr-sqrt
associate-*r*
cbrt-prod
add-exp-log
pow1
sqrt-prod
add-cbrt-cube
cbrt-div
add-log-exp
flip-+
flip3-+
associate-*l*
associate-/r*
associate-/r/
associate-*r/
sqrt-div
pow1/3
inv-pow
pow-flip
div-inv
cbrt-unprod
*-commutative
prod-exp
pow-prod-down
frac-2neg
clear-num
rec-exp
Counts
4 → 69
Calls
4 calls:
Slowest
11.0ms
(/ 1 (+ (* (fabs (cbrt (+ 1 x))) (sqrt (cbrt (+ x 1)))) (sqrt x)))
10.0ms
(* (fabs (cbrt (+ 1 x))) (sqrt (cbrt (+ x 1))))
1.0ms
(cbrt (+ x 1))
1.0ms
(cbrt (+ 1 x))

series239.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
92.0ms
(/ 1 (+ (* (fabs (cbrt (+ 1 x))) (sqrt (cbrt (+ x 1)))) (sqrt x)))
55.0ms
(cbrt (+ 1 x))
50.0ms
(cbrt (+ x 1))
41.0ms
(* (fabs (cbrt (+ 1 x))) (sqrt (cbrt (+ x 1))))

simplify1.5s

Counts
44 → 81
Calls
44 calls:
Slowest
242.0ms
(- (+ (fabs (pow (+ x 1) 1/3)) (* 1/6 (* (fabs (pow (+ x 1) 1/3)) x))) (* 5/72 (* (fabs (pow (+ x 1) 1/3)) (pow x 2))))
194.0ms
(- (+ (exp (* 1/3 (- (log -1) (log (/ -1 x))))) (* 1/3 (/ (exp (* 1/3 (- (log -1) (log (/ -1 x))))) x))) (* 1/9 (/ (exp (* 1/3 (- (log -1) (log (/ -1 x))))) (pow x 2))))
184.0ms
(+ (* (* (fabs (cbrt (+ 1 x))) (sqrt (cbrt (+ x 1)))) (* (fabs (cbrt (+ 1 x))) (sqrt (cbrt (+ x 1))))) (- (* (sqrt x) (sqrt x)) (* (* (fabs (cbrt (+ 1 x))) (sqrt (cbrt (+ x 1)))) (sqrt x))))
180.0ms
(- (+ (* 1/6 (/ (* (fabs (pow (+ x 1) 1/3)) (exp (* 1/6 (- (log -1) (log (/ -1 x)))))) x)) (* (fabs (pow (+ x 1) 1/3)) (exp (* 1/6 (- (log -1) (log (/ -1 x))))))) (* 5/72 (/ (* (fabs (pow (+ x 1) 1/3)) (exp (* 1/6 (- (log -1) (log (/ -1 x)))))) (pow x 2))))
151.0ms
(- (+ (exp (* 1/3 (- (log -1) (log (/ -1 x))))) (* 1/3 (/ (exp (* 1/3 (- (log -1) (log (/ -1 x))))) x))) (* 1/9 (/ (exp (* 1/3 (- (log -1) (log (/ -1 x))))) (pow x 2))))

prune937.0ms

Pruning

9 alts after pruning (7 fresh and 2 done)

Merged error: 0.0b

regimes69.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.1s

Algorithm
intervals
Results
888.0ms1686×body1280valid
388.0ms7849×body80nan
292.0ms4151×body80valid
255.0ms1225×body640valid
120.0ms618×body320valid
30.0ms321×body160valid