Average Error: 20.1 → 0.4
Time: 25.6s
Precision: 64
Internal Precision: 128
\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
\[\frac{\frac{1}{\sqrt{x + 1} \cdot \sqrt{x}}}{\sqrt{x} + \sqrt{x + 1}}\]

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 20.1

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

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

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

    \[\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.9

    \[\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. Final simplification0.4

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

Reproduce

herbie shell --seed 1042149663 
(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.1s)Debug log

sample206.0ms

Algorithm
intervals
Results
472×(pre true 80)
215×(body nan 80)
141×(body real 80)
45×(body real 640)
40×(body real 1280)
26×(body real 320)
(body real 160)

simplify18.0ms

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

prune22.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 18.2b

localize50.0ms

Local error

Found 4 expressions with local error:

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

rewrite33.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
13.0ms
(- (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1))))
3.0ms
(/ 1 (sqrt (+ x 1)))
2.0ms
(/ 1 (sqrt x))
1.0ms
(sqrt (+ x 1))

series125.0ms

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

simplify516.0ms

Counts
42 → 83
Calls
42 calls:
Slowest
97.0ms
(- (+ (* 1/2 x) 1) (* 1/8 (pow x 2)))
90.0ms
(- (+ (* 3/8 (pow x 2)) 1) (* 1/2 x))
54.0ms
(sqrt (+ (* x x) (- (* 1 1) (* x 1))))
43.0ms
(- (* 1 (sqrt (+ x 1))) (* (sqrt x) 1))
38.0ms
(/ (exp (/ 1 (sqrt x))) (exp (/ 1 (sqrt (+ x 1)))))

prune1.1s

Pruning

12 alts after pruning (12 fresh and 0 done)

Merged error: 17.7b

localize23.0ms

Local error

Found 4 expressions with local error:

2.1b
(- (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))

rewrite59.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
33.0ms
(/ (- (sqrt (+ x 1)) (sqrt x)) (* (sqrt x) (sqrt (+ x 1))))
12.0ms
(- (sqrt (+ x 1)) (sqrt x))
10.0ms
(* (sqrt x) (sqrt (+ x 1)))
1.0ms
(sqrt (+ x 1))

series231.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
113.0ms
(/ (- (sqrt (+ x 1)) (sqrt x)) (* (sqrt x) (sqrt (+ x 1))))
49.0ms
(- (sqrt (+ x 1)) (sqrt x))
46.0ms
(* (sqrt x) (sqrt (+ x 1)))
23.0ms
(sqrt (+ x 1))

simplify1.6s

Counts
65 → 97
Calls
65 calls:
Slowest
438.0ms
(* (* (* (sqrt x) (sqrt x)) (sqrt x)) (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))))
142.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)))))
119.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)))))
95.0ms
(- (+ (* 1/2 x) 1) (* 1/8 (pow x 2)))
80.0ms
(- (+ x 1/2) (* 1/8 (/ 1 x)))

prune1.4s

Pruning

3 alts after pruning (3 fresh and 0 done)

Merged error: 0.4b

localize23.0ms

Local error

Found 4 expressions with local error:

0.4b
(/ 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))

rewrite103.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
41.0ms
(/ 1 (* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x))))
39.0ms
(* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x)))
10.0ms
(+ (sqrt (+ x 1)) (sqrt x))
10.0ms
(* (sqrt x) (sqrt (+ x 1)))

series360.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
149.0ms
(/ 1 (* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x))))
127.0ms
(* (* (sqrt x) (sqrt (+ x 1))) (+ (sqrt (+ x 1)) (sqrt x)))
43.0ms
(* (sqrt x) (sqrt (+ x 1)))
41.0ms
(+ (sqrt (+ x 1)) (sqrt x))

simplify5.4s

Counts
66 → 103
Calls
66 calls:
Slowest
547.0ms
(* (sqrt (- x 1)) (+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x)))))
540.0ms
(* (sqrt (- x 1)) (+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x)))))
459.0ms
(* (sqrt (+ (* x x) (- (* 1 1) (* x 1)))) (+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x)))))
455.0ms
(* (sqrt (+ (* x x) (- (* 1 1) (* x 1)))) (+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x)))))
441.0ms
(* (* (* (sqrt x) (sqrt x)) (sqrt x)) (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))))

prune1.5s

Pruning

9 alts after pruning (9 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))

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

series283.0ms

Counts
4 → 12
Calls
4 calls:
Slowest
146.0ms
(/ (/ 1 (* (sqrt x) (sqrt (+ x 1)))) (+ (sqrt (+ x 1)) (sqrt x)))
51.0ms
(/ 1 (* (sqrt x) (sqrt (+ x 1))))
44.0ms
(* (sqrt x) (sqrt (+ x 1)))
42.0ms
(+ (sqrt (+ x 1)) (sqrt x))

simplify3.5s

Counts
97 → 118
Calls
97 calls:
Slowest
432.0ms
(* (* (* (sqrt x) (sqrt x)) (sqrt x)) (* (* (sqrt (+ x 1)) (sqrt (+ x 1))) (sqrt (+ x 1))))
185.0ms
(- (+ (* 3/8 (/ 1 (pow x 3))) (/ 1 x)) (* 1/2 (/ 1 (pow x 2))))
168.0ms
(+ (* (sqrt (+ x 1)) (sqrt (+ x 1))) (- (* (sqrt x) (sqrt x)) (* (sqrt (+ x 1)) (sqrt x))))
166.0ms
(- (log (/ 1 (* (sqrt x) (sqrt (+ x 1))))) (log (+ (sqrt (+ x 1)) (sqrt x))))
152.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.6s

Pruning

8 alts after pruning (7 fresh and 1 done)

Merged error: 0b

regimes91.0ms

Accuracy

0% (0.4b remaining)

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

bsearch3.0ms

end0.0ms

sample5.7s

Algorithm
intervals
Results
16095×(pre true 80)
8094×(body nan 80)
4040×(body real 80)
1842×(body real 640)
1174×(body real 1280)
642×(body real 320)
303×(body real 160)