2nthrt (problem 3.4.6)

Percentage Accurate: 53.2% → 85.8%
Time: 20.1s
Alternatives: 14
Speedup: 2.0×

Specification

?
\[\begin{array}{l} \\ {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \end{array} \]
(FPCore (x n)
 :precision binary64
 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
double code(double x, double n) {
	return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    code = ((x + 1.0d0) ** (1.0d0 / n)) - (x ** (1.0d0 / n))
end function
public static double code(double x, double n) {
	return Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
}
def code(x, n):
	return math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n))
function code(x, n)
	return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n)))
end
function tmp = code(x, n)
	tmp = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n));
end
code[x_, n_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 14 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 53.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \end{array} \]
(FPCore (x n)
 :precision binary64
 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
double code(double x, double n) {
	return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    code = ((x + 1.0d0) ** (1.0d0 / n)) - (x ** (1.0d0 / n))
end function
public static double code(double x, double n) {
	return Math.pow((x + 1.0), (1.0 / n)) - Math.pow(x, (1.0 / n));
}
def code(x, n):
	return math.pow((x + 1.0), (1.0 / n)) - math.pow(x, (1.0 / n))
function code(x, n)
	return Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - (x ^ Float64(1.0 / n)))
end
function tmp = code(x, n)
	tmp = ((x + 1.0) ^ (1.0 / n)) - (x ^ (1.0 / n));
end
code[x_, n_] := N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}
\end{array}

Alternative 1: 85.8% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq -1400000 \lor \neg \left(n \leq 10500\right):\\ \;\;\;\;\left(\mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, \frac{\mathsf{log1p}\left(x\right) - \log x}{n}\right) + \frac{0.16666666666666666 \cdot \left({\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}\right)}{{n}^{3}}\right) + \frac{{\log x}^{2}}{n \cdot n} \cdot -0.5\\ \mathbf{else}:\\ \;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (or (<= n -1400000.0) (not (<= n 10500.0)))
   (+
    (+
     (fma 0.5 (/ (pow (log1p x) 2.0) (* n n)) (/ (- (log1p x) (log x)) n))
     (/
      (* 0.16666666666666666 (- (pow (log1p x) 3.0) (pow (log x) 3.0)))
      (pow n 3.0)))
    (* (/ (pow (log x) 2.0) (* n n)) -0.5))
   (- (exp (/ (log1p x) n)) (pow x (/ 1.0 n)))))
double code(double x, double n) {
	double tmp;
	if ((n <= -1400000.0) || !(n <= 10500.0)) {
		tmp = (fma(0.5, (pow(log1p(x), 2.0) / (n * n)), ((log1p(x) - log(x)) / n)) + ((0.16666666666666666 * (pow(log1p(x), 3.0) - pow(log(x), 3.0))) / pow(n, 3.0))) + ((pow(log(x), 2.0) / (n * n)) * -0.5);
	} else {
		tmp = exp((log1p(x) / n)) - pow(x, (1.0 / n));
	}
	return tmp;
}
function code(x, n)
	tmp = 0.0
	if ((n <= -1400000.0) || !(n <= 10500.0))
		tmp = Float64(Float64(fma(0.5, Float64((log1p(x) ^ 2.0) / Float64(n * n)), Float64(Float64(log1p(x) - log(x)) / n)) + Float64(Float64(0.16666666666666666 * Float64((log1p(x) ^ 3.0) - (log(x) ^ 3.0))) / (n ^ 3.0))) + Float64(Float64((log(x) ^ 2.0) / Float64(n * n)) * -0.5));
	else
		tmp = Float64(exp(Float64(log1p(x) / n)) - (x ^ Float64(1.0 / n)));
	end
	return tmp
end
code[x_, n_] := If[Or[LessEqual[n, -1400000.0], N[Not[LessEqual[n, 10500.0]], $MachinePrecision]], N[(N[(N[(0.5 * N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] + N[(N[(0.16666666666666666 * N[(N[Power[N[Log[1 + x], $MachinePrecision], 3.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[n, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision], N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;n \leq -1400000 \lor \neg \left(n \leq 10500\right):\\
\;\;\;\;\left(\mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, \frac{\mathsf{log1p}\left(x\right) - \log x}{n}\right) + \frac{0.16666666666666666 \cdot \left({\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}\right)}{{n}^{3}}\right) + \frac{{\log x}^{2}}{n \cdot n} \cdot -0.5\\

\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if n < -1.4e6 or 10500 < n

    1. Initial program 26.5%

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

      \[\leadsto \color{blue}{\left(0.5 \cdot \frac{{\log \left(1 + x\right)}^{2}}{{n}^{2}} + \left(-1 \cdot \frac{-0.16666666666666666 \cdot {\log \left(1 + x\right)}^{3} - -0.16666666666666666 \cdot {\log x}^{3}}{{n}^{3}} + -1 \cdot \frac{-1 \cdot \log \left(1 + x\right) - -1 \cdot \log x}{n}\right)\right) - 0.5 \cdot \frac{{\log x}^{2}}{{n}^{2}}} \]
    3. Step-by-step derivation
      1. sub-neg80.0%

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

      \[\leadsto \color{blue}{\left(\mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, \frac{\mathsf{log1p}\left(x\right) - \log x}{n}\right) + \frac{0.16666666666666666 \cdot \left({\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}\right)}{{n}^{3}}\right) + \frac{{\log x}^{2}}{n \cdot n} \cdot -0.5} \]

    if -1.4e6 < n < 10500

    1. Initial program 88.8%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Taylor expanded in n around 0 88.8%

      \[\leadsto \color{blue}{e^{\frac{\log \left(1 + x\right)}{n}} - e^{\frac{\log x}{n}}} \]
    3. Step-by-step derivation
      1. log1p-def100.0%

        \[\leadsto e^{\frac{\color{blue}{\mathsf{log1p}\left(x\right)}}{n}} - e^{\frac{\log x}{n}} \]
      2. *-rgt-identity100.0%

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - e^{\frac{\color{blue}{\log x \cdot 1}}{n}} \]
      3. associate-*r/100.0%

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - e^{\color{blue}{\log x \cdot \frac{1}{n}}} \]
      4. unpow-1100.0%

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - e^{\log x \cdot \color{blue}{{n}^{-1}}} \]
      5. exp-to-pow100.0%

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - \color{blue}{{x}^{\left({n}^{-1}\right)}} \]
      6. /-rgt-identity100.0%

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\color{blue}{\left(\frac{{n}^{-1}}{1}\right)}} \]
      7. metadata-eval100.0%

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{{n}^{-1}}{\color{blue}{\frac{2}{2}}}\right)} \]
      8. associate-/l*100.0%

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\color{blue}{\left(\frac{{n}^{-1} \cdot 2}{2}\right)}} \]
      9. *-commutative100.0%

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{\color{blue}{2 \cdot {n}^{-1}}}{2}\right)} \]
      10. *-commutative100.0%

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{\color{blue}{{n}^{-1} \cdot 2}}{2}\right)} \]
      11. associate-/l*100.0%

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\color{blue}{\left(\frac{{n}^{-1}}{\frac{2}{2}}\right)}} \]
      12. metadata-eval100.0%

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{{n}^{-1}}{\color{blue}{1}}\right)} \]
      13. /-rgt-identity100.0%

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\color{blue}{\left({n}^{-1}\right)}} \]
      14. unpow-1100.0%

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\color{blue}{\left(\frac{1}{n}\right)}} \]
    4. Simplified100.0%

      \[\leadsto \color{blue}{e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification89.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -1400000 \lor \neg \left(n \leq 10500\right):\\ \;\;\;\;\left(\mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, \frac{\mathsf{log1p}\left(x\right) - \log x}{n}\right) + \frac{0.16666666666666666 \cdot \left({\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}\right)}{{n}^{3}}\right) + \frac{{\log x}^{2}}{n \cdot n} \cdot -0.5\\ \mathbf{else}:\\ \;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}\\ \end{array} \]

Alternative 2: 85.8% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-11}:\\ \;\;\;\;\frac{t_0}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-10}:\\ \;\;\;\;\mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, \frac{\mathsf{log1p}\left(x\right) - \log x}{n}\right) + \frac{{\log x}^{2}}{n \cdot n} \cdot -0.5\\ \mathbf{else}:\\ \;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t_0\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (pow x (/ 1.0 n))))
   (if (<= (/ 1.0 n) -2e-11)
     (/ t_0 (* n x))
     (if (<= (/ 1.0 n) 2e-10)
       (+
        (fma 0.5 (/ (pow (log1p x) 2.0) (* n n)) (/ (- (log1p x) (log x)) n))
        (* (/ (pow (log x) 2.0) (* n n)) -0.5))
       (- (exp (/ (log1p x) n)) t_0)))))
double code(double x, double n) {
	double t_0 = pow(x, (1.0 / n));
	double tmp;
	if ((1.0 / n) <= -2e-11) {
		tmp = t_0 / (n * x);
	} else if ((1.0 / n) <= 2e-10) {
		tmp = fma(0.5, (pow(log1p(x), 2.0) / (n * n)), ((log1p(x) - log(x)) / n)) + ((pow(log(x), 2.0) / (n * n)) * -0.5);
	} else {
		tmp = exp((log1p(x) / n)) - t_0;
	}
	return tmp;
}
function code(x, n)
	t_0 = x ^ Float64(1.0 / n)
	tmp = 0.0
	if (Float64(1.0 / n) <= -2e-11)
		tmp = Float64(t_0 / Float64(n * x));
	elseif (Float64(1.0 / n) <= 2e-10)
		tmp = Float64(fma(0.5, Float64((log1p(x) ^ 2.0) / Float64(n * n)), Float64(Float64(log1p(x) - log(x)) / n)) + Float64(Float64((log(x) ^ 2.0) / Float64(n * n)) * -0.5));
	else
		tmp = Float64(exp(Float64(log1p(x) / n)) - t_0);
	end
	return tmp
end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-11], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-10], N[(N[(0.5 * N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision], N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-11}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\

\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-10}:\\
\;\;\;\;\mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, \frac{\mathsf{log1p}\left(x\right) - \log x}{n}\right) + \frac{{\log x}^{2}}{n \cdot n} \cdot -0.5\\

\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 1 n) < -1.99999999999999988e-11

    1. Initial program 98.5%

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

      \[\leadsto \color{blue}{\frac{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}}}{n \cdot x}} \]
    3. Step-by-step derivation
      1. log-rec98.8%

        \[\leadsto \frac{e^{-1 \cdot \frac{\color{blue}{-\log x}}{n}}}{n \cdot x} \]
      2. mul-1-neg98.8%

        \[\leadsto \frac{e^{-1 \cdot \frac{\color{blue}{-1 \cdot \log x}}{n}}}{n \cdot x} \]
      3. mul-1-neg98.8%

        \[\leadsto \frac{e^{-1 \cdot \frac{\color{blue}{-\log x}}{n}}}{n \cdot x} \]
      4. distribute-frac-neg98.8%

        \[\leadsto \frac{e^{-1 \cdot \color{blue}{\left(-\frac{\log x}{n}\right)}}}{n \cdot x} \]
      5. neg-mul-198.8%

        \[\leadsto \frac{e^{\color{blue}{-\left(-\frac{\log x}{n}\right)}}}{n \cdot x} \]
      6. remove-double-neg98.8%

        \[\leadsto \frac{e^{\color{blue}{\frac{\log x}{n}}}}{n \cdot x} \]
      7. *-rgt-identity98.8%

        \[\leadsto \frac{e^{\frac{\color{blue}{\log x \cdot 1}}{n}}}{n \cdot x} \]
      8. associate-*r/98.8%

        \[\leadsto \frac{e^{\color{blue}{\log x \cdot \frac{1}{n}}}}{n \cdot x} \]
      9. unpow-198.8%

        \[\leadsto \frac{e^{\log x \cdot \color{blue}{{n}^{-1}}}}{n \cdot x} \]
      10. exp-to-pow98.8%

        \[\leadsto \frac{\color{blue}{{x}^{\left({n}^{-1}\right)}}}{n \cdot x} \]
      11. unpow-198.8%

        \[\leadsto \frac{{x}^{\color{blue}{\left(\frac{1}{n}\right)}}}{n \cdot x} \]
      12. *-commutative98.8%

        \[\leadsto \frac{{x}^{\left(\frac{1}{n}\right)}}{\color{blue}{x \cdot n}} \]
    4. Simplified98.8%

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

    if -1.99999999999999988e-11 < (/.f64 1 n) < 2.00000000000000007e-10

    1. Initial program 26.5%

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

      \[\leadsto \color{blue}{\left(0.5 \cdot \frac{{\log \left(1 + x\right)}^{2}}{{n}^{2}} + \frac{\log \left(1 + x\right)}{n}\right) - \left(\frac{\log x}{n} + 0.5 \cdot \frac{{\log x}^{2}}{{n}^{2}}\right)} \]
    3. Step-by-step derivation
      1. associate--r+74.3%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, \frac{\mathsf{log1p}\left(x\right) - \log x}{n}\right) + \frac{{\log x}^{2}}{n \cdot n} \cdot -0.5} \]

    if 2.00000000000000007e-10 < (/.f64 1 n)

    1. Initial program 59.4%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Taylor expanded in n around 0 59.4%

      \[\leadsto \color{blue}{e^{\frac{\log \left(1 + x\right)}{n}} - e^{\frac{\log x}{n}}} \]
    3. Step-by-step derivation
      1. log1p-def97.1%

        \[\leadsto e^{\frac{\color{blue}{\mathsf{log1p}\left(x\right)}}{n}} - e^{\frac{\log x}{n}} \]
      2. *-rgt-identity97.1%

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - e^{\frac{\color{blue}{\log x \cdot 1}}{n}} \]
      3. associate-*r/97.1%

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - e^{\color{blue}{\log x \cdot \frac{1}{n}}} \]
      4. unpow-197.1%

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - e^{\log x \cdot \color{blue}{{n}^{-1}}} \]
      5. exp-to-pow97.1%

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - \color{blue}{{x}^{\left({n}^{-1}\right)}} \]
      6. /-rgt-identity97.1%

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\color{blue}{\left(\frac{{n}^{-1}}{1}\right)}} \]
      7. metadata-eval97.1%

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{{n}^{-1}}{\color{blue}{\frac{2}{2}}}\right)} \]
      8. associate-/l*97.1%

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\color{blue}{\left(\frac{{n}^{-1} \cdot 2}{2}\right)}} \]
      9. *-commutative97.1%

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{\color{blue}{2 \cdot {n}^{-1}}}{2}\right)} \]
      10. *-commutative97.1%

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{\color{blue}{{n}^{-1} \cdot 2}}{2}\right)} \]
      11. associate-/l*97.1%

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\color{blue}{\left(\frac{{n}^{-1}}{\frac{2}{2}}\right)}} \]
      12. metadata-eval97.1%

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{{n}^{-1}}{\color{blue}{1}}\right)} \]
      13. /-rgt-identity97.1%

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\color{blue}{\left({n}^{-1}\right)}} \]
      14. unpow-197.1%

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\color{blue}{\left(\frac{1}{n}\right)}} \]
    4. Simplified97.1%

      \[\leadsto \color{blue}{e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification88.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-11}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-10}:\\ \;\;\;\;\mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, \frac{\mathsf{log1p}\left(x\right) - \log x}{n}\right) + \frac{{\log x}^{2}}{n \cdot n} \cdot -0.5\\ \mathbf{else}:\\ \;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}\\ \end{array} \]

Alternative 3: 85.6% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-22}:\\ \;\;\;\;\frac{t_0}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{-17}:\\ \;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t_0\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (pow x (/ 1.0 n))))
   (if (<= (/ 1.0 n) -1e-22)
     (/ t_0 (* n x))
     (if (<= (/ 1.0 n) 1e-17)
       (/ (- (log1p x) (log x)) n)
       (- (exp (/ (log1p x) n)) t_0)))))
double code(double x, double n) {
	double t_0 = pow(x, (1.0 / n));
	double tmp;
	if ((1.0 / n) <= -1e-22) {
		tmp = t_0 / (n * x);
	} else if ((1.0 / n) <= 1e-17) {
		tmp = (log1p(x) - log(x)) / n;
	} else {
		tmp = exp((log1p(x) / n)) - t_0;
	}
	return tmp;
}
public static double code(double x, double n) {
	double t_0 = Math.pow(x, (1.0 / n));
	double tmp;
	if ((1.0 / n) <= -1e-22) {
		tmp = t_0 / (n * x);
	} else if ((1.0 / n) <= 1e-17) {
		tmp = (Math.log1p(x) - Math.log(x)) / n;
	} else {
		tmp = Math.exp((Math.log1p(x) / n)) - t_0;
	}
	return tmp;
}
def code(x, n):
	t_0 = math.pow(x, (1.0 / n))
	tmp = 0
	if (1.0 / n) <= -1e-22:
		tmp = t_0 / (n * x)
	elif (1.0 / n) <= 1e-17:
		tmp = (math.log1p(x) - math.log(x)) / n
	else:
		tmp = math.exp((math.log1p(x) / n)) - t_0
	return tmp
function code(x, n)
	t_0 = x ^ Float64(1.0 / n)
	tmp = 0.0
	if (Float64(1.0 / n) <= -1e-22)
		tmp = Float64(t_0 / Float64(n * x));
	elseif (Float64(1.0 / n) <= 1e-17)
		tmp = Float64(Float64(log1p(x) - log(x)) / n);
	else
		tmp = Float64(exp(Float64(log1p(x) / n)) - t_0);
	end
	return tmp
end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-22], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-17], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-22}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\

\mathbf{elif}\;\frac{1}{n} \leq 10^{-17}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\

\mathbf{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 1 n) < -1e-22

    1. Initial program 96.8%

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

      \[\leadsto \color{blue}{\frac{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}}}{n \cdot x}} \]
    3. Step-by-step derivation
      1. log-rec97.8%

        \[\leadsto \frac{e^{-1 \cdot \frac{\color{blue}{-\log x}}{n}}}{n \cdot x} \]
      2. mul-1-neg97.8%

        \[\leadsto \frac{e^{-1 \cdot \frac{\color{blue}{-1 \cdot \log x}}{n}}}{n \cdot x} \]
      3. mul-1-neg97.8%

        \[\leadsto \frac{e^{-1 \cdot \frac{\color{blue}{-\log x}}{n}}}{n \cdot x} \]
      4. distribute-frac-neg97.8%

        \[\leadsto \frac{e^{-1 \cdot \color{blue}{\left(-\frac{\log x}{n}\right)}}}{n \cdot x} \]
      5. neg-mul-197.8%

        \[\leadsto \frac{e^{\color{blue}{-\left(-\frac{\log x}{n}\right)}}}{n \cdot x} \]
      6. remove-double-neg97.8%

        \[\leadsto \frac{e^{\color{blue}{\frac{\log x}{n}}}}{n \cdot x} \]
      7. *-rgt-identity97.8%

        \[\leadsto \frac{e^{\frac{\color{blue}{\log x \cdot 1}}{n}}}{n \cdot x} \]
      8. associate-*r/97.8%

        \[\leadsto \frac{e^{\color{blue}{\log x \cdot \frac{1}{n}}}}{n \cdot x} \]
      9. unpow-197.8%

        \[\leadsto \frac{e^{\log x \cdot \color{blue}{{n}^{-1}}}}{n \cdot x} \]
      10. exp-to-pow97.8%

        \[\leadsto \frac{\color{blue}{{x}^{\left({n}^{-1}\right)}}}{n \cdot x} \]
      11. unpow-197.8%

        \[\leadsto \frac{{x}^{\color{blue}{\left(\frac{1}{n}\right)}}}{n \cdot x} \]
      12. *-commutative97.8%

        \[\leadsto \frac{{x}^{\left(\frac{1}{n}\right)}}{\color{blue}{x \cdot n}} \]
    4. Simplified97.8%

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

    if -1e-22 < (/.f64 1 n) < 1.00000000000000007e-17

    1. Initial program 26.3%

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

      \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
    3. Step-by-step derivation
      1. log1p-def81.2%

        \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(x\right)} - \log x}{n} \]
    4. Simplified81.2%

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]

    if 1.00000000000000007e-17 < (/.f64 1 n)

    1. Initial program 59.6%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Taylor expanded in n around 0 59.6%

      \[\leadsto \color{blue}{e^{\frac{\log \left(1 + x\right)}{n}} - e^{\frac{\log x}{n}}} \]
    3. Step-by-step derivation
      1. log1p-def96.2%

        \[\leadsto e^{\frac{\color{blue}{\mathsf{log1p}\left(x\right)}}{n}} - e^{\frac{\log x}{n}} \]
      2. *-rgt-identity96.2%

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - e^{\frac{\color{blue}{\log x \cdot 1}}{n}} \]
      3. associate-*r/96.2%

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - e^{\color{blue}{\log x \cdot \frac{1}{n}}} \]
      4. unpow-196.2%

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - e^{\log x \cdot \color{blue}{{n}^{-1}}} \]
      5. exp-to-pow96.2%

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - \color{blue}{{x}^{\left({n}^{-1}\right)}} \]
      6. /-rgt-identity96.2%

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\color{blue}{\left(\frac{{n}^{-1}}{1}\right)}} \]
      7. metadata-eval96.2%

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{{n}^{-1}}{\color{blue}{\frac{2}{2}}}\right)} \]
      8. associate-/l*96.2%

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\color{blue}{\left(\frac{{n}^{-1} \cdot 2}{2}\right)}} \]
      9. *-commutative96.2%

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{\color{blue}{2 \cdot {n}^{-1}}}{2}\right)} \]
      10. *-commutative96.2%

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{\color{blue}{{n}^{-1} \cdot 2}}{2}\right)} \]
      11. associate-/l*96.2%

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\color{blue}{\left(\frac{{n}^{-1}}{\frac{2}{2}}\right)}} \]
      12. metadata-eval96.2%

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{{n}^{-1}}{\color{blue}{1}}\right)} \]
      13. /-rgt-identity96.2%

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\color{blue}{\left({n}^{-1}\right)}} \]
      14. unpow-196.2%

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\color{blue}{\left(\frac{1}{n}\right)}} \]
    4. Simplified96.2%

      \[\leadsto \color{blue}{e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification88.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-22}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{-17}:\\ \;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}\\ \end{array} \]

Alternative 4: 80.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-22}:\\ \;\;\;\;\frac{t_0}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{-17}:\\ \;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+156}:\\ \;\;\;\;\left(\left(\frac{0.5}{n \cdot n} - \frac{0.5}{n}\right) \cdot \left(x \cdot x\right) + \left(1 + \frac{x}{n}\right)\right) - t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (pow x (/ 1.0 n))))
   (if (<= (/ 1.0 n) -1e-22)
     (/ t_0 (* n x))
     (if (<= (/ 1.0 n) 1e-17)
       (/ (- (log1p x) (log x)) n)
       (if (<= (/ 1.0 n) 2e+156)
         (- (+ (* (- (/ 0.5 (* n n)) (/ 0.5 n)) (* x x)) (+ 1.0 (/ x n))) t_0)
         (/ 1.0 (* n x)))))))
double code(double x, double n) {
	double t_0 = pow(x, (1.0 / n));
	double tmp;
	if ((1.0 / n) <= -1e-22) {
		tmp = t_0 / (n * x);
	} else if ((1.0 / n) <= 1e-17) {
		tmp = (log1p(x) - log(x)) / n;
	} else if ((1.0 / n) <= 2e+156) {
		tmp = ((((0.5 / (n * n)) - (0.5 / n)) * (x * x)) + (1.0 + (x / n))) - t_0;
	} else {
		tmp = 1.0 / (n * x);
	}
	return tmp;
}
public static double code(double x, double n) {
	double t_0 = Math.pow(x, (1.0 / n));
	double tmp;
	if ((1.0 / n) <= -1e-22) {
		tmp = t_0 / (n * x);
	} else if ((1.0 / n) <= 1e-17) {
		tmp = (Math.log1p(x) - Math.log(x)) / n;
	} else if ((1.0 / n) <= 2e+156) {
		tmp = ((((0.5 / (n * n)) - (0.5 / n)) * (x * x)) + (1.0 + (x / n))) - t_0;
	} else {
		tmp = 1.0 / (n * x);
	}
	return tmp;
}
def code(x, n):
	t_0 = math.pow(x, (1.0 / n))
	tmp = 0
	if (1.0 / n) <= -1e-22:
		tmp = t_0 / (n * x)
	elif (1.0 / n) <= 1e-17:
		tmp = (math.log1p(x) - math.log(x)) / n
	elif (1.0 / n) <= 2e+156:
		tmp = ((((0.5 / (n * n)) - (0.5 / n)) * (x * x)) + (1.0 + (x / n))) - t_0
	else:
		tmp = 1.0 / (n * x)
	return tmp
function code(x, n)
	t_0 = x ^ Float64(1.0 / n)
	tmp = 0.0
	if (Float64(1.0 / n) <= -1e-22)
		tmp = Float64(t_0 / Float64(n * x));
	elseif (Float64(1.0 / n) <= 1e-17)
		tmp = Float64(Float64(log1p(x) - log(x)) / n);
	elseif (Float64(1.0 / n) <= 2e+156)
		tmp = Float64(Float64(Float64(Float64(Float64(0.5 / Float64(n * n)) - Float64(0.5 / n)) * Float64(x * x)) + Float64(1.0 + Float64(x / n))) - t_0);
	else
		tmp = Float64(1.0 / Float64(n * x));
	end
	return tmp
end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-22], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-17], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+156], N[(N[(N[(N[(N[(0.5 / N[(n * n), $MachinePrecision]), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-22}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\

\mathbf{elif}\;\frac{1}{n} \leq 10^{-17}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\

\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+156}:\\
\;\;\;\;\left(\left(\frac{0.5}{n \cdot n} - \frac{0.5}{n}\right) \cdot \left(x \cdot x\right) + \left(1 + \frac{x}{n}\right)\right) - t_0\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (/.f64 1 n) < -1e-22

    1. Initial program 96.8%

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

      \[\leadsto \color{blue}{\frac{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}}}{n \cdot x}} \]
    3. Step-by-step derivation
      1. log-rec97.8%

        \[\leadsto \frac{e^{-1 \cdot \frac{\color{blue}{-\log x}}{n}}}{n \cdot x} \]
      2. mul-1-neg97.8%

        \[\leadsto \frac{e^{-1 \cdot \frac{\color{blue}{-1 \cdot \log x}}{n}}}{n \cdot x} \]
      3. mul-1-neg97.8%

        \[\leadsto \frac{e^{-1 \cdot \frac{\color{blue}{-\log x}}{n}}}{n \cdot x} \]
      4. distribute-frac-neg97.8%

        \[\leadsto \frac{e^{-1 \cdot \color{blue}{\left(-\frac{\log x}{n}\right)}}}{n \cdot x} \]
      5. neg-mul-197.8%

        \[\leadsto \frac{e^{\color{blue}{-\left(-\frac{\log x}{n}\right)}}}{n \cdot x} \]
      6. remove-double-neg97.8%

        \[\leadsto \frac{e^{\color{blue}{\frac{\log x}{n}}}}{n \cdot x} \]
      7. *-rgt-identity97.8%

        \[\leadsto \frac{e^{\frac{\color{blue}{\log x \cdot 1}}{n}}}{n \cdot x} \]
      8. associate-*r/97.8%

        \[\leadsto \frac{e^{\color{blue}{\log x \cdot \frac{1}{n}}}}{n \cdot x} \]
      9. unpow-197.8%

        \[\leadsto \frac{e^{\log x \cdot \color{blue}{{n}^{-1}}}}{n \cdot x} \]
      10. exp-to-pow97.8%

        \[\leadsto \frac{\color{blue}{{x}^{\left({n}^{-1}\right)}}}{n \cdot x} \]
      11. unpow-197.8%

        \[\leadsto \frac{{x}^{\color{blue}{\left(\frac{1}{n}\right)}}}{n \cdot x} \]
      12. *-commutative97.8%

        \[\leadsto \frac{{x}^{\left(\frac{1}{n}\right)}}{\color{blue}{x \cdot n}} \]
    4. Simplified97.8%

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

    if -1e-22 < (/.f64 1 n) < 1.00000000000000007e-17

    1. Initial program 26.3%

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

      \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
    3. Step-by-step derivation
      1. log1p-def81.2%

        \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(x\right)} - \log x}{n} \]
    4. Simplified81.2%

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]

    if 1.00000000000000007e-17 < (/.f64 1 n) < 2e156

    1. Initial program 85.7%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Taylor expanded in x around 0 90.1%

      \[\leadsto \color{blue}{\left(\frac{x}{n} + \left(1 + \left(0.5 \cdot \frac{1}{{n}^{2}} - 0.5 \cdot \frac{1}{n}\right) \cdot {x}^{2}\right)\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    3. Step-by-step derivation
      1. associate-+r+90.1%

        \[\leadsto \color{blue}{\left(\left(\frac{x}{n} + 1\right) + \left(0.5 \cdot \frac{1}{{n}^{2}} - 0.5 \cdot \frac{1}{n}\right) \cdot {x}^{2}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
      2. +-commutative90.1%

        \[\leadsto \left(\color{blue}{\left(1 + \frac{x}{n}\right)} + \left(0.5 \cdot \frac{1}{{n}^{2}} - 0.5 \cdot \frac{1}{n}\right) \cdot {x}^{2}\right) - {x}^{\left(\frac{1}{n}\right)} \]
      3. associate-*r/90.1%

        \[\leadsto \left(\left(1 + \frac{x}{n}\right) + \left(\color{blue}{\frac{0.5 \cdot 1}{{n}^{2}}} - 0.5 \cdot \frac{1}{n}\right) \cdot {x}^{2}\right) - {x}^{\left(\frac{1}{n}\right)} \]
      4. metadata-eval90.1%

        \[\leadsto \left(\left(1 + \frac{x}{n}\right) + \left(\frac{\color{blue}{0.5}}{{n}^{2}} - 0.5 \cdot \frac{1}{n}\right) \cdot {x}^{2}\right) - {x}^{\left(\frac{1}{n}\right)} \]
      5. unpow290.1%

        \[\leadsto \left(\left(1 + \frac{x}{n}\right) + \left(\frac{0.5}{\color{blue}{n \cdot n}} - 0.5 \cdot \frac{1}{n}\right) \cdot {x}^{2}\right) - {x}^{\left(\frac{1}{n}\right)} \]
      6. associate-*r/90.1%

        \[\leadsto \left(\left(1 + \frac{x}{n}\right) + \left(\frac{0.5}{n \cdot n} - \color{blue}{\frac{0.5 \cdot 1}{n}}\right) \cdot {x}^{2}\right) - {x}^{\left(\frac{1}{n}\right)} \]
      7. metadata-eval90.1%

        \[\leadsto \left(\left(1 + \frac{x}{n}\right) + \left(\frac{0.5}{n \cdot n} - \frac{\color{blue}{0.5}}{n}\right) \cdot {x}^{2}\right) - {x}^{\left(\frac{1}{n}\right)} \]
      8. unpow290.1%

        \[\leadsto \left(\left(1 + \frac{x}{n}\right) + \left(\frac{0.5}{n \cdot n} - \frac{0.5}{n}\right) \cdot \color{blue}{\left(x \cdot x\right)}\right) - {x}^{\left(\frac{1}{n}\right)} \]
    4. Simplified90.1%

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

    if 2e156 < (/.f64 1 n)

    1. Initial program 15.3%

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

      \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
    3. Step-by-step derivation
      1. log1p-def8.4%

        \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(x\right)} - \log x}{n} \]
    4. Simplified8.4%

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Taylor expanded in x around inf 78.6%

      \[\leadsto \color{blue}{\frac{1}{n \cdot x}} \]
    6. Step-by-step derivation
      1. *-commutative78.6%

        \[\leadsto \frac{1}{\color{blue}{x \cdot n}} \]
    7. Simplified78.6%

      \[\leadsto \color{blue}{\frac{1}{x \cdot n}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification87.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-22}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{-17}:\\ \;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+156}:\\ \;\;\;\;\left(\left(\frac{0.5}{n \cdot n} - \frac{0.5}{n}\right) \cdot \left(x \cdot x\right) + \left(1 + \frac{x}{n}\right)\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \end{array} \]

Alternative 5: 80.0% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-22}:\\ \;\;\;\;\frac{t_0}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{-17}:\\ \;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+156}:\\ \;\;\;\;\left(\left(\frac{0.5}{n \cdot n} - \frac{0.5}{n}\right) \cdot \left(x \cdot x\right) + \left(1 + \frac{x}{n}\right)\right) - t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (pow x (/ 1.0 n))))
   (if (<= (/ 1.0 n) -1e-22)
     (/ t_0 (* n x))
     (if (<= (/ 1.0 n) 1e-17)
       (/ (log (/ (+ x 1.0) x)) n)
       (if (<= (/ 1.0 n) 2e+156)
         (- (+ (* (- (/ 0.5 (* n n)) (/ 0.5 n)) (* x x)) (+ 1.0 (/ x n))) t_0)
         (/ 1.0 (* n x)))))))
double code(double x, double n) {
	double t_0 = pow(x, (1.0 / n));
	double tmp;
	if ((1.0 / n) <= -1e-22) {
		tmp = t_0 / (n * x);
	} else if ((1.0 / n) <= 1e-17) {
		tmp = log(((x + 1.0) / x)) / n;
	} else if ((1.0 / n) <= 2e+156) {
		tmp = ((((0.5 / (n * n)) - (0.5 / n)) * (x * x)) + (1.0 + (x / n))) - t_0;
	} else {
		tmp = 1.0 / (n * x);
	}
	return tmp;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    real(8) :: t_0
    real(8) :: tmp
    t_0 = x ** (1.0d0 / n)
    if ((1.0d0 / n) <= (-1d-22)) then
        tmp = t_0 / (n * x)
    else if ((1.0d0 / n) <= 1d-17) then
        tmp = log(((x + 1.0d0) / x)) / n
    else if ((1.0d0 / n) <= 2d+156) then
        tmp = ((((0.5d0 / (n * n)) - (0.5d0 / n)) * (x * x)) + (1.0d0 + (x / n))) - t_0
    else
        tmp = 1.0d0 / (n * x)
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double t_0 = Math.pow(x, (1.0 / n));
	double tmp;
	if ((1.0 / n) <= -1e-22) {
		tmp = t_0 / (n * x);
	} else if ((1.0 / n) <= 1e-17) {
		tmp = Math.log(((x + 1.0) / x)) / n;
	} else if ((1.0 / n) <= 2e+156) {
		tmp = ((((0.5 / (n * n)) - (0.5 / n)) * (x * x)) + (1.0 + (x / n))) - t_0;
	} else {
		tmp = 1.0 / (n * x);
	}
	return tmp;
}
def code(x, n):
	t_0 = math.pow(x, (1.0 / n))
	tmp = 0
	if (1.0 / n) <= -1e-22:
		tmp = t_0 / (n * x)
	elif (1.0 / n) <= 1e-17:
		tmp = math.log(((x + 1.0) / x)) / n
	elif (1.0 / n) <= 2e+156:
		tmp = ((((0.5 / (n * n)) - (0.5 / n)) * (x * x)) + (1.0 + (x / n))) - t_0
	else:
		tmp = 1.0 / (n * x)
	return tmp
function code(x, n)
	t_0 = x ^ Float64(1.0 / n)
	tmp = 0.0
	if (Float64(1.0 / n) <= -1e-22)
		tmp = Float64(t_0 / Float64(n * x));
	elseif (Float64(1.0 / n) <= 1e-17)
		tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n);
	elseif (Float64(1.0 / n) <= 2e+156)
		tmp = Float64(Float64(Float64(Float64(Float64(0.5 / Float64(n * n)) - Float64(0.5 / n)) * Float64(x * x)) + Float64(1.0 + Float64(x / n))) - t_0);
	else
		tmp = Float64(1.0 / Float64(n * x));
	end
	return tmp
end
function tmp_2 = code(x, n)
	t_0 = x ^ (1.0 / n);
	tmp = 0.0;
	if ((1.0 / n) <= -1e-22)
		tmp = t_0 / (n * x);
	elseif ((1.0 / n) <= 1e-17)
		tmp = log(((x + 1.0) / x)) / n;
	elseif ((1.0 / n) <= 2e+156)
		tmp = ((((0.5 / (n * n)) - (0.5 / n)) * (x * x)) + (1.0 + (x / n))) - t_0;
	else
		tmp = 1.0 / (n * x);
	end
	tmp_2 = tmp;
end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-22], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-17], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+156], N[(N[(N[(N[(N[(0.5 / N[(n * n), $MachinePrecision]), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision] + N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-22}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\

\mathbf{elif}\;\frac{1}{n} \leq 10^{-17}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\

\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+156}:\\
\;\;\;\;\left(\left(\frac{0.5}{n \cdot n} - \frac{0.5}{n}\right) \cdot \left(x \cdot x\right) + \left(1 + \frac{x}{n}\right)\right) - t_0\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (/.f64 1 n) < -1e-22

    1. Initial program 96.8%

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

      \[\leadsto \color{blue}{\frac{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}}}{n \cdot x}} \]
    3. Step-by-step derivation
      1. log-rec97.8%

        \[\leadsto \frac{e^{-1 \cdot \frac{\color{blue}{-\log x}}{n}}}{n \cdot x} \]
      2. mul-1-neg97.8%

        \[\leadsto \frac{e^{-1 \cdot \frac{\color{blue}{-1 \cdot \log x}}{n}}}{n \cdot x} \]
      3. mul-1-neg97.8%

        \[\leadsto \frac{e^{-1 \cdot \frac{\color{blue}{-\log x}}{n}}}{n \cdot x} \]
      4. distribute-frac-neg97.8%

        \[\leadsto \frac{e^{-1 \cdot \color{blue}{\left(-\frac{\log x}{n}\right)}}}{n \cdot x} \]
      5. neg-mul-197.8%

        \[\leadsto \frac{e^{\color{blue}{-\left(-\frac{\log x}{n}\right)}}}{n \cdot x} \]
      6. remove-double-neg97.8%

        \[\leadsto \frac{e^{\color{blue}{\frac{\log x}{n}}}}{n \cdot x} \]
      7. *-rgt-identity97.8%

        \[\leadsto \frac{e^{\frac{\color{blue}{\log x \cdot 1}}{n}}}{n \cdot x} \]
      8. associate-*r/97.8%

        \[\leadsto \frac{e^{\color{blue}{\log x \cdot \frac{1}{n}}}}{n \cdot x} \]
      9. unpow-197.8%

        \[\leadsto \frac{e^{\log x \cdot \color{blue}{{n}^{-1}}}}{n \cdot x} \]
      10. exp-to-pow97.8%

        \[\leadsto \frac{\color{blue}{{x}^{\left({n}^{-1}\right)}}}{n \cdot x} \]
      11. unpow-197.8%

        \[\leadsto \frac{{x}^{\color{blue}{\left(\frac{1}{n}\right)}}}{n \cdot x} \]
      12. *-commutative97.8%

        \[\leadsto \frac{{x}^{\left(\frac{1}{n}\right)}}{\color{blue}{x \cdot n}} \]
    4. Simplified97.8%

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

    if -1e-22 < (/.f64 1 n) < 1.00000000000000007e-17

    1. Initial program 26.3%

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

      \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
    3. Step-by-step derivation
      1. log1p-def81.2%

        \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(x\right)} - \log x}{n} \]
    4. Simplified81.2%

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Step-by-step derivation
      1. add-cbrt-cube80.9%

        \[\leadsto \frac{\color{blue}{\sqrt[3]{\left(\left(\mathsf{log1p}\left(x\right) - \log x\right) \cdot \left(\mathsf{log1p}\left(x\right) - \log x\right)\right) \cdot \left(\mathsf{log1p}\left(x\right) - \log x\right)}}}{n} \]
    6. Applied egg-rr80.9%

      \[\leadsto \frac{\color{blue}{\sqrt[3]{\left(\left(\mathsf{log1p}\left(x\right) - \log x\right) \cdot \left(\mathsf{log1p}\left(x\right) - \log x\right)\right) \cdot \left(\mathsf{log1p}\left(x\right) - \log x\right)}}}{n} \]
    7. Step-by-step derivation
      1. associate-*l*80.9%

        \[\leadsto \frac{\sqrt[3]{\color{blue}{\left(\mathsf{log1p}\left(x\right) - \log x\right) \cdot \left(\left(\mathsf{log1p}\left(x\right) - \log x\right) \cdot \left(\mathsf{log1p}\left(x\right) - \log x\right)\right)}}}{n} \]
      2. cube-unmult81.0%

        \[\leadsto \frac{\sqrt[3]{\color{blue}{{\left(\mathsf{log1p}\left(x\right) - \log x\right)}^{3}}}}{n} \]
    8. Simplified81.0%

      \[\leadsto \frac{\color{blue}{\sqrt[3]{{\left(\mathsf{log1p}\left(x\right) - \log x\right)}^{3}}}}{n} \]
    9. Step-by-step derivation
      1. rem-cbrt-cube81.2%

        \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(x\right) - \log x}}{n} \]
      2. log1p-udef81.2%

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

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

        \[\leadsto \frac{\log \left(\frac{\color{blue}{x + 1}}{x}\right)}{n} \]
    10. Applied egg-rr80.6%

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

    if 1.00000000000000007e-17 < (/.f64 1 n) < 2e156

    1. Initial program 85.7%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Taylor expanded in x around 0 90.1%

      \[\leadsto \color{blue}{\left(\frac{x}{n} + \left(1 + \left(0.5 \cdot \frac{1}{{n}^{2}} - 0.5 \cdot \frac{1}{n}\right) \cdot {x}^{2}\right)\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    3. Step-by-step derivation
      1. associate-+r+90.1%

        \[\leadsto \color{blue}{\left(\left(\frac{x}{n} + 1\right) + \left(0.5 \cdot \frac{1}{{n}^{2}} - 0.5 \cdot \frac{1}{n}\right) \cdot {x}^{2}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
      2. +-commutative90.1%

        \[\leadsto \left(\color{blue}{\left(1 + \frac{x}{n}\right)} + \left(0.5 \cdot \frac{1}{{n}^{2}} - 0.5 \cdot \frac{1}{n}\right) \cdot {x}^{2}\right) - {x}^{\left(\frac{1}{n}\right)} \]
      3. associate-*r/90.1%

        \[\leadsto \left(\left(1 + \frac{x}{n}\right) + \left(\color{blue}{\frac{0.5 \cdot 1}{{n}^{2}}} - 0.5 \cdot \frac{1}{n}\right) \cdot {x}^{2}\right) - {x}^{\left(\frac{1}{n}\right)} \]
      4. metadata-eval90.1%

        \[\leadsto \left(\left(1 + \frac{x}{n}\right) + \left(\frac{\color{blue}{0.5}}{{n}^{2}} - 0.5 \cdot \frac{1}{n}\right) \cdot {x}^{2}\right) - {x}^{\left(\frac{1}{n}\right)} \]
      5. unpow290.1%

        \[\leadsto \left(\left(1 + \frac{x}{n}\right) + \left(\frac{0.5}{\color{blue}{n \cdot n}} - 0.5 \cdot \frac{1}{n}\right) \cdot {x}^{2}\right) - {x}^{\left(\frac{1}{n}\right)} \]
      6. associate-*r/90.1%

        \[\leadsto \left(\left(1 + \frac{x}{n}\right) + \left(\frac{0.5}{n \cdot n} - \color{blue}{\frac{0.5 \cdot 1}{n}}\right) \cdot {x}^{2}\right) - {x}^{\left(\frac{1}{n}\right)} \]
      7. metadata-eval90.1%

        \[\leadsto \left(\left(1 + \frac{x}{n}\right) + \left(\frac{0.5}{n \cdot n} - \frac{\color{blue}{0.5}}{n}\right) \cdot {x}^{2}\right) - {x}^{\left(\frac{1}{n}\right)} \]
      8. unpow290.1%

        \[\leadsto \left(\left(1 + \frac{x}{n}\right) + \left(\frac{0.5}{n \cdot n} - \frac{0.5}{n}\right) \cdot \color{blue}{\left(x \cdot x\right)}\right) - {x}^{\left(\frac{1}{n}\right)} \]
    4. Simplified90.1%

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

    if 2e156 < (/.f64 1 n)

    1. Initial program 15.3%

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

      \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
    3. Step-by-step derivation
      1. log1p-def8.4%

        \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(x\right)} - \log x}{n} \]
    4. Simplified8.4%

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Taylor expanded in x around inf 78.6%

      \[\leadsto \color{blue}{\frac{1}{n \cdot x}} \]
    6. Step-by-step derivation
      1. *-commutative78.6%

        \[\leadsto \frac{1}{\color{blue}{x \cdot n}} \]
    7. Simplified78.6%

      \[\leadsto \color{blue}{\frac{1}{x \cdot n}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification87.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-22}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{-17}:\\ \;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+156}:\\ \;\;\;\;\left(\left(\frac{0.5}{n \cdot n} - \frac{0.5}{n}\right) \cdot \left(x \cdot x\right) + \left(1 + \frac{x}{n}\right)\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \end{array} \]

Alternative 6: 65.8% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\ t_1 := \frac{\log \left(\frac{x + 1}{x}\right)}{n}\\ \mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{+193}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{+151}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{+69}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{1}{n} \leq -4 \cdot 10^{+15}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{-17}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{+144}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))) (t_1 (/ (log (/ (+ x 1.0) x)) n)))
   (if (<= (/ 1.0 n) -5e+193)
     t_1
     (if (<= (/ 1.0 n) -2e+151)
       t_0
       (if (<= (/ 1.0 n) -2e+69)
         t_1
         (if (<= (/ 1.0 n) -4e+15)
           t_0
           (if (<= (/ 1.0 n) 1e-17)
             t_1
             (if (<= (/ 1.0 n) 1e+144) t_0 (/ 1.0 (* n x))))))))))
double code(double x, double n) {
	double t_0 = 1.0 - pow(x, (1.0 / n));
	double t_1 = log(((x + 1.0) / x)) / n;
	double tmp;
	if ((1.0 / n) <= -5e+193) {
		tmp = t_1;
	} else if ((1.0 / n) <= -2e+151) {
		tmp = t_0;
	} else if ((1.0 / n) <= -2e+69) {
		tmp = t_1;
	} else if ((1.0 / n) <= -4e+15) {
		tmp = t_0;
	} else if ((1.0 / n) <= 1e-17) {
		tmp = t_1;
	} else if ((1.0 / n) <= 1e+144) {
		tmp = t_0;
	} else {
		tmp = 1.0 / (n * x);
	}
	return tmp;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = 1.0d0 - (x ** (1.0d0 / n))
    t_1 = log(((x + 1.0d0) / x)) / n
    if ((1.0d0 / n) <= (-5d+193)) then
        tmp = t_1
    else if ((1.0d0 / n) <= (-2d+151)) then
        tmp = t_0
    else if ((1.0d0 / n) <= (-2d+69)) then
        tmp = t_1
    else if ((1.0d0 / n) <= (-4d+15)) then
        tmp = t_0
    else if ((1.0d0 / n) <= 1d-17) then
        tmp = t_1
    else if ((1.0d0 / n) <= 1d+144) then
        tmp = t_0
    else
        tmp = 1.0d0 / (n * x)
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double t_0 = 1.0 - Math.pow(x, (1.0 / n));
	double t_1 = Math.log(((x + 1.0) / x)) / n;
	double tmp;
	if ((1.0 / n) <= -5e+193) {
		tmp = t_1;
	} else if ((1.0 / n) <= -2e+151) {
		tmp = t_0;
	} else if ((1.0 / n) <= -2e+69) {
		tmp = t_1;
	} else if ((1.0 / n) <= -4e+15) {
		tmp = t_0;
	} else if ((1.0 / n) <= 1e-17) {
		tmp = t_1;
	} else if ((1.0 / n) <= 1e+144) {
		tmp = t_0;
	} else {
		tmp = 1.0 / (n * x);
	}
	return tmp;
}
def code(x, n):
	t_0 = 1.0 - math.pow(x, (1.0 / n))
	t_1 = math.log(((x + 1.0) / x)) / n
	tmp = 0
	if (1.0 / n) <= -5e+193:
		tmp = t_1
	elif (1.0 / n) <= -2e+151:
		tmp = t_0
	elif (1.0 / n) <= -2e+69:
		tmp = t_1
	elif (1.0 / n) <= -4e+15:
		tmp = t_0
	elif (1.0 / n) <= 1e-17:
		tmp = t_1
	elif (1.0 / n) <= 1e+144:
		tmp = t_0
	else:
		tmp = 1.0 / (n * x)
	return tmp
function code(x, n)
	t_0 = Float64(1.0 - (x ^ Float64(1.0 / n)))
	t_1 = Float64(log(Float64(Float64(x + 1.0) / x)) / n)
	tmp = 0.0
	if (Float64(1.0 / n) <= -5e+193)
		tmp = t_1;
	elseif (Float64(1.0 / n) <= -2e+151)
		tmp = t_0;
	elseif (Float64(1.0 / n) <= -2e+69)
		tmp = t_1;
	elseif (Float64(1.0 / n) <= -4e+15)
		tmp = t_0;
	elseif (Float64(1.0 / n) <= 1e-17)
		tmp = t_1;
	elseif (Float64(1.0 / n) <= 1e+144)
		tmp = t_0;
	else
		tmp = Float64(1.0 / Float64(n * x));
	end
	return tmp
end
function tmp_2 = code(x, n)
	t_0 = 1.0 - (x ^ (1.0 / n));
	t_1 = log(((x + 1.0) / x)) / n;
	tmp = 0.0;
	if ((1.0 / n) <= -5e+193)
		tmp = t_1;
	elseif ((1.0 / n) <= -2e+151)
		tmp = t_0;
	elseif ((1.0 / n) <= -2e+69)
		tmp = t_1;
	elseif ((1.0 / n) <= -4e+15)
		tmp = t_0;
	elseif ((1.0 / n) <= 1e-17)
		tmp = t_1;
	elseif ((1.0 / n) <= 1e+144)
		tmp = t_0;
	else
		tmp = 1.0 / (n * x);
	end
	tmp_2 = tmp;
end
code[x_, n_] := Block[{t$95$0 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e+193], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e+151], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e+69], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], -4e+15], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-17], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+144], t$95$0, N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{+193}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{+151}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{+69}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;\frac{1}{n} \leq -4 \cdot 10^{+15}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;\frac{1}{n} \leq 10^{-17}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;\frac{1}{n} \leq 10^{+144}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 1 n) < -4.99999999999999972e193 or -2.00000000000000003e151 < (/.f64 1 n) < -2.0000000000000001e69 or -4e15 < (/.f64 1 n) < 1.00000000000000007e-17

    1. Initial program 45.6%

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

      \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
    3. Step-by-step derivation
      1. log1p-def77.9%

        \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(x\right)} - \log x}{n} \]
    4. Simplified77.9%

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Step-by-step derivation
      1. add-cbrt-cube77.7%

        \[\leadsto \frac{\color{blue}{\sqrt[3]{\left(\left(\mathsf{log1p}\left(x\right) - \log x\right) \cdot \left(\mathsf{log1p}\left(x\right) - \log x\right)\right) \cdot \left(\mathsf{log1p}\left(x\right) - \log x\right)}}}{n} \]
    6. Applied egg-rr77.7%

      \[\leadsto \frac{\color{blue}{\sqrt[3]{\left(\left(\mathsf{log1p}\left(x\right) - \log x\right) \cdot \left(\mathsf{log1p}\left(x\right) - \log x\right)\right) \cdot \left(\mathsf{log1p}\left(x\right) - \log x\right)}}}{n} \]
    7. Step-by-step derivation
      1. associate-*l*77.7%

        \[\leadsto \frac{\sqrt[3]{\color{blue}{\left(\mathsf{log1p}\left(x\right) - \log x\right) \cdot \left(\left(\mathsf{log1p}\left(x\right) - \log x\right) \cdot \left(\mathsf{log1p}\left(x\right) - \log x\right)\right)}}}{n} \]
      2. cube-unmult77.7%

        \[\leadsto \frac{\sqrt[3]{\color{blue}{{\left(\mathsf{log1p}\left(x\right) - \log x\right)}^{3}}}}{n} \]
    8. Simplified77.7%

      \[\leadsto \frac{\color{blue}{\sqrt[3]{{\left(\mathsf{log1p}\left(x\right) - \log x\right)}^{3}}}}{n} \]
    9. Step-by-step derivation
      1. rem-cbrt-cube77.9%

        \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(x\right) - \log x}}{n} \]
      2. log1p-udef77.9%

        \[\leadsto \frac{\color{blue}{\log \left(1 + x\right)} - \log x}{n} \]
      3. diff-log77.4%

        \[\leadsto \frac{\color{blue}{\log \left(\frac{1 + x}{x}\right)}}{n} \]
      4. +-commutative77.4%

        \[\leadsto \frac{\log \left(\frac{\color{blue}{x + 1}}{x}\right)}{n} \]
    10. Applied egg-rr77.4%

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

    if -4.99999999999999972e193 < (/.f64 1 n) < -2.00000000000000003e151 or -2.0000000000000001e69 < (/.f64 1 n) < -4e15 or 1.00000000000000007e-17 < (/.f64 1 n) < 1.00000000000000002e144

    1. Initial program 96.0%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Taylor expanded in x around 0 85.2%

      \[\leadsto \color{blue}{1 - e^{\frac{\log x}{n}}} \]
    3. Step-by-step derivation
      1. *-rgt-identity85.2%

        \[\leadsto 1 - e^{\frac{\color{blue}{\log x \cdot 1}}{n}} \]
      2. associate-*r/85.2%

        \[\leadsto 1 - e^{\color{blue}{\log x \cdot \frac{1}{n}}} \]
      3. unpow-185.2%

        \[\leadsto 1 - e^{\log x \cdot \color{blue}{{n}^{-1}}} \]
      4. exp-to-pow85.2%

        \[\leadsto 1 - \color{blue}{{x}^{\left({n}^{-1}\right)}} \]
      5. unpow-185.2%

        \[\leadsto 1 - {x}^{\color{blue}{\left(\frac{1}{n}\right)}} \]
    4. Simplified85.2%

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

    if 1.00000000000000002e144 < (/.f64 1 n)

    1. Initial program 14.5%

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

      \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
    3. Step-by-step derivation
      1. log1p-def8.1%

        \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(x\right)} - \log x}{n} \]
    4. Simplified8.1%

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Taylor expanded in x around inf 73.4%

      \[\leadsto \color{blue}{\frac{1}{n \cdot x}} \]
    6. Step-by-step derivation
      1. *-commutative73.4%

        \[\leadsto \frac{1}{\color{blue}{x \cdot n}} \]
    7. Simplified73.4%

      \[\leadsto \color{blue}{\frac{1}{x \cdot n}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification78.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{+193}:\\ \;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{+151}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{+69}:\\ \;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq -4 \cdot 10^{+15}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{-17}:\\ \;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{+144}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \end{array} \]

Alternative 7: 79.8% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-22}:\\ \;\;\;\;\frac{t_0}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{-17}:\\ \;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{+144}:\\ \;\;\;\;\left(1 + \frac{x}{n}\right) - t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (pow x (/ 1.0 n))))
   (if (<= (/ 1.0 n) -1e-22)
     (/ t_0 (* n x))
     (if (<= (/ 1.0 n) 1e-17)
       (/ (log (/ (+ x 1.0) x)) n)
       (if (<= (/ 1.0 n) 1e+144) (- (+ 1.0 (/ x n)) t_0) (/ 1.0 (* n x)))))))
double code(double x, double n) {
	double t_0 = pow(x, (1.0 / n));
	double tmp;
	if ((1.0 / n) <= -1e-22) {
		tmp = t_0 / (n * x);
	} else if ((1.0 / n) <= 1e-17) {
		tmp = log(((x + 1.0) / x)) / n;
	} else if ((1.0 / n) <= 1e+144) {
		tmp = (1.0 + (x / n)) - t_0;
	} else {
		tmp = 1.0 / (n * x);
	}
	return tmp;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    real(8) :: t_0
    real(8) :: tmp
    t_0 = x ** (1.0d0 / n)
    if ((1.0d0 / n) <= (-1d-22)) then
        tmp = t_0 / (n * x)
    else if ((1.0d0 / n) <= 1d-17) then
        tmp = log(((x + 1.0d0) / x)) / n
    else if ((1.0d0 / n) <= 1d+144) then
        tmp = (1.0d0 + (x / n)) - t_0
    else
        tmp = 1.0d0 / (n * x)
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double t_0 = Math.pow(x, (1.0 / n));
	double tmp;
	if ((1.0 / n) <= -1e-22) {
		tmp = t_0 / (n * x);
	} else if ((1.0 / n) <= 1e-17) {
		tmp = Math.log(((x + 1.0) / x)) / n;
	} else if ((1.0 / n) <= 1e+144) {
		tmp = (1.0 + (x / n)) - t_0;
	} else {
		tmp = 1.0 / (n * x);
	}
	return tmp;
}
def code(x, n):
	t_0 = math.pow(x, (1.0 / n))
	tmp = 0
	if (1.0 / n) <= -1e-22:
		tmp = t_0 / (n * x)
	elif (1.0 / n) <= 1e-17:
		tmp = math.log(((x + 1.0) / x)) / n
	elif (1.0 / n) <= 1e+144:
		tmp = (1.0 + (x / n)) - t_0
	else:
		tmp = 1.0 / (n * x)
	return tmp
function code(x, n)
	t_0 = x ^ Float64(1.0 / n)
	tmp = 0.0
	if (Float64(1.0 / n) <= -1e-22)
		tmp = Float64(t_0 / Float64(n * x));
	elseif (Float64(1.0 / n) <= 1e-17)
		tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n);
	elseif (Float64(1.0 / n) <= 1e+144)
		tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0);
	else
		tmp = Float64(1.0 / Float64(n * x));
	end
	return tmp
end
function tmp_2 = code(x, n)
	t_0 = x ^ (1.0 / n);
	tmp = 0.0;
	if ((1.0 / n) <= -1e-22)
		tmp = t_0 / (n * x);
	elseif ((1.0 / n) <= 1e-17)
		tmp = log(((x + 1.0) / x)) / n;
	elseif ((1.0 / n) <= 1e+144)
		tmp = (1.0 + (x / n)) - t_0;
	else
		tmp = 1.0 / (n * x);
	end
	tmp_2 = tmp;
end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-22], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-17], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+144], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-22}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\

\mathbf{elif}\;\frac{1}{n} \leq 10^{-17}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\

\mathbf{elif}\;\frac{1}{n} \leq 10^{+144}:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t_0\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (/.f64 1 n) < -1e-22

    1. Initial program 96.8%

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

      \[\leadsto \color{blue}{\frac{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}}}{n \cdot x}} \]
    3. Step-by-step derivation
      1. log-rec97.8%

        \[\leadsto \frac{e^{-1 \cdot \frac{\color{blue}{-\log x}}{n}}}{n \cdot x} \]
      2. mul-1-neg97.8%

        \[\leadsto \frac{e^{-1 \cdot \frac{\color{blue}{-1 \cdot \log x}}{n}}}{n \cdot x} \]
      3. mul-1-neg97.8%

        \[\leadsto \frac{e^{-1 \cdot \frac{\color{blue}{-\log x}}{n}}}{n \cdot x} \]
      4. distribute-frac-neg97.8%

        \[\leadsto \frac{e^{-1 \cdot \color{blue}{\left(-\frac{\log x}{n}\right)}}}{n \cdot x} \]
      5. neg-mul-197.8%

        \[\leadsto \frac{e^{\color{blue}{-\left(-\frac{\log x}{n}\right)}}}{n \cdot x} \]
      6. remove-double-neg97.8%

        \[\leadsto \frac{e^{\color{blue}{\frac{\log x}{n}}}}{n \cdot x} \]
      7. *-rgt-identity97.8%

        \[\leadsto \frac{e^{\frac{\color{blue}{\log x \cdot 1}}{n}}}{n \cdot x} \]
      8. associate-*r/97.8%

        \[\leadsto \frac{e^{\color{blue}{\log x \cdot \frac{1}{n}}}}{n \cdot x} \]
      9. unpow-197.8%

        \[\leadsto \frac{e^{\log x \cdot \color{blue}{{n}^{-1}}}}{n \cdot x} \]
      10. exp-to-pow97.8%

        \[\leadsto \frac{\color{blue}{{x}^{\left({n}^{-1}\right)}}}{n \cdot x} \]
      11. unpow-197.8%

        \[\leadsto \frac{{x}^{\color{blue}{\left(\frac{1}{n}\right)}}}{n \cdot x} \]
      12. *-commutative97.8%

        \[\leadsto \frac{{x}^{\left(\frac{1}{n}\right)}}{\color{blue}{x \cdot n}} \]
    4. Simplified97.8%

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

    if -1e-22 < (/.f64 1 n) < 1.00000000000000007e-17

    1. Initial program 26.3%

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

      \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
    3. Step-by-step derivation
      1. log1p-def81.2%

        \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(x\right)} - \log x}{n} \]
    4. Simplified81.2%

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Step-by-step derivation
      1. add-cbrt-cube80.9%

        \[\leadsto \frac{\color{blue}{\sqrt[3]{\left(\left(\mathsf{log1p}\left(x\right) - \log x\right) \cdot \left(\mathsf{log1p}\left(x\right) - \log x\right)\right) \cdot \left(\mathsf{log1p}\left(x\right) - \log x\right)}}}{n} \]
    6. Applied egg-rr80.9%

      \[\leadsto \frac{\color{blue}{\sqrt[3]{\left(\left(\mathsf{log1p}\left(x\right) - \log x\right) \cdot \left(\mathsf{log1p}\left(x\right) - \log x\right)\right) \cdot \left(\mathsf{log1p}\left(x\right) - \log x\right)}}}{n} \]
    7. Step-by-step derivation
      1. associate-*l*80.9%

        \[\leadsto \frac{\sqrt[3]{\color{blue}{\left(\mathsf{log1p}\left(x\right) - \log x\right) \cdot \left(\left(\mathsf{log1p}\left(x\right) - \log x\right) \cdot \left(\mathsf{log1p}\left(x\right) - \log x\right)\right)}}}{n} \]
      2. cube-unmult81.0%

        \[\leadsto \frac{\sqrt[3]{\color{blue}{{\left(\mathsf{log1p}\left(x\right) - \log x\right)}^{3}}}}{n} \]
    8. Simplified81.0%

      \[\leadsto \frac{\color{blue}{\sqrt[3]{{\left(\mathsf{log1p}\left(x\right) - \log x\right)}^{3}}}}{n} \]
    9. Step-by-step derivation
      1. rem-cbrt-cube81.2%

        \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(x\right) - \log x}}{n} \]
      2. log1p-udef81.2%

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

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

        \[\leadsto \frac{\log \left(\frac{\color{blue}{x + 1}}{x}\right)}{n} \]
    10. Applied egg-rr80.6%

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

    if 1.00000000000000007e-17 < (/.f64 1 n) < 1.00000000000000002e144

    1. Initial program 89.7%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Taylor expanded in x around 0 89.8%

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

    if 1.00000000000000002e144 < (/.f64 1 n)

    1. Initial program 14.5%

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

      \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
    3. Step-by-step derivation
      1. log1p-def8.1%

        \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(x\right)} - \log x}{n} \]
    4. Simplified8.1%

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Taylor expanded in x around inf 73.4%

      \[\leadsto \color{blue}{\frac{1}{n \cdot x}} \]
    6. Step-by-step derivation
      1. *-commutative73.4%

        \[\leadsto \frac{1}{\color{blue}{x \cdot n}} \]
    7. Simplified73.4%

      \[\leadsto \color{blue}{\frac{1}{x \cdot n}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification86.7%

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

Alternative 8: 79.7% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-22}:\\ \;\;\;\;\frac{t_0}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{-17}:\\ \;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{+144}:\\ \;\;\;\;1 - t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (pow x (/ 1.0 n))))
   (if (<= (/ 1.0 n) -1e-22)
     (/ t_0 (* n x))
     (if (<= (/ 1.0 n) 1e-17)
       (/ (log (/ (+ x 1.0) x)) n)
       (if (<= (/ 1.0 n) 1e+144) (- 1.0 t_0) (/ 1.0 (* n x)))))))
double code(double x, double n) {
	double t_0 = pow(x, (1.0 / n));
	double tmp;
	if ((1.0 / n) <= -1e-22) {
		tmp = t_0 / (n * x);
	} else if ((1.0 / n) <= 1e-17) {
		tmp = log(((x + 1.0) / x)) / n;
	} else if ((1.0 / n) <= 1e+144) {
		tmp = 1.0 - t_0;
	} else {
		tmp = 1.0 / (n * x);
	}
	return tmp;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    real(8) :: t_0
    real(8) :: tmp
    t_0 = x ** (1.0d0 / n)
    if ((1.0d0 / n) <= (-1d-22)) then
        tmp = t_0 / (n * x)
    else if ((1.0d0 / n) <= 1d-17) then
        tmp = log(((x + 1.0d0) / x)) / n
    else if ((1.0d0 / n) <= 1d+144) then
        tmp = 1.0d0 - t_0
    else
        tmp = 1.0d0 / (n * x)
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double t_0 = Math.pow(x, (1.0 / n));
	double tmp;
	if ((1.0 / n) <= -1e-22) {
		tmp = t_0 / (n * x);
	} else if ((1.0 / n) <= 1e-17) {
		tmp = Math.log(((x + 1.0) / x)) / n;
	} else if ((1.0 / n) <= 1e+144) {
		tmp = 1.0 - t_0;
	} else {
		tmp = 1.0 / (n * x);
	}
	return tmp;
}
def code(x, n):
	t_0 = math.pow(x, (1.0 / n))
	tmp = 0
	if (1.0 / n) <= -1e-22:
		tmp = t_0 / (n * x)
	elif (1.0 / n) <= 1e-17:
		tmp = math.log(((x + 1.0) / x)) / n
	elif (1.0 / n) <= 1e+144:
		tmp = 1.0 - t_0
	else:
		tmp = 1.0 / (n * x)
	return tmp
function code(x, n)
	t_0 = x ^ Float64(1.0 / n)
	tmp = 0.0
	if (Float64(1.0 / n) <= -1e-22)
		tmp = Float64(t_0 / Float64(n * x));
	elseif (Float64(1.0 / n) <= 1e-17)
		tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n);
	elseif (Float64(1.0 / n) <= 1e+144)
		tmp = Float64(1.0 - t_0);
	else
		tmp = Float64(1.0 / Float64(n * x));
	end
	return tmp
end
function tmp_2 = code(x, n)
	t_0 = x ^ (1.0 / n);
	tmp = 0.0;
	if ((1.0 / n) <= -1e-22)
		tmp = t_0 / (n * x);
	elseif ((1.0 / n) <= 1e-17)
		tmp = log(((x + 1.0) / x)) / n;
	elseif ((1.0 / n) <= 1e+144)
		tmp = 1.0 - t_0;
	else
		tmp = 1.0 / (n * x);
	end
	tmp_2 = tmp;
end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-22], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-17], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+144], N[(1.0 - t$95$0), $MachinePrecision], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-22}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\

\mathbf{elif}\;\frac{1}{n} \leq 10^{-17}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\

\mathbf{elif}\;\frac{1}{n} \leq 10^{+144}:\\
\;\;\;\;1 - t_0\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (/.f64 1 n) < -1e-22

    1. Initial program 96.8%

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

      \[\leadsto \color{blue}{\frac{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}}}{n \cdot x}} \]
    3. Step-by-step derivation
      1. log-rec97.8%

        \[\leadsto \frac{e^{-1 \cdot \frac{\color{blue}{-\log x}}{n}}}{n \cdot x} \]
      2. mul-1-neg97.8%

        \[\leadsto \frac{e^{-1 \cdot \frac{\color{blue}{-1 \cdot \log x}}{n}}}{n \cdot x} \]
      3. mul-1-neg97.8%

        \[\leadsto \frac{e^{-1 \cdot \frac{\color{blue}{-\log x}}{n}}}{n \cdot x} \]
      4. distribute-frac-neg97.8%

        \[\leadsto \frac{e^{-1 \cdot \color{blue}{\left(-\frac{\log x}{n}\right)}}}{n \cdot x} \]
      5. neg-mul-197.8%

        \[\leadsto \frac{e^{\color{blue}{-\left(-\frac{\log x}{n}\right)}}}{n \cdot x} \]
      6. remove-double-neg97.8%

        \[\leadsto \frac{e^{\color{blue}{\frac{\log x}{n}}}}{n \cdot x} \]
      7. *-rgt-identity97.8%

        \[\leadsto \frac{e^{\frac{\color{blue}{\log x \cdot 1}}{n}}}{n \cdot x} \]
      8. associate-*r/97.8%

        \[\leadsto \frac{e^{\color{blue}{\log x \cdot \frac{1}{n}}}}{n \cdot x} \]
      9. unpow-197.8%

        \[\leadsto \frac{e^{\log x \cdot \color{blue}{{n}^{-1}}}}{n \cdot x} \]
      10. exp-to-pow97.8%

        \[\leadsto \frac{\color{blue}{{x}^{\left({n}^{-1}\right)}}}{n \cdot x} \]
      11. unpow-197.8%

        \[\leadsto \frac{{x}^{\color{blue}{\left(\frac{1}{n}\right)}}}{n \cdot x} \]
      12. *-commutative97.8%

        \[\leadsto \frac{{x}^{\left(\frac{1}{n}\right)}}{\color{blue}{x \cdot n}} \]
    4. Simplified97.8%

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

    if -1e-22 < (/.f64 1 n) < 1.00000000000000007e-17

    1. Initial program 26.3%

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

      \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
    3. Step-by-step derivation
      1. log1p-def81.2%

        \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(x\right)} - \log x}{n} \]
    4. Simplified81.2%

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Step-by-step derivation
      1. add-cbrt-cube80.9%

        \[\leadsto \frac{\color{blue}{\sqrt[3]{\left(\left(\mathsf{log1p}\left(x\right) - \log x\right) \cdot \left(\mathsf{log1p}\left(x\right) - \log x\right)\right) \cdot \left(\mathsf{log1p}\left(x\right) - \log x\right)}}}{n} \]
    6. Applied egg-rr80.9%

      \[\leadsto \frac{\color{blue}{\sqrt[3]{\left(\left(\mathsf{log1p}\left(x\right) - \log x\right) \cdot \left(\mathsf{log1p}\left(x\right) - \log x\right)\right) \cdot \left(\mathsf{log1p}\left(x\right) - \log x\right)}}}{n} \]
    7. Step-by-step derivation
      1. associate-*l*80.9%

        \[\leadsto \frac{\sqrt[3]{\color{blue}{\left(\mathsf{log1p}\left(x\right) - \log x\right) \cdot \left(\left(\mathsf{log1p}\left(x\right) - \log x\right) \cdot \left(\mathsf{log1p}\left(x\right) - \log x\right)\right)}}}{n} \]
      2. cube-unmult81.0%

        \[\leadsto \frac{\sqrt[3]{\color{blue}{{\left(\mathsf{log1p}\left(x\right) - \log x\right)}^{3}}}}{n} \]
    8. Simplified81.0%

      \[\leadsto \frac{\color{blue}{\sqrt[3]{{\left(\mathsf{log1p}\left(x\right) - \log x\right)}^{3}}}}{n} \]
    9. Step-by-step derivation
      1. rem-cbrt-cube81.2%

        \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(x\right) - \log x}}{n} \]
      2. log1p-udef81.2%

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

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

        \[\leadsto \frac{\log \left(\frac{\color{blue}{x + 1}}{x}\right)}{n} \]
    10. Applied egg-rr80.6%

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

    if 1.00000000000000007e-17 < (/.f64 1 n) < 1.00000000000000002e144

    1. Initial program 89.7%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Taylor expanded in x around 0 89.6%

      \[\leadsto \color{blue}{1 - e^{\frac{\log x}{n}}} \]
    3. Step-by-step derivation
      1. *-rgt-identity89.6%

        \[\leadsto 1 - e^{\frac{\color{blue}{\log x \cdot 1}}{n}} \]
      2. associate-*r/89.6%

        \[\leadsto 1 - e^{\color{blue}{\log x \cdot \frac{1}{n}}} \]
      3. unpow-189.6%

        \[\leadsto 1 - e^{\log x \cdot \color{blue}{{n}^{-1}}} \]
      4. exp-to-pow89.6%

        \[\leadsto 1 - \color{blue}{{x}^{\left({n}^{-1}\right)}} \]
      5. unpow-189.6%

        \[\leadsto 1 - {x}^{\color{blue}{\left(\frac{1}{n}\right)}} \]
    4. Simplified89.6%

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

    if 1.00000000000000002e144 < (/.f64 1 n)

    1. Initial program 14.5%

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

      \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
    3. Step-by-step derivation
      1. log1p-def8.1%

        \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(x\right)} - \log x}{n} \]
    4. Simplified8.1%

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Taylor expanded in x around inf 73.4%

      \[\leadsto \color{blue}{\frac{1}{n \cdot x}} \]
    6. Step-by-step derivation
      1. *-commutative73.4%

        \[\leadsto \frac{1}{\color{blue}{x \cdot n}} \]
    7. Simplified73.4%

      \[\leadsto \color{blue}{\frac{1}{x \cdot n}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification86.7%

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

Alternative 9: 57.2% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{-\log x}{n}\\ t_1 := 1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{if}\;x \leq 5.5 \cdot 10^{-223}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 6.8 \cdot 10^{-205}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 4.8 \cdot 10^{-178}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 4.8 \cdot 10^{-165}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 0.95:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (/ (- (log x)) n)) (t_1 (- 1.0 (pow x (/ 1.0 n)))))
   (if (<= x 5.5e-223)
     t_0
     (if (<= x 6.8e-205)
       t_1
       (if (<= x 4.8e-178)
         t_0
         (if (<= x 4.8e-165)
           t_1
           (if (<= x 0.95)
             (/ (- x (log x)) n)
             (/ (- (/ 1.0 x) (/ 0.5 (* x x))) n))))))))
double code(double x, double n) {
	double t_0 = -log(x) / n;
	double t_1 = 1.0 - pow(x, (1.0 / n));
	double tmp;
	if (x <= 5.5e-223) {
		tmp = t_0;
	} else if (x <= 6.8e-205) {
		tmp = t_1;
	} else if (x <= 4.8e-178) {
		tmp = t_0;
	} else if (x <= 4.8e-165) {
		tmp = t_1;
	} else if (x <= 0.95) {
		tmp = (x - log(x)) / n;
	} else {
		tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
	}
	return tmp;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = -log(x) / n
    t_1 = 1.0d0 - (x ** (1.0d0 / n))
    if (x <= 5.5d-223) then
        tmp = t_0
    else if (x <= 6.8d-205) then
        tmp = t_1
    else if (x <= 4.8d-178) then
        tmp = t_0
    else if (x <= 4.8d-165) then
        tmp = t_1
    else if (x <= 0.95d0) then
        tmp = (x - log(x)) / n
    else
        tmp = ((1.0d0 / x) - (0.5d0 / (x * x))) / n
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double t_0 = -Math.log(x) / n;
	double t_1 = 1.0 - Math.pow(x, (1.0 / n));
	double tmp;
	if (x <= 5.5e-223) {
		tmp = t_0;
	} else if (x <= 6.8e-205) {
		tmp = t_1;
	} else if (x <= 4.8e-178) {
		tmp = t_0;
	} else if (x <= 4.8e-165) {
		tmp = t_1;
	} else if (x <= 0.95) {
		tmp = (x - Math.log(x)) / n;
	} else {
		tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
	}
	return tmp;
}
def code(x, n):
	t_0 = -math.log(x) / n
	t_1 = 1.0 - math.pow(x, (1.0 / n))
	tmp = 0
	if x <= 5.5e-223:
		tmp = t_0
	elif x <= 6.8e-205:
		tmp = t_1
	elif x <= 4.8e-178:
		tmp = t_0
	elif x <= 4.8e-165:
		tmp = t_1
	elif x <= 0.95:
		tmp = (x - math.log(x)) / n
	else:
		tmp = ((1.0 / x) - (0.5 / (x * x))) / n
	return tmp
function code(x, n)
	t_0 = Float64(Float64(-log(x)) / n)
	t_1 = Float64(1.0 - (x ^ Float64(1.0 / n)))
	tmp = 0.0
	if (x <= 5.5e-223)
		tmp = t_0;
	elseif (x <= 6.8e-205)
		tmp = t_1;
	elseif (x <= 4.8e-178)
		tmp = t_0;
	elseif (x <= 4.8e-165)
		tmp = t_1;
	elseif (x <= 0.95)
		tmp = Float64(Float64(x - log(x)) / n);
	else
		tmp = Float64(Float64(Float64(1.0 / x) - Float64(0.5 / Float64(x * x))) / n);
	end
	return tmp
end
function tmp_2 = code(x, n)
	t_0 = -log(x) / n;
	t_1 = 1.0 - (x ^ (1.0 / n));
	tmp = 0.0;
	if (x <= 5.5e-223)
		tmp = t_0;
	elseif (x <= 6.8e-205)
		tmp = t_1;
	elseif (x <= 4.8e-178)
		tmp = t_0;
	elseif (x <= 4.8e-165)
		tmp = t_1;
	elseif (x <= 0.95)
		tmp = (x - log(x)) / n;
	else
		tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
	end
	tmp_2 = tmp;
end
code[x_, n_] := Block[{t$95$0 = N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 5.5e-223], t$95$0, If[LessEqual[x, 6.8e-205], t$95$1, If[LessEqual[x, 4.8e-178], t$95$0, If[LessEqual[x, 4.8e-165], t$95$1, If[LessEqual[x, 0.95], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(1.0 / x), $MachinePrecision] - N[(0.5 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{-\log x}{n}\\
t_1 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 5.5 \cdot 10^{-223}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 6.8 \cdot 10^{-205}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 4.8 \cdot 10^{-178}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 4.8 \cdot 10^{-165}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 0.95:\\
\;\;\;\;\frac{x - \log x}{n}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < 5.5e-223 or 6.8000000000000004e-205 < x < 4.8000000000000001e-178

    1. Initial program 31.5%

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

      \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
    3. Step-by-step derivation
      1. log1p-def63.5%

        \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(x\right)} - \log x}{n} \]
    4. Simplified63.5%

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Taylor expanded in x around 0 63.5%

      \[\leadsto \frac{\color{blue}{-1 \cdot \log x}}{n} \]
    6. Step-by-step derivation
      1. neg-mul-163.5%

        \[\leadsto \frac{\color{blue}{-\log x}}{n} \]
    7. Simplified63.5%

      \[\leadsto \frac{\color{blue}{-\log x}}{n} \]

    if 5.5e-223 < x < 6.8000000000000004e-205 or 4.8000000000000001e-178 < x < 4.8000000000000004e-165

    1. Initial program 84.2%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Taylor expanded in x around 0 84.2%

      \[\leadsto \color{blue}{1 - e^{\frac{\log x}{n}}} \]
    3. Step-by-step derivation
      1. *-rgt-identity84.2%

        \[\leadsto 1 - e^{\frac{\color{blue}{\log x \cdot 1}}{n}} \]
      2. associate-*r/84.2%

        \[\leadsto 1 - e^{\color{blue}{\log x \cdot \frac{1}{n}}} \]
      3. unpow-184.2%

        \[\leadsto 1 - e^{\log x \cdot \color{blue}{{n}^{-1}}} \]
      4. exp-to-pow84.2%

        \[\leadsto 1 - \color{blue}{{x}^{\left({n}^{-1}\right)}} \]
      5. unpow-184.2%

        \[\leadsto 1 - {x}^{\color{blue}{\left(\frac{1}{n}\right)}} \]
    4. Simplified84.2%

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

    if 4.8000000000000004e-165 < x < 0.94999999999999996

    1. Initial program 42.0%

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

      \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
    3. Step-by-step derivation
      1. log1p-def58.2%

        \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(x\right)} - \log x}{n} \]
    4. Simplified58.2%

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Taylor expanded in x around 0 58.2%

      \[\leadsto \frac{\color{blue}{x + -1 \cdot \log x}}{n} \]
    6. Step-by-step derivation
      1. neg-mul-158.2%

        \[\leadsto \frac{x + \color{blue}{\left(-\log x\right)}}{n} \]
      2. sub-neg58.2%

        \[\leadsto \frac{\color{blue}{x - \log x}}{n} \]
    7. Simplified58.2%

      \[\leadsto \frac{\color{blue}{x - \log x}}{n} \]

    if 0.94999999999999996 < x

    1. Initial program 71.6%

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

      \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
    3. Step-by-step derivation
      1. log1p-def71.4%

        \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(x\right)} - \log x}{n} \]
    4. Simplified71.4%

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Taylor expanded in x around inf 59.2%

      \[\leadsto \frac{\color{blue}{\frac{1}{x} - 0.5 \cdot \frac{1}{{x}^{2}}}}{n} \]
    6. Step-by-step derivation
      1. associate-*r/59.2%

        \[\leadsto \frac{\frac{1}{x} - \color{blue}{\frac{0.5 \cdot 1}{{x}^{2}}}}{n} \]
      2. metadata-eval59.2%

        \[\leadsto \frac{\frac{1}{x} - \frac{\color{blue}{0.5}}{{x}^{2}}}{n} \]
      3. unpow259.2%

        \[\leadsto \frac{\frac{1}{x} - \frac{0.5}{\color{blue}{x \cdot x}}}{n} \]
    7. Simplified59.2%

      \[\leadsto \frac{\color{blue}{\frac{1}{x} - \frac{0.5}{x \cdot x}}}{n} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification61.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 5.5 \cdot 10^{-223}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 6.8 \cdot 10^{-205}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 4.8 \cdot 10^{-178}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 4.8 \cdot 10^{-165}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 0.95:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\ \end{array} \]

Alternative 10: 57.5% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 0.98:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= x 0.98) (/ (- x (log x)) n) (/ (- (/ 1.0 x) (/ 0.5 (* x x))) n)))
double code(double x, double n) {
	double tmp;
	if (x <= 0.98) {
		tmp = (x - log(x)) / n;
	} else {
		tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
	}
	return tmp;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    real(8) :: tmp
    if (x <= 0.98d0) then
        tmp = (x - log(x)) / n
    else
        tmp = ((1.0d0 / x) - (0.5d0 / (x * x))) / n
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double tmp;
	if (x <= 0.98) {
		tmp = (x - Math.log(x)) / n;
	} else {
		tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if x <= 0.98:
		tmp = (x - math.log(x)) / n
	else:
		tmp = ((1.0 / x) - (0.5 / (x * x))) / n
	return tmp
function code(x, n)
	tmp = 0.0
	if (x <= 0.98)
		tmp = Float64(Float64(x - log(x)) / n);
	else
		tmp = Float64(Float64(Float64(1.0 / x) - Float64(0.5 / Float64(x * x))) / n);
	end
	return tmp
end
function tmp_2 = code(x, n)
	tmp = 0.0;
	if (x <= 0.98)
		tmp = (x - log(x)) / n;
	else
		tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
	end
	tmp_2 = tmp;
end
code[x_, n_] := If[LessEqual[x, 0.98], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(1.0 / x), $MachinePrecision] - N[(0.5 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.98:\\
\;\;\;\;\frac{x - \log x}{n}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 0.97999999999999998

    1. Initial program 43.4%

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

      \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
    3. Step-by-step derivation
      1. log1p-def54.5%

        \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(x\right)} - \log x}{n} \]
    4. Simplified54.5%

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Taylor expanded in x around 0 54.5%

      \[\leadsto \frac{\color{blue}{x + -1 \cdot \log x}}{n} \]
    6. Step-by-step derivation
      1. neg-mul-154.5%

        \[\leadsto \frac{x + \color{blue}{\left(-\log x\right)}}{n} \]
      2. sub-neg54.5%

        \[\leadsto \frac{\color{blue}{x - \log x}}{n} \]
    7. Simplified54.5%

      \[\leadsto \frac{\color{blue}{x - \log x}}{n} \]

    if 0.97999999999999998 < x

    1. Initial program 71.6%

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

      \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
    3. Step-by-step derivation
      1. log1p-def71.4%

        \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(x\right)} - \log x}{n} \]
    4. Simplified71.4%

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Taylor expanded in x around inf 59.2%

      \[\leadsto \frac{\color{blue}{\frac{1}{x} - 0.5 \cdot \frac{1}{{x}^{2}}}}{n} \]
    6. Step-by-step derivation
      1. associate-*r/59.2%

        \[\leadsto \frac{\frac{1}{x} - \color{blue}{\frac{0.5 \cdot 1}{{x}^{2}}}}{n} \]
      2. metadata-eval59.2%

        \[\leadsto \frac{\frac{1}{x} - \frac{\color{blue}{0.5}}{{x}^{2}}}{n} \]
      3. unpow259.2%

        \[\leadsto \frac{\frac{1}{x} - \frac{0.5}{\color{blue}{x \cdot x}}}{n} \]
    7. Simplified59.2%

      \[\leadsto \frac{\color{blue}{\frac{1}{x} - \frac{0.5}{x \cdot x}}}{n} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification56.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 0.98:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\ \end{array} \]

Alternative 11: 57.3% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 0.7:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= x 0.7) (/ (- (log x)) n) (/ (- (/ 1.0 x) (/ 0.5 (* x x))) n)))
double code(double x, double n) {
	double tmp;
	if (x <= 0.7) {
		tmp = -log(x) / n;
	} else {
		tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
	}
	return tmp;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    real(8) :: tmp
    if (x <= 0.7d0) then
        tmp = -log(x) / n
    else
        tmp = ((1.0d0 / x) - (0.5d0 / (x * x))) / n
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double tmp;
	if (x <= 0.7) {
		tmp = -Math.log(x) / n;
	} else {
		tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if x <= 0.7:
		tmp = -math.log(x) / n
	else:
		tmp = ((1.0 / x) - (0.5 / (x * x))) / n
	return tmp
function code(x, n)
	tmp = 0.0
	if (x <= 0.7)
		tmp = Float64(Float64(-log(x)) / n);
	else
		tmp = Float64(Float64(Float64(1.0 / x) - Float64(0.5 / Float64(x * x))) / n);
	end
	return tmp
end
function tmp_2 = code(x, n)
	tmp = 0.0;
	if (x <= 0.7)
		tmp = -log(x) / n;
	else
		tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
	end
	tmp_2 = tmp;
end
code[x_, n_] := If[LessEqual[x, 0.7], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], N[(N[(N[(1.0 / x), $MachinePrecision] - N[(0.5 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.7:\\
\;\;\;\;\frac{-\log x}{n}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 0.69999999999999996

    1. Initial program 43.4%

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

      \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
    3. Step-by-step derivation
      1. log1p-def54.5%

        \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(x\right)} - \log x}{n} \]
    4. Simplified54.5%

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Taylor expanded in x around 0 54.3%

      \[\leadsto \frac{\color{blue}{-1 \cdot \log x}}{n} \]
    6. Step-by-step derivation
      1. neg-mul-154.3%

        \[\leadsto \frac{\color{blue}{-\log x}}{n} \]
    7. Simplified54.3%

      \[\leadsto \frac{\color{blue}{-\log x}}{n} \]

    if 0.69999999999999996 < x

    1. Initial program 71.6%

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

      \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
    3. Step-by-step derivation
      1. log1p-def71.4%

        \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(x\right)} - \log x}{n} \]
    4. Simplified71.4%

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Taylor expanded in x around inf 59.2%

      \[\leadsto \frac{\color{blue}{\frac{1}{x} - 0.5 \cdot \frac{1}{{x}^{2}}}}{n} \]
    6. Step-by-step derivation
      1. associate-*r/59.2%

        \[\leadsto \frac{\frac{1}{x} - \color{blue}{\frac{0.5 \cdot 1}{{x}^{2}}}}{n} \]
      2. metadata-eval59.2%

        \[\leadsto \frac{\frac{1}{x} - \frac{\color{blue}{0.5}}{{x}^{2}}}{n} \]
      3. unpow259.2%

        \[\leadsto \frac{\frac{1}{x} - \frac{0.5}{\color{blue}{x \cdot x}}}{n} \]
    7. Simplified59.2%

      \[\leadsto \frac{\color{blue}{\frac{1}{x} - \frac{0.5}{x \cdot x}}}{n} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification56.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 0.7:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\ \end{array} \]

Alternative 12: 40.7% accurate, 42.2× speedup?

\[\begin{array}{l} \\ \frac{1}{n \cdot x} \end{array} \]
(FPCore (x n) :precision binary64 (/ 1.0 (* n x)))
double code(double x, double n) {
	return 1.0 / (n * x);
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    code = 1.0d0 / (n * x)
end function
public static double code(double x, double n) {
	return 1.0 / (n * x);
}
def code(x, n):
	return 1.0 / (n * x)
function code(x, n)
	return Float64(1.0 / Float64(n * x))
end
function tmp = code(x, n)
	tmp = 1.0 / (n * x);
end
code[x_, n_] := N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1}{n \cdot x}
\end{array}
Derivation
  1. Initial program 54.5%

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

    \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
  3. Step-by-step derivation
    1. log1p-def61.2%

      \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(x\right)} - \log x}{n} \]
  4. Simplified61.2%

    \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
  5. Taylor expanded in x around inf 35.1%

    \[\leadsto \color{blue}{\frac{1}{n \cdot x}} \]
  6. Step-by-step derivation
    1. *-commutative35.1%

      \[\leadsto \frac{1}{\color{blue}{x \cdot n}} \]
  7. Simplified35.1%

    \[\leadsto \color{blue}{\frac{1}{x \cdot n}} \]
  8. Final simplification35.1%

    \[\leadsto \frac{1}{n \cdot x} \]

Alternative 13: 41.2% accurate, 42.2× speedup?

\[\begin{array}{l} \\ \frac{\frac{1}{n}}{x} \end{array} \]
(FPCore (x n) :precision binary64 (/ (/ 1.0 n) x))
double code(double x, double n) {
	return (1.0 / n) / x;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    code = (1.0d0 / n) / x
end function
public static double code(double x, double n) {
	return (1.0 / n) / x;
}
def code(x, n):
	return (1.0 / n) / x
function code(x, n)
	return Float64(Float64(1.0 / n) / x)
end
function tmp = code(x, n)
	tmp = (1.0 / n) / x;
end
code[x_, n_] := N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]
\begin{array}{l}

\\
\frac{\frac{1}{n}}{x}
\end{array}
Derivation
  1. Initial program 54.5%

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

    \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
  3. Step-by-step derivation
    1. log1p-def61.2%

      \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(x\right)} - \log x}{n} \]
  4. Simplified61.2%

    \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
  5. Step-by-step derivation
    1. add-cbrt-cube61.0%

      \[\leadsto \frac{\color{blue}{\sqrt[3]{\left(\left(\mathsf{log1p}\left(x\right) - \log x\right) \cdot \left(\mathsf{log1p}\left(x\right) - \log x\right)\right) \cdot \left(\mathsf{log1p}\left(x\right) - \log x\right)}}}{n} \]
  6. Applied egg-rr61.0%

    \[\leadsto \frac{\color{blue}{\sqrt[3]{\left(\left(\mathsf{log1p}\left(x\right) - \log x\right) \cdot \left(\mathsf{log1p}\left(x\right) - \log x\right)\right) \cdot \left(\mathsf{log1p}\left(x\right) - \log x\right)}}}{n} \]
  7. Step-by-step derivation
    1. associate-*l*61.0%

      \[\leadsto \frac{\sqrt[3]{\color{blue}{\left(\mathsf{log1p}\left(x\right) - \log x\right) \cdot \left(\left(\mathsf{log1p}\left(x\right) - \log x\right) \cdot \left(\mathsf{log1p}\left(x\right) - \log x\right)\right)}}}{n} \]
    2. cube-unmult61.0%

      \[\leadsto \frac{\sqrt[3]{\color{blue}{{\left(\mathsf{log1p}\left(x\right) - \log x\right)}^{3}}}}{n} \]
  8. Simplified61.0%

    \[\leadsto \frac{\color{blue}{\sqrt[3]{{\left(\mathsf{log1p}\left(x\right) - \log x\right)}^{3}}}}{n} \]
  9. Taylor expanded in x around inf 35.1%

    \[\leadsto \color{blue}{\frac{1}{n \cdot x}} \]
  10. Step-by-step derivation
    1. associate-/r*35.8%

      \[\leadsto \color{blue}{\frac{\frac{1}{n}}{x}} \]
  11. Simplified35.8%

    \[\leadsto \color{blue}{\frac{\frac{1}{n}}{x}} \]
  12. Final simplification35.8%

    \[\leadsto \frac{\frac{1}{n}}{x} \]

Alternative 14: 4.5% accurate, 70.3× speedup?

\[\begin{array}{l} \\ \frac{x}{n} \end{array} \]
(FPCore (x n) :precision binary64 (/ x n))
double code(double x, double n) {
	return x / n;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    code = x / n
end function
public static double code(double x, double n) {
	return x / n;
}
def code(x, n):
	return x / n
function code(x, n)
	return Float64(x / n)
end
function tmp = code(x, n)
	tmp = x / n;
end
code[x_, n_] := N[(x / n), $MachinePrecision]
\begin{array}{l}

\\
\frac{x}{n}
\end{array}
Derivation
  1. Initial program 54.5%

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

    \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
  3. Step-by-step derivation
    1. log1p-def61.2%

      \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(x\right)} - \log x}{n} \]
  4. Simplified61.2%

    \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
  5. Taylor expanded in x around inf 35.1%

    \[\leadsto \color{blue}{\frac{1}{n \cdot x}} \]
  6. Step-by-step derivation
    1. *-commutative35.1%

      \[\leadsto \frac{1}{\color{blue}{x \cdot n}} \]
  7. Simplified35.1%

    \[\leadsto \color{blue}{\frac{1}{x \cdot n}} \]
  8. Step-by-step derivation
    1. expm1-log1p-u28.0%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{x \cdot n}\right)\right)} \]
    2. expm1-udef23.4%

      \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{1}{x \cdot n}\right)} - 1} \]
    3. associate-/r*23.4%

      \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\frac{\frac{1}{x}}{n}}\right)} - 1 \]
    4. add-exp-log23.4%

      \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{e^{\log \left(\frac{1}{x}\right)}}}{n}\right)} - 1 \]
    5. neg-log23.4%

      \[\leadsto e^{\mathsf{log1p}\left(\frac{e^{\color{blue}{-\log x}}}{n}\right)} - 1 \]
    6. add-sqr-sqrt5.7%

      \[\leadsto e^{\mathsf{log1p}\left(\frac{e^{\color{blue}{\sqrt{-\log x} \cdot \sqrt{-\log x}}}}{n}\right)} - 1 \]
    7. sqrt-unprod11.6%

      \[\leadsto e^{\mathsf{log1p}\left(\frac{e^{\color{blue}{\sqrt{\left(-\log x\right) \cdot \left(-\log x\right)}}}}{n}\right)} - 1 \]
    8. sqr-neg11.6%

      \[\leadsto e^{\mathsf{log1p}\left(\frac{e^{\sqrt{\color{blue}{\log x \cdot \log x}}}}{n}\right)} - 1 \]
    9. sqrt-unprod5.9%

      \[\leadsto e^{\mathsf{log1p}\left(\frac{e^{\color{blue}{\sqrt{\log x} \cdot \sqrt{\log x}}}}{n}\right)} - 1 \]
    10. add-sqr-sqrt8.2%

      \[\leadsto e^{\mathsf{log1p}\left(\frac{e^{\color{blue}{\log x}}}{n}\right)} - 1 \]
    11. add-exp-log8.2%

      \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{x}}{n}\right)} - 1 \]
  9. Applied egg-rr8.2%

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{x}{n}\right)} - 1} \]
  10. Step-by-step derivation
    1. expm1-def3.6%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{x}{n}\right)\right)} \]
    2. expm1-log1p4.5%

      \[\leadsto \color{blue}{\frac{x}{n}} \]
  11. Simplified4.5%

    \[\leadsto \color{blue}{\frac{x}{n}} \]
  12. Final simplification4.5%

    \[\leadsto \frac{x}{n} \]

Reproduce

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