Average Error: 29.7 → 0.2
Time: 14.5s
Precision: 64
Internal Precision: 128
\[\sqrt{x + 1} - \sqrt{x}\]
\[\frac{1}{\sqrt{x} + \sqrt{1 + x}}\]

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original29.7
Target0.2
Herbie0.2
\[\frac{1}{\sqrt{x + 1} + \sqrt{x}}\]

Derivation

  1. Initial program 29.7

    \[\sqrt{x + 1} - \sqrt{x}\]
  2. Initial simplification29.7

    \[\leadsto \sqrt{1 + x} - \sqrt{x}\]
  3. Using strategy rm
  4. Applied flip--29.6

    \[\leadsto \color{blue}{\frac{\sqrt{1 + x} \cdot \sqrt{1 + x} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{1 + x} + \sqrt{x}}}\]
  5. Taylor expanded around inf 0.2

    \[\leadsto \frac{\color{blue}{1}}{\sqrt{1 + x} + \sqrt{x}}\]
  6. Using strategy rm
  7. Applied add-sqr-sqrt0.2

    \[\leadsto \frac{1}{\sqrt{\color{blue}{\sqrt{1 + x} \cdot \sqrt{1 + x}}} + \sqrt{x}}\]
  8. Applied sqrt-prod0.3

    \[\leadsto \frac{1}{\color{blue}{\sqrt{\sqrt{1 + x}} \cdot \sqrt{\sqrt{1 + x}}} + \sqrt{x}}\]
  9. Using strategy rm
  10. Applied *-un-lft-identity0.3

    \[\leadsto \frac{1}{\color{blue}{1 \cdot \left(\sqrt{\sqrt{1 + x}} \cdot \sqrt{\sqrt{1 + x}} + \sqrt{x}\right)}}\]
  11. Applied associate-/r*0.3

    \[\leadsto \color{blue}{\frac{\frac{1}{1}}{\sqrt{\sqrt{1 + x}} \cdot \sqrt{\sqrt{1 + x}} + \sqrt{x}}}\]
  12. Simplified0.2

    \[\leadsto \frac{\frac{1}{1}}{\color{blue}{\sqrt{x + 1} + \sqrt{x}}}\]
  13. Final simplification0.2

    \[\leadsto \frac{1}{\sqrt{x} + \sqrt{1 + x}}\]

Reproduce

herbie shell --seed 2018360 +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.3s)Debug log

start50.0ms

Algorithm
intervals

setup27.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 28.2b

localize10.0ms

Local error

Found 2 expressions with local error:

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

rewrite7.0ms

Algorithm
rewrite-expression-head
Counts
2 → 57
Calls

2 calls. Slowest were:

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

series33.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

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

simplify750.0ms

Counts
59 → 63
Calls

59 calls. Slowest were:

75.0ms
(- (+ (* 1/2 x) 1) (* 1/8 (pow x 2)))
37.0ms
(fma (sqrt (sqrt (+ 1 x))) (sqrt (sqrt (+ 1 x))) (- (* (sqrt (sqrt x)) (sqrt (sqrt x)))))
30.0ms
(fma (sqrt (sqrt (+ 1 x))) (sqrt (sqrt (+ 1 x))) (- (* (sqrt (sqrt x)) (sqrt (sqrt x)))))

prune570.0ms

Pruning

13 alts after pruning (13 fresh and 0 done)

Merged error: 27.1b

localize13.0ms

Local error

Found 4 expressions with local error:

1.7b
(- (* (sqrt (+ 1 x)) (sqrt (+ 1 x))) (* (sqrt x) (sqrt x)))
0.5b
(* (sqrt x) (sqrt x))
0.2b
(* (sqrt (+ 1 x)) (sqrt (+ 1 x)))
0.1b
(/ (- (* (sqrt (+ 1 x)) (sqrt (+ 1 x))) (* (sqrt x) (sqrt x))) (+ (sqrt (+ 1 x)) (sqrt x)))

rewrite55.0ms

Algorithm
rewrite-expression-head
Counts
4 → 126
Calls

4 calls. Slowest were:

24.0ms
(/ (- (* (sqrt (+ 1 x)) (sqrt (+ 1 x))) (* (sqrt x) (sqrt x))) (+ (sqrt (+ 1 x)) (sqrt x)))
14.0ms
(* (sqrt (+ 1 x)) (sqrt (+ 1 x)))
10.0ms
(- (* (sqrt (+ 1 x)) (sqrt (+ 1 x))) (* (sqrt x) (sqrt x)))

series89.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

57.0ms
(/ (- (* (sqrt (+ 1 x)) (sqrt (+ 1 x))) (* (sqrt x) (sqrt x))) (+ (sqrt (+ 1 x)) (sqrt x)))
16.0ms
(* (sqrt (+ 1 x)) (sqrt (+ 1 x)))
10.0ms
(* (sqrt x) (sqrt x))
7.0ms
(- (* (sqrt (+ 1 x)) (sqrt (+ 1 x))) (* (sqrt x) (sqrt x)))

simplify2.7s

Counts
111 → 138
Calls

111 calls. Slowest were:

527.0ms
(- (pow (* (sqrt (+ 1 x)) (sqrt (+ 1 x))) 3) (pow (* (sqrt x) (sqrt x)) 3))
489.0ms
(- (* (* (sqrt (+ 1 x)) (sqrt (+ 1 x))) (* (sqrt (+ 1 x)) (sqrt (+ 1 x)))) (* (* (sqrt x) (sqrt x)) (* (sqrt x) (sqrt x))))
316.0ms
(* (* (* (sqrt (+ 1 x)) (sqrt (+ 1 x))) (sqrt (+ 1 x))) (* (* (sqrt (+ 1 x)) (sqrt (+ 1 x))) (sqrt (+ 1 x))))

prune1.5s

Pruning

10 alts after pruning (10 fresh and 0 done)

Merged error: 0.0b

localize3.0ms

Local error

Found 3 expressions with local error:

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

rewrite10.0ms

Algorithm
rewrite-expression-head
Counts
3 → 57
Calls

3 calls. Slowest were:

5.0ms
(+ (sqrt (+ 1 x)) (sqrt x))
4.0ms
(/ 1 (+ (sqrt (+ 1 x)) (sqrt x)))
1.0ms
(sqrt (+ 1 x))

series100.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

47.0ms
(/ 1 (+ (sqrt (+ 1 x)) (sqrt x)))
33.0ms
(+ (sqrt (+ 1 x)) (sqrt x))
20.0ms
(sqrt (+ 1 x))

simplify307.0ms

Counts
29 → 66
Calls

29 calls. Slowest were:

155.0ms
(+ (* (sqrt (+ 1 x)) (sqrt (+ 1 x))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ 1 x)) (sqrt x))))
73.0ms
(- (+ (* 1/2 x) 1) (* 1/8 (pow x 2)))
9.0ms
(- (sqrt (+ 1 x)) (sqrt x))

prune666.0ms

Pruning

9 alts after pruning (9 fresh and 0 done)

Merged error: 0.0b

localize13.0ms

Local error

Found 4 expressions with local error:

0.2b
(* (sqrt (sqrt (+ 1 x))) (sqrt (sqrt (+ 1 x))))
0.2b
(/ 1 (+ (* (sqrt (sqrt (+ 1 x))) (sqrt (sqrt (+ 1 x)))) (sqrt x)))
0.1b
(sqrt (sqrt (+ 1 x)))
0.1b
(sqrt (sqrt (+ 1 x)))

rewrite34.0ms

Algorithm
rewrite-expression-head
Counts
4 → 106
Calls

4 calls. Slowest were:

17.0ms
(/ 1 (+ (* (sqrt (sqrt (+ 1 x))) (sqrt (sqrt (+ 1 x)))) (sqrt x)))
10.0ms
(* (sqrt (sqrt (+ 1 x))) (sqrt (sqrt (+ 1 x))))
2.0ms
(sqrt (sqrt (+ 1 x)))

series150.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

49.0ms
(sqrt (sqrt (+ 1 x)))
45.0ms
(/ 1 (+ (* (sqrt (sqrt (+ 1 x))) (sqrt (sqrt (+ 1 x)))) (sqrt x)))
37.0ms
(sqrt (sqrt (+ 1 x)))
19.0ms
(* (sqrt (sqrt (+ 1 x))) (sqrt (sqrt (+ 1 x))))

simplify1.7s

Counts
78 → 118
Calls

78 calls. Slowest were:

284.0ms
(- (+ (* 1/4 (/ (exp (* 1/4 (- (log -1) (log (/ -1 x))))) x)) (exp (* 1/4 (- (log -1) (log (/ -1 x)))))) (* 3/32 (/ (exp (* 1/4 (- (log -1) (log (/ -1 x))))) (pow x 2))))
238.0ms
(- (+ (* 1/4 (/ (exp (* 1/4 (- (log -1) (log (/ -1 x))))) x)) (exp (* 1/4 (- (log -1) (log (/ -1 x)))))) (* 3/32 (/ (exp (* 1/4 (- (log -1) (log (/ -1 x))))) (pow x 2))))
191.0ms
(+ (* (* (sqrt (sqrt (+ 1 x))) (sqrt (sqrt (+ 1 x)))) (* (sqrt (sqrt (+ 1 x))) (sqrt (sqrt (+ 1 x))))) (- (* (sqrt x) (sqrt x)) (* (* (sqrt (sqrt (+ 1 x))) (sqrt (sqrt (+ 1 x)))) (sqrt x))))

prune1.4s

Pruning

9 alts after pruning (9 fresh and 0 done)

Merged error: 0.0b

regimes76.0ms

Accuracy

0% (0.1b remaining)

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

bsearch2.0ms