Average Error: 33.2 → 7.1
Time: 17.8s
Precision: binary64
\[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\]
\[\begin{array}{l} \mathbf{if}\;x \leq 3749.2329152300117:\\ \;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{x \cdot n}\\ \end{array}\]
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\begin{array}{l}
\mathbf{if}\;x \leq 3749.2329152300117:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\

\mathbf{else}:\\
\;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{x \cdot n}\\

\end{array}
(FPCore (x n)
 :precision binary64
 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
(FPCore (x n)
 :precision binary64
 (if (<= x 3749.2329152300117)
   (/ (log (/ (+ x 1.0) x)) n)
   (/ (pow x (/ 1.0 n)) (* x n))))
double code(double x, double n) {
	return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
double code(double x, double n) {
	double tmp;
	if (x <= 3749.2329152300117) {
		tmp = log((x + 1.0) / x) / n;
	} else {
		tmp = pow(x, (1.0 / n)) / (x * n);
	}
	return tmp;
}

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 2 regimes
  2. if x < 3749.2329152300117

    1. Initial program 47.4

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

      \[\leadsto \color{blue}{\frac{\log \left(x + 1\right) - \log x}{n}}\]
    3. Simplified13.6

      \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}}\]
    4. Using strategy rm
    5. Applied diff-log_binary64_51113.6

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

    if 3749.2329152300117 < x

    1. Initial program 21.0

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

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

      \[\leadsto \color{blue}{\frac{{x}^{\left(\frac{1}{n}\right)}}{x \cdot n}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification7.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 3749.2329152300117:\\ \;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{x \cdot n}\\ \end{array}\]

Reproduce

herbie shell --seed 2021044 
(FPCore (x n)
  :name "2nthrt (problem 3.4.6)"
  :precision binary64
  (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))