Average Error: 19.5 → 0.6
Time: 16.7s
Precision: 64
Internal Precision: 128
\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
\[\frac{\sqrt{\frac{1}{\sqrt{x + 1} \cdot \sqrt{x}}}}{\frac{\sqrt{x} + \sqrt{x + 1}}{\sqrt{\frac{1}{\sqrt{x + 1} \cdot \sqrt{x}}}}}\]

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 19.5

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

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

    \[\leadsto \frac{\color{blue}{\sqrt{x + 1} - \sqrt{x}}}{\sqrt{x} \cdot \sqrt{x + 1}}\]
  5. Using strategy rm
  6. Applied flip--19.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/19.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 associate-/r*0.4

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

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

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

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

Reproduce

herbie shell --seed 2019016 
(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: 15.9s)Debug log

sample160.0ms

Algorithm
intervals
Results
573×(pre true 80)
316×(body nan 80)
137×(body real 80)
60×(body real 640)
39×(body real 1280)
12×(body real 320)
(body real 160)

simplify6.0ms

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

prune5.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 17.1b

localize15.0ms

Local error

Found 4 expressions with local error:

2.4b
(- (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1))))
0.2b
(/ 1 (sqrt x))
0.1b
(/ 1 (sqrt (+ x 1)))
0.0b
(sqrt (+ x 1))

rewrite15.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
8.0ms
(- (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1))))
2.0ms
(/ 1 (sqrt (+ x 1)))
1.0ms
(/ 1 (sqrt x))
1.0ms
(sqrt (+ x 1))

series112.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
56.0ms
(- (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1))))
21.0ms
(/ 1 (sqrt (+ x 1)))
18.0ms
(/ 1 (sqrt x))
17.0ms
(sqrt (+ x 1))

simplify305.0ms

Counts
42 → 83
Calls
42 calls:
Slowest
43.0ms
(- (+ (* 3/8 (pow x 2)) 1) (* 1/2 x))
43.0ms
(sqrt (+ (* x x) (- (* 1 1) (* x 1))))
40.0ms
(- (+ (* 1/2 x) 1) (* 1/8 (pow x 2)))
37.0ms
(/ (exp (/ 1 (sqrt x))) (exp (/ 1 (sqrt (+ x 1)))))
29.0ms
(sqrt (- (* x x) (* 1 1)))

prune659.0ms

Pruning

8 alts after pruning (8 fresh and 0 done)

Merged error: 16.6b

localize10.0ms

Local error

Found 4 expressions with local error:

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

rewrite25.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
14.0ms
(/ (- (sqrt (+ x 1)) (sqrt x)) (* (sqrt x) (sqrt (+ x 1))))
5.0ms
(- (sqrt (+ x 1)) (sqrt x))
4.0ms
(* (sqrt x) (sqrt (+ x 1)))
1.0ms
(sqrt (+ x 1))

series161.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
88.0ms
(/ (- (sqrt (+ x 1)) (sqrt x)) (* (sqrt x) (sqrt (+ x 1))))
33.0ms
(- (sqrt (+ x 1)) (sqrt x))
23.0ms
(* (sqrt x) (sqrt (+ x 1)))
17.0ms
(sqrt (+ x 1))

simplify1.2s

Counts
65 → 97
Calls
65 calls:
Slowest
304.0ms
(* (* (* (sqrt x) (sqrt x)) (sqrt x)) (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))))
117.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)))))
85.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)))))
67.0ms
(- (+ (* 1/2 x) 1) (* 1/8 (pow x 2)))
55.0ms
(- (log (- (sqrt (+ x 1)) (sqrt x))) (log (* (sqrt x) (sqrt (+ x 1)))))

prune838.0ms

Pruning

4 alts after pruning (4 fresh and 0 done)

Merged error: 0.9b

localize21.0ms

Local error

Found 4 expressions with local error:

1.0b
(/ 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)) (sqrt x))

rewrite52.0ms

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

series213.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
85.0ms
(/ 1 (* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x))))
68.0ms
(* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x)))
33.0ms
(+ (sqrt (+ x 1)) (sqrt x))
26.0ms
(* (sqrt x) (sqrt (+ x 1)))

simplify3.8s

Counts
66 → 103
Calls
66 calls:
Slowest
425.0ms
(* (sqrt (- x 1)) (+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x)))))
345.0ms
(* (* (* (sqrt x) (sqrt x)) (sqrt x)) (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))))
336.0ms
(* (sqrt (+ (* x x) (- (* 1 1) (* x 1)))) (+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x)))))
314.0ms
(* (sqrt (- x 1)) (+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x)))))
293.0ms
(* (sqrt (+ (* x x) (- (* 1 1) (* x 1)))) (+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x)))))

prune1.0s

Pruning

7 alts after pruning (7 fresh and 0 done)

Merged error: 0.0b

localize16.0ms

Local error

Found 4 expressions with local error:

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

rewrite37.0ms

Algorithm
rewrite-expression-head
Rules
35×*-un-lft-identity
24×times-frac
19×add-cube-cbrt
19×add-sqr-sqrt
16×add-exp-log
14×associate-/r/
14×associate-*r/
14×sqrt-div
flip-+
flip3-+
pow1
distribute-lft-out
add-cbrt-cube
div-inv
add-log-exp
associate-/l*
associate-*r*
associate-/r*
pow-prod-down
pow1/2
rec-exp
pow-flip
sqrt-prod
prod-exp
associate-*l*
div-exp
frac-2neg
clear-num
associate-/l/
inv-pow
cbrt-unprod
*-commutative
sqrt-unprod
sum-log
+-commutative
cbrt-undiv
Counts
4 → 106
Calls
4 calls:
Slowest
14.0ms
(/ (/ 1 (* (sqrt x) (sqrt (+ x 1)))) (+ (sqrt (+ x 1)) (sqrt x)))
9.0ms
(* (sqrt x) (sqrt (+ x 1)))
8.0ms
(/ 1 (* (sqrt x) (sqrt (+ x 1))))
5.0ms
(+ (sqrt (+ x 1)) (sqrt x))

series188.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
98.0ms
(/ (/ 1 (* (sqrt x) (sqrt (+ x 1)))) (+ (sqrt (+ x 1)) (sqrt x)))
40.0ms
(/ 1 (* (sqrt x) (sqrt (+ x 1))))
30.0ms
(* (sqrt x) (sqrt (+ x 1)))
20.0ms
(+ (sqrt (+ x 1)) (sqrt x))

simplify2.3s

Counts
97 → 118
Calls
97 calls:
Slowest
315.0ms
(* (* (* (sqrt x) (sqrt x)) (sqrt x)) (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))))
142.0ms
(- (+ (* 3/8 (/ 1 (pow x 3))) (/ 1 x)) (* 1/2 (/ 1 (pow x 2))))
118.0ms
(- (- (+ (log (sqrt x)) (log (sqrt (+ x 1))))) (log (+ (sqrt (+ x 1)) (sqrt x))))
113.0ms
(+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x))))
112.0ms
(/ (* (* (/ 1 (* (sqrt x) (sqrt (+ x 1)))) (/ 1 (* (sqrt x) (sqrt (+ x 1))))) (/ 1 (* (sqrt x) (sqrt (+ x 1))))) (* (* (+ (sqrt (+ x 1)) (sqrt x)) (+ (sqrt (+ x 1)) (sqrt x))) (+ (sqrt (+ x 1)) (sqrt x))))

prune1.0s

Pruning

7 alts after pruning (7 fresh and 0 done)

Merged error: 0b

regimes40.0ms

Accuracy

0% (0.5b remaining)

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

bsearch3.0ms

end0.0ms

sample3.8s

Algorithm
intervals
Results
16094×(pre true 80)
8093×(body nan 80)
4119×(body real 80)
1835×(body real 640)
1120×(body real 1280)
614×(body real 320)
313×(body real 160)