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

Derivation

  1. Initial program 29.2

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

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

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

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

Details

Time bar (total: 8.7s)Debug log

sample78.0ms

Algorithm
intervals
Results
25.0ms284×body80nan
12.0ms44×body1280valid
10.0ms47×body640valid
7.0ms126×body80valid
5.0ms28×body320valid
1.0ms12×body160valid

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: 31.1b

localize21.0ms

Local error

Found 2 expressions with local error:

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

series56.0ms

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

simplify131.0ms

Counts
18 → 35
Calls
18 calls:
Slowest
48.0ms
(- (+ (* 1/2 x) 1) (* 1/8 (pow x 2)))
32.0ms
(/ (exp (sqrt (+ x 1))) (exp (sqrt x)))
14.0ms
(sqrt (- (* x x) (* 1 1)))
6.0ms
(+ (sqrt (sqrt (+ x 1))) (sqrt (sqrt x)))
5.0ms
(- (sqrt (sqrt (+ x 1))) (sqrt (sqrt x)))

prune370.0ms

Pruning

12 alts after pruning (12 fresh and 0 done)

Merged error: 30.0b

localize13.0ms

Local error

Found 4 expressions with local error:

2.4b
(- (* (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)))

rewrite64.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)))
11.0ms
(- (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt x) (sqrt x)))
6.0ms
(* (sqrt (+ x 1)) (sqrt (+ x 1)))
3.0ms
(* (sqrt x) (sqrt x))

series76.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
35.0ms
(/ (- (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt x) (sqrt x))) (+ (sqrt (+ x 1)) (sqrt x)))
16.0ms
(* (sqrt (+ x 1)) (sqrt (+ x 1)))
13.0ms
(* (sqrt x) (sqrt x))
12.0ms
(- (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt x) (sqrt x)))

simplify2.1s

Counts
108 → 128
Calls
108 calls:
Slowest
372.0ms
(- (pow (* (sqrt (+ x 1)) (sqrt (+ x 1))) 3) (pow (* (sqrt x) (sqrt x)) 3))
351.0ms
(- (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt (+ x 1)) (sqrt (+ x 1)))) (* (* (sqrt x) (sqrt x)) (* (sqrt x) (sqrt x))))
145.0ms
(* (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))) (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))))
113.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))))
105.0ms
(+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x))))

prune1.1s

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

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

series69.0ms

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

simplify240.0ms

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

prune448.0ms

Pruning

8 alts after pruning (7 fresh and 1 done)

Merged error: 0.0b

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

rewrite15.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
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 → 93
Calls
4 calls:
Slowest
6.0ms
(* (sqrt (/ 1 (+ (sqrt (+ x 1)) (sqrt x)))) (sqrt (/ 1 (+ (sqrt (+ x 1)) (sqrt x)))))
3.0ms
(/ 1 (+ (sqrt (+ x 1)) (sqrt x)))
3.0ms
(/ 1 (+ (sqrt (+ x 1)) (sqrt x)))
1.0ms
(sqrt (/ 1 (+ (sqrt (+ x 1)) (sqrt x))))

series140.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
51.0ms
(sqrt (/ 1 (+ (sqrt (+ x 1)) (sqrt x))))
34.0ms
(/ 1 (+ (sqrt (+ x 1)) (sqrt x)))
28.0ms
(* (sqrt (/ 1 (+ (sqrt (+ x 1)) (sqrt x)))) (sqrt (/ 1 (+ (sqrt (+ x 1)) (sqrt x)))))
27.0ms
(/ 1 (+ (sqrt (+ x 1)) (sqrt x)))

simplify656.0ms

Counts
66 → 105
Calls
66 calls:
Slowest
120.0ms
(+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x))))
102.0ms
(+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x))))
100.0ms
(sqrt (+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x)))))
70.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))))))
24.0ms
(* (/ 1 (+ (sqrt (+ x 1)) (sqrt x))) (/ 1 (+ (sqrt (+ x 1)) (sqrt x))))

prune900.0ms

Pruning

9 alts after pruning (7 fresh and 2 done)

Merged error: 0b

regimes62.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
589.0ms4181×body80valid
481.0ms1646×body1280valid
376.0ms8053×body80nan
266.0ms1222×body640valid
197.0ms650×body320valid
28.0ms302×body160valid