Average Error: 30.1 → 0.2
Time: 11.1s
Precision: 64
Internal Precision: 128
\[\sqrt{x + 1} - \sqrt{x}\]
\[(e^{\log_* (1 + \frac{1}{\sqrt{x + 1} + \sqrt{x}})} - 1)^*\]

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.8

    \[\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 inf 0.2

    \[\leadsto \frac{\color{blue}{1}}{\sqrt{x + 1} + \sqrt{x}}\]
  5. Using strategy rm
  6. Applied expm1-log1p-u0.2

    \[\leadsto \color{blue}{(e^{\log_* (1 + \frac{1}{\sqrt{x + 1} + \sqrt{x}})} - 1)^*}\]
  7. Final simplification0.2

    \[\leadsto (e^{\log_* (1 + \frac{1}{\sqrt{x + 1} + \sqrt{x}})} - 1)^*\]

Reproduce

herbie shell --seed 2019005 +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: 10.1s)Debug log

sample47.0ms

Algorithm
intervals

simplify5.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune4.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 30.4b

localize10.0ms

Local error

Found 2 expressions with local error:

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

rewrite19.0ms

Algorithm
rewrite-expression-head
Counts
2 → 57
Calls

2 calls. Slowest were:

17.0ms
(- (sqrt (+ x 1)) (sqrt x))
1.0ms
(sqrt (+ x 1))

series34.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

23.0ms
(- (sqrt (+ x 1)) (sqrt x))
11.0ms
(sqrt (+ x 1))

simplify1.1s

Counts
59 → 63
Calls

59 calls. Slowest were:

82.0ms
(- (+ (* 1/2 x) 1) (* 1/8 (pow x 2)))
44.0ms
(fma (sqrt (sqrt (+ x 1))) (sqrt (sqrt (+ x 1))) (- (* (sqrt (sqrt x)) (sqrt (sqrt x)))))
39.0ms
(fma (sqrt 1) (sqrt (+ x 1)) (- (* (sqrt x) 1)))

prune455.0ms

Pruning

13 alts after pruning (13 fresh and 0 done)

Merged error: 29.4b

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

rewrite57.0ms

Algorithm
rewrite-expression-head
Counts
4 → 126
Calls

4 calls. Slowest were:

29.0ms
(/ (- (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt x) (sqrt x))) (+ (sqrt (+ x 1)) (sqrt x)))
16.0ms
(- (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt x) (sqrt x)))
5.0ms
(* (sqrt (+ x 1)) (sqrt (+ x 1)))

series72.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

42.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)))
10.0ms
(* (sqrt x) (sqrt x))
9.0ms
(* (sqrt (+ x 1)) (sqrt (+ x 1)))

simplify3.0s

Counts
111 → 138
Calls

111 calls. Slowest were:

587.0ms
(- (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt (+ x 1)) (sqrt (+ x 1)))) (* (* (sqrt x) (sqrt x)) (* (sqrt x) (sqrt x))))
247.0ms
(* (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))) (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))))
161.0ms
(- (pow (* (sqrt (+ x 1)) (sqrt (+ x 1))) 3) (pow (* (sqrt x) (sqrt x)) 3))

prune1.2s

Pruning

8 alts after pruning (8 fresh and 0 done)

Merged error: 0.1b

localize6.0ms

Local error

Found 3 expressions with local error:

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

rewrite21.0ms

Algorithm
rewrite-expression-head
Counts
3 → 57
Calls

3 calls. Slowest were:

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

series84.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

41.0ms
(/ 1 (+ (sqrt (+ x 1)) (sqrt x)))
31.0ms
(+ (sqrt (+ x 1)) (sqrt x))
11.0ms
(sqrt (+ x 1))

simplify260.0ms

Counts
29 → 66
Calls

29 calls. Slowest were:

101.0ms
(+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x))))
63.0ms
(- (+ (* 1/2 x) 1) (* 1/8 (pow x 2)))
20.0ms
(sqrt (- (* x x) (* 1 1)))

prune437.0ms

Pruning

10 alts after pruning (10 fresh and 0 done)

Merged error: 0.0b

localize7.0ms

Local error

Found 4 expressions with local error:

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

rewrite11.0ms

Algorithm
rewrite-expression-head
Counts
4 → 63
Calls

4 calls. Slowest were:

6.0ms
(+ (sqrt (+ x 1)) (sqrt x))
4.0ms
(/ 1 (+ (sqrt (+ x 1)) (sqrt x)))
0.0ms
(log1p (/ 1 (+ (sqrt (+ x 1)) (sqrt x))))

series215.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

80.0ms
(expm1 (log1p (/ 1 (+ (sqrt (+ x 1)) (sqrt x)))))
74.0ms
(log1p (/ 1 (+ (sqrt (+ x 1)) (sqrt x))))
34.0ms
(+ (sqrt (+ x 1)) (sqrt x))
27.0ms
(/ 1 (+ (sqrt (+ x 1)) (sqrt x)))

simplify174.0ms

Counts
27 → 75
Calls

27 calls. Slowest were:

117.0ms
(+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x))))
6.0ms
(* (exp (sqrt (+ x 1))) (exp (sqrt x)))
6.0ms
(sqrt (+ (sqrt (+ x 1)) (sqrt x)))

prune492.0ms

Pruning

10 alts after pruning (9 fresh and 1 done)

Merged error: 0.0b

regimes43.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.3s

Algorithm
intervals