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

Derivation

  1. Initial program 30.4

    \[\sqrt{x + 1} - \sqrt{x}\]
  2. Using strategy rm
  3. Applied flip--30.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 0 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 1137770271 
(FPCore (x)
  :name "2sqrt (example 3.1)"

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

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

Details

Time bar (total: 16.4s)Debug log

sample133.0ms

Algorithm
intervals
Results
52×28.0ms(body real 1280)
249×24.0ms(body nan 80)
42×18.0ms(body real 640)
125×14.0ms(body real 80)
505×12.0ms(pre true 80)
28×9.0ms(body real 320)
2.0ms(body real 160)

simplify9.0ms

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

prune12.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 31.2b

localize29.0ms

Local error

Found 2 expressions with local error:

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

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

series87.0ms

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

simplify217.0ms

Counts
18 → 35
Calls
18 calls:
Slowest
93.0ms
(- (+ (* 1/2 x) 1) (* 1/8 (pow x 2)))
31.0ms
(sqrt (- (* x x) (* 1 1)))
28.0ms
(/ (exp (sqrt (+ x 1))) (exp (sqrt x)))
10.0ms
(- (sqrt (sqrt (+ x 1))) (sqrt (sqrt x)))
10.0ms
(- (sqrt (sqrt (+ x 1))) (sqrt (sqrt x)))

prune511.0ms

Pruning

9 alts after pruning (9 fresh and 0 done)

Merged error: 30.3b

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

rewrite99.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
51.0ms
(/ (- (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt x) (sqrt x))) (+ (sqrt (+ x 1)) (sqrt x)))
23.0ms
(- (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt x) (sqrt x)))
13.0ms
(* (sqrt (+ x 1)) (sqrt (+ x 1)))
9.0ms
(* (sqrt x) (sqrt x))

series123.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
70.0ms
(/ (- (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt x) (sqrt x))) (+ (sqrt (+ x 1)) (sqrt x)))
23.0ms
(* (sqrt (+ x 1)) (sqrt (+ x 1)))
16.0ms
(* (sqrt x) (sqrt x))
14.0ms
(- (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt x) (sqrt x)))

simplify3.5s

Counts
108 → 128
Calls
108 calls:
Slowest
662.0ms
(- (pow (* (sqrt (+ x 1)) (sqrt (+ x 1))) 3) (pow (* (sqrt x) (sqrt x)) 3))
544.0ms
(- (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt (+ x 1)) (sqrt (+ x 1)))) (* (* (sqrt x) (sqrt x)) (* (sqrt x) (sqrt x))))
259.0ms
(* (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))) (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))))
164.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))))
162.0ms
(+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x))))

prune2.0s

Pruning

6 alts after pruning (6 fresh and 0 done)

Merged error: 0.0b

localize9.0ms

Local error

Found 2 expressions with local error:

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

rewrite12.0ms

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

series89.0ms

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

simplify375.0ms

Counts
19 → 39
Calls
19 calls:
Slowest
180.0ms
(+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x))))
97.0ms
(- (+ (* 1/2 x) 1) (* 1/8 (pow x 2)))
35.0ms
(sqrt (- (* x x) (* 1 1)))
9.0ms
(- (sqrt (+ x 1)) (sqrt x))
8.0ms
(sqrt (+ (pow x 3) (pow 1 3)))

prune620.0ms

Pruning

11 alts after pruning (10 fresh and 1 done)

Merged error: 0.0b

localize33.0ms

Local error

Found 4 expressions with local error:

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

rewrite48.0ms

Algorithm
rewrite-expression-head
Rules
38×sqrt-prod
32×sqrt-div
19×add-sqr-sqrt
15×add-cube-cbrt
15×*-un-lft-identity
10×pow1
flip-+
associate-*l*
associate-*r*
flip3-+
add-exp-log
pow1/2
add-cbrt-cube
add-log-exp
rem-sqrt-square
frac-times
associate-/r*
pow-prod-up
associate-/r/
associate-*r/
associate-*l/
pow-prod-down
inv-pow
pow-flip
div-inv
cbrt-unprod
*-commutative
prod-exp
sqrt-unprod
pow-plus
frac-2neg
rem-square-sqrt
clear-num
rec-exp
pow2
Counts
4 → 98
Calls
4 calls:
Slowest
23.0ms
(/ 1 (+ (* (sqrt (sqrt (+ x 1))) (sqrt (sqrt (+ x 1)))) (sqrt x)))
17.0ms
(* (sqrt (sqrt (+ x 1))) (sqrt (sqrt (+ x 1))))
3.0ms
(sqrt (sqrt (+ x 1)))
2.0ms
(sqrt (sqrt (+ x 1)))

series239.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
72.0ms
(sqrt (sqrt (+ x 1)))
70.0ms
(sqrt (sqrt (+ x 1)))
67.0ms
(/ 1 (+ (* (sqrt (sqrt (+ x 1))) (sqrt (sqrt (+ x 1)))) (sqrt x)))
29.0ms
(* (sqrt (sqrt (+ x 1))) (sqrt (sqrt (+ x 1))))

simplify2.2s

Counts
78 → 110
Calls
78 calls:
Slowest
270.0ms
(- (+ (* 1/4 (/ (exp (* 1/4 (- (log -1) (log (/ -1 x))))) x)) (exp (* 1/4 (- (log -1) (log (/ -1 x)))))) (* 3/32 (/ (exp (* 1/4 (- (log -1) (log (/ -1 x))))) (pow x 2))))
270.0ms
(- (+ (* 1/4 (/ (exp (* 1/4 (- (log -1) (log (/ -1 x))))) x)) (exp (* 1/4 (- (log -1) (log (/ -1 x)))))) (* 3/32 (/ (exp (* 1/4 (- (log -1) (log (/ -1 x))))) (pow x 2))))
227.0ms
(+ (* (* (sqrt (sqrt (+ x 1))) (sqrt (sqrt (+ x 1)))) (* (sqrt (sqrt (+ x 1))) (sqrt (sqrt (+ x 1))))) (- (* (sqrt x) (sqrt x)) (* (* (sqrt (sqrt (+ x 1))) (sqrt (sqrt (+ x 1)))) (sqrt x))))
94.0ms
(- (+ (* 1/4 x) 1) (* 3/32 (pow x 2)))
90.0ms
(- (+ (* 1/4 x) 1) (* 3/32 (pow x 2)))

prune1.9s

Pruning

10 alts after pruning (9 fresh and 1 done)

Merged error: 0.0b

regimes110.0ms

Accuracy

0% (0.1b remaining)

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

bsearch2.0ms

end0.0ms

sample4.0s

Algorithm
intervals
Results
1692×1.4s(body real 1280)
7935×755.0ms(body nan 80)
1246×557.0ms(body real 640)
4014×451.0ms(body real 80)
15935×371.0ms(pre true 80)
707×203.0ms(body real 320)
341×67.0ms(body real 160)