Average Error: 20.6 → 0.7
Time: 26.4s
Precision: 64
Internal Precision: 128
\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
\[\frac{1}{\left(x + 1\right) \cdot \sqrt{x} + \sqrt{x + 1} \cdot x}\]

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original20.6
Target0.7
Herbie0.7
\[\frac{1}{\left(x + 1\right) \cdot \sqrt{x} + x \cdot \sqrt{x + 1}}\]

Derivation

  1. Initial program 20.6

    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
  2. Using strategy rm
  3. Applied frac-sub20.5

    \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}}\]
  4. Simplified20.5

    \[\leadsto \frac{\color{blue}{\sqrt{x + 1} - \sqrt{x}}}{\sqrt{x} \cdot \sqrt{x + 1}}\]
  5. Using strategy rm
  6. Applied flip--20.3

    \[\leadsto \frac{\color{blue}{\frac{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x + 1} + \sqrt{x}}}}{\sqrt{x} \cdot \sqrt{x + 1}}\]
  7. Applied associate-/l/20.3

    \[\leadsto \color{blue}{\frac{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}{\left(\sqrt{x} \cdot \sqrt{x + 1}\right) \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)}}\]
  8. Simplified0.8

    \[\leadsto \frac{\color{blue}{1}}{\left(\sqrt{x} \cdot \sqrt{x + 1}\right) \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)}\]
  9. Using strategy rm
  10. Applied pow10.8

    \[\leadsto \frac{1}{\left(\sqrt{x} \cdot \sqrt{x + 1}\right) \cdot \color{blue}{{\left(\sqrt{x + 1} + \sqrt{x}\right)}^{1}}}\]
  11. Applied pow10.8

    \[\leadsto \frac{1}{\color{blue}{{\left(\sqrt{x} \cdot \sqrt{x + 1}\right)}^{1}} \cdot {\left(\sqrt{x + 1} + \sqrt{x}\right)}^{1}}\]
  12. Applied pow-prod-down0.8

    \[\leadsto \frac{1}{\color{blue}{{\left(\left(\sqrt{x} \cdot \sqrt{x + 1}\right) \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)\right)}^{1}}}\]
  13. Simplified0.7

    \[\leadsto \frac{1}{{\color{blue}{\left(x \cdot \sqrt{x + 1} + \left(x + 1\right) \cdot \sqrt{x}\right)}}^{1}}\]
  14. Final simplification0.7

    \[\leadsto \frac{1}{\left(x + 1\right) \cdot \sqrt{x} + \sqrt{x + 1} \cdot x}\]

Reproduce

herbie shell --seed 1137770271 
(FPCore (x)
  :name "2isqrt (example 3.6)"

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

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

Details

Time bar (total: 24.5s)Debug log

sample197.0ms

Algorithm
intervals
Results
66×45.0ms(body real 640)
249×40.0ms(body nan 80)
28×25.0ms(body real 1280)
125×21.0ms(body real 80)
28×14.0ms(body real 320)
505×11.0ms(pre true 80)
3.0ms(body real 160)

simplify12.0ms

Counts
1 → 1
Calls
1 calls:
Slowest
12.0ms
(- (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1))))

prune12.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 21.2b

localize44.0ms

Local error

Found 4 expressions with local error:

2.1b
(- (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1))))
0.3b
(/ 1 (sqrt x))
0.1b
(/ 1 (sqrt (+ x 1)))
0.0b
(sqrt (+ x 1))

rewrite42.0ms

Algorithm
rewrite-expression-head
Rules
12×*-un-lft-identity
11×add-sqr-sqrt
associate-/r*
add-cube-cbrt
add-log-exp
div-inv
sqrt-prod
add-exp-log
pow1
distribute-lft-out--
pow-flip
sqrt-div
add-cbrt-cube
pow1/2
inv-pow
flip-+
associate-/r/
flip3-+
frac-2neg
clear-num
rec-exp
difference-of-squares
flip--
frac-sub
diff-log
flip3--
sub-neg
rem-sqrt-square
Counts
4 → 71
Calls
4 calls:
Slowest
32.0ms
(- (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1))))
4.0ms
(/ 1 (sqrt x))
3.0ms
(/ 1 (sqrt (+ x 1)))
1.0ms
(sqrt (+ x 1))

series126.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
53.0ms
(- (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1))))
26.0ms
(/ 1 (sqrt (+ x 1)))
24.0ms
(/ 1 (sqrt x))
23.0ms
(sqrt (+ x 1))

simplify472.0ms

Counts
42 → 83
Calls
42 calls:
Slowest
92.0ms
(- (+ (* 1/2 x) 1) (* 1/8 (pow x 2)))
80.0ms
(- (+ (* 3/8 (pow x 2)) 1) (* 1/2 x))
51.0ms
(sqrt (+ (* x x) (- (* 1 1) (* x 1))))
41.0ms
(- (* 1 (sqrt (+ x 1))) (* (sqrt x) 1))
34.0ms
(/ (exp (/ 1 (sqrt x))) (exp (/ 1 (sqrt (+ x 1)))))

prune1.2s

Pruning

11 alts after pruning (11 fresh and 0 done)

Merged error: 20.6b

localize24.0ms

Local error

Found 4 expressions with local error:

2.1b
(- (sqrt (+ x 1)) (sqrt x))
0.3b
(* (sqrt x) (sqrt (+ x 1)))
0.2b
(/ (- (sqrt (+ x 1)) (sqrt x)) (* (sqrt x) (sqrt (+ x 1))))
0.0b
(sqrt (+ x 1))

rewrite62.0ms

Algorithm
rewrite-expression-head
Rules
23×add-sqr-sqrt
16×*-un-lft-identity
11×add-exp-log
11×add-cbrt-cube
10×add-cube-cbrt
sqrt-prod
difference-of-squares
add-log-exp
associate-/l*
associate-*r*
sqrt-div
times-frac
pow1
associate-*r/
distribute-lft-out--
flip-+
associate-*l*
pow1/2
flip3-+
associate-/l/
flip--
cbrt-unprod
associate-/r/
prod-exp
pow-prod-down
div-exp
flip3--
cbrt-undiv
div-inv
*-commutative
div-sub
diff-log
sqrt-unprod
frac-2neg
sub-neg
associate-/r*
clear-num
rem-sqrt-square
Counts
4 → 85
Calls
4 calls:
Slowest
35.0ms
(/ (- (sqrt (+ x 1)) (sqrt x)) (* (sqrt x) (sqrt (+ x 1))))
13.0ms
(- (sqrt (+ x 1)) (sqrt x))
10.0ms
(* (sqrt x) (sqrt (+ x 1)))
1.0ms
(sqrt (+ x 1))

series235.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
118.0ms
(/ (- (sqrt (+ x 1)) (sqrt x)) (* (sqrt x) (sqrt (+ x 1))))
50.0ms
(- (sqrt (+ x 1)) (sqrt x))
44.0ms
(* (sqrt x) (sqrt (+ x 1)))
23.0ms
(sqrt (+ x 1))

simplify1.5s

Counts
65 → 97
Calls
65 calls:
Slowest
425.0ms
(* (* (* (sqrt x) (sqrt x)) (sqrt x)) (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))))
139.0ms
(/ (* (* (- (sqrt (+ x 1)) (sqrt x)) (- (sqrt (+ x 1)) (sqrt x))) (- (sqrt (+ x 1)) (sqrt x))) (* (* (* (sqrt x) (sqrt x)) (sqrt x)) (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1)))))
118.0ms
(/ (* (* (- (sqrt (+ x 1)) (sqrt x)) (- (sqrt (+ x 1)) (sqrt x))) (- (sqrt (+ x 1)) (sqrt x))) (* (* (* (sqrt x) (sqrt (+ x 1))) (* (sqrt x) (sqrt (+ x 1)))) (* (sqrt x) (sqrt (+ x 1)))))
90.0ms
(- (+ (* 1/2 x) 1) (* 1/8 (pow x 2)))
75.0ms
(- (+ x 1/2) (* 1/8 (/ 1 x)))

prune1.4s

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.3b

localize25.0ms

Local error

Found 4 expressions with local error:

0.3b
(/ 1 (* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x))))
0.3b
(* (sqrt x) (sqrt (+ x 1)))
0.1b
(* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x)))
0.0b
(sqrt (+ x 1))

rewrite95.0ms

Algorithm
rewrite-expression-head
Rules
18×associate-*r/
17×add-exp-log
17×pow1
16×sqrt-div
14×flip-+
14×flip3-+
11×add-cbrt-cube
11×*-un-lft-identity
10×associate-*r*
10×add-sqr-sqrt
add-cube-cbrt
associate-/r/
pow-prod-down
frac-times
prod-exp
sqrt-prod
add-log-exp
cbrt-unprod
associate-*l/
associate-*l*
pow-flip
pow1/2
rec-exp
*-commutative
inv-pow
distribute-lft-out
div-inv
sqrt-unprod
distribute-lft-in
frac-2neg
associate-/r*
clear-num
rem-sqrt-square
distribute-rgt-in
Counts
4 → 93
Calls
4 calls:
Slowest
42.0ms
(* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x)))
38.0ms
(/ 1 (* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x))))
10.0ms
(* (sqrt x) (sqrt (+ x 1)))
1.0ms
(sqrt (+ x 1))

series354.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
153.0ms
(/ 1 (* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x))))
134.0ms
(* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x)))
45.0ms
(* (sqrt x) (sqrt (+ x 1)))
21.0ms
(sqrt (+ x 1))

simplify5.3s

Counts
70 → 105
Calls
70 calls:
Slowest
535.0ms
(* (sqrt (- x 1)) (+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x)))))
528.0ms
(* (sqrt (- x 1)) (+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x)))))
442.0ms
(* (sqrt (+ (* x x) (- (* 1 1) (* x 1)))) (+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x)))))
439.0ms
(* (sqrt (+ (* x x) (- (* 1 1) (* x 1)))) (+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x)))))
433.0ms
(* (* (* (sqrt x) (sqrt x)) (sqrt x)) (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))))

prune1.7s

Pruning

9 alts after pruning (9 fresh and 0 done)

Merged error: 0.0b

localize44.0ms

Local error

Found 4 expressions with local error:

0.3b
(/ 1 (pow (+ (* x (sqrt (+ x 1))) (* (+ x 1) (sqrt x))) 1))
0.1b
(* x (sqrt (+ x 1)))
0.1b
(* (+ x 1) (sqrt x))
0.0b
(+ (* x (sqrt (+ x 1))) (* (+ x 1) (sqrt x)))

rewrite45.0ms

Algorithm
rewrite-expression-head
Rules
10×add-cube-cbrt
10×*-un-lft-identity
10×add-sqr-sqrt
associate-*r*
add-exp-log
flip-+
flip3-+
add-log-exp
associate-*r/
associate-*l/
sqrt-div
add-cbrt-cube
associate-/r*
pow1
frac-add
sqrt-prod
associate-*l*
unpow-prod-down
rec-exp
*-commutative
inv-pow
pow-flip
div-inv
cbrt-unprod
prod-exp
pow-exp
pow-prod-down
frac-2neg
sum-log
clear-num
+-commutative
pow-to-exp
Counts
4 → 71
Calls
4 calls:
Slowest
16.0ms
(/ 1 (pow (+ (* x (sqrt (+ x 1))) (* (+ x 1) (sqrt x))) 1))
13.0ms
(+ (* x (sqrt (+ x 1))) (* (+ x 1) (sqrt x)))
10.0ms
(* (+ x 1) (sqrt x))
4.0ms
(* x (sqrt (+ x 1)))

series272.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
105.0ms
(/ 1 (pow (+ (* x (sqrt (+ x 1))) (* (+ x 1) (sqrt x))) 1))
82.0ms
(+ (* x (sqrt (+ x 1))) (* (+ x 1) (sqrt x)))
43.0ms
(* (+ x 1) (sqrt x))
43.0ms
(* x (sqrt (+ x 1)))

simplify4.2s

Counts
46 → 83
Calls
46 calls:
Slowest
478.0ms
(* (* (* (+ x 1) (+ x 1)) (+ x 1)) (* (* (sqrt x) (sqrt x)) (sqrt x)))
460.0ms
(+ (* (* x (sqrt (- (* x x) (* 1 1)))) (+ (* x x) (- (* 1 1) (* x 1)))) (* (sqrt (- x 1)) (* (+ (pow x 3) (pow 1 3)) (sqrt x))))
438.0ms
(+ (* (* x (sqrt (+ (pow x 3) (pow 1 3)))) (- x 1)) (* (sqrt (+ (* x x) (- (* 1 1) (* x 1)))) (* (- (* x x) (* 1 1)) (sqrt x))))
427.0ms
(+ (* (* x (sqrt (+ (pow x 3) (pow 1 3)))) (+ (* x x) (- (* 1 1) (* x 1)))) (* (sqrt (+ (* x x) (- (* 1 1) (* x 1)))) (* (+ (pow x 3) (pow 1 3)) (sqrt x))))
354.0ms
(+ (* (* x (sqrt (- (* x x) (* 1 1)))) (- x 1)) (* (sqrt (- x 1)) (* (- (* x x) (* 1 1)) (sqrt x))))

prune1.4s

Pruning

9 alts after pruning (8 fresh and 1 done)

Merged error: 0.0b

regimes116.0ms

Accuracy

0% (0.7b remaining)

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

bsearch4.0ms

end0.0ms

sample5.7s

Algorithm
intervals
Results
1847×1.4s(body real 640)
1096×1.4s(body real 1280)
7935×1.1s(body nan 80)
4008×634.0ms(body real 80)
712×380.0ms(body real 320)
15935×364.0ms(pre true 80)
337×106.0ms(body real 160)