Average Error: 29.4 → 19.3
Time: 1.1m
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}\;\frac{1}{n} \le -0.0004894433671653746:\\ \;\;\;\;{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - \sqrt[3]{{x}^{\left(\frac{1}{n}\right)}} \cdot \left(\sqrt[3]{{x}^{\left(\frac{1}{n}\right)}} \cdot \sqrt[3]{{x}^{\left(\frac{1}{n}\right)}}\right)\\ \mathbf{elif}\;\frac{1}{n} \le 2.5145598140327372 \cdot 10^{-26}:\\ \;\;\;\;\frac{\frac{\frac{-1}{2}}{x}}{x \cdot n} + \left(\frac{\log x}{\left(x \cdot n\right) \cdot n} + \frac{\frac{1}{x}}{n}\right)\\ \mathbf{else}:\\ \;\;\;\;e^{\frac{\log_* (1 + x)}{n}} - {x}^{\left(\frac{1}{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 3 regimes
  2. if (/ 1 n) < -0.0004894433671653746

    1. Initial program 0.4

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

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

    if -0.0004894433671653746 < (/ 1 n) < 2.5145598140327372e-26

    1. Initial program 44.7

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\]
    2. Taylor expanded around -inf 63.0

      \[\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)}\]
    3. Simplified32.2

      \[\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)}\]

    if 2.5145598140327372e-26 < (/ 1 n)

    1. Initial program 28.1

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

      \[\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-exp28.2

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

      \[\leadsto e^{\color{blue}{\frac{\log_* (1 + x)}{n}}} - {x}^{\left(\frac{1}{n}\right)}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification19.3

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

Reproduce

herbie shell --seed 2019005 +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: 1.1m)Debug log

sample325.0ms

Algorithm
intervals

simplify5.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune6.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 29.3b

localize15.0ms

Local error

Found 3 expressions with local error:

0.9b
(- (pow (+ x 1) (/ 1 n)) (pow x (/ 1 n)))
0.7b
(pow (+ x 1) (/ 1 n))
0.5b
(pow x (/ 1 n))

rewrite25.0ms

Algorithm
rewrite-expression-head
Counts
3 → 74
Calls

3 calls. Slowest were:

22.0ms
(- (pow (+ x 1) (/ 1 n)) (pow x (/ 1 n)))
1.0ms
(pow (+ x 1) (/ 1 n))
1.0ms
(pow x (/ 1 n))

series378.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

210.0ms
(- (pow (+ x 1) (/ 1 n)) (pow x (/ 1 n)))
90.0ms
(pow (+ x 1) (/ 1 n))
78.0ms
(pow x (/ 1 n))

simplify2.6s

Counts
69 → 83
Calls

69 calls. Slowest were:

502.0ms
(- (+ (/ (log -1) n) (+ 1 (/ 1 (* x n)))) (/ (log (/ -1 x)) n))
453.0ms
(- (+ (/ (log -1) (* x (pow n 2))) (/ 1 (* x n))) (+ (* 1/2 (/ 1 (* (pow x 2) n))) (/ (log (/ -1 x)) (* x (pow n 2)))))
315.0ms
(- (/ 1 (* x n)) (+ (/ (log (/ 1 x)) (* x (pow n 2))) (* 1/2 (/ 1 (* (pow x 2) n)))))

prune914.0ms

Pruning

9 alts after pruning (9 fresh and 0 done)

Merged error: 16.7b

localize24.0ms

Local error

Found 4 expressions with local error:

0.9b
(- (sqrt (pow (+ x 1) (/ 1 n))) (sqrt (pow x (/ 1 n))))
0.7b
(pow (+ x 1) (/ 1 n))
0.7b
(pow (+ x 1) (/ 1 n))
0.5b
(pow x (/ 1 n))

rewrite37.0ms

Algorithm
rewrite-expression-head
Counts
4 → 137
Calls

4 calls. Slowest were:

25.0ms
(- (sqrt (pow (+ x 1) (/ 1 n))) (sqrt (pow x (/ 1 n))))
3.0ms
(pow (+ x 1) (/ 1 n))
3.0ms
(pow (+ x 1) (/ 1 n))

series426.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

235.0ms
(- (sqrt (pow (+ x 1) (/ 1 n))) (sqrt (pow x (/ 1 n))))
71.0ms
(pow (+ x 1) (/ 1 n))
66.0ms
(pow (+ x 1) (/ 1 n))
54.0ms
(pow x (/ 1 n))

simplify5.5s

Counts
166 → 149
Calls

166 calls. Slowest were:

578.0ms
(- (+ (/ (log -1) n) (+ 1 (/ 1 (* x n)))) (/ (log (/ -1 x)) n))
560.0ms
(- (+ (/ (log -1) n) (+ 1 (/ 1 (* x n)))) (/ (log (/ -1 x)) n))
429.0ms
(- (+ (* 1/4 (/ (log -1) (* x (pow n 2)))) (* 1/2 (/ 1 (* x n)))) (+ (* 1/4 (/ 1 (* (pow x 2) n))) (* 1/4 (/ (log (/ -1 x)) (* x (pow n 2))))))

prune2.2s

Pruning

10 alts after pruning (10 fresh and 0 done)

Merged error: 16.6b

localize15.0ms

Local error

Found 4 expressions with local error:

0.9b
(- (sqrt (pow (+ x 1) (/ 1 n))) (sqrt (pow x (/ 1 n))))
0.9b
(- (sqrt (pow (+ x 1) (/ 1 n))) (sqrt (pow x (/ 1 n))))
0.9b
(- (sqrt (pow (+ x 1) (/ 1 n))) (sqrt (pow x (/ 1 n))))
0.7b
(pow (+ x 1) (/ 1 n))

rewrite60.0ms

Algorithm
rewrite-expression-head
Counts
4 → 274
Calls

4 calls. Slowest were:

25.0ms
(- (sqrt (pow (+ x 1) (/ 1 n))) (sqrt (pow x (/ 1 n))))
15.0ms
(- (sqrt (pow (+ x 1) (/ 1 n))) (sqrt (pow x (/ 1 n))))
13.0ms
(- (sqrt (pow (+ x 1) (/ 1 n))) (sqrt (pow x (/ 1 n))))

series847.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

263.0ms
(- (sqrt (pow (+ x 1) (/ 1 n))) (sqrt (pow x (/ 1 n))))
255.0ms
(- (sqrt (pow (+ x 1) (/ 1 n))) (sqrt (pow x (/ 1 n))))
254.0ms
(- (sqrt (pow (+ x 1) (/ 1 n))) (sqrt (pow x (/ 1 n))))
75.0ms
(pow (+ x 1) (/ 1 n))

simplify11.9s

Counts
417 → 286
Calls

417 calls. Slowest were:

557.0ms
(- (+ (/ (log -1) n) (+ 1 (/ 1 (* x n)))) (/ (log (/ -1 x)) n))
541.0ms
(- (+ (* 1/4 (/ (log -1) (* x (pow n 2)))) (* 1/2 (/ 1 (* x n)))) (+ (* 1/4 (/ 1 (* (pow x 2) n))) (* 1/4 (/ (log (/ -1 x)) (* x (pow n 2))))))
434.0ms
(- (+ (* 1/4 (/ (log -1) (* x (pow n 2)))) (* 1/2 (/ 1 (* x n)))) (+ (* 1/4 (/ 1 (* (pow x 2) n))) (* 1/4 (/ (log (/ -1 x)) (* x (pow n 2))))))

prune5.0s

Pruning

10 alts after pruning (10 fresh and 0 done)

Merged error: 16.6b

localize28.0ms

Local error

Found 4 expressions with local error:

0.9b
(- (sqrt (pow (+ x 1) (/ 1 n))) (sqrt (pow x (/ 1 n))))
0.9b
(- (sqrt (pow (+ x 1) (/ 1 n))) (sqrt (pow x (/ 1 n))))
0.9b
(- (sqrt (pow (+ x 1) (/ 1 n))) (sqrt (pow x (/ 1 n))))
0.9b
(- (sqrt (pow (+ x 1) (/ 1 n))) (sqrt (pow x (/ 1 n))))

rewrite115.0ms

Algorithm
rewrite-expression-head
Counts
4 → 340
Calls

4 calls. Slowest were:

29.0ms
(- (sqrt (pow (+ x 1) (/ 1 n))) (sqrt (pow x (/ 1 n))))
25.0ms
(- (sqrt (pow (+ x 1) (/ 1 n))) (sqrt (pow x (/ 1 n))))
24.0ms
(- (sqrt (pow (+ x 1) (/ 1 n))) (sqrt (pow x (/ 1 n))))

series1.0s

Counts
4 → 12
Calls

4 calls. Slowest were:

275.0ms
(- (sqrt (pow (+ x 1) (/ 1 n))) (sqrt (pow x (/ 1 n))))
252.0ms
(- (sqrt (pow (+ x 1) (/ 1 n))) (sqrt (pow x (/ 1 n))))
241.0ms
(- (sqrt (pow (+ x 1) (/ 1 n))) (sqrt (pow x (/ 1 n))))
239.0ms
(- (sqrt (pow (+ x 1) (/ 1 n))) (sqrt (pow x (/ 1 n))))

simplify14.8s

Counts
540 → 352
Calls

540 calls. Slowest were:

432.0ms
(- (+ (* 1/4 (/ (log -1) (* x (pow n 2)))) (* 1/2 (/ 1 (* x n)))) (+ (* 1/4 (/ 1 (* (pow x 2) n))) (* 1/4 (/ (log (/ -1 x)) (* x (pow n 2))))))
389.0ms
(- (+ (* 1/4 (/ (log -1) (* x (pow n 2)))) (* 1/2 (/ 1 (* x n)))) (+ (* 1/4 (/ 1 (* (pow x 2) n))) (* 1/4 (/ (log (/ -1 x)) (* x (pow n 2))))))
387.0ms
(- (+ (* 1/4 (/ (log -1) (* x (pow n 2)))) (* 1/2 (/ 1 (* x n)))) (+ (* 1/4 (/ 1 (* (pow x 2) n))) (* 1/4 (/ (log (/ -1 x)) (* x (pow n 2))))))

prune7.3s

Pruning

10 alts after pruning (10 fresh and 0 done)

Merged error: 16.6b

regimes379.0ms

Accuracy

86.6% (1.6b remaining)

Error of 19.3b against oracle of 17.7b and baseline of 29.5b

bsearch6.0ms

end0.0ms

sample11.2s

Algorithm
intervals