Average Error: 29.2 → 18.6
Time: 33.4s
Precision: 64
Internal Precision: 128
\[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\]
\[\begin{array}{l} \mathbf{if}\;n \le -1803761.66460632:\\ \;\;\;\;\left(\frac{\sqrt{\frac{1}{x}}}{\frac{n}{\sqrt{\frac{1}{x}}}} + \frac{\log x}{n \cdot \left(x \cdot n\right)}\right) + \frac{\frac{\frac{-1}{2}}{x}}{x \cdot n}\\ \mathbf{elif}\;n \le -5.6048574067154 \cdot 10^{-308}:\\ \;\;\;\;{\left(1 + x\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;n \le 1716508256.237214:\\ \;\;\;\;e^{\frac{\log_* (1 + x)}{n}} - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{\log x}{n \cdot \left(x \cdot n\right)} + \frac{\frac{1}{x}}{n}\right) + \log \left(e^{\frac{\frac{\frac{-1}{2}}{x}}{x \cdot n}}\right)\\ \end{array}\]

Error

Bits error versus x

Bits error versus n

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 4 regimes
  2. if n < -1803761.66460632

    1. Initial program 44.5

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\]
    2. Using strategy rm
    3. Applied add-exp-log44.5

      \[\leadsto {\color{blue}{\left(e^{\log \left(x + 1\right)}\right)}}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\]
    4. Applied pow-exp44.5

      \[\leadsto \color{blue}{e^{\log \left(x + 1\right) \cdot \frac{1}{n}}} - {x}^{\left(\frac{1}{n}\right)}\]
    5. Simplified44.5

      \[\leadsto e^{\color{blue}{\frac{\log_* (1 + x)}{n}}} - {x}^{\left(\frac{1}{n}\right)}\]
    6. Taylor expanded around -inf 63.2

      \[\leadsto \color{blue}{\left(\frac{\log -1}{x \cdot {n}^{2}} + \frac{1}{x \cdot n}\right) - \left(\frac{1}{2} \cdot \frac{1}{{x}^{2} \cdot n} + \frac{\log \left(\frac{-1}{x}\right)}{x \cdot {n}^{2}}\right)}\]
    7. Simplified32.0

      \[\leadsto \color{blue}{\frac{\frac{\frac{-1}{2}}{x}}{x \cdot n} + \left(\left(\frac{\frac{1}{x}}{n} + 0\right) + \frac{\log x}{n \cdot \left(x \cdot n\right)}\right)}\]
    8. Using strategy rm
    9. Applied add-sqr-sqrt32.1

      \[\leadsto \frac{\frac{\frac{-1}{2}}{x}}{x \cdot n} + \left(\left(\frac{\color{blue}{\sqrt{\frac{1}{x}} \cdot \sqrt{\frac{1}{x}}}}{n} + 0\right) + \frac{\log x}{n \cdot \left(x \cdot n\right)}\right)\]
    10. Applied associate-/l*32.1

      \[\leadsto \frac{\frac{\frac{-1}{2}}{x}}{x \cdot n} + \left(\left(\color{blue}{\frac{\sqrt{\frac{1}{x}}}{\frac{n}{\sqrt{\frac{1}{x}}}}} + 0\right) + \frac{\log x}{n \cdot \left(x \cdot n\right)}\right)\]

    if -1803761.66460632 < n < -5.6048574067154e-308

    1. Initial program 0.5

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\]

    if -5.6048574067154e-308 < n < 1716508256.237214

    1. Initial program 25.8

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\]
    2. Using strategy rm
    3. Applied add-exp-log25.9

      \[\leadsto {\color{blue}{\left(e^{\log \left(x + 1\right)}\right)}}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\]
    4. Applied pow-exp25.9

      \[\leadsto \color{blue}{e^{\log \left(x + 1\right) \cdot \frac{1}{n}}} - {x}^{\left(\frac{1}{n}\right)}\]
    5. Simplified1.8

      \[\leadsto e^{\color{blue}{\frac{\log_* (1 + x)}{n}}} - {x}^{\left(\frac{1}{n}\right)}\]

    if 1716508256.237214 < n

    1. Initial program 44.2

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\]
    2. Using strategy rm
    3. Applied add-exp-log44.2

      \[\leadsto {\color{blue}{\left(e^{\log \left(x + 1\right)}\right)}}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\]
    4. Applied pow-exp44.2

      \[\leadsto \color{blue}{e^{\log \left(x + 1\right) \cdot \frac{1}{n}}} - {x}^{\left(\frac{1}{n}\right)}\]
    5. Simplified44.2

      \[\leadsto e^{\color{blue}{\frac{\log_* (1 + x)}{n}}} - {x}^{\left(\frac{1}{n}\right)}\]
    6. Taylor expanded around -inf 62.7

      \[\leadsto \color{blue}{\left(\frac{\log -1}{x \cdot {n}^{2}} + \frac{1}{x \cdot n}\right) - \left(\frac{1}{2} \cdot \frac{1}{{x}^{2} \cdot n} + \frac{\log \left(\frac{-1}{x}\right)}{x \cdot {n}^{2}}\right)}\]
    7. Simplified31.4

      \[\leadsto \color{blue}{\frac{\frac{\frac{-1}{2}}{x}}{x \cdot n} + \left(\left(\frac{\frac{1}{x}}{n} + 0\right) + \frac{\log x}{n \cdot \left(x \cdot n\right)}\right)}\]
    8. Using strategy rm
    9. Applied add-log-exp31.4

      \[\leadsto \color{blue}{\log \left(e^{\frac{\frac{\frac{-1}{2}}{x}}{x \cdot n}}\right)} + \left(\left(\frac{\frac{1}{x}}{n} + 0\right) + \frac{\log x}{n \cdot \left(x \cdot n\right)}\right)\]
  3. Recombined 4 regimes into one program.
  4. Final simplification18.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \le -1803761.66460632:\\ \;\;\;\;\left(\frac{\sqrt{\frac{1}{x}}}{\frac{n}{\sqrt{\frac{1}{x}}}} + \frac{\log x}{n \cdot \left(x \cdot n\right)}\right) + \frac{\frac{\frac{-1}{2}}{x}}{x \cdot n}\\ \mathbf{elif}\;n \le -5.6048574067154 \cdot 10^{-308}:\\ \;\;\;\;{\left(1 + x\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;n \le 1716508256.237214:\\ \;\;\;\;e^{\frac{\log_* (1 + x)}{n}} - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{\log x}{n \cdot \left(x \cdot n\right)} + \frac{\frac{1}{x}}{n}\right) + \log \left(e^{\frac{\frac{\frac{-1}{2}}{x}}{x \cdot n}}\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019008 +o rules:numerics
(FPCore (x n)
  :name "2nthrt (problem 3.4.6)"
  (- (pow (+ x 1) (/ 1 n)) (pow x (/ 1 n))))

Details

Time bar (total: 31.8s)Debug log

sample430.0ms

Algorithm
intervals

simplify10.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

10.0ms
(- (pow (+ x 1) (/ 1 n)) (pow x (/ 1 n)))

prune11.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 29.1b

localize34.0ms

Local error

Found 3 expressions with local error:

1.0b
(pow (+ x 1) (/ 1 n))
1.0b
(- (pow (+ x 1) (/ 1 n)) (pow x (/ 1 n)))
0.3b
(pow x (/ 1 n))

rewrite29.0ms

Algorithm
rewrite-expression-head
Counts
3 → 74
Calls

3 calls. Slowest were:

21.0ms
(- (pow (+ x 1) (/ 1 n)) (pow x (/ 1 n)))
4.0ms
(pow (+ x 1) (/ 1 n))
1.0ms
(pow x (/ 1 n))

series425.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

246.0ms
(- (pow (+ x 1) (/ 1 n)) (pow x (/ 1 n)))
98.0ms
(pow (+ x 1) (/ 1 n))
81.0ms
(pow x (/ 1 n))

simplify2.5s

Counts
69 → 83
Calls

69 calls. Slowest were:

470.0ms
(- (+ (/ (log -1) n) (+ 1 (/ 1 (* x n)))) (/ (log (/ -1 x)) n))
427.0ms
(- (+ (/ (log -1) (* x (pow n 2))) (/ 1 (* x n))) (+ (* 1/2 (/ 1 (* (pow x 2) n))) (/ (log (/ -1 x)) (* x (pow n 2)))))
324.0ms
(- (/ 1 (* x n)) (+ (/ (log (/ 1 x)) (* x (pow n 2))) (* 1/2 (/ 1 (* (pow x 2) n)))))

prune909.0ms

Pruning

5 alts after pruning (4 fresh and 1 done)

Merged error: 15.4b

localize12.0ms

Local error

Found 4 expressions with local error:

1.2b
(- (exp (/ (log1p x) n)) (pow x (/ 1 n)))
0.3b
(pow x (/ 1 n))
0.1b
(/ (log1p x) n)
0.0b
(exp (/ (log1p x) n))

rewrite21.0ms

Algorithm
rewrite-expression-head
Counts
4 → 71
Calls

4 calls. Slowest were:

12.0ms
(- (exp (/ (log1p x) n)) (pow x (/ 1 n)))
5.0ms
(/ (log1p x) n)
3.0ms
(exp (/ (log1p x) n))

series441.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

222.0ms
(- (exp (/ (log1p x) n)) (pow x (/ 1 n)))
77.0ms
(pow x (/ 1 n))
76.0ms
(exp (/ (log1p x) n))
65.0ms
(/ (log1p x) n)

simplify3.1s

Counts
47 → 83
Calls

47 calls. Slowest were:

596.0ms
(- (+ (/ (log -1) n) (+ 1 (/ 1 (* x n)))) (/ (log (/ -1 x)) n))
390.0ms
(- (+ (/ (log -1) (* x (pow n 2))) (/ 1 (* x n))) (+ (* 1/2 (/ 1 (* (pow x 2) n))) (/ (log (/ -1 x)) (* x (pow n 2)))))
351.0ms
(- (/ 1 (* x n)) (+ (/ (log (/ 1 x)) (* x (pow n 2))) (* 1/2 (/ 1 (* (pow x 2) n)))))

prune952.0ms

Pruning

5 alts after pruning (3 fresh and 2 done)

Merged error: 15.4b

localize57.0ms

Local error

Found 4 expressions with local error:

2.5b
(+ (+ (/ (/ 1 x) n) 0) (/ (log x) (* n (* x n))))
0.6b
(/ (log x) (* n (* x n)))
0.2b
(/ (/ -1/2 x) (* x n))
0.2b
(/ (/ 1 x) n)

rewrite46.0ms

Algorithm
rewrite-expression-head
Counts
4 → 82
Calls

4 calls. Slowest were:

35.0ms
(+ (+ (/ (/ 1 x) n) 0) (/ (log x) (* n (* x n))))
4.0ms
(/ (log x) (* n (* x n)))
3.0ms
(/ (/ -1/2 x) (* x n))

series213.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

106.0ms
(+ (+ (/ (/ 1 x) n) 0) (/ (log x) (* n (* x n))))
84.0ms
(/ (log x) (* n (* x n)))
14.0ms
(/ (/ -1/2 x) (* x n))
9.0ms
(/ (/ 1 x) n)

simplify2.8s

Counts
46 → 94
Calls

46 calls. Slowest were:

511.0ms
(* -1 (/ (log (/ 1 x)) (* x (pow n 2))))
490.0ms
(+ (* (+ (pow (/ (/ 1 x) n) 3) (pow 0 3)) (* n (* x n))) (* (+ (* (/ (/ 1 x) n) (/ (/ 1 x) n)) (- (* 0 0) (* (/ (/ 1 x) n) 0))) (log x)))
378.0ms
(+ (* (- (* (/ (/ 1 x) n) (/ (/ 1 x) n)) (* 0 0)) (* n (* x n))) (* (- (/ (/ 1 x) n) 0) (log x)))

prune1.1s

Pruning

9 alts after pruning (7 fresh and 2 done)

Merged error: 15.2b

localize13.0ms

Local error

Found 4 expressions with local error:

2.5b
(+ (+ (* (/ 1 x) (/ 1 n)) 0) (/ (log x) (* n (* x n))))
0.6b
(/ (log x) (* n (* x n)))
0.3b
(* (/ 1 x) (/ 1 n))
0.2b
(/ (/ -1/2 x) (* x n))

rewrite39.0ms

Algorithm
rewrite-expression-head
Counts
4 → 91
Calls

4 calls. Slowest were:

26.0ms
(+ (+ (* (/ 1 x) (/ 1 n)) 0) (/ (log x) (* n (* x n))))
5.0ms
(/ (log x) (* n (* x n)))
4.0ms
(* (/ 1 x) (/ 1 n))

series258.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

121.0ms
(+ (+ (* (/ 1 x) (/ 1 n)) 0) (/ (log x) (* n (* x n))))
104.0ms
(/ (log x) (* n (* x n)))
20.0ms
(/ (/ -1/2 x) (* x n))
13.0ms
(* (/ 1 x) (/ 1 n))

simplify4.6s

Counts
57 → 103
Calls

57 calls. Slowest were:

1.3s
(+ (* (+ (pow (* (/ 1 x) (/ 1 n)) 3) (pow 0 3)) (* n (* x n))) (* (+ (* (* (/ 1 x) (/ 1 n)) (* (/ 1 x) (/ 1 n))) (- (* 0 0) (* (* (/ 1 x) (/ 1 n)) 0))) (log x)))
603.0ms
(* -1 (/ (log (/ 1 x)) (* x (pow n 2))))
437.0ms
(* (+ (* (* (/ 1 x) (/ 1 n)) (* (/ 1 x) (/ 1 n))) (- (* 0 0) (* (* (/ 1 x) (/ 1 n)) 0))) (* n (* x n)))

prune1.2s

Pruning

10 alts after pruning (8 fresh and 2 done)

Merged error: 15.2b

regimes451.0ms

Accuracy

89.4% (1.3b remaining)

Error of 18.6b against oracle of 17.3b and baseline of 29.2b

bsearch770.0ms

end0.0ms

sample11.3s

Algorithm
intervals