Average Error: 29.4 → 19.3
Time: 38.7s
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 -1.847675679304028 \cdot 10^{+22}:\\ \;\;\;\;\left(\frac{1}{x \cdot n} - \frac{\frac{\frac{1}{2}}{x}}{x \cdot n}\right) + \frac{\frac{\log x}{n \cdot n}}{x}\\ \mathbf{elif}\;n \le -6.33257455003563 \cdot 10^{-310}:\\ \;\;\;\;\log \left(e^{{\left(1 + x\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}}\right)\\ \mathbf{elif}\;n \le 10838.751390580817:\\ \;\;\;\;\sqrt[3]{{\left(1 + x\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}} \cdot \log \left(e^{\sqrt[3]{{\left(1 + x\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}} \cdot \sqrt[3]{e^{\frac{\log_* (1 + x)}{n}} - {x}^{\left(\frac{1}{n}\right)}}}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\frac{-1}{2}}{x}}{x \cdot n} + \left(\frac{\log x}{n \cdot \left(x \cdot n\right)} + \frac{\frac{1}{x}}{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 < -1.847675679304028e+22

    1. Initial program 45.1

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

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

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

    if -1.847675679304028e+22 < n < -6.33257455003563e-310

    1. Initial program 2.9

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

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

    if -6.33257455003563e-310 < n < 10838.751390580817

    1. Initial program 25.3

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

      \[\leadsto \color{blue}{\log \left(e^{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}}\right)}\]
    4. Using strategy rm
    5. Applied add-cube-cbrt25.3

      \[\leadsto \log \left(e^{\color{blue}{\left(\sqrt[3]{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}} \cdot \sqrt[3]{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}}\right) \cdot \sqrt[3]{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}}}}\right)\]
    6. Applied exp-prod25.3

      \[\leadsto \log \color{blue}{\left({\left(e^{\sqrt[3]{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}} \cdot \sqrt[3]{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}}}\right)}^{\left(\sqrt[3]{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}}\right)}\right)}\]
    7. Applied log-pow25.3

      \[\leadsto \color{blue}{\sqrt[3]{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}} \cdot \log \left(e^{\sqrt[3]{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}} \cdot \sqrt[3]{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}}}\right)}\]
    8. Using strategy rm
    9. Applied add-exp-log25.3

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

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

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

    if 10838.751390580817 < n

    1. Initial program 45.1

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

      \[\leadsto \color{blue}{\log \left(e^{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}}\right)}\]
    4. 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)}\]
    5. Simplified32.7

      \[\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)}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification19.3

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

Reproduce

herbie shell --seed 2019002 +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: 37.2s)Debug log

sample366.0ms

Algorithm
intervals

simplify5.0ms

Counts
1 → 1
Calls

1 calls. Slowest were:

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

prune5.0ms

Pruning

1 alts after pruning (1 fresh and 0 done)

Merged error: 31.4b

localize22.0ms

Local error

Found 3 expressions with local error:

1.3b
(pow (+ x 1) (/ 1 n))
1.1b
(- (pow (+ x 1) (/ 1 n)) (pow x (/ 1 n)))
0.5b
(pow x (/ 1 n))

rewrite38.0ms

Algorithm
rewrite-expression-head
Counts
3 → 74
Calls

3 calls. Slowest were:

33.0ms
(- (pow (+ x 1) (/ 1 n)) (pow x (/ 1 n)))
3.0ms
(pow (+ x 1) (/ 1 n))
1.0ms
(pow x (/ 1 n))

series350.0ms

Counts
3 → 9
Calls

3 calls. Slowest were:

198.0ms
(- (pow (+ x 1) (/ 1 n)) (pow x (/ 1 n)))
89.0ms
(pow x (/ 1 n))
63.0ms
(pow (+ x 1) (/ 1 n))

simplify2.8s

Counts
69 → 83
Calls

69 calls. Slowest were:

693.0ms
(- (+ (/ (log -1) n) (+ 1 (/ 1 (* x n)))) (/ (log (/ -1 x)) n))
439.0ms
(- (/ 1 (* x n)) (+ (/ (log (/ 1 x)) (* x (pow n 2))) (* 1/2 (/ 1 (* (pow x 2) n)))))
387.0ms
(- (+ (/ (log -1) (* x (pow n 2))) (/ 1 (* x n))) (+ (* 1/2 (/ 1 (* (pow x 2) n))) (/ (log (/ -1 x)) (* x (pow n 2)))))

prune906.0ms

Pruning

8 alts after pruning (8 fresh and 0 done)

Merged error: 18.2b

localize9.0ms

Local error

Found 4 expressions with local error:

1.3b
(pow (+ x 1) (/ 1 n))
1.3b
(pow (+ x 1) (/ 1 n))
1.3b
(pow (+ x 1) (/ 1 n))
1.1b
(- (pow (+ x 1) (/ 1 n)) (pow x (/ 1 n)))

rewrite19.0ms

Algorithm
rewrite-expression-head
Counts
4 → 98
Calls

4 calls. Slowest were:

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

series486.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

233.0ms
(- (pow (+ x 1) (/ 1 n)) (pow x (/ 1 n)))
89.0ms
(pow (+ x 1) (/ 1 n))
82.0ms
(pow (+ x 1) (/ 1 n))
82.0ms
(pow (+ x 1) (/ 1 n))

simplify4.3s

Counts
86 → 110
Calls

86 calls. Slowest were:

866.0ms
(- (+ (/ (log -1) n) (+ 1 (/ 1 (* x n)))) (/ (log (/ -1 x)) n))
610.0ms
(- (+ (/ (log -1) n) (+ 1 (/ 1 (* x n)))) (/ (log (/ -1 x)) n))
543.0ms
(- (+ (/ (log -1) n) (+ 1 (/ 1 (* x n)))) (/ (log (/ -1 x)) n))

prune1.4s

Pruning

7 alts after pruning (7 fresh and 0 done)

Merged error: 18.2b

localize10.0ms

Local error

Found 4 expressions with local error:

1.3b
(pow (+ x 1) (/ 1 n))
1.1b
(log (exp (- (pow (+ x 1) (/ 1 n)) (pow x (/ 1 n)))))
1.1b
(- (pow (+ x 1) (/ 1 n)) (pow x (/ 1 n)))
0.5b
(pow x (/ 1 n))

rewrite41.0ms

Algorithm
rewrite-expression-head
Counts
4 → 115
Calls

4 calls. Slowest were:

22.0ms
(log (exp (- (pow (+ x 1) (/ 1 n)) (pow x (/ 1 n)))))
12.0ms
(- (pow (+ x 1) (/ 1 n)) (pow x (/ 1 n)))
3.0ms
(pow (+ x 1) (/ 1 n))

series532.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

202.0ms
(log (exp (- (pow (+ x 1) (/ 1 n)) (pow x (/ 1 n)))))
195.0ms
(- (pow (+ x 1) (/ 1 n)) (pow x (/ 1 n)))
78.0ms
(pow (+ x 1) (/ 1 n))
57.0ms
(pow x (/ 1 n))

simplify5.0s

Counts
103 → 127
Calls

103 calls. Slowest were:

538.0ms
(- (+ (/ (log -1) n) (+ 1 (/ 1 (* x n)))) (/ (log (/ -1 x)) n))
480.0ms
(- (/ 1 (* x n)) (+ (/ (log (/ 1 x)) (* x (pow n 2))) (* 1/2 (/ 1 (* (pow x 2) n)))))
442.0ms
(- (+ (/ (log -1) (* x (pow n 2))) (/ 1 (* x n))) (+ (* 1/2 (/ 1 (* (pow x 2) n))) (/ (log (/ -1 x)) (* x (pow n 2)))))

prune1.7s

Pruning

9 alts after pruning (8 fresh and 1 done)

Merged error: 18.2b

localize26.0ms

Local error

Found 4 expressions with local error:

1.3b
(pow (+ x 1) (/ 1 n))
1.3b
(pow (+ x 1) (/ 1 n))
1.3b
(pow (+ x 1) (/ 1 n))
1.1b
(- (pow (+ x 1) (/ 1 n)) (pow x (/ 1 n)))

rewrite16.0ms

Algorithm
rewrite-expression-head
Counts
4 → 98
Calls

4 calls. Slowest were:

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

series403.0ms

Counts
4 → 12
Calls

4 calls. Slowest were:

188.0ms
(- (pow (+ x 1) (/ 1 n)) (pow x (/ 1 n)))
75.0ms
(pow (+ x 1) (/ 1 n))
75.0ms
(pow (+ x 1) (/ 1 n))
66.0ms
(pow (+ x 1) (/ 1 n))

simplify3.9s

Counts
86 → 110
Calls

86 calls. Slowest were:

641.0ms
(- (+ (/ (log -1) n) (+ 1 (/ 1 (* x n)))) (/ (log (/ -1 x)) n))
630.0ms
(- (+ (/ (log -1) n) (+ 1 (/ 1 (* x n)))) (/ (log (/ -1 x)) n))
550.0ms
(- (+ (/ (log -1) n) (+ 1 (/ 1 (* x n)))) (/ (log (/ -1 x)) n))

prune1.7s

Pruning

8 alts after pruning (7 fresh and 1 done)

Merged error: 18.2b

regimes476.0ms

Accuracy

86.2% (1.6b remaining)

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

bsearch1.6s

end0.0ms

sample11.2s

Algorithm
intervals