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

Derivation

  1. Initial program 30.2

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

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

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

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

Details

Time bar (total: 15.2s)Debug log

sample124.0ms

Algorithm
intervals
Results
472×(pre true 80)
215×(body nan 80)
141×(body real 80)
52×(body real 1280)
33×(body real 640)
26×(body real 320)
(body real 160)

simplify10.0ms

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

prune11.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 27.6b

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

series85.0ms

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

simplify232.0ms

Counts
18 → 35
Calls
18 calls:
Slowest
97.0ms
(- (+ (* 1/2 x) 1) (* 1/8 (pow x 2)))
33.0ms
(sqrt (- (* x x) (* 1 1)))
31.0ms
(/ (exp (sqrt (+ x 1))) (exp (sqrt x)))
11.0ms
(- (sqrt (sqrt (+ x 1))) (sqrt (sqrt x)))
11.0ms
(- (sqrt (sqrt (+ x 1))) (sqrt (sqrt x)))

prune500.0ms

Pruning

11 alts after pruning (11 fresh and 0 done)

Merged error: 26.6b

localize37.0ms

Local error

Found 4 expressions with local error:

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

rewrite92.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
47.0ms
(/ (- (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt x) (sqrt x))) (+ (sqrt (+ x 1)) (sqrt x)))
22.0ms
(- (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt x) (sqrt x)))
12.0ms
(* (sqrt (+ x 1)) (sqrt (+ x 1)))
8.0ms
(* (sqrt x) (sqrt x))

series121.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
68.0ms
(/ (- (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt x) (sqrt x))) (+ (sqrt (+ x 1)) (sqrt x)))
19.0ms
(* (sqrt (+ x 1)) (sqrt (+ x 1)))
19.0ms
(* (sqrt x) (sqrt x))
14.0ms
(- (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt x) (sqrt x)))

simplify3.7s

Counts
108 → 128
Calls
108 calls:
Slowest
668.0ms
(- (pow (* (sqrt (+ x 1)) (sqrt (+ x 1))) 3) (pow (* (sqrt x) (sqrt x)) 3))
553.0ms
(- (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt (+ x 1)) (sqrt (+ x 1)))) (* (* (sqrt x) (sqrt x)) (* (sqrt x) (sqrt x))))
264.0ms
(* (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))) (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))))
170.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))))
170.0ms
(+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x))))

prune1.9s

Pruning

8 alts after pruning (8 fresh and 0 done)

Merged error: 0.1b

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

rewrite21.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
10.0ms
(+ (sqrt (+ x 1)) (sqrt x))
8.0ms
(/ 1 (+ (sqrt (+ x 1)) (sqrt x)))
1.0ms
(sqrt (+ x 1))

series120.0ms

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

simplify385.0ms

Counts
24 → 54
Calls
24 calls:
Slowest
169.0ms
(+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x))))
96.0ms
(- (+ (* 1/2 x) 1) (* 1/8 (pow x 2)))
35.0ms
(sqrt (- (* x x) (* 1 1)))
12.0ms
(* (exp (sqrt (+ x 1))) (exp (sqrt x)))
10.0ms
(- (sqrt (+ x 1)) (sqrt x))

prune712.0ms

Pruning

10 alts after pruning (9 fresh and 1 done)

Merged error: 0.0b

localize16.0ms

Local error

Found 4 expressions with local error:

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

rewrite36.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
14.0ms
(* (sqrt (/ 1 (+ (sqrt (+ x 1)) (sqrt x)))) (sqrt (/ 1 (+ (sqrt (+ x 1)) (sqrt x)))))
8.0ms
(/ 1 (+ (sqrt (+ x 1)) (sqrt x)))
8.0ms
(/ 1 (+ (sqrt (+ x 1)) (sqrt x)))
3.0ms
(sqrt (/ 1 (+ (sqrt (+ x 1)) (sqrt x))))

series270.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
95.0ms
(sqrt (/ 1 (+ (sqrt (+ x 1)) (sqrt x))))
61.0ms
(* (sqrt (/ 1 (+ (sqrt (+ x 1)) (sqrt x)))) (sqrt (/ 1 (+ (sqrt (+ x 1)) (sqrt x)))))
57.0ms
(/ 1 (+ (sqrt (+ x 1)) (sqrt x)))
56.0ms
(/ 1 (+ (sqrt (+ x 1)) (sqrt x)))

simplify1.1s

Counts
66 → 105
Calls
66 calls:
Slowest
169.0ms
(sqrt (+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x)))))
168.0ms
(+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x))))
168.0ms
(+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x))))
145.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))))))
49.0ms
(* (/ 1 (+ (sqrt (+ x 1)) (sqrt x))) (/ 1 (+ (sqrt (+ x 1)) (sqrt x))))

prune1.6s

Pruning

10 alts after pruning (9 fresh and 1 done)

Merged error: 0.0b

regimes109.0ms

Accuracy

0% (0.1b remaining)

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

bsearch2.0ms

end0.0ms

sample4.0s

Algorithm
intervals
Results
16095×(pre true 80)
8094×(body nan 80)
4049×(body real 80)
1719×(body real 1280)
1295×(body real 640)
636×(body real 320)
302×(body real 160)