Average Error: 29.8 → 0.3
Time: 14.7s
Precision: 64
Internal Precision: 128
\[\sqrt{x + 1} - \sqrt{x}\]
\[\frac{1}{\sqrt{\sqrt{x + 1}} \cdot \sqrt{\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

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

Derivation

  1. Initial program 29.8

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

    \[\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 add-sqr-sqrt0.2

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

    \[\leadsto \frac{1}{\color{blue}{\sqrt{\sqrt{x + 1}} \cdot \sqrt{\sqrt{x + 1}}} + \sqrt{x}}\]
  8. Final simplification0.3

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

Reproduce

herbie shell --seed 2018362 +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

start64.0ms

Algorithm
intervals

setup21.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 27.8b

localize10.0ms

Local error

Found 2 expressions with local error:

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

rewrite7.0ms

Algorithm
rewrite-expression-head
Counts
2 → 57
Calls

2 calls. Slowest were:

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

series41.0ms

Counts
2 → 6
Calls

2 calls. Slowest were:

25.0ms
(- (sqrt (+ x 1)) (sqrt x))
16.0ms
(sqrt (+ x 1))

simplify746.0ms

Counts
59 → 63
Calls

59 calls. Slowest were:

90.0ms
(- (+ (* 1/2 x) 1) (* 1/8 (pow x 2)))
39.0ms
(fma (sqrt (sqrt (+ x 1))) (sqrt (sqrt (+ x 1))) (- (* (sqrt (sqrt x)) (sqrt (sqrt x)))))
32.0ms
(fma (- (cbrt (sqrt x))) (* (cbrt (sqrt x)) (cbrt (sqrt x))) (* (cbrt (sqrt x)) (* (cbrt (sqrt x)) (cbrt (sqrt x)))))

prune602.0ms

Pruning

13 alts after pruning (13 fresh and 0 done)

Merged error: 27.2b

localize31.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.2b
(* (sqrt (+ x 1)) (sqrt (+ x 1)))
0.0b
(/ (- (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt x) (sqrt x))) (+ (sqrt (+ x 1)) (sqrt x)))

rewrite51.0ms

Algorithm
rewrite-expression-head
Counts
4 → 126
Calls

4 calls. Slowest were:

23.0ms
(/ (- (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt x) (sqrt x))) (+ (sqrt (+ x 1)) (sqrt x)))
17.0ms
(- (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt x) (sqrt x)))
5.0ms
(* (sqrt (+ x 1)) (sqrt (+ x 1)))

series80.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

39.0ms
(/ (- (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt x) (sqrt x))) (+ (sqrt (+ x 1)) (sqrt x)))
16.0ms
(* (sqrt (+ x 1)) (sqrt (+ x 1)))
13.0ms
(* (sqrt x) (sqrt x))
12.0ms
(- (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt x) (sqrt x)))

simplify3.5s

Counts
111 → 138
Calls

111 calls. Slowest were:

844.0ms
(- (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (* (sqrt (+ x 1)) (sqrt (+ x 1)))) (* (* (sqrt x) (sqrt x)) (* (sqrt x) (sqrt x))))
291.0ms
(* (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))) (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))))
215.0ms
(- (pow (* (sqrt (+ x 1)) (sqrt (+ x 1))) 3) (pow (* (sqrt x) (sqrt x)) 3))

prune1.4s

Pruning

7 alts after pruning (7 fresh and 0 done)

Merged error: 0.1b

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

rewrite9.0ms

Algorithm
rewrite-expression-head
Counts
3 → 57
Calls

3 calls. Slowest were:

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

series73.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

35.0ms
(/ 1 (+ (sqrt (+ x 1)) (sqrt x)))
28.0ms
(+ (sqrt (+ x 1)) (sqrt x))
10.0ms
(sqrt (+ x 1))

simplify350.0ms

Counts
29 → 66
Calls

29 calls. Slowest were:

119.0ms
(+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x))))
107.0ms
(- (+ (* 1/2 x) 1) (* 1/8 (pow x 2)))
36.0ms
(sqrt (- (* x x) (* 1 1)))

prune653.0ms

Pruning

10 alts after pruning (10 fresh and 0 done)

Merged error: 0.0b

localize22.0ms

Local error

Found 4 expressions with local error:

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

rewrite37.0ms

Algorithm
rewrite-expression-head
Counts
4 → 106
Calls

4 calls. Slowest were:

16.0ms
(/ 1 (+ (* (sqrt (sqrt (+ x 1))) (sqrt (sqrt (+ x 1)))) (sqrt x)))
13.0ms
(* (sqrt (sqrt (+ x 1))) (sqrt (sqrt (+ x 1))))
3.0ms
(sqrt (sqrt (+ x 1)))

series153.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

48.0ms
(sqrt (sqrt (+ x 1)))
47.0ms
(/ 1 (+ (* (sqrt (sqrt (+ x 1))) (sqrt (sqrt (+ x 1)))) (sqrt x)))
35.0ms
(sqrt (sqrt (+ x 1)))
23.0ms
(* (sqrt (sqrt (+ x 1))) (sqrt (sqrt (+ x 1))))

simplify1.9s

Counts
78 → 118
Calls

78 calls. Slowest were:

263.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))))
261.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))))
136.0ms
(+ (* (* (sqrt (sqrt (+ x 1))) (sqrt (sqrt (+ x 1)))) (* (sqrt (sqrt (+ x 1))) (sqrt (sqrt (+ x 1))))) (- (* (sqrt x) (sqrt x)) (* (* (sqrt (sqrt (+ x 1))) (sqrt (sqrt (+ x 1)))) (sqrt x))))

prune1.4s

Pruning

10 alts after pruning (9 fresh and 1 done)

Merged error: 0.0b

regimes80.0ms

Accuracy

0% (0.2b remaining)

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

bsearch2.0ms