2nthrt (problem 3.4.6)

Percentage Accurate: 53.7% → 85.7%
Time: 20.9s
Alternatives: 19
Speedup: 1.9×

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 19 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.7% 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.7% accurate, 0.2× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{0.5}{n \cdot n}\\
t_1 := {x}^{\left(\frac{1}{n}\right)}\\
t_2 := \frac{\log x}{n}\\
t_3 := e^{t_2}\\
\mathbf{if}\;\frac{1}{n} \leq -4 \cdot 10^{-26}:\\
\;\;\;\;\frac{t_1}{n \cdot x}\\

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

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

\mathbf{else}:\\
\;\;\;\;\sqrt[3]{e^{3 \cdot \frac{x}{n}}} - t_1\\


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

    1. Initial program 93.8%

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

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

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

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

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

        \[\leadsto \frac{e^{\color{blue}{\frac{\log x}{n}}}}{n \cdot x} \]
      5. *-commutative98.4%

        \[\leadsto \frac{e^{\frac{\log x}{n}}}{\color{blue}{x \cdot n}} \]
    4. Simplified98.4%

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    5. Taylor expanded in x around 0 98.4%

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{n \cdot x}} \]
    6. Step-by-step derivation
      1. remove-double-neg98.4%

        \[\leadsto \frac{e^{\color{blue}{-\left(-\frac{\log x}{n}\right)}}}{n \cdot x} \]
      2. distribute-frac-neg98.4%

        \[\leadsto \frac{e^{-\color{blue}{\frac{-\log x}{n}}}}{n \cdot x} \]
      3. *-commutative98.4%

        \[\leadsto \frac{e^{-\frac{-\log x}{n}}}{\color{blue}{x \cdot n}} \]
      4. rem-exp-log45.6%

        \[\leadsto \color{blue}{e^{\log \left(\frac{e^{-\frac{-\log x}{n}}}{x \cdot n}\right)}} \]
      5. log-div0.0%

        \[\leadsto e^{\color{blue}{\log \left(e^{-\frac{-\log x}{n}}\right) - \log \left(x \cdot n\right)}} \]
      6. exp-diff0.0%

        \[\leadsto \color{blue}{\frac{e^{\log \left(e^{-\frac{-\log x}{n}}\right)}}{e^{\log \left(x \cdot n\right)}}} \]
      7. distribute-frac-neg0.0%

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

        \[\leadsto \frac{e^{\log \left(e^{\color{blue}{\frac{\log x}{n}}}\right)}}{e^{\log \left(x \cdot n\right)}} \]
      9. rem-log-exp0.0%

        \[\leadsto \frac{e^{\color{blue}{\frac{\log x}{n}}}}{e^{\log \left(x \cdot n\right)}} \]
      10. *-rgt-identity0.0%

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

        \[\leadsto \frac{e^{\color{blue}{\log x \cdot \frac{1}{n}}}}{e^{\log \left(x \cdot n\right)}} \]
      12. *-commutative0.0%

        \[\leadsto \frac{e^{\color{blue}{\frac{1}{n} \cdot \log x}}}{e^{\log \left(x \cdot n\right)}} \]
      13. log-pow0.0%

        \[\leadsto \frac{e^{\color{blue}{\log \left({x}^{\left(\frac{1}{n}\right)}\right)}}}{e^{\log \left(x \cdot n\right)}} \]
      14. exp-diff0.0%

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

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

    if -4.0000000000000002e-26 < (/.f64 1 n) < 1.99999999999999998e-92

    1. Initial program 32.5%

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

      \[\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(0.5 \cdot \frac{{\log x}^{2}}{{n}^{2}} + \frac{\log x}{n}\right)} \]
    3. Step-by-step derivation
      1. fma-def84.0%

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

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

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

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

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

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

      \[\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)}{n}\right) - \mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{n \cdot n}, \frac{\log x}{n}\right)} \]

    if 1.99999999999999998e-92 < (/.f64 1 n) < 2e-8

    1. Initial program 7.0%

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

      \[\leadsto \color{blue}{\frac{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}}}{n \cdot x} + \left(\frac{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}} \cdot \left(0.5 \cdot \frac{1}{{n}^{2}} - 0.5 \cdot \frac{1}{n}\right)}{{x}^{2}} + \frac{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}} \cdot \left(\left(0.16666666666666666 \cdot \frac{1}{{n}^{3}} + 0.3333333333333333 \cdot \frac{1}{n}\right) - 0.5 \cdot \frac{1}{{n}^{2}}\right)}{{x}^{3}}\right)} \]
    3. Simplified68.7%

      \[\leadsto \color{blue}{\frac{e^{-\frac{-\log x}{n}}}{x \cdot n} + \left(\frac{e^{-\frac{-\log x}{n}}}{\frac{x \cdot x}{\frac{0.5}{n \cdot n} - \frac{0.5}{n}}} + \frac{e^{-\frac{-\log x}{n}}}{\frac{{x}^{3}}{\frac{0.16666666666666666}{{n}^{3}} + \left(\frac{0.3333333333333333}{n} - \frac{0.5}{n \cdot n}\right)}}\right)} \]

    if 2e-8 < (/.f64 1 n)

    1. Initial program 43.5%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Step-by-step derivation
      1. add-cbrt-cube43.5%

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

        \[\leadsto \sqrt[3]{\color{blue}{{\left({\left(x + 1\right)}^{\left(\frac{1}{n}\right)}\right)}^{3}}} - {x}^{\left(\frac{1}{n}\right)} \]
      3. pow-to-exp43.5%

        \[\leadsto \sqrt[3]{{\color{blue}{\left(e^{\log \left(x + 1\right) \cdot \frac{1}{n}}\right)}}^{3}} - {x}^{\left(\frac{1}{n}\right)} \]
      4. pow-exp43.5%

        \[\leadsto \sqrt[3]{\color{blue}{e^{\left(\log \left(x + 1\right) \cdot \frac{1}{n}\right) \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
      5. un-div-inv43.5%

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

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

        \[\leadsto \sqrt[3]{e^{\frac{\color{blue}{\mathsf{log1p}\left(x\right)}}{n} \cdot 3}} - {x}^{\left(\frac{1}{n}\right)} \]
    3. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\sqrt[3]{e^{\frac{\mathsf{log1p}\left(x\right)}{n} \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
    4. Taylor expanded in x around 0 100.0%

      \[\leadsto \sqrt[3]{e^{\color{blue}{3 \cdot \frac{x}{n}}}} - {x}^{\left(\frac{1}{n}\right)} \]
    5. Step-by-step derivation
      1. *-commutative100.0%

        \[\leadsto \sqrt[3]{e^{\color{blue}{\frac{x}{n} \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
    6. Simplified100.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -4 \cdot 10^{-26}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-92}:\\ \;\;\;\;\mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, \frac{\mathsf{log1p}\left(x\right)}{n}\right) - \mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{n \cdot n}, \frac{\log x}{n}\right)\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-8}:\\ \;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x} + \left(\frac{e^{\frac{\log x}{n}}}{\frac{x \cdot x}{\frac{0.5}{n \cdot n} - \frac{0.5}{n}}} + \frac{e^{\frac{\log x}{n}}}{\frac{{x}^{3}}{\frac{0.16666666666666666}{{n}^{3}} + \left(\frac{0.3333333333333333}{n} - \frac{0.5}{n \cdot n}\right)}}\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{e^{3 \cdot \frac{x}{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 -4 \cdot 10^{-26}:\\ \;\;\;\;\frac{t_0}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-92}:\\ \;\;\;\;\mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, \frac{\mathsf{log1p}\left(x\right)}{n}\right) - \mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{n \cdot n}, \frac{\log x}{n}\right)\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-8}:\\ \;\;\;\;\frac{\log x}{x \cdot \left(n \cdot n\right)} + \left(\frac{\frac{1}{x} + \frac{0.3333333333333333}{{x}^{3}}}{n} + \frac{-0.5}{n \cdot \left(x \cdot x\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{e^{3 \cdot \frac{x}{n}}} - t_0\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (pow x (/ 1.0 n))))
   (if (<= (/ 1.0 n) -4e-26)
     (/ t_0 (* n x))
     (if (<= (/ 1.0 n) 2e-92)
       (-
        (fma 0.5 (/ (pow (log1p x) 2.0) (* n n)) (/ (log1p x) n))
        (fma 0.5 (/ (pow (log x) 2.0) (* n n)) (/ (log x) n)))
       (if (<= (/ 1.0 n) 2e-8)
         (+
          (/ (log x) (* x (* n n)))
          (+
           (/ (+ (/ 1.0 x) (/ 0.3333333333333333 (pow x 3.0))) n)
           (/ -0.5 (* n (* x x)))))
         (- (cbrt (exp (* 3.0 (/ x n)))) t_0))))))
double code(double x, double n) {
	double t_0 = pow(x, (1.0 / n));
	double tmp;
	if ((1.0 / n) <= -4e-26) {
		tmp = t_0 / (n * x);
	} else if ((1.0 / n) <= 2e-92) {
		tmp = fma(0.5, (pow(log1p(x), 2.0) / (n * n)), (log1p(x) / n)) - fma(0.5, (pow(log(x), 2.0) / (n * n)), (log(x) / n));
	} else if ((1.0 / n) <= 2e-8) {
		tmp = (log(x) / (x * (n * n))) + ((((1.0 / x) + (0.3333333333333333 / pow(x, 3.0))) / n) + (-0.5 / (n * (x * x))));
	} else {
		tmp = cbrt(exp((3.0 * (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) <= -4e-26)
		tmp = Float64(t_0 / Float64(n * x));
	elseif (Float64(1.0 / n) <= 2e-92)
		tmp = Float64(fma(0.5, Float64((log1p(x) ^ 2.0) / Float64(n * n)), Float64(log1p(x) / n)) - fma(0.5, Float64((log(x) ^ 2.0) / Float64(n * n)), Float64(log(x) / n)));
	elseif (Float64(1.0 / n) <= 2e-8)
		tmp = Float64(Float64(log(x) / Float64(x * Float64(n * n))) + Float64(Float64(Float64(Float64(1.0 / x) + Float64(0.3333333333333333 / (x ^ 3.0))) / n) + Float64(-0.5 / Float64(n * Float64(x * x)))));
	else
		tmp = Float64(cbrt(exp(Float64(3.0 * Float64(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], -4e-26], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-92], N[(N[(0.5 * N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision] + N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] - N[(0.5 * N[(N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision] + N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-8], N[(N[(N[Log[x], $MachinePrecision] / N[(x * N[(n * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(N[(1.0 / x), $MachinePrecision] + N[(0.3333333333333333 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] + N[(-0.5 / N[(n * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[N[Exp[N[(3.0 * N[(x / n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 1/3], $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 -4 \cdot 10^{-26}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\

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

\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-8}:\\
\;\;\;\;\frac{\log x}{x \cdot \left(n \cdot n\right)} + \left(\frac{\frac{1}{x} + \frac{0.3333333333333333}{{x}^{3}}}{n} + \frac{-0.5}{n \cdot \left(x \cdot x\right)}\right)\\

\mathbf{else}:\\
\;\;\;\;\sqrt[3]{e^{3 \cdot \frac{x}{n}}} - t_0\\


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

    1. Initial program 93.8%

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

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

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

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

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

        \[\leadsto \frac{e^{\color{blue}{\frac{\log x}{n}}}}{n \cdot x} \]
      5. *-commutative98.4%

        \[\leadsto \frac{e^{\frac{\log x}{n}}}{\color{blue}{x \cdot n}} \]
    4. Simplified98.4%

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    5. Taylor expanded in x around 0 98.4%

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{n \cdot x}} \]
    6. Step-by-step derivation
      1. remove-double-neg98.4%

        \[\leadsto \frac{e^{\color{blue}{-\left(-\frac{\log x}{n}\right)}}}{n \cdot x} \]
      2. distribute-frac-neg98.4%

        \[\leadsto \frac{e^{-\color{blue}{\frac{-\log x}{n}}}}{n \cdot x} \]
      3. *-commutative98.4%

        \[\leadsto \frac{e^{-\frac{-\log x}{n}}}{\color{blue}{x \cdot n}} \]
      4. rem-exp-log45.6%

        \[\leadsto \color{blue}{e^{\log \left(\frac{e^{-\frac{-\log x}{n}}}{x \cdot n}\right)}} \]
      5. log-div0.0%

        \[\leadsto e^{\color{blue}{\log \left(e^{-\frac{-\log x}{n}}\right) - \log \left(x \cdot n\right)}} \]
      6. exp-diff0.0%

        \[\leadsto \color{blue}{\frac{e^{\log \left(e^{-\frac{-\log x}{n}}\right)}}{e^{\log \left(x \cdot n\right)}}} \]
      7. distribute-frac-neg0.0%

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

        \[\leadsto \frac{e^{\log \left(e^{\color{blue}{\frac{\log x}{n}}}\right)}}{e^{\log \left(x \cdot n\right)}} \]
      9. rem-log-exp0.0%

        \[\leadsto \frac{e^{\color{blue}{\frac{\log x}{n}}}}{e^{\log \left(x \cdot n\right)}} \]
      10. *-rgt-identity0.0%

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

        \[\leadsto \frac{e^{\color{blue}{\log x \cdot \frac{1}{n}}}}{e^{\log \left(x \cdot n\right)}} \]
      12. *-commutative0.0%

        \[\leadsto \frac{e^{\color{blue}{\frac{1}{n} \cdot \log x}}}{e^{\log \left(x \cdot n\right)}} \]
      13. log-pow0.0%

        \[\leadsto \frac{e^{\color{blue}{\log \left({x}^{\left(\frac{1}{n}\right)}\right)}}}{e^{\log \left(x \cdot n\right)}} \]
      14. exp-diff0.0%

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

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

    if -4.0000000000000002e-26 < (/.f64 1 n) < 1.99999999999999998e-92

    1. Initial program 32.5%

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

      \[\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(0.5 \cdot \frac{{\log x}^{2}}{{n}^{2}} + \frac{\log x}{n}\right)} \]
    3. Step-by-step derivation
      1. fma-def84.0%

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

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

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

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

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

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

      \[\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)}{n}\right) - \mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{n \cdot n}, \frac{\log x}{n}\right)} \]

    if 1.99999999999999998e-92 < (/.f64 1 n) < 2e-8

    1. Initial program 7.0%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Taylor expanded in n around inf 41.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(0.5 \cdot \frac{{\log x}^{2}}{{n}^{2}} + \frac{\log x}{n}\right)} \]
    3. Step-by-step derivation
      1. fma-def41.9%

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, \frac{\mathsf{log1p}\left(x\right)}{n}\right) - \mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{\color{blue}{n \cdot n}}, \frac{\log x}{n}\right) \]
    4. Simplified41.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)}{n}\right) - \mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{n \cdot n}, \frac{\log x}{n}\right)} \]
    5. Taylor expanded in x around inf 67.2%

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

      \[\leadsto \color{blue}{\frac{\log x}{x \cdot \left(n \cdot n\right)} + \left(\left(\mathsf{fma}\left(0.5, \frac{\frac{0.6666666666666666 \cdot \log x}{n \cdot n} + \frac{-1}{n \cdot n}}{{x}^{3}}, \frac{1}{x \cdot n}\right) + \left(\frac{0.3333333333333333}{n \cdot {x}^{3}} + \frac{\frac{-0.5 \cdot \log x}{n \cdot n} + \frac{0.5}{n \cdot n}}{x \cdot x}\right)\right) + \frac{-0.5}{n \cdot \left(x \cdot x\right)}\right)} \]
    7. Taylor expanded in n around inf 67.3%

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

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

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

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

    if 2e-8 < (/.f64 1 n)

    1. Initial program 43.5%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Step-by-step derivation
      1. add-cbrt-cube43.5%

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

        \[\leadsto \sqrt[3]{\color{blue}{{\left({\left(x + 1\right)}^{\left(\frac{1}{n}\right)}\right)}^{3}}} - {x}^{\left(\frac{1}{n}\right)} \]
      3. pow-to-exp43.5%

        \[\leadsto \sqrt[3]{{\color{blue}{\left(e^{\log \left(x + 1\right) \cdot \frac{1}{n}}\right)}}^{3}} - {x}^{\left(\frac{1}{n}\right)} \]
      4. pow-exp43.5%

        \[\leadsto \sqrt[3]{\color{blue}{e^{\left(\log \left(x + 1\right) \cdot \frac{1}{n}\right) \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
      5. un-div-inv43.5%

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

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

        \[\leadsto \sqrt[3]{e^{\frac{\color{blue}{\mathsf{log1p}\left(x\right)}}{n} \cdot 3}} - {x}^{\left(\frac{1}{n}\right)} \]
    3. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\sqrt[3]{e^{\frac{\mathsf{log1p}\left(x\right)}{n} \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
    4. Taylor expanded in x around 0 100.0%

      \[\leadsto \sqrt[3]{e^{\color{blue}{3 \cdot \frac{x}{n}}}} - {x}^{\left(\frac{1}{n}\right)} \]
    5. Step-by-step derivation
      1. *-commutative100.0%

        \[\leadsto \sqrt[3]{e^{\color{blue}{\frac{x}{n} \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
    6. Simplified100.0%

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

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

Alternative 3: 85.8% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{if}\;\frac{1}{n} \leq -4 \cdot 10^{-26}:\\ \;\;\;\;\frac{t_0}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-92}:\\ \;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-8}:\\ \;\;\;\;\frac{\log x}{x \cdot \left(n \cdot n\right)} + \left(\frac{\frac{1}{x} + \frac{0.3333333333333333}{{x}^{3}}}{n} + \frac{-0.5}{n \cdot \left(x \cdot x\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{e^{3 \cdot \frac{x}{n}}} - t_0\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (pow x (/ 1.0 n))))
   (if (<= (/ 1.0 n) -4e-26)
     (/ t_0 (* n x))
     (if (<= (/ 1.0 n) 2e-92)
       (/ (- (log1p x) (log x)) n)
       (if (<= (/ 1.0 n) 2e-8)
         (+
          (/ (log x) (* x (* n n)))
          (+
           (/ (+ (/ 1.0 x) (/ 0.3333333333333333 (pow x 3.0))) n)
           (/ -0.5 (* n (* x x)))))
         (- (cbrt (exp (* 3.0 (/ x n)))) t_0))))))
double code(double x, double n) {
	double t_0 = pow(x, (1.0 / n));
	double tmp;
	if ((1.0 / n) <= -4e-26) {
		tmp = t_0 / (n * x);
	} else if ((1.0 / n) <= 2e-92) {
		tmp = (log1p(x) - log(x)) / n;
	} else if ((1.0 / n) <= 2e-8) {
		tmp = (log(x) / (x * (n * n))) + ((((1.0 / x) + (0.3333333333333333 / pow(x, 3.0))) / n) + (-0.5 / (n * (x * x))));
	} else {
		tmp = cbrt(exp((3.0 * (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) <= -4e-26) {
		tmp = t_0 / (n * x);
	} else if ((1.0 / n) <= 2e-92) {
		tmp = (Math.log1p(x) - Math.log(x)) / n;
	} else if ((1.0 / n) <= 2e-8) {
		tmp = (Math.log(x) / (x * (n * n))) + ((((1.0 / x) + (0.3333333333333333 / Math.pow(x, 3.0))) / n) + (-0.5 / (n * (x * x))));
	} else {
		tmp = Math.cbrt(Math.exp((3.0 * (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) <= -4e-26)
		tmp = Float64(t_0 / Float64(n * x));
	elseif (Float64(1.0 / n) <= 2e-92)
		tmp = Float64(Float64(log1p(x) - log(x)) / n);
	elseif (Float64(1.0 / n) <= 2e-8)
		tmp = Float64(Float64(log(x) / Float64(x * Float64(n * n))) + Float64(Float64(Float64(Float64(1.0 / x) + Float64(0.3333333333333333 / (x ^ 3.0))) / n) + Float64(-0.5 / Float64(n * Float64(x * x)))));
	else
		tmp = Float64(cbrt(exp(Float64(3.0 * Float64(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], -4e-26], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-92], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-8], N[(N[(N[Log[x], $MachinePrecision] / N[(x * N[(n * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(N[(1.0 / x), $MachinePrecision] + N[(0.3333333333333333 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] + N[(-0.5 / N[(n * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[N[Exp[N[(3.0 * N[(x / n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 1/3], $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 -4 \cdot 10^{-26}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\

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

\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-8}:\\
\;\;\;\;\frac{\log x}{x \cdot \left(n \cdot n\right)} + \left(\frac{\frac{1}{x} + \frac{0.3333333333333333}{{x}^{3}}}{n} + \frac{-0.5}{n \cdot \left(x \cdot x\right)}\right)\\

\mathbf{else}:\\
\;\;\;\;\sqrt[3]{e^{3 \cdot \frac{x}{n}}} - t_0\\


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

    1. Initial program 93.8%

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

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

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

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

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

        \[\leadsto \frac{e^{\color{blue}{\frac{\log x}{n}}}}{n \cdot x} \]
      5. *-commutative98.4%

        \[\leadsto \frac{e^{\frac{\log x}{n}}}{\color{blue}{x \cdot n}} \]
    4. Simplified98.4%

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    5. Taylor expanded in x around 0 98.4%

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{n \cdot x}} \]
    6. Step-by-step derivation
      1. remove-double-neg98.4%

        \[\leadsto \frac{e^{\color{blue}{-\left(-\frac{\log x}{n}\right)}}}{n \cdot x} \]
      2. distribute-frac-neg98.4%

        \[\leadsto \frac{e^{-\color{blue}{\frac{-\log x}{n}}}}{n \cdot x} \]
      3. *-commutative98.4%

        \[\leadsto \frac{e^{-\frac{-\log x}{n}}}{\color{blue}{x \cdot n}} \]
      4. rem-exp-log45.6%

        \[\leadsto \color{blue}{e^{\log \left(\frac{e^{-\frac{-\log x}{n}}}{x \cdot n}\right)}} \]
      5. log-div0.0%

        \[\leadsto e^{\color{blue}{\log \left(e^{-\frac{-\log x}{n}}\right) - \log \left(x \cdot n\right)}} \]
      6. exp-diff0.0%

        \[\leadsto \color{blue}{\frac{e^{\log \left(e^{-\frac{-\log x}{n}}\right)}}{e^{\log \left(x \cdot n\right)}}} \]
      7. distribute-frac-neg0.0%

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

        \[\leadsto \frac{e^{\log \left(e^{\color{blue}{\frac{\log x}{n}}}\right)}}{e^{\log \left(x \cdot n\right)}} \]
      9. rem-log-exp0.0%

        \[\leadsto \frac{e^{\color{blue}{\frac{\log x}{n}}}}{e^{\log \left(x \cdot n\right)}} \]
      10. *-rgt-identity0.0%

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

        \[\leadsto \frac{e^{\color{blue}{\log x \cdot \frac{1}{n}}}}{e^{\log \left(x \cdot n\right)}} \]
      12. *-commutative0.0%

        \[\leadsto \frac{e^{\color{blue}{\frac{1}{n} \cdot \log x}}}{e^{\log \left(x \cdot n\right)}} \]
      13. log-pow0.0%

        \[\leadsto \frac{e^{\color{blue}{\log \left({x}^{\left(\frac{1}{n}\right)}\right)}}}{e^{\log \left(x \cdot n\right)}} \]
      14. exp-diff0.0%

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

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

    if -4.0000000000000002e-26 < (/.f64 1 n) < 1.99999999999999998e-92

    1. Initial program 32.5%

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

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

        \[\leadsto \frac{\color{blue}{\left(\log \left(1 + x\right) + 0\right)} - \log x}{n} \]
      2. +-rgt-identity83.9%

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

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

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

    if 1.99999999999999998e-92 < (/.f64 1 n) < 2e-8

    1. Initial program 7.0%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Taylor expanded in n around inf 41.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(0.5 \cdot \frac{{\log x}^{2}}{{n}^{2}} + \frac{\log x}{n}\right)} \]
    3. Step-by-step derivation
      1. fma-def41.9%

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, \frac{\mathsf{log1p}\left(x\right)}{n}\right) - \mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{\color{blue}{n \cdot n}}, \frac{\log x}{n}\right) \]
    4. Simplified41.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)}{n}\right) - \mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{n \cdot n}, \frac{\log x}{n}\right)} \]
    5. Taylor expanded in x around inf 67.2%

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

      \[\leadsto \color{blue}{\frac{\log x}{x \cdot \left(n \cdot n\right)} + \left(\left(\mathsf{fma}\left(0.5, \frac{\frac{0.6666666666666666 \cdot \log x}{n \cdot n} + \frac{-1}{n \cdot n}}{{x}^{3}}, \frac{1}{x \cdot n}\right) + \left(\frac{0.3333333333333333}{n \cdot {x}^{3}} + \frac{\frac{-0.5 \cdot \log x}{n \cdot n} + \frac{0.5}{n \cdot n}}{x \cdot x}\right)\right) + \frac{-0.5}{n \cdot \left(x \cdot x\right)}\right)} \]
    7. Taylor expanded in n around inf 67.3%

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

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

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

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

    if 2e-8 < (/.f64 1 n)

    1. Initial program 43.5%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Step-by-step derivation
      1. add-cbrt-cube43.5%

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

        \[\leadsto \sqrt[3]{\color{blue}{{\left({\left(x + 1\right)}^{\left(\frac{1}{n}\right)}\right)}^{3}}} - {x}^{\left(\frac{1}{n}\right)} \]
      3. pow-to-exp43.5%

        \[\leadsto \sqrt[3]{{\color{blue}{\left(e^{\log \left(x + 1\right) \cdot \frac{1}{n}}\right)}}^{3}} - {x}^{\left(\frac{1}{n}\right)} \]
      4. pow-exp43.5%

        \[\leadsto \sqrt[3]{\color{blue}{e^{\left(\log \left(x + 1\right) \cdot \frac{1}{n}\right) \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
      5. un-div-inv43.5%

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

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

        \[\leadsto \sqrt[3]{e^{\frac{\color{blue}{\mathsf{log1p}\left(x\right)}}{n} \cdot 3}} - {x}^{\left(\frac{1}{n}\right)} \]
    3. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\sqrt[3]{e^{\frac{\mathsf{log1p}\left(x\right)}{n} \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
    4. Taylor expanded in x around 0 100.0%

      \[\leadsto \sqrt[3]{e^{\color{blue}{3 \cdot \frac{x}{n}}}} - {x}^{\left(\frac{1}{n}\right)} \]
    5. Step-by-step derivation
      1. *-commutative100.0%

        \[\leadsto \sqrt[3]{e^{\color{blue}{\frac{x}{n} \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
    6. Simplified100.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -4 \cdot 10^{-26}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-92}:\\ \;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-8}:\\ \;\;\;\;\frac{\log x}{x \cdot \left(n \cdot n\right)} + \left(\frac{\frac{1}{x} + \frac{0.3333333333333333}{{x}^{3}}}{n} + \frac{-0.5}{n \cdot \left(x \cdot x\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{e^{3 \cdot \frac{x}{n}}} - {x}^{\left(\frac{1}{n}\right)}\\ \end{array} \]

Alternative 4: 85.8% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{if}\;\frac{1}{n} \leq -4 \cdot 10^{-26}:\\ \;\;\;\;\frac{t_0}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-92}:\\ \;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-8}:\\ \;\;\;\;\frac{\log x}{x \cdot \left(n \cdot n\right)} + \left(\frac{\frac{1}{x} + \frac{0.3333333333333333}{{x}^{3}}}{n} + \frac{-0.5}{n \cdot \left(x \cdot x\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;e^{\frac{x}{n}} - t_0\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (pow x (/ 1.0 n))))
   (if (<= (/ 1.0 n) -4e-26)
     (/ t_0 (* n x))
     (if (<= (/ 1.0 n) 2e-92)
       (/ (- (log1p x) (log x)) n)
       (if (<= (/ 1.0 n) 2e-8)
         (+
          (/ (log x) (* x (* n n)))
          (+
           (/ (+ (/ 1.0 x) (/ 0.3333333333333333 (pow x 3.0))) n)
           (/ -0.5 (* n (* x x)))))
         (- (exp (/ x n)) t_0))))))
double code(double x, double n) {
	double t_0 = pow(x, (1.0 / n));
	double tmp;
	if ((1.0 / n) <= -4e-26) {
		tmp = t_0 / (n * x);
	} else if ((1.0 / n) <= 2e-92) {
		tmp = (log1p(x) - log(x)) / n;
	} else if ((1.0 / n) <= 2e-8) {
		tmp = (log(x) / (x * (n * n))) + ((((1.0 / x) + (0.3333333333333333 / pow(x, 3.0))) / n) + (-0.5 / (n * (x * x))));
	} else {
		tmp = exp((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) <= -4e-26) {
		tmp = t_0 / (n * x);
	} else if ((1.0 / n) <= 2e-92) {
		tmp = (Math.log1p(x) - Math.log(x)) / n;
	} else if ((1.0 / n) <= 2e-8) {
		tmp = (Math.log(x) / (x * (n * n))) + ((((1.0 / x) + (0.3333333333333333 / Math.pow(x, 3.0))) / n) + (-0.5 / (n * (x * x))));
	} else {
		tmp = Math.exp((x / n)) - t_0;
	}
	return tmp;
}
def code(x, n):
	t_0 = math.pow(x, (1.0 / n))
	tmp = 0
	if (1.0 / n) <= -4e-26:
		tmp = t_0 / (n * x)
	elif (1.0 / n) <= 2e-92:
		tmp = (math.log1p(x) - math.log(x)) / n
	elif (1.0 / n) <= 2e-8:
		tmp = (math.log(x) / (x * (n * n))) + ((((1.0 / x) + (0.3333333333333333 / math.pow(x, 3.0))) / n) + (-0.5 / (n * (x * x))))
	else:
		tmp = math.exp((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) <= -4e-26)
		tmp = Float64(t_0 / Float64(n * x));
	elseif (Float64(1.0 / n) <= 2e-92)
		tmp = Float64(Float64(log1p(x) - log(x)) / n);
	elseif (Float64(1.0 / n) <= 2e-8)
		tmp = Float64(Float64(log(x) / Float64(x * Float64(n * n))) + Float64(Float64(Float64(Float64(1.0 / x) + Float64(0.3333333333333333 / (x ^ 3.0))) / n) + Float64(-0.5 / Float64(n * Float64(x * x)))));
	else
		tmp = Float64(exp(Float64(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], -4e-26], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-92], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-8], N[(N[(N[Log[x], $MachinePrecision] / N[(x * N[(n * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(N[(1.0 / x), $MachinePrecision] + N[(0.3333333333333333 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] + N[(-0.5 / N[(n * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Exp[N[(x / 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 -4 \cdot 10^{-26}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\

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

\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-8}:\\
\;\;\;\;\frac{\log x}{x \cdot \left(n \cdot n\right)} + \left(\frac{\frac{1}{x} + \frac{0.3333333333333333}{{x}^{3}}}{n} + \frac{-0.5}{n \cdot \left(x \cdot x\right)}\right)\\

\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t_0\\


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

    1. Initial program 93.8%

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

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

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

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

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

        \[\leadsto \frac{e^{\color{blue}{\frac{\log x}{n}}}}{n \cdot x} \]
      5. *-commutative98.4%

        \[\leadsto \frac{e^{\frac{\log x}{n}}}{\color{blue}{x \cdot n}} \]
    4. Simplified98.4%

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    5. Taylor expanded in x around 0 98.4%

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{n \cdot x}} \]
    6. Step-by-step derivation
      1. remove-double-neg98.4%

        \[\leadsto \frac{e^{\color{blue}{-\left(-\frac{\log x}{n}\right)}}}{n \cdot x} \]
      2. distribute-frac-neg98.4%

        \[\leadsto \frac{e^{-\color{blue}{\frac{-\log x}{n}}}}{n \cdot x} \]
      3. *-commutative98.4%

        \[\leadsto \frac{e^{-\frac{-\log x}{n}}}{\color{blue}{x \cdot n}} \]
      4. rem-exp-log45.6%

        \[\leadsto \color{blue}{e^{\log \left(\frac{e^{-\frac{-\log x}{n}}}{x \cdot n}\right)}} \]
      5. log-div0.0%

        \[\leadsto e^{\color{blue}{\log \left(e^{-\frac{-\log x}{n}}\right) - \log \left(x \cdot n\right)}} \]
      6. exp-diff0.0%

        \[\leadsto \color{blue}{\frac{e^{\log \left(e^{-\frac{-\log x}{n}}\right)}}{e^{\log \left(x \cdot n\right)}}} \]
      7. distribute-frac-neg0.0%

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

        \[\leadsto \frac{e^{\log \left(e^{\color{blue}{\frac{\log x}{n}}}\right)}}{e^{\log \left(x \cdot n\right)}} \]
      9. rem-log-exp0.0%

        \[\leadsto \frac{e^{\color{blue}{\frac{\log x}{n}}}}{e^{\log \left(x \cdot n\right)}} \]
      10. *-rgt-identity0.0%

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

        \[\leadsto \frac{e^{\color{blue}{\log x \cdot \frac{1}{n}}}}{e^{\log \left(x \cdot n\right)}} \]
      12. *-commutative0.0%

        \[\leadsto \frac{e^{\color{blue}{\frac{1}{n} \cdot \log x}}}{e^{\log \left(x \cdot n\right)}} \]
      13. log-pow0.0%

        \[\leadsto \frac{e^{\color{blue}{\log \left({x}^{\left(\frac{1}{n}\right)}\right)}}}{e^{\log \left(x \cdot n\right)}} \]
      14. exp-diff0.0%

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

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

    if -4.0000000000000002e-26 < (/.f64 1 n) < 1.99999999999999998e-92

    1. Initial program 32.5%

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

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

        \[\leadsto \frac{\color{blue}{\left(\log \left(1 + x\right) + 0\right)} - \log x}{n} \]
      2. +-rgt-identity83.9%

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

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

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

    if 1.99999999999999998e-92 < (/.f64 1 n) < 2e-8

    1. Initial program 7.0%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Taylor expanded in n around inf 41.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(0.5 \cdot \frac{{\log x}^{2}}{{n}^{2}} + \frac{\log x}{n}\right)} \]
    3. Step-by-step derivation
      1. fma-def41.9%

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, \frac{\mathsf{log1p}\left(x\right)}{n}\right) - \mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{\color{blue}{n \cdot n}}, \frac{\log x}{n}\right) \]
    4. Simplified41.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)}{n}\right) - \mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{n \cdot n}, \frac{\log x}{n}\right)} \]
    5. Taylor expanded in x around inf 67.2%

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

      \[\leadsto \color{blue}{\frac{\log x}{x \cdot \left(n \cdot n\right)} + \left(\left(\mathsf{fma}\left(0.5, \frac{\frac{0.6666666666666666 \cdot \log x}{n \cdot n} + \frac{-1}{n \cdot n}}{{x}^{3}}, \frac{1}{x \cdot n}\right) + \left(\frac{0.3333333333333333}{n \cdot {x}^{3}} + \frac{\frac{-0.5 \cdot \log x}{n \cdot n} + \frac{0.5}{n \cdot n}}{x \cdot x}\right)\right) + \frac{-0.5}{n \cdot \left(x \cdot x\right)}\right)} \]
    7. Taylor expanded in n around inf 67.3%

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

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

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

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

    if 2e-8 < (/.f64 1 n)

    1. Initial program 43.5%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Step-by-step derivation
      1. add-cbrt-cube43.5%

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

        \[\leadsto \sqrt[3]{\color{blue}{{\left({\left(x + 1\right)}^{\left(\frac{1}{n}\right)}\right)}^{3}}} - {x}^{\left(\frac{1}{n}\right)} \]
      3. pow-to-exp43.5%

        \[\leadsto \sqrt[3]{{\color{blue}{\left(e^{\log \left(x + 1\right) \cdot \frac{1}{n}}\right)}}^{3}} - {x}^{\left(\frac{1}{n}\right)} \]
      4. pow-exp43.5%

        \[\leadsto \sqrt[3]{\color{blue}{e^{\left(\log \left(x + 1\right) \cdot \frac{1}{n}\right) \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
      5. un-div-inv43.5%

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

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

        \[\leadsto \sqrt[3]{e^{\frac{\color{blue}{\mathsf{log1p}\left(x\right)}}{n} \cdot 3}} - {x}^{\left(\frac{1}{n}\right)} \]
    3. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\sqrt[3]{e^{\frac{\mathsf{log1p}\left(x\right)}{n} \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
    4. Taylor expanded in x around 0 100.0%

      \[\leadsto \sqrt[3]{e^{\color{blue}{3 \cdot \frac{x}{n}}}} - {x}^{\left(\frac{1}{n}\right)} \]
    5. Step-by-step derivation
      1. *-commutative100.0%

        \[\leadsto \sqrt[3]{e^{\color{blue}{\frac{x}{n} \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
    6. Simplified100.0%

      \[\leadsto \sqrt[3]{e^{\color{blue}{\frac{x}{n} \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
    7. Taylor expanded in x around inf 99.8%

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

        \[\leadsto {\left(e^{\color{blue}{\frac{x}{n} \cdot 3}}\right)}^{0.3333333333333333} - {x}^{\left(\frac{1}{n}\right)} \]
      2. exp-prod99.7%

        \[\leadsto {\color{blue}{\left({\left(e^{\frac{x}{n}}\right)}^{3}\right)}}^{0.3333333333333333} - {x}^{\left(\frac{1}{n}\right)} \]
      3. unpow1/399.7%

        \[\leadsto \color{blue}{\sqrt[3]{{\left(e^{\frac{x}{n}}\right)}^{3}}} - {x}^{\left(\frac{1}{n}\right)} \]
      4. rem-cbrt-cube99.8%

        \[\leadsto \color{blue}{e^{\frac{x}{n}}} - {x}^{\left(\frac{1}{n}\right)} \]
    9. Simplified99.8%

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

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

Alternative 5: 85.8% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{if}\;\frac{1}{n} \leq -4 \cdot 10^{-26}:\\ \;\;\;\;\frac{t_0}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-92}:\\ \;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-8}:\\ \;\;\;\;\frac{\log x}{x \cdot \left(n \cdot n\right)} + \frac{\frac{1}{x} + \left(\frac{0.3333333333333333}{{x}^{3}} + \frac{-0.5}{x \cdot x}\right)}{n}\\ \mathbf{else}:\\ \;\;\;\;e^{\frac{x}{n}} - t_0\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (pow x (/ 1.0 n))))
   (if (<= (/ 1.0 n) -4e-26)
     (/ t_0 (* n x))
     (if (<= (/ 1.0 n) 2e-92)
       (/ (- (log1p x) (log x)) n)
       (if (<= (/ 1.0 n) 2e-8)
         (+
          (/ (log x) (* x (* n n)))
          (/
           (+
            (/ 1.0 x)
            (+ (/ 0.3333333333333333 (pow x 3.0)) (/ -0.5 (* x x))))
           n))
         (- (exp (/ x n)) t_0))))))
double code(double x, double n) {
	double t_0 = pow(x, (1.0 / n));
	double tmp;
	if ((1.0 / n) <= -4e-26) {
		tmp = t_0 / (n * x);
	} else if ((1.0 / n) <= 2e-92) {
		tmp = (log1p(x) - log(x)) / n;
	} else if ((1.0 / n) <= 2e-8) {
		tmp = (log(x) / (x * (n * n))) + (((1.0 / x) + ((0.3333333333333333 / pow(x, 3.0)) + (-0.5 / (x * x)))) / n);
	} else {
		tmp = exp((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) <= -4e-26) {
		tmp = t_0 / (n * x);
	} else if ((1.0 / n) <= 2e-92) {
		tmp = (Math.log1p(x) - Math.log(x)) / n;
	} else if ((1.0 / n) <= 2e-8) {
		tmp = (Math.log(x) / (x * (n * n))) + (((1.0 / x) + ((0.3333333333333333 / Math.pow(x, 3.0)) + (-0.5 / (x * x)))) / n);
	} else {
		tmp = Math.exp((x / n)) - t_0;
	}
	return tmp;
}
def code(x, n):
	t_0 = math.pow(x, (1.0 / n))
	tmp = 0
	if (1.0 / n) <= -4e-26:
		tmp = t_0 / (n * x)
	elif (1.0 / n) <= 2e-92:
		tmp = (math.log1p(x) - math.log(x)) / n
	elif (1.0 / n) <= 2e-8:
		tmp = (math.log(x) / (x * (n * n))) + (((1.0 / x) + ((0.3333333333333333 / math.pow(x, 3.0)) + (-0.5 / (x * x)))) / n)
	else:
		tmp = math.exp((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) <= -4e-26)
		tmp = Float64(t_0 / Float64(n * x));
	elseif (Float64(1.0 / n) <= 2e-92)
		tmp = Float64(Float64(log1p(x) - log(x)) / n);
	elseif (Float64(1.0 / n) <= 2e-8)
		tmp = Float64(Float64(log(x) / Float64(x * Float64(n * n))) + Float64(Float64(Float64(1.0 / x) + Float64(Float64(0.3333333333333333 / (x ^ 3.0)) + Float64(-0.5 / Float64(x * x)))) / n));
	else
		tmp = Float64(exp(Float64(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], -4e-26], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-92], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-8], N[(N[(N[Log[x], $MachinePrecision] / N[(x * N[(n * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(1.0 / x), $MachinePrecision] + N[(N[(0.3333333333333333 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] + N[(-0.5 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision], N[(N[Exp[N[(x / 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 -4 \cdot 10^{-26}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\

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

\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-8}:\\
\;\;\;\;\frac{\log x}{x \cdot \left(n \cdot n\right)} + \frac{\frac{1}{x} + \left(\frac{0.3333333333333333}{{x}^{3}} + \frac{-0.5}{x \cdot x}\right)}{n}\\

\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t_0\\


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

    1. Initial program 93.8%

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

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

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

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

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

        \[\leadsto \frac{e^{\color{blue}{\frac{\log x}{n}}}}{n \cdot x} \]
      5. *-commutative98.4%

        \[\leadsto \frac{e^{\frac{\log x}{n}}}{\color{blue}{x \cdot n}} \]
    4. Simplified98.4%

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    5. Taylor expanded in x around 0 98.4%

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{n \cdot x}} \]
    6. Step-by-step derivation
      1. remove-double-neg98.4%

        \[\leadsto \frac{e^{\color{blue}{-\left(-\frac{\log x}{n}\right)}}}{n \cdot x} \]
      2. distribute-frac-neg98.4%

        \[\leadsto \frac{e^{-\color{blue}{\frac{-\log x}{n}}}}{n \cdot x} \]
      3. *-commutative98.4%

        \[\leadsto \frac{e^{-\frac{-\log x}{n}}}{\color{blue}{x \cdot n}} \]
      4. rem-exp-log45.6%

        \[\leadsto \color{blue}{e^{\log \left(\frac{e^{-\frac{-\log x}{n}}}{x \cdot n}\right)}} \]
      5. log-div0.0%

        \[\leadsto e^{\color{blue}{\log \left(e^{-\frac{-\log x}{n}}\right) - \log \left(x \cdot n\right)}} \]
      6. exp-diff0.0%

        \[\leadsto \color{blue}{\frac{e^{\log \left(e^{-\frac{-\log x}{n}}\right)}}{e^{\log \left(x \cdot n\right)}}} \]
      7. distribute-frac-neg0.0%

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

        \[\leadsto \frac{e^{\log \left(e^{\color{blue}{\frac{\log x}{n}}}\right)}}{e^{\log \left(x \cdot n\right)}} \]
      9. rem-log-exp0.0%

        \[\leadsto \frac{e^{\color{blue}{\frac{\log x}{n}}}}{e^{\log \left(x \cdot n\right)}} \]
      10. *-rgt-identity0.0%

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

        \[\leadsto \frac{e^{\color{blue}{\log x \cdot \frac{1}{n}}}}{e^{\log \left(x \cdot n\right)}} \]
      12. *-commutative0.0%

        \[\leadsto \frac{e^{\color{blue}{\frac{1}{n} \cdot \log x}}}{e^{\log \left(x \cdot n\right)}} \]
      13. log-pow0.0%

        \[\leadsto \frac{e^{\color{blue}{\log \left({x}^{\left(\frac{1}{n}\right)}\right)}}}{e^{\log \left(x \cdot n\right)}} \]
      14. exp-diff0.0%

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

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

    if -4.0000000000000002e-26 < (/.f64 1 n) < 1.99999999999999998e-92

    1. Initial program 32.5%

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

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

        \[\leadsto \frac{\color{blue}{\left(\log \left(1 + x\right) + 0\right)} - \log x}{n} \]
      2. +-rgt-identity83.9%

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

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

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

    if 1.99999999999999998e-92 < (/.f64 1 n) < 2e-8

    1. Initial program 7.0%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Taylor expanded in n around inf 41.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(0.5 \cdot \frac{{\log x}^{2}}{{n}^{2}} + \frac{\log x}{n}\right)} \]
    3. Step-by-step derivation
      1. fma-def41.9%

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, \frac{\mathsf{log1p}\left(x\right)}{n}\right) - \mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{\color{blue}{n \cdot n}}, \frac{\log x}{n}\right) \]
    4. Simplified41.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)}{n}\right) - \mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{n \cdot n}, \frac{\log x}{n}\right)} \]
    5. Taylor expanded in x around inf 67.2%

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

      \[\leadsto \color{blue}{\frac{\log x}{x \cdot \left(n \cdot n\right)} + \left(\left(\mathsf{fma}\left(0.5, \frac{\frac{0.6666666666666666 \cdot \log x}{n \cdot n} + \frac{-1}{n \cdot n}}{{x}^{3}}, \frac{1}{x \cdot n}\right) + \left(\frac{0.3333333333333333}{n \cdot {x}^{3}} + \frac{\frac{-0.5 \cdot \log x}{n \cdot n} + \frac{0.5}{n \cdot n}}{x \cdot x}\right)\right) + \frac{-0.5}{n \cdot \left(x \cdot x\right)}\right)} \]
    7. Taylor expanded in n around inf 67.1%

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

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

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

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

        \[\leadsto \frac{\log x}{x \cdot \left(n \cdot n\right)} + \frac{\left(\frac{1}{x} + 0.3333333333333333 \cdot \frac{1}{{x}^{3}}\right) + \left(-\frac{\color{blue}{0.5}}{{x}^{2}}\right)}{n} \]
      5. distribute-neg-frac67.1%

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

        \[\leadsto \frac{\log x}{x \cdot \left(n \cdot n\right)} + \frac{\left(\frac{1}{x} + 0.3333333333333333 \cdot \frac{1}{{x}^{3}}\right) + \frac{\color{blue}{-0.5}}{{x}^{2}}}{n} \]
      7. associate-+l+67.1%

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

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

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

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

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

    if 2e-8 < (/.f64 1 n)

    1. Initial program 43.5%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Step-by-step derivation
      1. add-cbrt-cube43.5%

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

        \[\leadsto \sqrt[3]{\color{blue}{{\left({\left(x + 1\right)}^{\left(\frac{1}{n}\right)}\right)}^{3}}} - {x}^{\left(\frac{1}{n}\right)} \]
      3. pow-to-exp43.5%

        \[\leadsto \sqrt[3]{{\color{blue}{\left(e^{\log \left(x + 1\right) \cdot \frac{1}{n}}\right)}}^{3}} - {x}^{\left(\frac{1}{n}\right)} \]
      4. pow-exp43.5%

        \[\leadsto \sqrt[3]{\color{blue}{e^{\left(\log \left(x + 1\right) \cdot \frac{1}{n}\right) \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
      5. un-div-inv43.5%

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

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

        \[\leadsto \sqrt[3]{e^{\frac{\color{blue}{\mathsf{log1p}\left(x\right)}}{n} \cdot 3}} - {x}^{\left(\frac{1}{n}\right)} \]
    3. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\sqrt[3]{e^{\frac{\mathsf{log1p}\left(x\right)}{n} \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
    4. Taylor expanded in x around 0 100.0%

      \[\leadsto \sqrt[3]{e^{\color{blue}{3 \cdot \frac{x}{n}}}} - {x}^{\left(\frac{1}{n}\right)} \]
    5. Step-by-step derivation
      1. *-commutative100.0%

        \[\leadsto \sqrt[3]{e^{\color{blue}{\frac{x}{n} \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
    6. Simplified100.0%

      \[\leadsto \sqrt[3]{e^{\color{blue}{\frac{x}{n} \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
    7. Taylor expanded in x around inf 99.8%

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

        \[\leadsto {\left(e^{\color{blue}{\frac{x}{n} \cdot 3}}\right)}^{0.3333333333333333} - {x}^{\left(\frac{1}{n}\right)} \]
      2. exp-prod99.7%

        \[\leadsto {\color{blue}{\left({\left(e^{\frac{x}{n}}\right)}^{3}\right)}}^{0.3333333333333333} - {x}^{\left(\frac{1}{n}\right)} \]
      3. unpow1/399.7%

        \[\leadsto \color{blue}{\sqrt[3]{{\left(e^{\frac{x}{n}}\right)}^{3}}} - {x}^{\left(\frac{1}{n}\right)} \]
      4. rem-cbrt-cube99.8%

        \[\leadsto \color{blue}{e^{\frac{x}{n}}} - {x}^{\left(\frac{1}{n}\right)} \]
    9. Simplified99.8%

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

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

Alternative 6: 85.6% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{if}\;\frac{1}{n} \leq -4 \cdot 10^{-26}:\\ \;\;\;\;\frac{t_0}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-92}:\\ \;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-8}:\\ \;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x} + \frac{-0.5}{n \cdot \left(x \cdot x\right)}\\ \mathbf{else}:\\ \;\;\;\;e^{\frac{x}{n}} - t_0\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (pow x (/ 1.0 n))))
   (if (<= (/ 1.0 n) -4e-26)
     (/ t_0 (* n x))
     (if (<= (/ 1.0 n) 2e-92)
       (/ (- (log1p x) (log x)) n)
       (if (<= (/ 1.0 n) 2e-8)
         (+ (/ (exp (/ (log x) n)) (* n x)) (/ -0.5 (* n (* x x))))
         (- (exp (/ x n)) t_0))))))
double code(double x, double n) {
	double t_0 = pow(x, (1.0 / n));
	double tmp;
	if ((1.0 / n) <= -4e-26) {
		tmp = t_0 / (n * x);
	} else if ((1.0 / n) <= 2e-92) {
		tmp = (log1p(x) - log(x)) / n;
	} else if ((1.0 / n) <= 2e-8) {
		tmp = (exp((log(x) / n)) / (n * x)) + (-0.5 / (n * (x * x)));
	} else {
		tmp = exp((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) <= -4e-26) {
		tmp = t_0 / (n * x);
	} else if ((1.0 / n) <= 2e-92) {
		tmp = (Math.log1p(x) - Math.log(x)) / n;
	} else if ((1.0 / n) <= 2e-8) {
		tmp = (Math.exp((Math.log(x) / n)) / (n * x)) + (-0.5 / (n * (x * x)));
	} else {
		tmp = Math.exp((x / n)) - t_0;
	}
	return tmp;
}
def code(x, n):
	t_0 = math.pow(x, (1.0 / n))
	tmp = 0
	if (1.0 / n) <= -4e-26:
		tmp = t_0 / (n * x)
	elif (1.0 / n) <= 2e-92:
		tmp = (math.log1p(x) - math.log(x)) / n
	elif (1.0 / n) <= 2e-8:
		tmp = (math.exp((math.log(x) / n)) / (n * x)) + (-0.5 / (n * (x * x)))
	else:
		tmp = math.exp((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) <= -4e-26)
		tmp = Float64(t_0 / Float64(n * x));
	elseif (Float64(1.0 / n) <= 2e-92)
		tmp = Float64(Float64(log1p(x) - log(x)) / n);
	elseif (Float64(1.0 / n) <= 2e-8)
		tmp = Float64(Float64(exp(Float64(log(x) / n)) / Float64(n * x)) + Float64(-0.5 / Float64(n * Float64(x * x))));
	else
		tmp = Float64(exp(Float64(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], -4e-26], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-92], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-8], N[(N[(N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision] + N[(-0.5 / N[(n * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Exp[N[(x / 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 -4 \cdot 10^{-26}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\

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

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

\mathbf{else}:\\
\;\;\;\;e^{\frac{x}{n}} - t_0\\


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

    1. Initial program 93.8%

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

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

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

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

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

        \[\leadsto \frac{e^{\color{blue}{\frac{\log x}{n}}}}{n \cdot x} \]
      5. *-commutative98.4%

        \[\leadsto \frac{e^{\frac{\log x}{n}}}{\color{blue}{x \cdot n}} \]
    4. Simplified98.4%

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    5. Taylor expanded in x around 0 98.4%

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{n \cdot x}} \]
    6. Step-by-step derivation
      1. remove-double-neg98.4%

        \[\leadsto \frac{e^{\color{blue}{-\left(-\frac{\log x}{n}\right)}}}{n \cdot x} \]
      2. distribute-frac-neg98.4%

        \[\leadsto \frac{e^{-\color{blue}{\frac{-\log x}{n}}}}{n \cdot x} \]
      3. *-commutative98.4%

        \[\leadsto \frac{e^{-\frac{-\log x}{n}}}{\color{blue}{x \cdot n}} \]
      4. rem-exp-log45.6%

        \[\leadsto \color{blue}{e^{\log \left(\frac{e^{-\frac{-\log x}{n}}}{x \cdot n}\right)}} \]
      5. log-div0.0%

        \[\leadsto e^{\color{blue}{\log \left(e^{-\frac{-\log x}{n}}\right) - \log \left(x \cdot n\right)}} \]
      6. exp-diff0.0%

        \[\leadsto \color{blue}{\frac{e^{\log \left(e^{-\frac{-\log x}{n}}\right)}}{e^{\log \left(x \cdot n\right)}}} \]
      7. distribute-frac-neg0.0%

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

        \[\leadsto \frac{e^{\log \left(e^{\color{blue}{\frac{\log x}{n}}}\right)}}{e^{\log \left(x \cdot n\right)}} \]
      9. rem-log-exp0.0%

        \[\leadsto \frac{e^{\color{blue}{\frac{\log x}{n}}}}{e^{\log \left(x \cdot n\right)}} \]
      10. *-rgt-identity0.0%

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

        \[\leadsto \frac{e^{\color{blue}{\log x \cdot \frac{1}{n}}}}{e^{\log \left(x \cdot n\right)}} \]
      12. *-commutative0.0%

        \[\leadsto \frac{e^{\color{blue}{\frac{1}{n} \cdot \log x}}}{e^{\log \left(x \cdot n\right)}} \]
      13. log-pow0.0%

        \[\leadsto \frac{e^{\color{blue}{\log \left({x}^{\left(\frac{1}{n}\right)}\right)}}}{e^{\log \left(x \cdot n\right)}} \]
      14. exp-diff0.0%

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

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

    if -4.0000000000000002e-26 < (/.f64 1 n) < 1.99999999999999998e-92

    1. Initial program 32.5%

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

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

        \[\leadsto \frac{\color{blue}{\left(\log \left(1 + x\right) + 0\right)} - \log x}{n} \]
      2. +-rgt-identity83.9%

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

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

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

    if 1.99999999999999998e-92 < (/.f64 1 n) < 2e-8

    1. Initial program 7.0%

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

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

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

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

        \[\leadsto \frac{e^{-\frac{-\log x}{n}}}{\color{blue}{x \cdot n}} + \frac{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}} \cdot \left(0.5 \cdot \frac{1}{{n}^{2}} - 0.5 \cdot \frac{1}{n}\right)}{{x}^{2}} \]
      4. associate-/l*67.1%

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

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

        \[\leadsto \frac{e^{-\frac{-\log x}{n}}}{x \cdot n} + \frac{e^{-\frac{\color{blue}{-\log x}}{n}}}{\frac{{x}^{2}}{0.5 \cdot \frac{1}{{n}^{2}} - 0.5 \cdot \frac{1}{n}}} \]
      7. unpow267.1%

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

        \[\leadsto \frac{e^{-\frac{-\log x}{n}}}{x \cdot n} + \frac{e^{-\frac{-\log x}{n}}}{\frac{x \cdot x}{\color{blue}{\frac{0.5 \cdot 1}{{n}^{2}}} - 0.5 \cdot \frac{1}{n}}} \]
      9. metadata-eval67.1%

        \[\leadsto \frac{e^{-\frac{-\log x}{n}}}{x \cdot n} + \frac{e^{-\frac{-\log x}{n}}}{\frac{x \cdot x}{\frac{\color{blue}{0.5}}{{n}^{2}} - 0.5 \cdot \frac{1}{n}}} \]
      10. unpow267.1%

        \[\leadsto \frac{e^{-\frac{-\log x}{n}}}{x \cdot n} + \frac{e^{-\frac{-\log x}{n}}}{\frac{x \cdot x}{\frac{0.5}{\color{blue}{n \cdot n}} - 0.5 \cdot \frac{1}{n}}} \]
      11. associate-*r/67.1%

        \[\leadsto \frac{e^{-\frac{-\log x}{n}}}{x \cdot n} + \frac{e^{-\frac{-\log x}{n}}}{\frac{x \cdot x}{\frac{0.5}{n \cdot n} - \color{blue}{\frac{0.5 \cdot 1}{n}}}} \]
      12. metadata-eval67.1%

        \[\leadsto \frac{e^{-\frac{-\log x}{n}}}{x \cdot n} + \frac{e^{-\frac{-\log x}{n}}}{\frac{x \cdot x}{\frac{0.5}{n \cdot n} - \frac{\color{blue}{0.5}}{n}}} \]
    4. Simplified67.1%

      \[\leadsto \color{blue}{\frac{e^{-\frac{-\log x}{n}}}{x \cdot n} + \frac{e^{-\frac{-\log x}{n}}}{\frac{x \cdot x}{\frac{0.5}{n \cdot n} - \frac{0.5}{n}}}} \]
    5. Taylor expanded in n around inf 67.1%

      \[\leadsto \frac{e^{-\frac{-\log x}{n}}}{x \cdot n} + \color{blue}{\frac{-0.5}{n \cdot {x}^{2}}} \]
    6. Step-by-step derivation
      1. unpow267.1%

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

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

    if 2e-8 < (/.f64 1 n)

    1. Initial program 43.5%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Step-by-step derivation
      1. add-cbrt-cube43.5%

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

        \[\leadsto \sqrt[3]{\color{blue}{{\left({\left(x + 1\right)}^{\left(\frac{1}{n}\right)}\right)}^{3}}} - {x}^{\left(\frac{1}{n}\right)} \]
      3. pow-to-exp43.5%

        \[\leadsto \sqrt[3]{{\color{blue}{\left(e^{\log \left(x + 1\right) \cdot \frac{1}{n}}\right)}}^{3}} - {x}^{\left(\frac{1}{n}\right)} \]
      4. pow-exp43.5%

        \[\leadsto \sqrt[3]{\color{blue}{e^{\left(\log \left(x + 1\right) \cdot \frac{1}{n}\right) \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
      5. un-div-inv43.5%

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

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

        \[\leadsto \sqrt[3]{e^{\frac{\color{blue}{\mathsf{log1p}\left(x\right)}}{n} \cdot 3}} - {x}^{\left(\frac{1}{n}\right)} \]
    3. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\sqrt[3]{e^{\frac{\mathsf{log1p}\left(x\right)}{n} \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
    4. Taylor expanded in x around 0 100.0%

      \[\leadsto \sqrt[3]{e^{\color{blue}{3 \cdot \frac{x}{n}}}} - {x}^{\left(\frac{1}{n}\right)} \]
    5. Step-by-step derivation
      1. *-commutative100.0%

        \[\leadsto \sqrt[3]{e^{\color{blue}{\frac{x}{n} \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
    6. Simplified100.0%

      \[\leadsto \sqrt[3]{e^{\color{blue}{\frac{x}{n} \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
    7. Taylor expanded in x around inf 99.8%

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

        \[\leadsto {\left(e^{\color{blue}{\frac{x}{n} \cdot 3}}\right)}^{0.3333333333333333} - {x}^{\left(\frac{1}{n}\right)} \]
      2. exp-prod99.7%

        \[\leadsto {\color{blue}{\left({\left(e^{\frac{x}{n}}\right)}^{3}\right)}}^{0.3333333333333333} - {x}^{\left(\frac{1}{n}\right)} \]
      3. unpow1/399.7%

        \[\leadsto \color{blue}{\sqrt[3]{{\left(e^{\frac{x}{n}}\right)}^{3}}} - {x}^{\left(\frac{1}{n}\right)} \]
      4. rem-cbrt-cube99.8%

        \[\leadsto \color{blue}{e^{\frac{x}{n}}} - {x}^{\left(\frac{1}{n}\right)} \]
    9. Simplified99.8%

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

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

Alternative 7: 82.6% accurate, 0.9× speedup?

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-43}:\\
\;\;\;\;\frac{1}{n} \cdot \frac{1}{x}\\

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

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

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


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

    1. Initial program 93.8%

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

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

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

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

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

        \[\leadsto \frac{e^{\color{blue}{\frac{\log x}{n}}}}{n \cdot x} \]
      5. *-commutative98.4%

        \[\leadsto \frac{e^{\frac{\log x}{n}}}{\color{blue}{x \cdot n}} \]
    4. Simplified98.4%

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    5. Taylor expanded in x around 0 98.4%

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{n \cdot x}} \]
    6. Step-by-step derivation
      1. remove-double-neg98.4%

        \[\leadsto \frac{e^{\color{blue}{-\left(-\frac{\log x}{n}\right)}}}{n \cdot x} \]
      2. distribute-frac-neg98.4%

        \[\leadsto \frac{e^{-\color{blue}{\frac{-\log x}{n}}}}{n \cdot x} \]
      3. *-commutative98.4%

        \[\leadsto \frac{e^{-\frac{-\log x}{n}}}{\color{blue}{x \cdot n}} \]
      4. rem-exp-log45.6%

        \[\leadsto \color{blue}{e^{\log \left(\frac{e^{-\frac{-\log x}{n}}}{x \cdot n}\right)}} \]
      5. log-div0.0%

        \[\leadsto e^{\color{blue}{\log \left(e^{-\frac{-\log x}{n}}\right) - \log \left(x \cdot n\right)}} \]
      6. exp-diff0.0%

        \[\leadsto \color{blue}{\frac{e^{\log \left(e^{-\frac{-\log x}{n}}\right)}}{e^{\log \left(x \cdot n\right)}}} \]
      7. distribute-frac-neg0.0%

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

        \[\leadsto \frac{e^{\log \left(e^{\color{blue}{\frac{\log x}{n}}}\right)}}{e^{\log \left(x \cdot n\right)}} \]
      9. rem-log-exp0.0%

        \[\leadsto \frac{e^{\color{blue}{\frac{\log x}{n}}}}{e^{\log \left(x \cdot n\right)}} \]
      10. *-rgt-identity0.0%

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

        \[\leadsto \frac{e^{\color{blue}{\log x \cdot \frac{1}{n}}}}{e^{\log \left(x \cdot n\right)}} \]
      12. *-commutative0.0%

        \[\leadsto \frac{e^{\color{blue}{\frac{1}{n} \cdot \log x}}}{e^{\log \left(x \cdot n\right)}} \]
      13. log-pow0.0%

        \[\leadsto \frac{e^{\color{blue}{\log \left({x}^{\left(\frac{1}{n}\right)}\right)}}}{e^{\log \left(x \cdot n\right)}} \]
      14. exp-diff0.0%

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

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

    if -4.0000000000000002e-26 < (/.f64 1 n) < 1.99999999999999998e-92 or 5.00000000000000019e-43 < (/.f64 1 n) < 2e-8

    1. Initial program 31.0%

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

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

        \[\leadsto \frac{\color{blue}{\left(\log \left(1 + x\right) + 0\right)} - \log x}{n} \]
      2. +-rgt-identity82.1%

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

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

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

    if 1.99999999999999998e-92 < (/.f64 1 n) < 5.00000000000000019e-43

    1. Initial program 5.5%

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

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

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

        \[\leadsto \frac{e^{-\frac{\color{blue}{-\log x}}{n}}}{n \cdot x} \]
      3. distribute-frac-neg80.9%

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

        \[\leadsto \frac{e^{\color{blue}{\frac{\log x}{n}}}}{n \cdot x} \]
      5. *-commutative80.9%

        \[\leadsto \frac{e^{\frac{\log x}{n}}}{\color{blue}{x \cdot n}} \]
    4. Simplified80.9%

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    5. Taylor expanded in n around inf 80.9%

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{1}{x}}{n}} \]
      2. div-inv81.3%

        \[\leadsto \color{blue}{\frac{1}{x} \cdot \frac{1}{n}} \]
    9. Applied egg-rr81.3%

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

    if 2e-8 < (/.f64 1 n) < 4.99999999999999967e145

    1. Initial program 81.6%

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

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

    if 4.99999999999999967e145 < (/.f64 1 n)

    1. Initial program 16.1%

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

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

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

        \[\leadsto \frac{e^{-\frac{\color{blue}{-\log x}}{n}}}{n \cdot x} \]
      3. distribute-frac-neg0.5%

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

        \[\leadsto \frac{e^{\color{blue}{\frac{\log x}{n}}}}{n \cdot x} \]
      5. *-commutative0.5%

        \[\leadsto \frac{e^{\frac{\log x}{n}}}{\color{blue}{x \cdot n}} \]
    4. Simplified0.5%

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    5. Taylor expanded in n around inf 58.4%

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

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

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

        \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{x \cdot n}\right)\right)} \]
      2. associate-/r*84.5%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\frac{\frac{1}{x}}{n}}\right)\right) \]
    9. Applied egg-rr84.5%

      \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\frac{1}{x}}{n}\right)\right)} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification87.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -4 \cdot 10^{-26}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-92}:\\ \;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-43}:\\ \;\;\;\;\frac{1}{n} \cdot \frac{1}{x}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-8}:\\ \;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+145}:\\ \;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\frac{1}{x}}{n}\right)\right)\\ \end{array} \]

Alternative 8: 70.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{-\log x}{n}\\ t_1 := \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\frac{1}{x}}{n}\right)\right)\\ t_2 := \frac{\frac{1}{n}}{x}\\ \mathbf{if}\;x \leq 7.8 \cdot 10^{-171}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 5 \cdot 10^{-118}:\\ \;\;\;\;\sqrt[3]{t_2 \cdot \left(t_2 \cdot t_2\right)}\\ \mathbf{elif}\;x \leq 7 \cdot 10^{-91}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 5.5 \cdot 10^{-55}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.6 \cdot 10^{-34}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (/ (- (log x)) n))
        (t_1 (log1p (expm1 (/ (/ 1.0 x) n))))
        (t_2 (/ (/ 1.0 n) x)))
   (if (<= x 7.8e-171)
     t_0
     (if (<= x 5e-118)
       (cbrt (* t_2 (* t_2 t_2)))
       (if (<= x 7e-91)
         t_0
         (if (<= x 5.5e-55)
           t_1
           (if (<= x 1.6e-34)
             t_0
             (if (<= x 1.0) t_1 (/ (pow x (/ 1.0 n)) (* n x))))))))))
double code(double x, double n) {
	double t_0 = -log(x) / n;
	double t_1 = log1p(expm1(((1.0 / x) / n)));
	double t_2 = (1.0 / n) / x;
	double tmp;
	if (x <= 7.8e-171) {
		tmp = t_0;
	} else if (x <= 5e-118) {
		tmp = cbrt((t_2 * (t_2 * t_2)));
	} else if (x <= 7e-91) {
		tmp = t_0;
	} else if (x <= 5.5e-55) {
		tmp = t_1;
	} else if (x <= 1.6e-34) {
		tmp = t_0;
	} else if (x <= 1.0) {
		tmp = t_1;
	} else {
		tmp = pow(x, (1.0 / n)) / (n * x);
	}
	return tmp;
}
public static double code(double x, double n) {
	double t_0 = -Math.log(x) / n;
	double t_1 = Math.log1p(Math.expm1(((1.0 / x) / n)));
	double t_2 = (1.0 / n) / x;
	double tmp;
	if (x <= 7.8e-171) {
		tmp = t_0;
	} else if (x <= 5e-118) {
		tmp = Math.cbrt((t_2 * (t_2 * t_2)));
	} else if (x <= 7e-91) {
		tmp = t_0;
	} else if (x <= 5.5e-55) {
		tmp = t_1;
	} else if (x <= 1.6e-34) {
		tmp = t_0;
	} else if (x <= 1.0) {
		tmp = t_1;
	} else {
		tmp = Math.pow(x, (1.0 / n)) / (n * x);
	}
	return tmp;
}
function code(x, n)
	t_0 = Float64(Float64(-log(x)) / n)
	t_1 = log1p(expm1(Float64(Float64(1.0 / x) / n)))
	t_2 = Float64(Float64(1.0 / n) / x)
	tmp = 0.0
	if (x <= 7.8e-171)
		tmp = t_0;
	elseif (x <= 5e-118)
		tmp = cbrt(Float64(t_2 * Float64(t_2 * t_2)));
	elseif (x <= 7e-91)
		tmp = t_0;
	elseif (x <= 5.5e-55)
		tmp = t_1;
	elseif (x <= 1.6e-34)
		tmp = t_0;
	elseif (x <= 1.0)
		tmp = t_1;
	else
		tmp = Float64((x ^ Float64(1.0 / n)) / Float64(n * x));
	end
	return tmp
end
code[x_, n_] := Block[{t$95$0 = N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision]}, Block[{t$95$1 = N[Log[1 + N[(Exp[N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[x, 7.8e-171], t$95$0, If[LessEqual[x, 5e-118], N[Power[N[(t$95$2 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], If[LessEqual[x, 7e-91], t$95$0, If[LessEqual[x, 5.5e-55], t$95$1, If[LessEqual[x, 1.6e-34], t$95$0, If[LessEqual[x, 1.0], t$95$1, N[(N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{-\log x}{n}\\
t_1 := \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\frac{1}{x}}{n}\right)\right)\\
t_2 := \frac{\frac{1}{n}}{x}\\
\mathbf{if}\;x \leq 7.8 \cdot 10^{-171}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 5 \cdot 10^{-118}:\\
\;\;\;\;\sqrt[3]{t_2 \cdot \left(t_2 \cdot t_2\right)}\\

\mathbf{elif}\;x \leq 7 \cdot 10^{-91}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 5.5 \cdot 10^{-55}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 1.6 \cdot 10^{-34}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 1:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < 7.7999999999999997e-171 or 5.00000000000000015e-118 < x < 6.9999999999999997e-91 or 5.4999999999999999e-55 < x < 1.60000000000000001e-34

    1. Initial program 34.6%

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

      \[\leadsto \color{blue}{1} - {x}^{\left(\frac{1}{n}\right)} \]
    3. Taylor expanded in n around inf 61.4%

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

        \[\leadsto \color{blue}{-\frac{\log x}{n}} \]
      2. distribute-frac-neg61.4%

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

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

    if 7.7999999999999997e-171 < x < 5.00000000000000015e-118

    1. Initial program 61.5%

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

      \[\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(0.5 \cdot \frac{{\log x}^{2}}{{n}^{2}} + \frac{\log x}{n}\right)} \]
    3. Step-by-step derivation
      1. fma-def26.3%

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

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

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

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

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

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

      \[\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)}{n}\right) - \mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{n \cdot n}, \frac{\log x}{n}\right)} \]
    5. Taylor expanded in x around inf 37.2%

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

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

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

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

        \[\leadsto \frac{\frac{1}{n} + \frac{-\color{blue}{\left(-\log x\right)}}{{n}^{2}}}{x} \]
      5. remove-double-neg37.2%

        \[\leadsto \frac{\frac{1}{n} + \frac{\color{blue}{\log x}}{{n}^{2}}}{x} \]
      6. unpow237.2%

        \[\leadsto \frac{\frac{1}{n} + \frac{\log x}{\color{blue}{n \cdot n}}}{x} \]
    7. Simplified37.2%

      \[\leadsto \color{blue}{\frac{\frac{1}{n} + \frac{\log x}{n \cdot n}}{x}} \]
    8. Taylor expanded in n around inf 43.6%

      \[\leadsto \frac{\color{blue}{\frac{1}{n}}}{x} \]
    9. Step-by-step derivation
      1. add-cbrt-cube71.3%

        \[\leadsto \color{blue}{\sqrt[3]{\left(\frac{\frac{1}{n}}{x} \cdot \frac{\frac{1}{n}}{x}\right) \cdot \frac{\frac{1}{n}}{x}}} \]
    10. Applied egg-rr71.3%

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

    if 6.9999999999999997e-91 < x < 5.4999999999999999e-55 or 1.60000000000000001e-34 < x < 1

    1. Initial program 42.5%

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

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

        \[\leadsto \frac{e^{\color{blue}{-\frac{\log \left(\frac{1}{x}\right)}{n}}}}{n \cdot x} \]
      2. log-rec32.6%

        \[\leadsto \frac{e^{-\frac{\color{blue}{-\log x}}{n}}}{n \cdot x} \]
      3. distribute-frac-neg32.6%

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

        \[\leadsto \frac{e^{\color{blue}{\frac{\log x}{n}}}}{n \cdot x} \]
      5. *-commutative32.6%

        \[\leadsto \frac{e^{\frac{\log x}{n}}}{\color{blue}{x \cdot n}} \]
    4. Simplified32.6%

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    5. Taylor expanded in n around inf 15.1%

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

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

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

        \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{x \cdot n}\right)\right)} \]
      2. associate-/r*67.5%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\frac{\frac{1}{x}}{n}}\right)\right) \]
    9. Applied egg-rr67.5%

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

    if 1 < x

    1. Initial program 68.0%

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

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

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

        \[\leadsto \frac{e^{-\frac{\color{blue}{-\log x}}{n}}}{n \cdot x} \]
      3. distribute-frac-neg96.5%

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

        \[\leadsto \frac{e^{\color{blue}{\frac{\log x}{n}}}}{n \cdot x} \]
      5. *-commutative96.5%

        \[\leadsto \frac{e^{\frac{\log x}{n}}}{\color{blue}{x \cdot n}} \]
    4. Simplified96.5%

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    5. Taylor expanded in x around 0 96.5%

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{n \cdot x}} \]
    6. Step-by-step derivation
      1. remove-double-neg96.5%

        \[\leadsto \frac{e^{\color{blue}{-\left(-\frac{\log x}{n}\right)}}}{n \cdot x} \]
      2. distribute-frac-neg96.5%

        \[\leadsto \frac{e^{-\color{blue}{\frac{-\log x}{n}}}}{n \cdot x} \]
      3. *-commutative96.5%

        \[\leadsto \frac{e^{-\frac{-\log x}{n}}}{\color{blue}{x \cdot n}} \]
      4. rem-exp-log82.8%

        \[\leadsto \color{blue}{e^{\log \left(\frac{e^{-\frac{-\log x}{n}}}{x \cdot n}\right)}} \]
      5. log-div35.9%

        \[\leadsto e^{\color{blue}{\log \left(e^{-\frac{-\log x}{n}}\right) - \log \left(x \cdot n\right)}} \]
      6. exp-diff35.9%

        \[\leadsto \color{blue}{\frac{e^{\log \left(e^{-\frac{-\log x}{n}}\right)}}{e^{\log \left(x \cdot n\right)}}} \]
      7. distribute-frac-neg35.9%

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

        \[\leadsto \frac{e^{\log \left(e^{\color{blue}{\frac{\log x}{n}}}\right)}}{e^{\log \left(x \cdot n\right)}} \]
      9. rem-log-exp35.9%

        \[\leadsto \frac{e^{\color{blue}{\frac{\log x}{n}}}}{e^{\log \left(x \cdot n\right)}} \]
      10. *-rgt-identity35.9%

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

        \[\leadsto \frac{e^{\color{blue}{\log x \cdot \frac{1}{n}}}}{e^{\log \left(x \cdot n\right)}} \]
      12. *-commutative35.9%

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

        \[\leadsto \frac{e^{\color{blue}{\log \left({x}^{\left(\frac{1}{n}\right)}\right)}}}{e^{\log \left(x \cdot n\right)}} \]
      14. exp-diff35.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 7.8 \cdot 10^{-171}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 5 \cdot 10^{-118}:\\ \;\;\;\;\sqrt[3]{\frac{\frac{1}{n}}{x} \cdot \left(\frac{\frac{1}{n}}{x} \cdot \frac{\frac{1}{n}}{x}\right)}\\ \mathbf{elif}\;x \leq 7 \cdot 10^{-91}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 5.5 \cdot 10^{-55}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\frac{1}{x}}{n}\right)\right)\\ \mathbf{elif}\;x \leq 1.6 \cdot 10^{-34}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\frac{1}{x}}{n}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\ \end{array} \]

Alternative 9: 85.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq -115000 \lor \neg \left(n \leq 85000000\right):\\ \;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;e^{\frac{x}{n}} - {x}^{\left(\frac{1}{n}\right)}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (or (<= n -115000.0) (not (<= n 85000000.0)))
   (/ (- (log1p x) (log x)) n)
   (- (exp (/ x n)) (pow x (/ 1.0 n)))))
double code(double x, double n) {
	double tmp;
	if ((n <= -115000.0) || !(n <= 85000000.0)) {
		tmp = (log1p(x) - log(x)) / n;
	} else {
		tmp = exp((x / n)) - pow(x, (1.0 / n));
	}
	return tmp;
}
public static double code(double x, double n) {
	double tmp;
	if ((n <= -115000.0) || !(n <= 85000000.0)) {
		tmp = (Math.log1p(x) - Math.log(x)) / n;
	} else {
		tmp = Math.exp((x / n)) - Math.pow(x, (1.0 / n));
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if (n <= -115000.0) or not (n <= 85000000.0):
		tmp = (math.log1p(x) - math.log(x)) / n
	else:
		tmp = math.exp((x / n)) - math.pow(x, (1.0 / n))
	return tmp
function code(x, n)
	tmp = 0.0
	if ((n <= -115000.0) || !(n <= 85000000.0))
		tmp = Float64(Float64(log1p(x) - log(x)) / n);
	else
		tmp = Float64(exp(Float64(x / n)) - (x ^ Float64(1.0 / n)));
	end
	return tmp
end
code[x_, n_] := If[Or[LessEqual[n, -115000.0], N[Not[LessEqual[n, 85000000.0]], $MachinePrecision]], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;n \leq -115000 \lor \neg \left(n \leq 85000000\right):\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if n < -115000 or 8.5e7 < n

    1. Initial program 29.0%

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

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

        \[\leadsto \frac{\color{blue}{\left(\log \left(1 + x\right) + 0\right)} - \log x}{n} \]
      2. +-rgt-identity76.3%

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

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

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

    if -115000 < n < 8.5e7

    1. Initial program 79.1%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Step-by-step derivation
      1. add-cbrt-cube79.1%

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

        \[\leadsto \sqrt[3]{\color{blue}{{\left({\left(x + 1\right)}^{\left(\frac{1}{n}\right)}\right)}^{3}}} - {x}^{\left(\frac{1}{n}\right)} \]
      3. pow-to-exp79.1%

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

        \[\leadsto \sqrt[3]{\color{blue}{e^{\left(\log \left(x + 1\right) \cdot \frac{1}{n}\right) \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
      5. un-div-inv79.1%

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

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

        \[\leadsto \sqrt[3]{e^{\frac{\color{blue}{\mathsf{log1p}\left(x\right)}}{n} \cdot 3}} - {x}^{\left(\frac{1}{n}\right)} \]
    3. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\sqrt[3]{e^{\frac{\mathsf{log1p}\left(x\right)}{n} \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
    4. Taylor expanded in x around 0 100.0%

      \[\leadsto \sqrt[3]{e^{\color{blue}{3 \cdot \frac{x}{n}}}} - {x}^{\left(\frac{1}{n}\right)} \]
    5. Step-by-step derivation
      1. *-commutative100.0%

        \[\leadsto \sqrt[3]{e^{\color{blue}{\frac{x}{n} \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
    6. Simplified100.0%

      \[\leadsto \sqrt[3]{e^{\color{blue}{\frac{x}{n} \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
    7. Taylor expanded in x around inf 99.9%

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

        \[\leadsto {\left(e^{\color{blue}{\frac{x}{n} \cdot 3}}\right)}^{0.3333333333333333} - {x}^{\left(\frac{1}{n}\right)} \]
      2. exp-prod99.9%

        \[\leadsto {\color{blue}{\left({\left(e^{\frac{x}{n}}\right)}^{3}\right)}}^{0.3333333333333333} - {x}^{\left(\frac{1}{n}\right)} \]
      3. unpow1/399.9%

        \[\leadsto \color{blue}{\sqrt[3]{{\left(e^{\frac{x}{n}}\right)}^{3}}} - {x}^{\left(\frac{1}{n}\right)} \]
      4. rem-cbrt-cube99.9%

        \[\leadsto \color{blue}{e^{\frac{x}{n}}} - {x}^{\left(\frac{1}{n}\right)} \]
    9. Simplified99.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -115000 \lor \neg \left(n \leq 85000000\right):\\ \;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;e^{\frac{x}{n}} - {x}^{\left(\frac{1}{n}\right)}\\ \end{array} \]

Alternative 10: 70.6% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{-\log x}{n}\\ t_1 := \frac{\frac{1}{n}}{x}\\ t_2 := \sqrt[3]{t_1 \cdot \left(t_1 \cdot t_1\right)}\\ \mathbf{if}\;x \leq 7.8 \cdot 10^{-171}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.85 \cdot 10^{-118}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 7 \cdot 10^{-91}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 8.2 \cdot 10^{-69}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 0.0145:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (/ (- (log x)) n))
        (t_1 (/ (/ 1.0 n) x))
        (t_2 (cbrt (* t_1 (* t_1 t_1)))))
   (if (<= x 7.8e-171)
     t_0
     (if (<= x 2.85e-118)
       t_2
       (if (<= x 7e-91)
         t_0
         (if (<= x 8.2e-69)
           t_2
           (if (<= x 0.0145)
             (/ (- x (log x)) n)
             (/ (pow x (/ 1.0 n)) (* n x)))))))))
double code(double x, double n) {
	double t_0 = -log(x) / n;
	double t_1 = (1.0 / n) / x;
	double t_2 = cbrt((t_1 * (t_1 * t_1)));
	double tmp;
	if (x <= 7.8e-171) {
		tmp = t_0;
	} else if (x <= 2.85e-118) {
		tmp = t_2;
	} else if (x <= 7e-91) {
		tmp = t_0;
	} else if (x <= 8.2e-69) {
		tmp = t_2;
	} else if (x <= 0.0145) {
		tmp = (x - log(x)) / n;
	} else {
		tmp = pow(x, (1.0 / n)) / (n * x);
	}
	return tmp;
}
public static double code(double x, double n) {
	double t_0 = -Math.log(x) / n;
	double t_1 = (1.0 / n) / x;
	double t_2 = Math.cbrt((t_1 * (t_1 * t_1)));
	double tmp;
	if (x <= 7.8e-171) {
		tmp = t_0;
	} else if (x <= 2.85e-118) {
		tmp = t_2;
	} else if (x <= 7e-91) {
		tmp = t_0;
	} else if (x <= 8.2e-69) {
		tmp = t_2;
	} else if (x <= 0.0145) {
		tmp = (x - Math.log(x)) / n;
	} else {
		tmp = Math.pow(x, (1.0 / n)) / (n * x);
	}
	return tmp;
}
function code(x, n)
	t_0 = Float64(Float64(-log(x)) / n)
	t_1 = Float64(Float64(1.0 / n) / x)
	t_2 = cbrt(Float64(t_1 * Float64(t_1 * t_1)))
	tmp = 0.0
	if (x <= 7.8e-171)
		tmp = t_0;
	elseif (x <= 2.85e-118)
		tmp = t_2;
	elseif (x <= 7e-91)
		tmp = t_0;
	elseif (x <= 8.2e-69)
		tmp = t_2;
	elseif (x <= 0.0145)
		tmp = Float64(Float64(x - log(x)) / n);
	else
		tmp = Float64((x ^ Float64(1.0 / n)) / Float64(n * x));
	end
	return tmp
end
code[x_, n_] := Block[{t$95$0 = N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision]}, Block[{t$95$1 = N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[(t$95$1 * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]}, If[LessEqual[x, 7.8e-171], t$95$0, If[LessEqual[x, 2.85e-118], t$95$2, If[LessEqual[x, 7e-91], t$95$0, If[LessEqual[x, 8.2e-69], t$95$2, If[LessEqual[x, 0.0145], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{-\log x}{n}\\
t_1 := \frac{\frac{1}{n}}{x}\\
t_2 := \sqrt[3]{t_1 \cdot \left(t_1 \cdot t_1\right)}\\
\mathbf{if}\;x \leq 7.8 \cdot 10^{-171}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 2.85 \cdot 10^{-118}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;x \leq 7 \cdot 10^{-91}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 8.2 \cdot 10^{-69}:\\
\;\;\;\;t_2\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < 7.7999999999999997e-171 or 2.85000000000000006e-118 < x < 6.9999999999999997e-91

    1. Initial program 37.3%

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

      \[\leadsto \color{blue}{1} - {x}^{\left(\frac{1}{n}\right)} \]
    3. Taylor expanded in n around inf 58.6%

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

        \[\leadsto \color{blue}{-\frac{\log x}{n}} \]
      2. distribute-frac-neg58.6%

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

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

    if 7.7999999999999997e-171 < x < 2.85000000000000006e-118 or 6.9999999999999997e-91 < x < 8.1999999999999998e-69

    1. Initial program 53.4%

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

      \[\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(0.5 \cdot \frac{{\log x}^{2}}{{n}^{2}} + \frac{\log x}{n}\right)} \]
    3. Step-by-step derivation
      1. fma-def25.5%

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

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

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

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

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

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

      \[\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)}{n}\right) - \mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{n \cdot n}, \frac{\log x}{n}\right)} \]
    5. Taylor expanded in x around inf 29.5%

      \[\leadsto \color{blue}{\frac{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{{n}^{2}} + \frac{1}{n}}{x}} \]
    6. Step-by-step derivation
      1. +-commutative29.5%

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

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

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

        \[\leadsto \frac{\frac{1}{n} + \frac{-\color{blue}{\left(-\log x\right)}}{{n}^{2}}}{x} \]
      5. remove-double-neg29.5%

        \[\leadsto \frac{\frac{1}{n} + \frac{\color{blue}{\log x}}{{n}^{2}}}{x} \]
      6. unpow229.5%

        \[\leadsto \frac{\frac{1}{n} + \frac{\log x}{\color{blue}{n \cdot n}}}{x} \]
    7. Simplified29.5%

      \[\leadsto \color{blue}{\frac{\frac{1}{n} + \frac{\log x}{n \cdot n}}{x}} \]
    8. Taylor expanded in n around inf 34.4%

      \[\leadsto \frac{\color{blue}{\frac{1}{n}}}{x} \]
    9. Step-by-step derivation
      1. add-cbrt-cube68.4%

        \[\leadsto \color{blue}{\sqrt[3]{\left(\frac{\frac{1}{n}}{x} \cdot \frac{\frac{1}{n}}{x}\right) \cdot \frac{\frac{1}{n}}{x}}} \]
    10. Applied egg-rr68.4%

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

    if 8.1999999999999998e-69 < x < 0.0145000000000000007

    1. Initial program 33.1%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Step-by-step derivation
      1. add-cbrt-cube33.1%

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

        \[\leadsto \sqrt[3]{\color{blue}{{\left({\left(x + 1\right)}^{\left(\frac{1}{n}\right)}\right)}^{3}}} - {x}^{\left(\frac{1}{n}\right)} \]
      3. pow-to-exp33.1%

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

        \[\leadsto \sqrt[3]{\color{blue}{e^{\left(\log \left(x + 1\right) \cdot \frac{1}{n}\right) \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
      5. un-div-inv33.1%

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

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

        \[\leadsto \sqrt[3]{e^{\frac{\color{blue}{\mathsf{log1p}\left(x\right)}}{n} \cdot 3}} - {x}^{\left(\frac{1}{n}\right)} \]
    3. Applied egg-rr52.5%

      \[\leadsto \color{blue}{\sqrt[3]{e^{\frac{\mathsf{log1p}\left(x\right)}{n} \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
    4. Taylor expanded in x around 0 52.5%

      \[\leadsto \sqrt[3]{e^{\color{blue}{3 \cdot \frac{x}{n}}}} - {x}^{\left(\frac{1}{n}\right)} \]
    5. Step-by-step derivation
      1. *-commutative52.5%

        \[\leadsto \sqrt[3]{e^{\color{blue}{\frac{x}{n} \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
    6. Simplified52.5%

      \[\leadsto \sqrt[3]{e^{\color{blue}{\frac{x}{n} \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
    7. Taylor expanded in n around inf 54.9%

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

    if 0.0145000000000000007 < x

    1. Initial program 68.0%

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

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

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

        \[\leadsto \frac{e^{-\frac{\color{blue}{-\log x}}{n}}}{n \cdot x} \]
      3. distribute-frac-neg96.5%

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

        \[\leadsto \frac{e^{\color{blue}{\frac{\log x}{n}}}}{n \cdot x} \]
      5. *-commutative96.5%

        \[\leadsto \frac{e^{\frac{\log x}{n}}}{\color{blue}{x \cdot n}} \]
    4. Simplified96.5%

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    5. Taylor expanded in x around 0 96.5%

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{n \cdot x}} \]
    6. Step-by-step derivation
      1. remove-double-neg96.5%

        \[\leadsto \frac{e^{\color{blue}{-\left(-\frac{\log x}{n}\right)}}}{n \cdot x} \]
      2. distribute-frac-neg96.5%

        \[\leadsto \frac{e^{-\color{blue}{\frac{-\log x}{n}}}}{n \cdot x} \]
      3. *-commutative96.5%

        \[\leadsto \frac{e^{-\frac{-\log x}{n}}}{\color{blue}{x \cdot n}} \]
      4. rem-exp-log82.8%

        \[\leadsto \color{blue}{e^{\log \left(\frac{e^{-\frac{-\log x}{n}}}{x \cdot n}\right)}} \]
      5. log-div35.9%

        \[\leadsto e^{\color{blue}{\log \left(e^{-\frac{-\log x}{n}}\right) - \log \left(x \cdot n\right)}} \]
      6. exp-diff35.9%

        \[\leadsto \color{blue}{\frac{e^{\log \left(e^{-\frac{-\log x}{n}}\right)}}{e^{\log \left(x \cdot n\right)}}} \]
      7. distribute-frac-neg35.9%

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

        \[\leadsto \frac{e^{\log \left(e^{\color{blue}{\frac{\log x}{n}}}\right)}}{e^{\log \left(x \cdot n\right)}} \]
      9. rem-log-exp35.9%

        \[\leadsto \frac{e^{\color{blue}{\frac{\log x}{n}}}}{e^{\log \left(x \cdot n\right)}} \]
      10. *-rgt-identity35.9%

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

        \[\leadsto \frac{e^{\color{blue}{\log x \cdot \frac{1}{n}}}}{e^{\log \left(x \cdot n\right)}} \]
      12. *-commutative35.9%

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

        \[\leadsto \frac{e^{\color{blue}{\log \left({x}^{\left(\frac{1}{n}\right)}\right)}}}{e^{\log \left(x \cdot n\right)}} \]
      14. exp-diff35.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 7.8 \cdot 10^{-171}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 2.85 \cdot 10^{-118}:\\ \;\;\;\;\sqrt[3]{\frac{\frac{1}{n}}{x} \cdot \left(\frac{\frac{1}{n}}{x} \cdot \frac{\frac{1}{n}}{x}\right)}\\ \mathbf{elif}\;x \leq 7 \cdot 10^{-91}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 8.2 \cdot 10^{-69}:\\ \;\;\;\;\sqrt[3]{\frac{\frac{1}{n}}{x} \cdot \left(\frac{\frac{1}{n}}{x} \cdot \frac{\frac{1}{n}}{x}\right)}\\ \mathbf{elif}\;x \leq 0.0145:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\ \end{array} \]

Alternative 11: 71.4% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{if}\;x \leq 1.85 \cdot 10^{-170}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 4 \cdot 10^{-148}:\\ \;\;\;\;1 - t_0\\ \mathbf{elif}\;x \leq 0.00156:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{t_0}{n \cdot x}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (pow x (/ 1.0 n))))
   (if (<= x 1.85e-170)
     (/ (- (log x)) n)
     (if (<= x 4e-148)
       (- 1.0 t_0)
       (if (<= x 0.00156) (/ (- x (log x)) n) (/ t_0 (* n x)))))))
double code(double x, double n) {
	double t_0 = pow(x, (1.0 / n));
	double tmp;
	if (x <= 1.85e-170) {
		tmp = -log(x) / n;
	} else if (x <= 4e-148) {
		tmp = 1.0 - t_0;
	} else if (x <= 0.00156) {
		tmp = (x - log(x)) / n;
	} else {
		tmp = t_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 (x <= 1.85d-170) then
        tmp = -log(x) / n
    else if (x <= 4d-148) then
        tmp = 1.0d0 - t_0
    else if (x <= 0.00156d0) then
        tmp = (x - log(x)) / n
    else
        tmp = t_0 / (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 (x <= 1.85e-170) {
		tmp = -Math.log(x) / n;
	} else if (x <= 4e-148) {
		tmp = 1.0 - t_0;
	} else if (x <= 0.00156) {
		tmp = (x - Math.log(x)) / n;
	} else {
		tmp = t_0 / (n * x);
	}
	return tmp;
}
def code(x, n):
	t_0 = math.pow(x, (1.0 / n))
	tmp = 0
	if x <= 1.85e-170:
		tmp = -math.log(x) / n
	elif x <= 4e-148:
		tmp = 1.0 - t_0
	elif x <= 0.00156:
		tmp = (x - math.log(x)) / n
	else:
		tmp = t_0 / (n * x)
	return tmp
function code(x, n)
	t_0 = x ^ Float64(1.0 / n)
	tmp = 0.0
	if (x <= 1.85e-170)
		tmp = Float64(Float64(-log(x)) / n);
	elseif (x <= 4e-148)
		tmp = Float64(1.0 - t_0);
	elseif (x <= 0.00156)
		tmp = Float64(Float64(x - log(x)) / n);
	else
		tmp = Float64(t_0 / Float64(n * x));
	end
	return tmp
end
function tmp_2 = code(x, n)
	t_0 = x ^ (1.0 / n);
	tmp = 0.0;
	if (x <= 1.85e-170)
		tmp = -log(x) / n;
	elseif (x <= 4e-148)
		tmp = 1.0 - t_0;
	elseif (x <= 0.00156)
		tmp = (x - log(x)) / n;
	else
		tmp = t_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[x, 1.85e-170], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 4e-148], N[(1.0 - t$95$0), $MachinePrecision], If[LessEqual[x, 0.00156], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq 4 \cdot 10^{-148}:\\
\;\;\;\;1 - t_0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < 1.85e-170

    1. Initial program 40.2%

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

      \[\leadsto \color{blue}{1} - {x}^{\left(\frac{1}{n}\right)} \]
    3. Taylor expanded in n around inf 56.1%

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

        \[\leadsto \color{blue}{-\frac{\log x}{n}} \]
      2. distribute-frac-neg56.1%

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

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

    if 1.85e-170 < x < 3.99999999999999974e-148

    1. Initial program 80.6%

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

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

    if 3.99999999999999974e-148 < x < 0.00155999999999999997

    1. Initial program 33.1%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Step-by-step derivation
      1. add-cbrt-cube33.1%

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

        \[\leadsto \sqrt[3]{\color{blue}{{\left({\left(x + 1\right)}^{\left(\frac{1}{n}\right)}\right)}^{3}}} - {x}^{\left(\frac{1}{n}\right)} \]
      3. pow-to-exp33.1%

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

        \[\leadsto \sqrt[3]{\color{blue}{e^{\left(\log \left(x + 1\right) \cdot \frac{1}{n}\right) \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
      5. un-div-inv33.1%

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

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

        \[\leadsto \sqrt[3]{e^{\frac{\color{blue}{\mathsf{log1p}\left(x\right)}}{n} \cdot 3}} - {x}^{\left(\frac{1}{n}\right)} \]
    3. Applied egg-rr55.6%

      \[\leadsto \color{blue}{\sqrt[3]{e^{\frac{\mathsf{log1p}\left(x\right)}{n} \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
    4. Taylor expanded in x around 0 55.6%

      \[\leadsto \sqrt[3]{e^{\color{blue}{3 \cdot \frac{x}{n}}}} - {x}^{\left(\frac{1}{n}\right)} \]
    5. Step-by-step derivation
      1. *-commutative55.6%

        \[\leadsto \sqrt[3]{e^{\color{blue}{\frac{x}{n} \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
    6. Simplified55.6%

      \[\leadsto \sqrt[3]{e^{\color{blue}{\frac{x}{n} \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
    7. Taylor expanded in n around inf 50.8%

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

    if 0.00155999999999999997 < x

    1. Initial program 68.0%

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

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

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

        \[\leadsto \frac{e^{-\frac{\color{blue}{-\log x}}{n}}}{n \cdot x} \]
      3. distribute-frac-neg96.5%

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

        \[\leadsto \frac{e^{\color{blue}{\frac{\log x}{n}}}}{n \cdot x} \]
      5. *-commutative96.5%

        \[\leadsto \frac{e^{\frac{\log x}{n}}}{\color{blue}{x \cdot n}} \]
    4. Simplified96.5%

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    5. Taylor expanded in x around 0 96.5%

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{n \cdot x}} \]
    6. Step-by-step derivation
      1. remove-double-neg96.5%

        \[\leadsto \frac{e^{\color{blue}{-\left(-\frac{\log x}{n}\right)}}}{n \cdot x} \]
      2. distribute-frac-neg96.5%

        \[\leadsto \frac{e^{-\color{blue}{\frac{-\log x}{n}}}}{n \cdot x} \]
      3. *-commutative96.5%

        \[\leadsto \frac{e^{-\frac{-\log x}{n}}}{\color{blue}{x \cdot n}} \]
      4. rem-exp-log82.8%

        \[\leadsto \color{blue}{e^{\log \left(\frac{e^{-\frac{-\log x}{n}}}{x \cdot n}\right)}} \]
      5. log-div35.9%

        \[\leadsto e^{\color{blue}{\log \left(e^{-\frac{-\log x}{n}}\right) - \log \left(x \cdot n\right)}} \]
      6. exp-diff35.9%

        \[\leadsto \color{blue}{\frac{e^{\log \left(e^{-\frac{-\log x}{n}}\right)}}{e^{\log \left(x \cdot n\right)}}} \]
      7. distribute-frac-neg35.9%

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

        \[\leadsto \frac{e^{\log \left(e^{\color{blue}{\frac{\log x}{n}}}\right)}}{e^{\log \left(x \cdot n\right)}} \]
      9. rem-log-exp35.9%

        \[\leadsto \frac{e^{\color{blue}{\frac{\log x}{n}}}}{e^{\log \left(x \cdot n\right)}} \]
      10. *-rgt-identity35.9%

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

        \[\leadsto \frac{e^{\color{blue}{\log x \cdot \frac{1}{n}}}}{e^{\log \left(x \cdot n\right)}} \]
      12. *-commutative35.9%

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

        \[\leadsto \frac{e^{\color{blue}{\log \left({x}^{\left(\frac{1}{n}\right)}\right)}}}{e^{\log \left(x \cdot n\right)}} \]
      14. exp-diff35.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.85 \cdot 10^{-170}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 4 \cdot 10^{-148}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 0.00156:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\ \end{array} \]

Alternative 12: 71.4% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{if}\;x \leq 4.5 \cdot 10^{-171}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 4.4 \cdot 10^{-148}:\\ \;\;\;\;\left(1 + \frac{x}{n}\right) - t_0\\ \mathbf{elif}\;x \leq 0.00031:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{t_0}{n \cdot x}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (pow x (/ 1.0 n))))
   (if (<= x 4.5e-171)
     (/ (- (log x)) n)
     (if (<= x 4.4e-148)
       (- (+ 1.0 (/ x n)) t_0)
       (if (<= x 0.00031) (/ (- x (log x)) n) (/ t_0 (* n x)))))))
double code(double x, double n) {
	double t_0 = pow(x, (1.0 / n));
	double tmp;
	if (x <= 4.5e-171) {
		tmp = -log(x) / n;
	} else if (x <= 4.4e-148) {
		tmp = (1.0 + (x / n)) - t_0;
	} else if (x <= 0.00031) {
		tmp = (x - log(x)) / n;
	} else {
		tmp = t_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 (x <= 4.5d-171) then
        tmp = -log(x) / n
    else if (x <= 4.4d-148) then
        tmp = (1.0d0 + (x / n)) - t_0
    else if (x <= 0.00031d0) then
        tmp = (x - log(x)) / n
    else
        tmp = t_0 / (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 (x <= 4.5e-171) {
		tmp = -Math.log(x) / n;
	} else if (x <= 4.4e-148) {
		tmp = (1.0 + (x / n)) - t_0;
	} else if (x <= 0.00031) {
		tmp = (x - Math.log(x)) / n;
	} else {
		tmp = t_0 / (n * x);
	}
	return tmp;
}
def code(x, n):
	t_0 = math.pow(x, (1.0 / n))
	tmp = 0
	if x <= 4.5e-171:
		tmp = -math.log(x) / n
	elif x <= 4.4e-148:
		tmp = (1.0 + (x / n)) - t_0
	elif x <= 0.00031:
		tmp = (x - math.log(x)) / n
	else:
		tmp = t_0 / (n * x)
	return tmp
function code(x, n)
	t_0 = x ^ Float64(1.0 / n)
	tmp = 0.0
	if (x <= 4.5e-171)
		tmp = Float64(Float64(-log(x)) / n);
	elseif (x <= 4.4e-148)
		tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0);
	elseif (x <= 0.00031)
		tmp = Float64(Float64(x - log(x)) / n);
	else
		tmp = Float64(t_0 / Float64(n * x));
	end
	return tmp
end
function tmp_2 = code(x, n)
	t_0 = x ^ (1.0 / n);
	tmp = 0.0;
	if (x <= 4.5e-171)
		tmp = -log(x) / n;
	elseif (x <= 4.4e-148)
		tmp = (1.0 + (x / n)) - t_0;
	elseif (x <= 0.00031)
		tmp = (x - log(x)) / n;
	else
		tmp = t_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[x, 4.5e-171], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 4.4e-148], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[x, 0.00031], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < 4.5000000000000004e-171

    1. Initial program 40.2%

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

      \[\leadsto \color{blue}{1} - {x}^{\left(\frac{1}{n}\right)} \]
    3. Taylor expanded in n around inf 56.1%

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

        \[\leadsto \color{blue}{-\frac{\log x}{n}} \]
      2. distribute-frac-neg56.1%

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

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

    if 4.5000000000000004e-171 < x < 4.40000000000000034e-148

    1. Initial program 80.6%

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

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

    if 4.40000000000000034e-148 < x < 3.1e-4

    1. Initial program 33.1%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Step-by-step derivation
      1. add-cbrt-cube33.1%

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

        \[\leadsto \sqrt[3]{\color{blue}{{\left({\left(x + 1\right)}^{\left(\frac{1}{n}\right)}\right)}^{3}}} - {x}^{\left(\frac{1}{n}\right)} \]
      3. pow-to-exp33.1%

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

        \[\leadsto \sqrt[3]{\color{blue}{e^{\left(\log \left(x + 1\right) \cdot \frac{1}{n}\right) \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
      5. un-div-inv33.1%

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

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

        \[\leadsto \sqrt[3]{e^{\frac{\color{blue}{\mathsf{log1p}\left(x\right)}}{n} \cdot 3}} - {x}^{\left(\frac{1}{n}\right)} \]
    3. Applied egg-rr55.6%

      \[\leadsto \color{blue}{\sqrt[3]{e^{\frac{\mathsf{log1p}\left(x\right)}{n} \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
    4. Taylor expanded in x around 0 55.6%

      \[\leadsto \sqrt[3]{e^{\color{blue}{3 \cdot \frac{x}{n}}}} - {x}^{\left(\frac{1}{n}\right)} \]
    5. Step-by-step derivation
      1. *-commutative55.6%

        \[\leadsto \sqrt[3]{e^{\color{blue}{\frac{x}{n} \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
    6. Simplified55.6%

      \[\leadsto \sqrt[3]{e^{\color{blue}{\frac{x}{n} \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
    7. Taylor expanded in n around inf 50.8%

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

    if 3.1e-4 < x

    1. Initial program 68.0%

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

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

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

        \[\leadsto \frac{e^{-\frac{\color{blue}{-\log x}}{n}}}{n \cdot x} \]
      3. distribute-frac-neg96.5%

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

        \[\leadsto \frac{e^{\color{blue}{\frac{\log x}{n}}}}{n \cdot x} \]
      5. *-commutative96.5%

        \[\leadsto \frac{e^{\frac{\log x}{n}}}{\color{blue}{x \cdot n}} \]
    4. Simplified96.5%

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    5. Taylor expanded in x around 0 96.5%

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{n \cdot x}} \]
    6. Step-by-step derivation
      1. remove-double-neg96.5%

        \[\leadsto \frac{e^{\color{blue}{-\left(-\frac{\log x}{n}\right)}}}{n \cdot x} \]
      2. distribute-frac-neg96.5%

        \[\leadsto \frac{e^{-\color{blue}{\frac{-\log x}{n}}}}{n \cdot x} \]
      3. *-commutative96.5%

        \[\leadsto \frac{e^{-\frac{-\log x}{n}}}{\color{blue}{x \cdot n}} \]
      4. rem-exp-log82.8%

        \[\leadsto \color{blue}{e^{\log \left(\frac{e^{-\frac{-\log x}{n}}}{x \cdot n}\right)}} \]
      5. log-div35.9%

        \[\leadsto e^{\color{blue}{\log \left(e^{-\frac{-\log x}{n}}\right) - \log \left(x \cdot n\right)}} \]
      6. exp-diff35.9%

        \[\leadsto \color{blue}{\frac{e^{\log \left(e^{-\frac{-\log x}{n}}\right)}}{e^{\log \left(x \cdot n\right)}}} \]
      7. distribute-frac-neg35.9%

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

        \[\leadsto \frac{e^{\log \left(e^{\color{blue}{\frac{\log x}{n}}}\right)}}{e^{\log \left(x \cdot n\right)}} \]
      9. rem-log-exp35.9%

        \[\leadsto \frac{e^{\color{blue}{\frac{\log x}{n}}}}{e^{\log \left(x \cdot n\right)}} \]
      10. *-rgt-identity35.9%

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

        \[\leadsto \frac{e^{\color{blue}{\log x \cdot \frac{1}{n}}}}{e^{\log \left(x \cdot n\right)}} \]
      12. *-commutative35.9%

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

        \[\leadsto \frac{e^{\color{blue}{\log \left({x}^{\left(\frac{1}{n}\right)}\right)}}}{e^{\log \left(x \cdot n\right)}} \]
      14. exp-diff35.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 4.5 \cdot 10^{-171}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 4.4 \cdot 10^{-148}:\\ \;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 0.00031:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\ \end{array} \]

Alternative 13: 56.7% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 6.5 \cdot 10^{-170}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 4 \cdot 10^{-148}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \mathbf{elif}\;x \leq 0.00024:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x}}{n}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= x 6.5e-170)
   (/ (- (log x)) n)
   (if (<= x 4e-148)
     (/ 1.0 (* n x))
     (if (<= x 0.00024) (/ (- x (log x)) n) (/ (/ 1.0 x) n)))))
double code(double x, double n) {
	double tmp;
	if (x <= 6.5e-170) {
		tmp = -log(x) / n;
	} else if (x <= 4e-148) {
		tmp = 1.0 / (n * x);
	} else if (x <= 0.00024) {
		tmp = (x - log(x)) / n;
	} else {
		tmp = (1.0 / 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 <= 6.5d-170) then
        tmp = -log(x) / n
    else if (x <= 4d-148) then
        tmp = 1.0d0 / (n * x)
    else if (x <= 0.00024d0) then
        tmp = (x - log(x)) / n
    else
        tmp = (1.0d0 / x) / n
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double tmp;
	if (x <= 6.5e-170) {
		tmp = -Math.log(x) / n;
	} else if (x <= 4e-148) {
		tmp = 1.0 / (n * x);
	} else if (x <= 0.00024) {
		tmp = (x - Math.log(x)) / n;
	} else {
		tmp = (1.0 / x) / n;
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if x <= 6.5e-170:
		tmp = -math.log(x) / n
	elif x <= 4e-148:
		tmp = 1.0 / (n * x)
	elif x <= 0.00024:
		tmp = (x - math.log(x)) / n
	else:
		tmp = (1.0 / x) / n
	return tmp
function code(x, n)
	tmp = 0.0
	if (x <= 6.5e-170)
		tmp = Float64(Float64(-log(x)) / n);
	elseif (x <= 4e-148)
		tmp = Float64(1.0 / Float64(n * x));
	elseif (x <= 0.00024)
		tmp = Float64(Float64(x - log(x)) / n);
	else
		tmp = Float64(Float64(1.0 / x) / n);
	end
	return tmp
end
function tmp_2 = code(x, n)
	tmp = 0.0;
	if (x <= 6.5e-170)
		tmp = -log(x) / n;
	elseif (x <= 4e-148)
		tmp = 1.0 / (n * x);
	elseif (x <= 0.00024)
		tmp = (x - log(x)) / n;
	else
		tmp = (1.0 / x) / n;
	end
	tmp_2 = tmp;
end
code[x_, n_] := If[LessEqual[x, 6.5e-170], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 4e-148], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.00024], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 6.5 \cdot 10^{-170}:\\
\;\;\;\;\frac{-\log x}{n}\\

\mathbf{elif}\;x \leq 4 \cdot 10^{-148}:\\
\;\;\;\;\frac{1}{n \cdot x}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < 6.50000000000000035e-170

    1. Initial program 40.2%

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

      \[\leadsto \color{blue}{1} - {x}^{\left(\frac{1}{n}\right)} \]
    3. Taylor expanded in n around inf 56.1%

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

        \[\leadsto \color{blue}{-\frac{\log x}{n}} \]
      2. distribute-frac-neg56.1%

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

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

    if 6.50000000000000035e-170 < x < 3.99999999999999974e-148

    1. Initial program 80.6%

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

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

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

        \[\leadsto \frac{e^{-\frac{\color{blue}{-\log x}}{n}}}{n \cdot x} \]
      3. distribute-frac-neg70.3%

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

        \[\leadsto \frac{e^{\color{blue}{\frac{\log x}{n}}}}{n \cdot x} \]
      5. *-commutative70.3%

        \[\leadsto \frac{e^{\frac{\log x}{n}}}{\color{blue}{x \cdot n}} \]
    4. Simplified70.3%

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    5. Taylor expanded in n around inf 62.6%

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

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

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

    if 3.99999999999999974e-148 < x < 2.40000000000000006e-4

    1. Initial program 32.0%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Step-by-step derivation
      1. add-cbrt-cube32.0%

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

        \[\leadsto \sqrt[3]{\color{blue}{{\left({\left(x + 1\right)}^{\left(\frac{1}{n}\right)}\right)}^{3}}} - {x}^{\left(\frac{1}{n}\right)} \]
      3. pow-to-exp32.0%

        \[\leadsto \sqrt[3]{{\color{blue}{\left(e^{\log \left(x + 1\right) \cdot \frac{1}{n}}\right)}}^{3}} - {x}^{\left(\frac{1}{n}\right)} \]
      4. pow-exp32.0%

        \[\leadsto \sqrt[3]{\color{blue}{e^{\left(\log \left(x + 1\right) \cdot \frac{1}{n}\right) \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
      5. un-div-inv32.0%

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

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

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

      \[\leadsto \color{blue}{\sqrt[3]{e^{\frac{\mathsf{log1p}\left(x\right)}{n} \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
    4. Taylor expanded in x around 0 54.9%

      \[\leadsto \sqrt[3]{e^{\color{blue}{3 \cdot \frac{x}{n}}}} - {x}^{\left(\frac{1}{n}\right)} \]
    5. Step-by-step derivation
      1. *-commutative54.9%

        \[\leadsto \sqrt[3]{e^{\color{blue}{\frac{x}{n} \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
    6. Simplified54.9%

      \[\leadsto \sqrt[3]{e^{\color{blue}{\frac{x}{n} \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
    7. Taylor expanded in n around inf 51.6%

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

    if 2.40000000000000006e-4 < x

    1. Initial program 68.3%

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

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

        \[\leadsto \frac{e^{\color{blue}{-\frac{\log \left(\frac{1}{x}\right)}{n}}}}{n \cdot x} \]
      2. log-rec95.6%

        \[\leadsto \frac{e^{-\frac{\color{blue}{-\log x}}{n}}}{n \cdot x} \]
      3. distribute-frac-neg95.6%

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

        \[\leadsto \frac{e^{\color{blue}{\frac{\log x}{n}}}}{n \cdot x} \]
      5. *-commutative95.6%

        \[\leadsto \frac{e^{\frac{\log x}{n}}}{\color{blue}{x \cdot n}} \]
    4. Simplified95.6%

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    5. Taylor expanded in n around inf 62.2%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 6.5 \cdot 10^{-170}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 4 \cdot 10^{-148}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \mathbf{elif}\;x \leq 0.00024:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x}}{n}\\ \end{array} \]

Alternative 14: 57.3% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 2.35 \cdot 10^{-170}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 4.2 \cdot 10^{-148}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 0.00024:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x}}{n}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= x 2.35e-170)
   (/ (- (log x)) n)
   (if (<= x 4.2e-148)
     (- 1.0 (pow x (/ 1.0 n)))
     (if (<= x 0.00024) (/ (- x (log x)) n) (/ (/ 1.0 x) n)))))
double code(double x, double n) {
	double tmp;
	if (x <= 2.35e-170) {
		tmp = -log(x) / n;
	} else if (x <= 4.2e-148) {
		tmp = 1.0 - pow(x, (1.0 / n));
	} else if (x <= 0.00024) {
		tmp = (x - log(x)) / n;
	} else {
		tmp = (1.0 / 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 <= 2.35d-170) then
        tmp = -log(x) / n
    else if (x <= 4.2d-148) then
        tmp = 1.0d0 - (x ** (1.0d0 / n))
    else if (x <= 0.00024d0) then
        tmp = (x - log(x)) / n
    else
        tmp = (1.0d0 / x) / n
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double tmp;
	if (x <= 2.35e-170) {
		tmp = -Math.log(x) / n;
	} else if (x <= 4.2e-148) {
		tmp = 1.0 - Math.pow(x, (1.0 / n));
	} else if (x <= 0.00024) {
		tmp = (x - Math.log(x)) / n;
	} else {
		tmp = (1.0 / x) / n;
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if x <= 2.35e-170:
		tmp = -math.log(x) / n
	elif x <= 4.2e-148:
		tmp = 1.0 - math.pow(x, (1.0 / n))
	elif x <= 0.00024:
		tmp = (x - math.log(x)) / n
	else:
		tmp = (1.0 / x) / n
	return tmp
function code(x, n)
	tmp = 0.0
	if (x <= 2.35e-170)
		tmp = Float64(Float64(-log(x)) / n);
	elseif (x <= 4.2e-148)
		tmp = Float64(1.0 - (x ^ Float64(1.0 / n)));
	elseif (x <= 0.00024)
		tmp = Float64(Float64(x - log(x)) / n);
	else
		tmp = Float64(Float64(1.0 / x) / n);
	end
	return tmp
end
function tmp_2 = code(x, n)
	tmp = 0.0;
	if (x <= 2.35e-170)
		tmp = -log(x) / n;
	elseif (x <= 4.2e-148)
		tmp = 1.0 - (x ^ (1.0 / n));
	elseif (x <= 0.00024)
		tmp = (x - log(x)) / n;
	else
		tmp = (1.0 / x) / n;
	end
	tmp_2 = tmp;
end
code[x_, n_] := If[LessEqual[x, 2.35e-170], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 4.2e-148], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.00024], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.35 \cdot 10^{-170}:\\
\;\;\;\;\frac{-\log x}{n}\\

\mathbf{elif}\;x \leq 4.2 \cdot 10^{-148}:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < 2.3500000000000001e-170

    1. Initial program 40.2%

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

      \[\leadsto \color{blue}{1} - {x}^{\left(\frac{1}{n}\right)} \]
    3. Taylor expanded in n around inf 56.1%

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

        \[\leadsto \color{blue}{-\frac{\log x}{n}} \]
      2. distribute-frac-neg56.1%

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

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

    if 2.3500000000000001e-170 < x < 4.2e-148

    1. Initial program 80.6%

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

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

    if 4.2e-148 < x < 2.40000000000000006e-4

    1. Initial program 32.0%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Step-by-step derivation
      1. add-cbrt-cube32.0%

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

        \[\leadsto \sqrt[3]{\color{blue}{{\left({\left(x + 1\right)}^{\left(\frac{1}{n}\right)}\right)}^{3}}} - {x}^{\left(\frac{1}{n}\right)} \]
      3. pow-to-exp32.0%

        \[\leadsto \sqrt[3]{{\color{blue}{\left(e^{\log \left(x + 1\right) \cdot \frac{1}{n}}\right)}}^{3}} - {x}^{\left(\frac{1}{n}\right)} \]
      4. pow-exp32.0%

        \[\leadsto \sqrt[3]{\color{blue}{e^{\left(\log \left(x + 1\right) \cdot \frac{1}{n}\right) \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
      5. un-div-inv32.0%

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

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

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

      \[\leadsto \color{blue}{\sqrt[3]{e^{\frac{\mathsf{log1p}\left(x\right)}{n} \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
    4. Taylor expanded in x around 0 54.9%

      \[\leadsto \sqrt[3]{e^{\color{blue}{3 \cdot \frac{x}{n}}}} - {x}^{\left(\frac{1}{n}\right)} \]
    5. Step-by-step derivation
      1. *-commutative54.9%

        \[\leadsto \sqrt[3]{e^{\color{blue}{\frac{x}{n} \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
    6. Simplified54.9%

      \[\leadsto \sqrt[3]{e^{\color{blue}{\frac{x}{n} \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
    7. Taylor expanded in n around inf 51.6%

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

    if 2.40000000000000006e-4 < x

    1. Initial program 68.3%

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

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

        \[\leadsto \frac{e^{\color{blue}{-\frac{\log \left(\frac{1}{x}\right)}{n}}}}{n \cdot x} \]
      2. log-rec95.6%

        \[\leadsto \frac{e^{-\frac{\color{blue}{-\log x}}{n}}}{n \cdot x} \]
      3. distribute-frac-neg95.6%

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

        \[\leadsto \frac{e^{\color{blue}{\frac{\log x}{n}}}}{n \cdot x} \]
      5. *-commutative95.6%

        \[\leadsto \frac{e^{\frac{\log x}{n}}}{\color{blue}{x \cdot n}} \]
    4. Simplified95.6%

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    5. Taylor expanded in n around inf 62.2%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 2.35 \cdot 10^{-170}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 4.2 \cdot 10^{-148}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 0.00024:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x}}{n}\\ \end{array} \]

Alternative 15: 56.5% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{-\log x}{n}\\ \mathbf{if}\;x \leq 7.5 \cdot 10^{-170}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 4 \cdot 10^{-148}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \mathbf{elif}\;x \leq 0.00024:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x}}{n}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (/ (- (log x)) n)))
   (if (<= x 7.5e-170)
     t_0
     (if (<= x 4e-148)
       (/ 1.0 (* n x))
       (if (<= x 0.00024) t_0 (/ (/ 1.0 x) n))))))
double code(double x, double n) {
	double t_0 = -log(x) / n;
	double tmp;
	if (x <= 7.5e-170) {
		tmp = t_0;
	} else if (x <= 4e-148) {
		tmp = 1.0 / (n * x);
	} else if (x <= 0.00024) {
		tmp = t_0;
	} else {
		tmp = (1.0 / 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) :: tmp
    t_0 = -log(x) / n
    if (x <= 7.5d-170) then
        tmp = t_0
    else if (x <= 4d-148) then
        tmp = 1.0d0 / (n * x)
    else if (x <= 0.00024d0) then
        tmp = t_0
    else
        tmp = (1.0d0 / x) / n
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double t_0 = -Math.log(x) / n;
	double tmp;
	if (x <= 7.5e-170) {
		tmp = t_0;
	} else if (x <= 4e-148) {
		tmp = 1.0 / (n * x);
	} else if (x <= 0.00024) {
		tmp = t_0;
	} else {
		tmp = (1.0 / x) / n;
	}
	return tmp;
}
def code(x, n):
	t_0 = -math.log(x) / n
	tmp = 0
	if x <= 7.5e-170:
		tmp = t_0
	elif x <= 4e-148:
		tmp = 1.0 / (n * x)
	elif x <= 0.00024:
		tmp = t_0
	else:
		tmp = (1.0 / x) / n
	return tmp
function code(x, n)
	t_0 = Float64(Float64(-log(x)) / n)
	tmp = 0.0
	if (x <= 7.5e-170)
		tmp = t_0;
	elseif (x <= 4e-148)
		tmp = Float64(1.0 / Float64(n * x));
	elseif (x <= 0.00024)
		tmp = t_0;
	else
		tmp = Float64(Float64(1.0 / x) / n);
	end
	return tmp
end
function tmp_2 = code(x, n)
	t_0 = -log(x) / n;
	tmp = 0.0;
	if (x <= 7.5e-170)
		tmp = t_0;
	elseif (x <= 4e-148)
		tmp = 1.0 / (n * x);
	elseif (x <= 0.00024)
		tmp = t_0;
	else
		tmp = (1.0 / x) / n;
	end
	tmp_2 = tmp;
end
code[x_, n_] := Block[{t$95$0 = N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision]}, If[LessEqual[x, 7.5e-170], t$95$0, If[LessEqual[x, 4e-148], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.00024], t$95$0, N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{-\log x}{n}\\
\mathbf{if}\;x \leq 7.5 \cdot 10^{-170}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 4 \cdot 10^{-148}:\\
\;\;\;\;\frac{1}{n \cdot x}\\

\mathbf{elif}\;x \leq 0.00024:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 7.4999999999999998e-170 or 3.99999999999999974e-148 < x < 2.40000000000000006e-4

    1. Initial program 36.6%

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

      \[\leadsto \color{blue}{1} - {x}^{\left(\frac{1}{n}\right)} \]
    3. Taylor expanded in n around inf 53.4%

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

        \[\leadsto \color{blue}{-\frac{\log x}{n}} \]
      2. distribute-frac-neg53.4%

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

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

    if 7.4999999999999998e-170 < x < 3.99999999999999974e-148

    1. Initial program 80.6%

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

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

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

        \[\leadsto \frac{e^{-\frac{\color{blue}{-\log x}}{n}}}{n \cdot x} \]
      3. distribute-frac-neg70.3%

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

        \[\leadsto \frac{e^{\color{blue}{\frac{\log x}{n}}}}{n \cdot x} \]
      5. *-commutative70.3%

        \[\leadsto \frac{e^{\frac{\log x}{n}}}{\color{blue}{x \cdot n}} \]
    4. Simplified70.3%

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    5. Taylor expanded in n around inf 62.6%

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

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

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

    if 2.40000000000000006e-4 < x

    1. Initial program 68.3%

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

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

        \[\leadsto \frac{e^{\color{blue}{-\frac{\log \left(\frac{1}{x}\right)}{n}}}}{n \cdot x} \]
      2. log-rec95.6%

        \[\leadsto \frac{e^{-\frac{\color{blue}{-\log x}}{n}}}{n \cdot x} \]
      3. distribute-frac-neg95.6%

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

        \[\leadsto \frac{e^{\color{blue}{\frac{\log x}{n}}}}{n \cdot x} \]
      5. *-commutative95.6%

        \[\leadsto \frac{e^{\frac{\log x}{n}}}{\color{blue}{x \cdot n}} \]
    4. Simplified95.6%

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    5. Taylor expanded in n around inf 62.2%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 7.5 \cdot 10^{-170}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 4 \cdot 10^{-148}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \mathbf{elif}\;x \leq 0.00024:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x}}{n}\\ \end{array} \]

Alternative 16: 41.0% 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 51.7%

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

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

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

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

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

      \[\leadsto \frac{e^{\color{blue}{\frac{\log x}{n}}}}{n \cdot x} \]
    5. *-commutative56.4%

      \[\leadsto \frac{e^{\frac{\log x}{n}}}{\color{blue}{x \cdot n}} \]
  4. Simplified56.4%

    \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
  5. Taylor expanded in n around inf 41.5%

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

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

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

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

Alternative 17: 41.6% 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 51.7%

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

    \[\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(0.5 \cdot \frac{{\log x}^{2}}{{n}^{2}} + \frac{\log x}{n}\right)} \]
  3. Step-by-step derivation
    1. fma-def49.0%

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

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

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

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

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

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

    \[\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)}{n}\right) - \mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{n \cdot n}, \frac{\log x}{n}\right)} \]
  5. Taylor expanded in x around inf 39.7%

    \[\leadsto \color{blue}{\frac{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{{n}^{2}} + \frac{1}{n}}{x}} \]
  6. Step-by-step derivation
    1. +-commutative39.7%

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

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

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

      \[\leadsto \frac{\frac{1}{n} + \frac{-\color{blue}{\left(-\log x\right)}}{{n}^{2}}}{x} \]
    5. remove-double-neg39.7%

      \[\leadsto \frac{\frac{1}{n} + \frac{\color{blue}{\log x}}{{n}^{2}}}{x} \]
    6. unpow239.7%

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

    \[\leadsto \color{blue}{\frac{\frac{1}{n} + \frac{\log x}{n \cdot n}}{x}} \]
  8. Taylor expanded in n around inf 42.1%

    \[\leadsto \frac{\color{blue}{\frac{1}{n}}}{x} \]
  9. Final simplification42.1%

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

Alternative 18: 41.6% accurate, 42.2× speedup?

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

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

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

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

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

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

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

      \[\leadsto \frac{e^{\color{blue}{\frac{\log x}{n}}}}{n \cdot x} \]
    5. *-commutative56.4%

      \[\leadsto \frac{e^{\frac{\log x}{n}}}{\color{blue}{x \cdot n}} \]
  4. Simplified56.4%

    \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
  5. Taylor expanded in n around inf 41.5%

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

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

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

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

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

Alternative 19: 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 51.7%

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

    \[\leadsto \color{blue}{\left(1 + \frac{x}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
  3. Taylor expanded in x around inf 4.4%

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

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

Reproduce

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