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

Derivation

  1. Initial program 30.1

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

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

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

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

Details

Time bar (total: 12.6s)Debug log

sample125.0ms

Algorithm
intervals
Results
28.0ms58×body1280valid
24.0ms277×body80nan
16.0ms43×body640valid
13.0ms127×body80valid
7.0ms23×body320valid
1.0msbody160valid

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.0b

localize28.0ms

Local error

Found 1 expressions with local error:

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

rewrite13.0ms

Algorithm
rewrite-expression-head
Rules
add-sqr-sqrt
add-log-exp
*-un-lft-identity
difference-of-squares
distribute-lft-out--
flip--
sqrt-prod
add-cube-cbrt
add-exp-log
diff-log
add-cbrt-cube
flip3--
sub-neg
pow1
Counts
1 → 15
Calls
1 calls:
Slowest
13.0ms
(- (sqrt (+ x 1)) (sqrt x))

series47.0ms

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

simplify78.0ms

Counts
9 → 18
Calls
9 calls:
Slowest
28.0ms
(/ (exp (sqrt (+ x 1))) (exp (sqrt x)))
16.0ms
(- (sqrt (sqrt (+ x 1))) (sqrt (sqrt x)))
10.0ms
(- (sqrt (sqrt (+ x 1))) (sqrt (sqrt x)))
8.0ms
(- (sqrt (+ x 1)) (sqrt x))
6.0ms
(+ (sqrt (sqrt (+ x 1))) (sqrt (sqrt x)))

prune239.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 31.0b

localize18.0ms

Local error

Found 3 expressions with local error:

2.7b
(- (sqrt (+ x 1)) (sqrt x))
2.1b
(log (exp (- (sqrt (+ x 1)) (sqrt x))))
0.0b
(exp (- (sqrt (+ x 1)) (sqrt x)))

rewrite67.0ms

Algorithm
rewrite-expression-head
Rules
18×add-sqr-sqrt
12×*-un-lft-identity
12×exp-prod
add-log-exp
log-pow
difference-of-squares
add-cube-cbrt
log-prod
exp-sum
pow1
distribute-lft-out--
sqrt-prod
add-exp-log
add-cbrt-cube
sub-neg
rem-exp-log
diff-log
exp-diff
flip--
rem-log-exp
flip3--
log-div
Counts
3 → 54
Calls
3 calls:
Slowest
28.0ms
(exp (- (sqrt (+ x 1)) (sqrt x)))
25.0ms
(log (exp (- (sqrt (+ x 1)) (sqrt x))))
13.0ms
(- (sqrt (+ x 1)) (sqrt x))

series171.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
78.0ms
(exp (- (sqrt (+ x 1)) (sqrt x)))
46.0ms
(- (sqrt (+ x 1)) (sqrt x))
46.0ms
(log (exp (- (sqrt (+ x 1)) (sqrt x))))

simplify309.0ms

Counts
39 → 63
Calls
39 calls:
Slowest
46.0ms
(log (* (cbrt (exp (- (sqrt (+ x 1)) (sqrt x)))) (cbrt (exp (- (sqrt (+ x 1)) (sqrt x))))))
38.0ms
(log (sqrt (exp (- (sqrt (+ x 1)) (sqrt x)))))
28.0ms
(/ (exp (sqrt (+ x 1))) (exp (sqrt x)))
13.0ms
(exp (* (cbrt (- (sqrt (+ x 1)) (sqrt x))) (cbrt (- (sqrt (+ x 1)) (sqrt x)))))
12.0ms
(exp (+ (sqrt (sqrt (+ x 1))) (sqrt (sqrt x))))

prune954.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 31.0b

localize16.0ms

Local error

Found 3 expressions with local error:

2.7b
(- (sqrt (+ x 1)) (sqrt x))
2.1b
(log (* 1 (exp (- (sqrt (+ x 1)) (sqrt x)))))
0.0b
(exp (- (sqrt (+ x 1)) (sqrt x)))

rewrite59.0ms

Algorithm
rewrite-expression-head
Rules
12×add-sqr-sqrt
add-log-exp
*-un-lft-identity
exp-prod
difference-of-squares
add-cube-cbrt
add-exp-log
pow1
add-cbrt-cube
rem-exp-log
distribute-lft-out--
sqrt-prod
exp-sum
diff-log
exp-diff
sub-neg
flip--
log-pow
associate-*r/
rem-log-exp
flip3--
log-prod
log-div
Counts
3 → 44
Calls
3 calls:
Slowest
28.0ms
(exp (- (sqrt (+ x 1)) (sqrt x)))
15.0ms
(- (sqrt (+ x 1)) (sqrt x))
15.0ms
(log (* 1 (exp (- (sqrt (+ x 1)) (sqrt x)))))

series167.0ms

Counts
3 → 9
Calls
3 calls:
Slowest
74.0ms
(exp (- (sqrt (+ x 1)) (sqrt x)))
47.0ms
(- (sqrt (+ x 1)) (sqrt x))
46.0ms
(log (* 1 (exp (- (sqrt (+ x 1)) (sqrt x)))))

simplify228.0ms

Counts
29 → 53
Calls
29 calls:
Slowest
61.0ms
(* 1 (exp (- (sqrt (+ x 1)) (sqrt x))))
28.0ms
(/ (exp (sqrt (+ x 1))) (exp (sqrt x)))
16.0ms
(log (* 1 (exp (sqrt (+ x 1)))))
13.0ms
(exp (* (cbrt (- (sqrt (+ x 1)) (sqrt x))) (cbrt (- (sqrt (+ x 1)) (sqrt x)))))
12.0ms
(exp (+ (sqrt (sqrt (+ x 1))) (sqrt (sqrt x))))

prune804.0ms

Pruning

4 alts after pruning (3 fresh and 1 done)

Merged error: 31.0b

localize36.0ms

Local error

Found 4 expressions with local error:

2.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.1b
(/ (- (* (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
49.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))

series116.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)))
18.0ms
(* (sqrt (+ x 1)) (sqrt (+ x 1)))
15.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
643.0ms
(- (pow (* (sqrt (+ x 1)) (sqrt (+ x 1))) 3) (pow (* (sqrt x) (sqrt x)) 3))
539.0ms
(- (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt (+ x 1)) (sqrt (+ x 1)))) (* (* (sqrt x) (sqrt x)) (* (sqrt x) (sqrt x))))
254.0ms
(* (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))) (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))))
166.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))))
160.0ms
(+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x))))

prune1.8s

Pruning

7 alts after pruning (7 fresh and 0 done)

Merged error: 0.1b

regimes81.0ms

Accuracy

0% (0.1b remaining)

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

bsearch2.0ms

end0.0ms

sample3.6s

Algorithm
intervals
Results
1.1s8083×body80nan
928.0ms1768×body1280valid
563.0ms1283×body640valid
453.0ms4072×body80valid
167.0ms587×body320valid
89.0ms290×body160valid