Average Error: 30.1 → 0.2
Time: 12.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.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 2019002 +o rules:numerics
(FPCore (x)
  :name "2sqrt (example 3.1)"

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

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

Details

Time bar (total: 11.3s)Debug log

sample80.0ms

Algorithm
intervals

simplify8.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

8.0ms
(- (sqrt (+ x 1)) (sqrt x))

prune9.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 32.4b

localize39.0ms

Local error

Found 1 expressions with local error:

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

rewrite14.0ms

Algorithm
rewrite-expression-head
Counts
1 → 41
Calls

1 calls. Slowest were:

13.0ms
(- (sqrt (+ x 1)) (sqrt x))

series29.0ms

Counts
1 → 3
Calls

1 calls. Slowest were:

29.0ms
(- (sqrt (+ x 1)) (sqrt x))

simplify725.0ms

Counts
50 → 44
Calls

50 calls. Slowest were:

43.0ms
(fma (sqrt (sqrt (+ x 1))) (sqrt (sqrt (+ x 1))) (- (* (sqrt (sqrt x)) (sqrt (sqrt x)))))
36.0ms
(fma (sqrt 1) (sqrt (+ x 1)) (- (* (sqrt x) 1)))
32.0ms
(fma (- (cbrt (sqrt x))) (* (cbrt (sqrt x)) (cbrt (sqrt x))) (* (cbrt (sqrt x)) (* (cbrt (sqrt x)) (cbrt (sqrt x)))))

prune364.0ms

Pruning

7 alts after pruning (7 fresh and 0 done)

Merged error: 31.6b

localize17.0ms

Local error

Found 4 expressions with local error:

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

rewrite60.0ms

Algorithm
rewrite-expression-head
Counts
4 → 126
Calls

4 calls. Slowest were:

30.0ms
(/ (- (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt x) (sqrt x))) (+ (sqrt (+ x 1)) (sqrt x)))
18.0ms
(- (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt x) (sqrt x)))
5.0ms
(* (sqrt (+ x 1)) (sqrt (+ x 1)))

series77.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

38.0ms
(/ (- (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt x) (sqrt x))) (+ (sqrt (+ x 1)) (sqrt x)))
15.0ms
(* (sqrt (+ x 1)) (sqrt (+ x 1)))
12.0ms
(* (sqrt x) (sqrt x))
12.0ms
(- (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt x) (sqrt x)))

simplify3.0s

Counts
111 → 138
Calls

111 calls. Slowest were:

723.0ms
(- (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt (+ x 1)) (sqrt (+ x 1)))) (* (* (sqrt x) (sqrt x)) (* (sqrt x) (sqrt x))))
277.0ms
(* (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))) (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))))
177.0ms
(- (pow (* (sqrt (+ x 1)) (sqrt (+ x 1))) 3) (pow (* (sqrt x) (sqrt x)) 3))

prune1.1s

Pruning

6 alts after pruning (6 fresh and 0 done)

Merged error: 0.0b

localize5.0ms

Local error

Found 2 expressions with local error:

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

rewrite16.0ms

Algorithm
rewrite-expression-head
Counts
2 → 41
Calls

2 calls. Slowest were:

9.0ms
(+ (sqrt (+ x 1)) (sqrt x))
7.0ms
(/ 1 (+ (sqrt (+ x 1)) (sqrt x)))

series71.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

36.0ms
(/ 1 (+ (sqrt (+ x 1)) (sqrt x)))
34.0ms
(+ (sqrt (+ x 1)) (sqrt x))

simplify174.0ms

Counts
20 → 47
Calls

20 calls. Slowest were:

121.0ms
(+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x))))
8.0ms
(- (sqrt (+ x 1)) (sqrt x))
7.0ms
(* (exp (sqrt (+ x 1))) (exp (sqrt x)))

prune417.0ms

Pruning

10 alts after pruning (9 fresh and 1 done)

Merged error: 0.0b

localize20.0ms

Local error

Found 4 expressions with local error:

0.3b
(cbrt (+ x 1))
0.3b
(cbrt (+ 1 x))
0.2b
(/ 1 (fma (fabs (cbrt (+ 1 x))) (sqrt (cbrt (+ x 1))) (sqrt x)))
0.1b
(sqrt (cbrt (+ x 1)))

rewrite7.0ms

Algorithm
rewrite-expression-head
Counts
4 → 68
Calls

4 calls. Slowest were:

2.0ms
(sqrt (cbrt (+ x 1)))
1.0ms
(/ 1 (fma (fabs (cbrt (+ 1 x))) (sqrt (cbrt (+ x 1))) (sqrt x)))
1.0ms
(cbrt (+ x 1))

series191.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

83.0ms
(/ 1 (fma (fabs (cbrt (+ 1 x))) (sqrt (cbrt (+ x 1))) (sqrt x)))
41.0ms
(cbrt (+ x 1))
34.0ms
(cbrt (+ 1 x))
32.0ms
(sqrt (cbrt (+ x 1)))

simplify1.2s

Counts
36 → 80
Calls

36 calls. Slowest were:

248.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))))
238.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))))
218.0ms
(- (+ (exp (* 1/6 (- (log -1) (log (/ -1 x))))) (* 1/6 (/ (exp (* 1/6 (- (log -1) (log (/ -1 x))))) x))) (* 5/72 (/ (exp (* 1/6 (- (log -1) (log (/ -1 x))))) (pow x 2))))

prune986.0ms

Pruning

10 alts after pruning (8 fresh and 2 done)

Merged error: 0.0b

regimes94.0ms

Accuracy

0% (0.1b remaining)

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

bsearch2.0ms

end0.0ms

sample2.5s

Algorithm
intervals