2nthrt (problem 3.4.6)

Percentage Accurate: 53.4% → 85.5%
Time: 27.8s
Alternatives: 22
Speedup: 2.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 22 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.4% 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.5% accurate, 0.2× speedup?

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-146}:\\
\;\;\;\;\frac{1}{n \cdot x + n \cdot 0.5}\\

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

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


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

    1. Initial program 92.5%

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

      \[\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-neg97.1%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    5. Step-by-step derivation
      1. *-un-lft-identity97.1%

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

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

      \[\leadsto \frac{\color{blue}{{\left(e^{1}\right)}^{\left(\frac{\log x}{n}\right)}}}{x \cdot n} \]
    7. Step-by-step derivation
      1. exp-1-e97.2%

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

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

    if -9.9999999999999998e-20 < (/.f64 1 n) < -9.99999999999999933e-103

    1. Initial program 8.6%

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

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

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

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

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

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

    if -9.99999999999999933e-103 < (/.f64 1 n) < -2.00000000000000005e-146

    1. Initial program 28.4%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Step-by-step derivation
      1. clear-num46.6%

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

        \[\leadsto \color{blue}{{\left(\frac{n}{\mathsf{log1p}\left(x\right) - \log x}\right)}^{-1}} \]
    6. Applied egg-rr46.6%

      \[\leadsto \color{blue}{{\left(\frac{n}{\mathsf{log1p}\left(x\right) - \log x}\right)}^{-1}} \]
    7. Step-by-step derivation
      1. unpow-146.6%

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

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

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

    if -2.00000000000000005e-146 < (/.f64 1 n) < 4.9999999999999998e-8

    1. Initial program 35.0%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(x\right)} - \log x}{n} + \left(\left(-1 \cdot \frac{-0.16666666666666666 \cdot {\log \left(1 + x\right)}^{3} - -0.16666666666666666 \cdot {\log x}^{3}}{{n}^{3}} + 0.5 \cdot \frac{{\log \left(1 + x\right)}^{2}}{{n}^{2}}\right) - 0.5 \cdot \frac{{\log x}^{2}}{{n}^{2}}\right) \]
      8. associate--l+87.7%

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

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

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

    1. Initial program 60.5%

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

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

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

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

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

Alternative 2: 85.5% accurate, 0.3× speedup?

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-146}:\\
\;\;\;\;\frac{1}{n \cdot x + n \cdot 0.5}\\

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

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


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

    1. Initial program 92.5%

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

      \[\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-neg97.1%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    5. Step-by-step derivation
      1. *-un-lft-identity97.1%

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

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

      \[\leadsto \frac{\color{blue}{{\left(e^{1}\right)}^{\left(\frac{\log x}{n}\right)}}}{x \cdot n} \]
    7. Step-by-step derivation
      1. exp-1-e97.2%

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

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

    if -9.9999999999999998e-20 < (/.f64 1 n) < -9.99999999999999933e-103

    1. Initial program 8.6%

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

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

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

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

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

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

    if -9.99999999999999933e-103 < (/.f64 1 n) < -2.00000000000000005e-146

    1. Initial program 28.4%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Step-by-step derivation
      1. clear-num46.6%

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

        \[\leadsto \color{blue}{{\left(\frac{n}{\mathsf{log1p}\left(x\right) - \log x}\right)}^{-1}} \]
    6. Applied egg-rr46.6%

      \[\leadsto \color{blue}{{\left(\frac{n}{\mathsf{log1p}\left(x\right) - \log x}\right)}^{-1}} \]
    7. Step-by-step derivation
      1. unpow-146.6%

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

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

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

    if -2.00000000000000005e-146 < (/.f64 1 n) < 2.00000000000000012e-9

    1. Initial program 34.6%

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

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

    if 2.00000000000000012e-9 < (/.f64 1 n)

    1. Initial program 61.2%

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

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

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

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

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

Alternative 3: 85.4% accurate, 0.7× speedup?

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-146}:\\
\;\;\;\;\frac{1}{n \cdot x + n \cdot 0.5}\\

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

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


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

    1. Initial program 92.5%

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

      \[\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-neg97.1%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    5. Step-by-step derivation
      1. *-un-lft-identity97.1%

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

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

      \[\leadsto \frac{\color{blue}{{\left(e^{1}\right)}^{\left(\frac{\log x}{n}\right)}}}{x \cdot n} \]
    7. Step-by-step derivation
      1. exp-1-e97.2%

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

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

    if -9.9999999999999998e-20 < (/.f64 1 n) < -9.99999999999999933e-103

    1. Initial program 8.6%

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

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

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

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

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

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

    if -9.99999999999999933e-103 < (/.f64 1 n) < -2.00000000000000005e-146

    1. Initial program 28.4%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Step-by-step derivation
      1. clear-num46.6%

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

        \[\leadsto \color{blue}{{\left(\frac{n}{\mathsf{log1p}\left(x\right) - \log x}\right)}^{-1}} \]
    6. Applied egg-rr46.6%

      \[\leadsto \color{blue}{{\left(\frac{n}{\mathsf{log1p}\left(x\right) - \log x}\right)}^{-1}} \]
    7. Step-by-step derivation
      1. unpow-146.6%

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

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

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

    if -2.00000000000000005e-146 < (/.f64 1 n) < 2.00000000000000012e-9

    1. Initial program 34.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{\frac{-n}{-\left(\mathsf{log1p}\left(x\right) - \log x\right)}}} \]
      6. associate-/r/87.4%

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

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

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

        \[\leadsto \frac{1}{-n} \cdot \left(-\color{blue}{\log \left(\frac{x + 1}{x}\right)}\right) \]
      10. neg-log87.5%

        \[\leadsto \frac{1}{-n} \cdot \color{blue}{\log \left(\frac{1}{\frac{x + 1}{x}}\right)} \]
      11. clear-num87.7%

        \[\leadsto \frac{1}{-n} \cdot \log \color{blue}{\left(\frac{x}{x + 1}\right)} \]
    8. Applied egg-rr87.7%

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

    if 2.00000000000000012e-9 < (/.f64 1 n)

    1. Initial program 61.2%

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

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

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

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

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

Alternative 4: 85.4% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-19}:\\ \;\;\;\;\frac{{e}^{\left(\frac{\log x}{n}\right)}}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-102}:\\ \;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-146}:\\ \;\;\;\;\frac{1}{n \cdot x + n \cdot 0.5}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-9}:\\ \;\;\;\;\frac{1}{-n} \cdot \log \left(\frac{x}{1 + x}\right)\\ \mathbf{else}:\\ \;\;\;\;e^{\frac{x}{n}} - {x}^{\left(\frac{1}{n}\right)}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= (/ 1.0 n) -1e-19)
   (/ (pow E (/ (log x) n)) (* n x))
   (if (<= (/ 1.0 n) -1e-102)
     (/ (- (log1p x) (log x)) n)
     (if (<= (/ 1.0 n) -2e-146)
       (/ 1.0 (+ (* n x) (* n 0.5)))
       (if (<= (/ 1.0 n) 2e-9)
         (* (/ 1.0 (- n)) (log (/ x (+ 1.0 x))))
         (- (exp (/ x n)) (pow x (/ 1.0 n))))))))
double code(double x, double n) {
	double tmp;
	if ((1.0 / n) <= -1e-19) {
		tmp = pow(((double) M_E), (log(x) / n)) / (n * x);
	} else if ((1.0 / n) <= -1e-102) {
		tmp = (log1p(x) - log(x)) / n;
	} else if ((1.0 / n) <= -2e-146) {
		tmp = 1.0 / ((n * x) + (n * 0.5));
	} else if ((1.0 / n) <= 2e-9) {
		tmp = (1.0 / -n) * log((x / (1.0 + x)));
	} else {
		tmp = exp((x / n)) - pow(x, (1.0 / n));
	}
	return tmp;
}
public static double code(double x, double n) {
	double tmp;
	if ((1.0 / n) <= -1e-19) {
		tmp = Math.pow(Math.E, (Math.log(x) / n)) / (n * x);
	} else if ((1.0 / n) <= -1e-102) {
		tmp = (Math.log1p(x) - Math.log(x)) / n;
	} else if ((1.0 / n) <= -2e-146) {
		tmp = 1.0 / ((n * x) + (n * 0.5));
	} else if ((1.0 / n) <= 2e-9) {
		tmp = (1.0 / -n) * Math.log((x / (1.0 + x)));
	} else {
		tmp = Math.exp((x / n)) - Math.pow(x, (1.0 / n));
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if (1.0 / n) <= -1e-19:
		tmp = math.pow(math.e, (math.log(x) / n)) / (n * x)
	elif (1.0 / n) <= -1e-102:
		tmp = (math.log1p(x) - math.log(x)) / n
	elif (1.0 / n) <= -2e-146:
		tmp = 1.0 / ((n * x) + (n * 0.5))
	elif (1.0 / n) <= 2e-9:
		tmp = (1.0 / -n) * math.log((x / (1.0 + x)))
	else:
		tmp = math.exp((x / n)) - math.pow(x, (1.0 / n))
	return tmp
function code(x, n)
	tmp = 0.0
	if (Float64(1.0 / n) <= -1e-19)
		tmp = Float64((exp(1) ^ Float64(log(x) / n)) / Float64(n * x));
	elseif (Float64(1.0 / n) <= -1e-102)
		tmp = Float64(Float64(log1p(x) - log(x)) / n);
	elseif (Float64(1.0 / n) <= -2e-146)
		tmp = Float64(1.0 / Float64(Float64(n * x) + Float64(n * 0.5)));
	elseif (Float64(1.0 / n) <= 2e-9)
		tmp = Float64(Float64(1.0 / Float64(-n)) * log(Float64(x / Float64(1.0 + x))));
	else
		tmp = Float64(exp(Float64(x / n)) - (x ^ Float64(1.0 / n)));
	end
	return tmp
end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-19], N[(N[Power[E, N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-102], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-146], N[(1.0 / N[(N[(n * x), $MachinePrecision] + N[(n * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-9], N[(N[(1.0 / (-n)), $MachinePrecision] * N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $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}\;\frac{1}{n} \leq -1 \cdot 10^{-19}:\\
\;\;\;\;\frac{{e}^{\left(\frac{\log x}{n}\right)}}{n \cdot x}\\

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

\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-146}:\\
\;\;\;\;\frac{1}{n \cdot x + n \cdot 0.5}\\

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

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


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

    1. Initial program 92.5%

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

      \[\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-neg97.1%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    5. Step-by-step derivation
      1. *-un-lft-identity97.1%

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

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

      \[\leadsto \frac{\color{blue}{{\left(e^{1}\right)}^{\left(\frac{\log x}{n}\right)}}}{x \cdot n} \]
    7. Step-by-step derivation
      1. exp-1-e97.2%

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

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

    if -9.9999999999999998e-20 < (/.f64 1 n) < -9.99999999999999933e-103

    1. Initial program 8.6%

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

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

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

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

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

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

    if -9.99999999999999933e-103 < (/.f64 1 n) < -2.00000000000000005e-146

    1. Initial program 28.4%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Step-by-step derivation
      1. clear-num46.6%

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

        \[\leadsto \color{blue}{{\left(\frac{n}{\mathsf{log1p}\left(x\right) - \log x}\right)}^{-1}} \]
    6. Applied egg-rr46.6%

      \[\leadsto \color{blue}{{\left(\frac{n}{\mathsf{log1p}\left(x\right) - \log x}\right)}^{-1}} \]
    7. Step-by-step derivation
      1. unpow-146.6%

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

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

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

    if -2.00000000000000005e-146 < (/.f64 1 n) < 2.00000000000000012e-9

    1. Initial program 34.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{\frac{-n}{-\left(\mathsf{log1p}\left(x\right) - \log x\right)}}} \]
      6. associate-/r/87.4%

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

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

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

        \[\leadsto \frac{1}{-n} \cdot \left(-\color{blue}{\log \left(\frac{x + 1}{x}\right)}\right) \]
      10. neg-log87.5%

        \[\leadsto \frac{1}{-n} \cdot \color{blue}{\log \left(\frac{1}{\frac{x + 1}{x}}\right)} \]
      11. clear-num87.7%

        \[\leadsto \frac{1}{-n} \cdot \log \color{blue}{\left(\frac{x}{x + 1}\right)} \]
    8. Applied egg-rr87.7%

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

    if 2.00000000000000012e-9 < (/.f64 1 n)

    1. Initial program 61.2%

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

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

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

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

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

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

Alternative 5: 81.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 -1 \cdot 10^{-19}:\\ \;\;\;\;t_0 \cdot \frac{1}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-102}:\\ \;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-146}:\\ \;\;\;\;\frac{1}{n \cdot x + n \cdot 0.5}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-9}:\\ \;\;\;\;\frac{1}{-n} \cdot \log \left(\frac{x}{1 + x}\right)\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+185}:\\ \;\;\;\;\left|1 - t_0\right|\\ \mathbf{else}:\\ \;\;\;\;\sqrt{{\left(n \cdot x\right)}^{-2}}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (pow x (/ 1.0 n))))
   (if (<= (/ 1.0 n) -1e-19)
     (* t_0 (/ 1.0 (* n x)))
     (if (<= (/ 1.0 n) -1e-102)
       (/ (- (log1p x) (log x)) n)
       (if (<= (/ 1.0 n) -2e-146)
         (/ 1.0 (+ (* n x) (* n 0.5)))
         (if (<= (/ 1.0 n) 2e-9)
           (* (/ 1.0 (- n)) (log (/ x (+ 1.0 x))))
           (if (<= (/ 1.0 n) 5e+185)
             (fabs (- 1.0 t_0))
             (sqrt (pow (* n x) -2.0)))))))))
double code(double x, double n) {
	double t_0 = pow(x, (1.0 / n));
	double tmp;
	if ((1.0 / n) <= -1e-19) {
		tmp = t_0 * (1.0 / (n * x));
	} else if ((1.0 / n) <= -1e-102) {
		tmp = (log1p(x) - log(x)) / n;
	} else if ((1.0 / n) <= -2e-146) {
		tmp = 1.0 / ((n * x) + (n * 0.5));
	} else if ((1.0 / n) <= 2e-9) {
		tmp = (1.0 / -n) * log((x / (1.0 + x)));
	} else if ((1.0 / n) <= 5e+185) {
		tmp = fabs((1.0 - t_0));
	} else {
		tmp = sqrt(pow((n * x), -2.0));
	}
	return tmp;
}
public static double code(double x, double n) {
	double t_0 = Math.pow(x, (1.0 / n));
	double tmp;
	if ((1.0 / n) <= -1e-19) {
		tmp = t_0 * (1.0 / (n * x));
	} else if ((1.0 / n) <= -1e-102) {
		tmp = (Math.log1p(x) - Math.log(x)) / n;
	} else if ((1.0 / n) <= -2e-146) {
		tmp = 1.0 / ((n * x) + (n * 0.5));
	} else if ((1.0 / n) <= 2e-9) {
		tmp = (1.0 / -n) * Math.log((x / (1.0 + x)));
	} else if ((1.0 / n) <= 5e+185) {
		tmp = Math.abs((1.0 - t_0));
	} else {
		tmp = Math.sqrt(Math.pow((n * x), -2.0));
	}
	return tmp;
}
def code(x, n):
	t_0 = math.pow(x, (1.0 / n))
	tmp = 0
	if (1.0 / n) <= -1e-19:
		tmp = t_0 * (1.0 / (n * x))
	elif (1.0 / n) <= -1e-102:
		tmp = (math.log1p(x) - math.log(x)) / n
	elif (1.0 / n) <= -2e-146:
		tmp = 1.0 / ((n * x) + (n * 0.5))
	elif (1.0 / n) <= 2e-9:
		tmp = (1.0 / -n) * math.log((x / (1.0 + x)))
	elif (1.0 / n) <= 5e+185:
		tmp = math.fabs((1.0 - t_0))
	else:
		tmp = math.sqrt(math.pow((n * x), -2.0))
	return tmp
function code(x, n)
	t_0 = x ^ Float64(1.0 / n)
	tmp = 0.0
	if (Float64(1.0 / n) <= -1e-19)
		tmp = Float64(t_0 * Float64(1.0 / Float64(n * x)));
	elseif (Float64(1.0 / n) <= -1e-102)
		tmp = Float64(Float64(log1p(x) - log(x)) / n);
	elseif (Float64(1.0 / n) <= -2e-146)
		tmp = Float64(1.0 / Float64(Float64(n * x) + Float64(n * 0.5)));
	elseif (Float64(1.0 / n) <= 2e-9)
		tmp = Float64(Float64(1.0 / Float64(-n)) * log(Float64(x / Float64(1.0 + x))));
	elseif (Float64(1.0 / n) <= 5e+185)
		tmp = abs(Float64(1.0 - t_0));
	else
		tmp = sqrt((Float64(n * x) ^ -2.0));
	end
	return tmp
end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-19], N[(t$95$0 * N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-102], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-146], N[(1.0 / N[(N[(n * x), $MachinePrecision] + N[(n * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-9], N[(N[(1.0 / (-n)), $MachinePrecision] * N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+185], N[Abs[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision], N[Sqrt[N[Power[N[(n * x), $MachinePrecision], -2.0], $MachinePrecision]], $MachinePrecision]]]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-146}:\\
\;\;\;\;\frac{1}{n \cdot x + n \cdot 0.5}\\

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

\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+185}:\\
\;\;\;\;\left|1 - t_0\right|\\

\mathbf{else}:\\
\;\;\;\;\sqrt{{\left(n \cdot x\right)}^{-2}}\\


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

    1. Initial program 92.5%

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

      \[\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-neg97.1%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    5. Step-by-step derivation
      1. div-inv97.2%

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

        \[\leadsto e^{\color{blue}{\log x \cdot \frac{1}{n}}} \cdot \frac{1}{x \cdot n} \]
      3. pow-to-exp97.2%

        \[\leadsto \color{blue}{{x}^{\left(\frac{1}{n}\right)}} \cdot \frac{1}{x \cdot n} \]
    6. Applied egg-rr97.2%

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

    if -9.9999999999999998e-20 < (/.f64 1 n) < -9.99999999999999933e-103

    1. Initial program 8.6%

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

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

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

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

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

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

    if -9.99999999999999933e-103 < (/.f64 1 n) < -2.00000000000000005e-146

    1. Initial program 28.4%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Step-by-step derivation
      1. clear-num46.6%

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

        \[\leadsto \color{blue}{{\left(\frac{n}{\mathsf{log1p}\left(x\right) - \log x}\right)}^{-1}} \]
    6. Applied egg-rr46.6%

      \[\leadsto \color{blue}{{\left(\frac{n}{\mathsf{log1p}\left(x\right) - \log x}\right)}^{-1}} \]
    7. Step-by-step derivation
      1. unpow-146.6%

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

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

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

    if -2.00000000000000005e-146 < (/.f64 1 n) < 2.00000000000000012e-9

    1. Initial program 34.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{\frac{-n}{-\left(\mathsf{log1p}\left(x\right) - \log x\right)}}} \]
      6. associate-/r/87.4%

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

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

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

        \[\leadsto \frac{1}{-n} \cdot \left(-\color{blue}{\log \left(\frac{x + 1}{x}\right)}\right) \]
      10. neg-log87.5%

        \[\leadsto \frac{1}{-n} \cdot \color{blue}{\log \left(\frac{1}{\frac{x + 1}{x}}\right)} \]
      11. clear-num87.7%

        \[\leadsto \frac{1}{-n} \cdot \log \color{blue}{\left(\frac{x}{x + 1}\right)} \]
    8. Applied egg-rr87.7%

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

    if 2.00000000000000012e-9 < (/.f64 1 n) < 4.9999999999999999e185

    1. Initial program 74.3%

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

      \[\leadsto \color{blue}{1} - {x}^{\left(\frac{1}{n}\right)} \]
    3. Step-by-step derivation
      1. add-sqr-sqrt66.3%

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

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

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

      \[\leadsto \color{blue}{\sqrt{{\left(1 - {x}^{\left(\frac{1}{n}\right)}\right)}^{2}}} \]
    5. Step-by-step derivation
      1. unpow274.4%

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

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

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

    if 4.9999999999999999e185 < (/.f64 1 n)

    1. Initial program 24.7%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{x \cdot n}} \]
    8. Step-by-step derivation
      1. add-sqr-sqrt59.1%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{x \cdot n}} \cdot \sqrt{\frac{1}{x \cdot n}}} \]
      2. sqrt-unprod89.2%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{x \cdot n} \cdot \frac{1}{x \cdot n}}} \]
      3. inv-pow89.2%

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

        \[\leadsto \sqrt{{\left(x \cdot n\right)}^{-1} \cdot \color{blue}{{\left(x \cdot n\right)}^{-1}}} \]
      5. pow-prod-up89.2%

        \[\leadsto \sqrt{\color{blue}{{\left(x \cdot n\right)}^{\left(-1 + -1\right)}}} \]
      6. metadata-eval89.2%

        \[\leadsto \sqrt{{\left(x \cdot n\right)}^{\color{blue}{-2}}} \]
    9. Applied egg-rr89.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-19}:\\ \;\;\;\;{x}^{\left(\frac{1}{n}\right)} \cdot \frac{1}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-102}:\\ \;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-146}:\\ \;\;\;\;\frac{1}{n \cdot x + n \cdot 0.5}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-9}:\\ \;\;\;\;\frac{1}{-n} \cdot \log \left(\frac{x}{1 + x}\right)\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+185}:\\ \;\;\;\;\left|1 - {x}^{\left(\frac{1}{n}\right)}\right|\\ \mathbf{else}:\\ \;\;\;\;\sqrt{{\left(n \cdot x\right)}^{-2}}\\ \end{array} \]

Alternative 6: 81.7% accurate, 0.9× speedup?

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-146}:\\
\;\;\;\;\frac{1}{n \cdot x + n \cdot 0.5}\\

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

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

\mathbf{else}:\\
\;\;\;\;\sqrt{{\left(n \cdot x\right)}^{-2}}\\


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

    1. Initial program 92.5%

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

      \[\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-neg97.1%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    5. Step-by-step derivation
      1. div-inv97.2%

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

        \[\leadsto e^{\color{blue}{\log x \cdot \frac{1}{n}}} \cdot \frac{1}{x \cdot n} \]
      3. pow-to-exp97.2%

        \[\leadsto \color{blue}{{x}^{\left(\frac{1}{n}\right)}} \cdot \frac{1}{x \cdot n} \]
    6. Applied egg-rr97.2%

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

    if -9.9999999999999998e-20 < (/.f64 1 n) < -9.99999999999999933e-103

    1. Initial program 8.6%

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

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

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

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

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

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

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

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

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

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

    if -9.99999999999999933e-103 < (/.f64 1 n) < -2.00000000000000005e-146

    1. Initial program 28.4%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Step-by-step derivation
      1. clear-num46.6%

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

        \[\leadsto \color{blue}{{\left(\frac{n}{\mathsf{log1p}\left(x\right) - \log x}\right)}^{-1}} \]
    6. Applied egg-rr46.6%

      \[\leadsto \color{blue}{{\left(\frac{n}{\mathsf{log1p}\left(x\right) - \log x}\right)}^{-1}} \]
    7. Step-by-step derivation
      1. unpow-146.6%

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

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

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

    if -2.00000000000000005e-146 < (/.f64 1 n) < 2.00000000000000012e-9

    1. Initial program 34.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{\frac{-n}{-\left(\mathsf{log1p}\left(x\right) - \log x\right)}}} \]
      6. associate-/r/87.4%

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

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

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

        \[\leadsto \frac{1}{-n} \cdot \left(-\color{blue}{\log \left(\frac{x + 1}{x}\right)}\right) \]
      10. neg-log87.5%

        \[\leadsto \frac{1}{-n} \cdot \color{blue}{\log \left(\frac{1}{\frac{x + 1}{x}}\right)} \]
      11. clear-num87.7%

        \[\leadsto \frac{1}{-n} \cdot \log \color{blue}{\left(\frac{x}{x + 1}\right)} \]
    8. Applied egg-rr87.7%

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

    if 2.00000000000000012e-9 < (/.f64 1 n) < 4.9999999999999999e185

    1. Initial program 74.3%

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

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

    if 4.9999999999999999e185 < (/.f64 1 n)

    1. Initial program 24.7%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{x \cdot n}} \]
    8. Step-by-step derivation
      1. add-sqr-sqrt59.1%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{x \cdot n}} \cdot \sqrt{\frac{1}{x \cdot n}}} \]
      2. sqrt-unprod89.2%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{x \cdot n} \cdot \frac{1}{x \cdot n}}} \]
      3. inv-pow89.2%

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

        \[\leadsto \sqrt{{\left(x \cdot n\right)}^{-1} \cdot \color{blue}{{\left(x \cdot n\right)}^{-1}}} \]
      5. pow-prod-up89.2%

        \[\leadsto \sqrt{\color{blue}{{\left(x \cdot n\right)}^{\left(-1 + -1\right)}}} \]
      6. metadata-eval89.2%

        \[\leadsto \sqrt{{\left(x \cdot n\right)}^{\color{blue}{-2}}} \]
    9. Applied egg-rr89.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-19}:\\ \;\;\;\;{x}^{\left(\frac{1}{n}\right)} \cdot \frac{1}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-102}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-146}:\\ \;\;\;\;\frac{1}{n \cdot x + n \cdot 0.5}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-9}:\\ \;\;\;\;\frac{1}{-n} \cdot \log \left(\frac{x}{1 + x}\right)\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+185}:\\ \;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{{\left(n \cdot x\right)}^{-2}}\\ \end{array} \]

Alternative 7: 81.7% accurate, 0.9× speedup?

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-146}:\\
\;\;\;\;\frac{1}{n \cdot x + n \cdot 0.5}\\

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

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

\mathbf{else}:\\
\;\;\;\;\sqrt{{\left(n \cdot x\right)}^{-2}}\\


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

    1. Initial program 92.5%

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

      \[\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-neg97.1%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    5. Step-by-step derivation
      1. div-inv97.2%

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

        \[\leadsto e^{\color{blue}{\log x \cdot \frac{1}{n}}} \cdot \frac{1}{x \cdot n} \]
      3. pow-to-exp97.2%

        \[\leadsto \color{blue}{{x}^{\left(\frac{1}{n}\right)}} \cdot \frac{1}{x \cdot n} \]
    6. Applied egg-rr97.2%

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

    if -9.9999999999999998e-20 < (/.f64 1 n) < -9.99999999999999933e-103

    1. Initial program 8.6%

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

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

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

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

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

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

    if -9.99999999999999933e-103 < (/.f64 1 n) < -2.00000000000000005e-146

    1. Initial program 28.4%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Step-by-step derivation
      1. clear-num46.6%

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

        \[\leadsto \color{blue}{{\left(\frac{n}{\mathsf{log1p}\left(x\right) - \log x}\right)}^{-1}} \]
    6. Applied egg-rr46.6%

      \[\leadsto \color{blue}{{\left(\frac{n}{\mathsf{log1p}\left(x\right) - \log x}\right)}^{-1}} \]
    7. Step-by-step derivation
      1. unpow-146.6%

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

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

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

    if -2.00000000000000005e-146 < (/.f64 1 n) < 2.00000000000000012e-9

    1. Initial program 34.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{\frac{-n}{-\left(\mathsf{log1p}\left(x\right) - \log x\right)}}} \]
      6. associate-/r/87.4%

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

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

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

        \[\leadsto \frac{1}{-n} \cdot \left(-\color{blue}{\log \left(\frac{x + 1}{x}\right)}\right) \]
      10. neg-log87.5%

        \[\leadsto \frac{1}{-n} \cdot \color{blue}{\log \left(\frac{1}{\frac{x + 1}{x}}\right)} \]
      11. clear-num87.7%

        \[\leadsto \frac{1}{-n} \cdot \log \color{blue}{\left(\frac{x}{x + 1}\right)} \]
    8. Applied egg-rr87.7%

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

    if 2.00000000000000012e-9 < (/.f64 1 n) < 4.9999999999999999e185

    1. Initial program 74.3%

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

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

    if 4.9999999999999999e185 < (/.f64 1 n)

    1. Initial program 24.7%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{x \cdot n}} \]
    8. Step-by-step derivation
      1. add-sqr-sqrt59.1%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{x \cdot n}} \cdot \sqrt{\frac{1}{x \cdot n}}} \]
      2. sqrt-unprod89.2%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{x \cdot n} \cdot \frac{1}{x \cdot n}}} \]
      3. inv-pow89.2%

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

        \[\leadsto \sqrt{{\left(x \cdot n\right)}^{-1} \cdot \color{blue}{{\left(x \cdot n\right)}^{-1}}} \]
      5. pow-prod-up89.2%

        \[\leadsto \sqrt{\color{blue}{{\left(x \cdot n\right)}^{\left(-1 + -1\right)}}} \]
      6. metadata-eval89.2%

        \[\leadsto \sqrt{{\left(x \cdot n\right)}^{\color{blue}{-2}}} \]
    9. Applied egg-rr89.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-19}:\\ \;\;\;\;{x}^{\left(\frac{1}{n}\right)} \cdot \frac{1}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-102}:\\ \;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-146}:\\ \;\;\;\;\frac{1}{n \cdot x + n \cdot 0.5}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-9}:\\ \;\;\;\;\frac{1}{-n} \cdot \log \left(\frac{x}{1 + x}\right)\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+185}:\\ \;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{{\left(n \cdot x\right)}^{-2}}\\ \end{array} \]

Alternative 8: 85.4% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-19}:\\ \;\;\;\;t_0 \cdot \frac{1}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-102}:\\ \;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-146}:\\ \;\;\;\;\frac{1}{n \cdot x + n \cdot 0.5}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-9}:\\ \;\;\;\;\frac{1}{-n} \cdot \log \left(\frac{x}{1 + 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) -1e-19)
     (* t_0 (/ 1.0 (* n x)))
     (if (<= (/ 1.0 n) -1e-102)
       (/ (- (log1p x) (log x)) n)
       (if (<= (/ 1.0 n) -2e-146)
         (/ 1.0 (+ (* n x) (* n 0.5)))
         (if (<= (/ 1.0 n) 2e-9)
           (* (/ 1.0 (- n)) (log (/ x (+ 1.0 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) <= -1e-19) {
		tmp = t_0 * (1.0 / (n * x));
	} else if ((1.0 / n) <= -1e-102) {
		tmp = (log1p(x) - log(x)) / n;
	} else if ((1.0 / n) <= -2e-146) {
		tmp = 1.0 / ((n * x) + (n * 0.5));
	} else if ((1.0 / n) <= 2e-9) {
		tmp = (1.0 / -n) * log((x / (1.0 + 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) <= -1e-19) {
		tmp = t_0 * (1.0 / (n * x));
	} else if ((1.0 / n) <= -1e-102) {
		tmp = (Math.log1p(x) - Math.log(x)) / n;
	} else if ((1.0 / n) <= -2e-146) {
		tmp = 1.0 / ((n * x) + (n * 0.5));
	} else if ((1.0 / n) <= 2e-9) {
		tmp = (1.0 / -n) * Math.log((x / (1.0 + 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) <= -1e-19:
		tmp = t_0 * (1.0 / (n * x))
	elif (1.0 / n) <= -1e-102:
		tmp = (math.log1p(x) - math.log(x)) / n
	elif (1.0 / n) <= -2e-146:
		tmp = 1.0 / ((n * x) + (n * 0.5))
	elif (1.0 / n) <= 2e-9:
		tmp = (1.0 / -n) * math.log((x / (1.0 + 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) <= -1e-19)
		tmp = Float64(t_0 * Float64(1.0 / Float64(n * x)));
	elseif (Float64(1.0 / n) <= -1e-102)
		tmp = Float64(Float64(log1p(x) - log(x)) / n);
	elseif (Float64(1.0 / n) <= -2e-146)
		tmp = Float64(1.0 / Float64(Float64(n * x) + Float64(n * 0.5)));
	elseif (Float64(1.0 / n) <= 2e-9)
		tmp = Float64(Float64(1.0 / Float64(-n)) * log(Float64(x / Float64(1.0 + 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], -1e-19], N[(t$95$0 * N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-102], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-146], N[(1.0 / N[(N[(n * x), $MachinePrecision] + N[(n * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-9], N[(N[(1.0 / (-n)), $MachinePrecision] * N[Log[N[(x / N[(1.0 + 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 -1 \cdot 10^{-19}:\\
\;\;\;\;t_0 \cdot \frac{1}{n \cdot x}\\

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

\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-146}:\\
\;\;\;\;\frac{1}{n \cdot x + n \cdot 0.5}\\

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

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


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

    1. Initial program 92.5%

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

      \[\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-neg97.1%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    5. Step-by-step derivation
      1. div-inv97.2%

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

        \[\leadsto e^{\color{blue}{\log x \cdot \frac{1}{n}}} \cdot \frac{1}{x \cdot n} \]
      3. pow-to-exp97.2%

        \[\leadsto \color{blue}{{x}^{\left(\frac{1}{n}\right)}} \cdot \frac{1}{x \cdot n} \]
    6. Applied egg-rr97.2%

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

    if -9.9999999999999998e-20 < (/.f64 1 n) < -9.99999999999999933e-103

    1. Initial program 8.6%

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

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

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

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

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

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

    if -9.99999999999999933e-103 < (/.f64 1 n) < -2.00000000000000005e-146

    1. Initial program 28.4%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Step-by-step derivation
      1. clear-num46.6%

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

        \[\leadsto \color{blue}{{\left(\frac{n}{\mathsf{log1p}\left(x\right) - \log x}\right)}^{-1}} \]
    6. Applied egg-rr46.6%

      \[\leadsto \color{blue}{{\left(\frac{n}{\mathsf{log1p}\left(x\right) - \log x}\right)}^{-1}} \]
    7. Step-by-step derivation
      1. unpow-146.6%

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

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

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

    if -2.00000000000000005e-146 < (/.f64 1 n) < 2.00000000000000012e-9

    1. Initial program 34.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{\frac{-n}{-\left(\mathsf{log1p}\left(x\right) - \log x\right)}}} \]
      6. associate-/r/87.4%

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

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

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

        \[\leadsto \frac{1}{-n} \cdot \left(-\color{blue}{\log \left(\frac{x + 1}{x}\right)}\right) \]
      10. neg-log87.5%

        \[\leadsto \frac{1}{-n} \cdot \color{blue}{\log \left(\frac{1}{\frac{x + 1}{x}}\right)} \]
      11. clear-num87.7%

        \[\leadsto \frac{1}{-n} \cdot \log \color{blue}{\left(\frac{x}{x + 1}\right)} \]
    8. Applied egg-rr87.7%

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

    if 2.00000000000000012e-9 < (/.f64 1 n)

    1. Initial program 61.2%

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

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

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

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

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

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

Alternative 9: 66.9% accurate, 1.7× speedup?

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-146}:\\
\;\;\;\;\frac{1}{n \cdot x + n \cdot 0.5}\\

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

\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+185}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (/.f64 1 n) < -2e-3 or 2.00000000000000012e-9 < (/.f64 1 n) < 4.9999999999999999e185

    1. Initial program 91.8%

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

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

    if -2e-3 < (/.f64 1 n) < -9.99999999999999933e-103 or -2.00000000000000005e-146 < (/.f64 1 n) < 2.00000000000000012e-9

    1. Initial program 30.2%

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

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

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

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

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

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

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

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

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

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

    if -9.99999999999999933e-103 < (/.f64 1 n) < -2.00000000000000005e-146

    1. Initial program 28.4%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Step-by-step derivation
      1. clear-num46.6%

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

        \[\leadsto \color{blue}{{\left(\frac{n}{\mathsf{log1p}\left(x\right) - \log x}\right)}^{-1}} \]
    6. Applied egg-rr46.6%

      \[\leadsto \color{blue}{{\left(\frac{n}{\mathsf{log1p}\left(x\right) - \log x}\right)}^{-1}} \]
    7. Step-by-step derivation
      1. unpow-146.6%

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

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

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

    if 4.9999999999999999e185 < (/.f64 1 n)

    1. Initial program 24.7%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -0.002:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-102}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-146}:\\ \;\;\;\;\frac{1}{n \cdot x + n \cdot 0.5}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-9}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+185}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \end{array} \]

Alternative 10: 80.6% accurate, 1.7× speedup?

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-146}:\\
\;\;\;\;\frac{1}{n \cdot x + n \cdot 0.5}\\

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

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

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


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

    1. Initial program 92.5%

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

      \[\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-neg97.1%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{e^{\color{blue}{\log x \cdot \frac{1}{n}}}}{x \cdot n} \]
      2. pow-to-exp97.2%

        \[\leadsto \frac{\color{blue}{{x}^{\left(\frac{1}{n}\right)}}}{x \cdot n} \]
      3. *-un-lft-identity97.2%

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

        \[\leadsto \color{blue}{\frac{1}{x} \cdot \frac{{x}^{\left(\frac{1}{n}\right)}}{n}} \]
    6. Applied egg-rr97.2%

      \[\leadsto \color{blue}{\frac{1}{x} \cdot \frac{{x}^{\left(\frac{1}{n}\right)}}{n}} \]
    7. Step-by-step derivation
      1. times-frac97.2%

        \[\leadsto \color{blue}{\frac{1 \cdot {x}^{\left(\frac{1}{n}\right)}}{x \cdot n}} \]
      2. *-lft-identity97.2%

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

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

    if -9.9999999999999998e-20 < (/.f64 1 n) < -9.99999999999999933e-103 or -2.00000000000000005e-146 < (/.f64 1 n) < 2.00000000000000012e-9

    1. Initial program 30.9%

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

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

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

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

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

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

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

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

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

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

    if -9.99999999999999933e-103 < (/.f64 1 n) < -2.00000000000000005e-146

    1. Initial program 28.4%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Step-by-step derivation
      1. clear-num46.6%

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

        \[\leadsto \color{blue}{{\left(\frac{n}{\mathsf{log1p}\left(x\right) - \log x}\right)}^{-1}} \]
    6. Applied egg-rr46.6%

      \[\leadsto \color{blue}{{\left(\frac{n}{\mathsf{log1p}\left(x\right) - \log x}\right)}^{-1}} \]
    7. Step-by-step derivation
      1. unpow-146.6%

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

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

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

    if 2.00000000000000012e-9 < (/.f64 1 n) < 4.9999999999999999e185

    1. Initial program 74.3%

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

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

    if 4.9999999999999999e185 < (/.f64 1 n)

    1. Initial program 24.7%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-19}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-102}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-146}:\\ \;\;\;\;\frac{1}{n \cdot x + n \cdot 0.5}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-9}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+185}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \end{array} \]

Alternative 11: 80.5% accurate, 1.7× speedup?

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-146}:\\
\;\;\;\;\frac{1}{n \cdot x + n \cdot 0.5}\\

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

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

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


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

    1. Initial program 92.5%

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

      \[\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-neg97.1%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{e^{\color{blue}{\log x \cdot \frac{1}{n}}}}{x \cdot n} \]
      2. pow-to-exp97.2%

        \[\leadsto \frac{\color{blue}{{x}^{\left(\frac{1}{n}\right)}}}{x \cdot n} \]
      3. *-un-lft-identity97.2%

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

        \[\leadsto \color{blue}{\frac{1}{x} \cdot \frac{{x}^{\left(\frac{1}{n}\right)}}{n}} \]
    6. Applied egg-rr97.2%

      \[\leadsto \color{blue}{\frac{1}{x} \cdot \frac{{x}^{\left(\frac{1}{n}\right)}}{n}} \]
    7. Step-by-step derivation
      1. times-frac97.2%

        \[\leadsto \color{blue}{\frac{1 \cdot {x}^{\left(\frac{1}{n}\right)}}{x \cdot n}} \]
      2. *-lft-identity97.2%

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

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

    if -9.9999999999999998e-20 < (/.f64 1 n) < -9.99999999999999933e-103

    1. Initial program 8.6%

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

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

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

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

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

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

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

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

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

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

    if -9.99999999999999933e-103 < (/.f64 1 n) < -2.00000000000000005e-146

    1. Initial program 28.4%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Step-by-step derivation
      1. clear-num46.6%

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

        \[\leadsto \color{blue}{{\left(\frac{n}{\mathsf{log1p}\left(x\right) - \log x}\right)}^{-1}} \]
    6. Applied egg-rr46.6%

      \[\leadsto \color{blue}{{\left(\frac{n}{\mathsf{log1p}\left(x\right) - \log x}\right)}^{-1}} \]
    7. Step-by-step derivation
      1. unpow-146.6%

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

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

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

    if -2.00000000000000005e-146 < (/.f64 1 n) < 2.00000000000000012e-9

    1. Initial program 34.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{\frac{-n}{-\left(\mathsf{log1p}\left(x\right) - \log x\right)}}} \]
      6. associate-/r/87.4%

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

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

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

        \[\leadsto \frac{1}{-n} \cdot \left(-\color{blue}{\log \left(\frac{x + 1}{x}\right)}\right) \]
      10. neg-log87.5%

        \[\leadsto \frac{1}{-n} \cdot \color{blue}{\log \left(\frac{1}{\frac{x + 1}{x}}\right)} \]
      11. clear-num87.7%

        \[\leadsto \frac{1}{-n} \cdot \log \color{blue}{\left(\frac{x}{x + 1}\right)} \]
    8. Applied egg-rr87.7%

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

    if 2.00000000000000012e-9 < (/.f64 1 n) < 4.9999999999999999e185

    1. Initial program 74.3%

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

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

    if 4.9999999999999999e185 < (/.f64 1 n)

    1. Initial program 24.7%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-19}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-102}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-146}:\\ \;\;\;\;\frac{1}{n \cdot x + n \cdot 0.5}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-9}:\\ \;\;\;\;\frac{1}{-n} \cdot \log \left(\frac{x}{1 + x}\right)\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+185}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \end{array} \]

Alternative 12: 80.5% accurate, 1.7× speedup?

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-146}:\\
\;\;\;\;\frac{1}{n \cdot x + n \cdot 0.5}\\

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

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

\mathbf{else}:\\
\;\;\;\;t_1\\


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

    1. Initial program 92.5%

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

      \[\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-neg97.1%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    5. Step-by-step derivation
      1. div-inv97.2%

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

        \[\leadsto e^{\color{blue}{\log x \cdot \frac{1}{n}}} \cdot \frac{1}{x \cdot n} \]
      3. pow-to-exp97.2%

        \[\leadsto \color{blue}{{x}^{\left(\frac{1}{n}\right)}} \cdot \frac{1}{x \cdot n} \]
    6. Applied egg-rr97.2%

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

    if -9.9999999999999998e-20 < (/.f64 1 n) < -9.99999999999999933e-103

    1. Initial program 8.6%

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

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

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

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

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

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

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

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

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

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

    if -9.99999999999999933e-103 < (/.f64 1 n) < -2.00000000000000005e-146

    1. Initial program 28.4%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Step-by-step derivation
      1. clear-num46.6%

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

        \[\leadsto \color{blue}{{\left(\frac{n}{\mathsf{log1p}\left(x\right) - \log x}\right)}^{-1}} \]
    6. Applied egg-rr46.6%

      \[\leadsto \color{blue}{{\left(\frac{n}{\mathsf{log1p}\left(x\right) - \log x}\right)}^{-1}} \]
    7. Step-by-step derivation
      1. unpow-146.6%

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

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

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

    if -2.00000000000000005e-146 < (/.f64 1 n) < 2.00000000000000012e-9

    1. Initial program 34.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{\frac{-n}{-\left(\mathsf{log1p}\left(x\right) - \log x\right)}}} \]
      6. associate-/r/87.4%

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

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

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

        \[\leadsto \frac{1}{-n} \cdot \left(-\color{blue}{\log \left(\frac{x + 1}{x}\right)}\right) \]
      10. neg-log87.5%

        \[\leadsto \frac{1}{-n} \cdot \color{blue}{\log \left(\frac{1}{\frac{x + 1}{x}}\right)} \]
      11. clear-num87.7%

        \[\leadsto \frac{1}{-n} \cdot \log \color{blue}{\left(\frac{x}{x + 1}\right)} \]
    8. Applied egg-rr87.7%

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

    if 2.00000000000000012e-9 < (/.f64 1 n) < 4.9999999999999999e185

    1. Initial program 74.3%

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

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

    if 4.9999999999999999e185 < (/.f64 1 n)

    1. Initial program 24.7%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-19}:\\ \;\;\;\;{x}^{\left(\frac{1}{n}\right)} \cdot \frac{1}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-102}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-146}:\\ \;\;\;\;\frac{1}{n \cdot x + n \cdot 0.5}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-9}:\\ \;\;\;\;\frac{1}{-n} \cdot \log \left(\frac{x}{1 + x}\right)\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+185}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \end{array} \]

Alternative 13: 78.5% accurate, 1.7× speedup?

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

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

\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-146}:\\
\;\;\;\;\frac{1}{n \cdot x + n \cdot 0.5}\\

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

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


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

    1. Initial program 92.5%

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

      \[\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-neg97.1%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    5. Step-by-step derivation
      1. div-inv97.2%

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

        \[\leadsto e^{\color{blue}{\log x \cdot \frac{1}{n}}} \cdot \frac{1}{x \cdot n} \]
      3. pow-to-exp97.2%

        \[\leadsto \color{blue}{{x}^{\left(\frac{1}{n}\right)}} \cdot \frac{1}{x \cdot n} \]
    6. Applied egg-rr97.2%

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

    if -9.9999999999999998e-20 < (/.f64 1 n) < -9.99999999999999933e-103

    1. Initial program 8.6%

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

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

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

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

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

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

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

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

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

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

    if -9.99999999999999933e-103 < (/.f64 1 n) < -2.00000000000000005e-146

    1. Initial program 28.4%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Step-by-step derivation
      1. clear-num46.6%

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

        \[\leadsto \color{blue}{{\left(\frac{n}{\mathsf{log1p}\left(x\right) - \log x}\right)}^{-1}} \]
    6. Applied egg-rr46.6%

      \[\leadsto \color{blue}{{\left(\frac{n}{\mathsf{log1p}\left(x\right) - \log x}\right)}^{-1}} \]
    7. Step-by-step derivation
      1. unpow-146.6%

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

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

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

    if -2.00000000000000005e-146 < (/.f64 1 n) < 2.00000000000000012e-9

    1. Initial program 34.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{\frac{-n}{-\left(\mathsf{log1p}\left(x\right) - \log x\right)}}} \]
      6. associate-/r/87.4%

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

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

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

        \[\leadsto \frac{1}{-n} \cdot \left(-\color{blue}{\log \left(\frac{x + 1}{x}\right)}\right) \]
      10. neg-log87.5%

        \[\leadsto \frac{1}{-n} \cdot \color{blue}{\log \left(\frac{1}{\frac{x + 1}{x}}\right)} \]
      11. clear-num87.7%

        \[\leadsto \frac{1}{-n} \cdot \log \color{blue}{\left(\frac{x}{x + 1}\right)} \]
    8. Applied egg-rr87.7%

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

    if 2.00000000000000012e-9 < (/.f64 1 n)

    1. Initial program 61.2%

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

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

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

Alternative 14: 59.6% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{-\log x}{n}\\ t_1 := 1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{if}\;x \leq 5.9 \cdot 10^{-248}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.85 \cdot 10^{-244}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2.8 \cdot 10^{-241}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{-221}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 4.4 \cdot 10^{-78}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 9.2 \cdot 10^{-51}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 0.52:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{elif}\;x \leq 9 \cdot 10^{+166}:\\ \;\;\;\;\frac{1}{-0.3333333333333333 \cdot \frac{n}{x} + \left(\left(n \cdot x + n \cdot 0.5\right) + \frac{n}{x} \cdot 0.25\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{0}{n}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (/ (- (log x)) n)) (t_1 (- 1.0 (pow x (/ 1.0 n)))))
   (if (<= x 5.9e-248)
     t_0
     (if (<= x 1.85e-244)
       t_1
       (if (<= x 2.8e-241)
         t_0
         (if (<= x 1.5e-221)
           t_1
           (if (<= x 4.4e-78)
             t_0
             (if (<= x 9.2e-51)
               t_1
               (if (<= x 0.52)
                 (/ (- x (log x)) n)
                 (if (<= x 9e+166)
                   (/
                    1.0
                    (+
                     (* -0.3333333333333333 (/ n x))
                     (+ (+ (* n x) (* n 0.5)) (* (/ n x) 0.25))))
                   (/ 0.0 n)))))))))))
double code(double x, double n) {
	double t_0 = -log(x) / n;
	double t_1 = 1.0 - pow(x, (1.0 / n));
	double tmp;
	if (x <= 5.9e-248) {
		tmp = t_0;
	} else if (x <= 1.85e-244) {
		tmp = t_1;
	} else if (x <= 2.8e-241) {
		tmp = t_0;
	} else if (x <= 1.5e-221) {
		tmp = t_1;
	} else if (x <= 4.4e-78) {
		tmp = t_0;
	} else if (x <= 9.2e-51) {
		tmp = t_1;
	} else if (x <= 0.52) {
		tmp = (x - log(x)) / n;
	} else if (x <= 9e+166) {
		tmp = 1.0 / ((-0.3333333333333333 * (n / x)) + (((n * x) + (n * 0.5)) + ((n / x) * 0.25)));
	} else {
		tmp = 0.0 / n;
	}
	return tmp;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = -log(x) / n
    t_1 = 1.0d0 - (x ** (1.0d0 / n))
    if (x <= 5.9d-248) then
        tmp = t_0
    else if (x <= 1.85d-244) then
        tmp = t_1
    else if (x <= 2.8d-241) then
        tmp = t_0
    else if (x <= 1.5d-221) then
        tmp = t_1
    else if (x <= 4.4d-78) then
        tmp = t_0
    else if (x <= 9.2d-51) then
        tmp = t_1
    else if (x <= 0.52d0) then
        tmp = (x - log(x)) / n
    else if (x <= 9d+166) then
        tmp = 1.0d0 / (((-0.3333333333333333d0) * (n / x)) + (((n * x) + (n * 0.5d0)) + ((n / x) * 0.25d0)))
    else
        tmp = 0.0d0 / n
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double t_0 = -Math.log(x) / n;
	double t_1 = 1.0 - Math.pow(x, (1.0 / n));
	double tmp;
	if (x <= 5.9e-248) {
		tmp = t_0;
	} else if (x <= 1.85e-244) {
		tmp = t_1;
	} else if (x <= 2.8e-241) {
		tmp = t_0;
	} else if (x <= 1.5e-221) {
		tmp = t_1;
	} else if (x <= 4.4e-78) {
		tmp = t_0;
	} else if (x <= 9.2e-51) {
		tmp = t_1;
	} else if (x <= 0.52) {
		tmp = (x - Math.log(x)) / n;
	} else if (x <= 9e+166) {
		tmp = 1.0 / ((-0.3333333333333333 * (n / x)) + (((n * x) + (n * 0.5)) + ((n / x) * 0.25)));
	} else {
		tmp = 0.0 / n;
	}
	return tmp;
}
def code(x, n):
	t_0 = -math.log(x) / n
	t_1 = 1.0 - math.pow(x, (1.0 / n))
	tmp = 0
	if x <= 5.9e-248:
		tmp = t_0
	elif x <= 1.85e-244:
		tmp = t_1
	elif x <= 2.8e-241:
		tmp = t_0
	elif x <= 1.5e-221:
		tmp = t_1
	elif x <= 4.4e-78:
		tmp = t_0
	elif x <= 9.2e-51:
		tmp = t_1
	elif x <= 0.52:
		tmp = (x - math.log(x)) / n
	elif x <= 9e+166:
		tmp = 1.0 / ((-0.3333333333333333 * (n / x)) + (((n * x) + (n * 0.5)) + ((n / x) * 0.25)))
	else:
		tmp = 0.0 / n
	return tmp
function code(x, n)
	t_0 = Float64(Float64(-log(x)) / n)
	t_1 = Float64(1.0 - (x ^ Float64(1.0 / n)))
	tmp = 0.0
	if (x <= 5.9e-248)
		tmp = t_0;
	elseif (x <= 1.85e-244)
		tmp = t_1;
	elseif (x <= 2.8e-241)
		tmp = t_0;
	elseif (x <= 1.5e-221)
		tmp = t_1;
	elseif (x <= 4.4e-78)
		tmp = t_0;
	elseif (x <= 9.2e-51)
		tmp = t_1;
	elseif (x <= 0.52)
		tmp = Float64(Float64(x - log(x)) / n);
	elseif (x <= 9e+166)
		tmp = Float64(1.0 / Float64(Float64(-0.3333333333333333 * Float64(n / x)) + Float64(Float64(Float64(n * x) + Float64(n * 0.5)) + Float64(Float64(n / x) * 0.25))));
	else
		tmp = Float64(0.0 / n);
	end
	return tmp
end
function tmp_2 = code(x, n)
	t_0 = -log(x) / n;
	t_1 = 1.0 - (x ^ (1.0 / n));
	tmp = 0.0;
	if (x <= 5.9e-248)
		tmp = t_0;
	elseif (x <= 1.85e-244)
		tmp = t_1;
	elseif (x <= 2.8e-241)
		tmp = t_0;
	elseif (x <= 1.5e-221)
		tmp = t_1;
	elseif (x <= 4.4e-78)
		tmp = t_0;
	elseif (x <= 9.2e-51)
		tmp = t_1;
	elseif (x <= 0.52)
		tmp = (x - log(x)) / n;
	elseif (x <= 9e+166)
		tmp = 1.0 / ((-0.3333333333333333 * (n / x)) + (((n * x) + (n * 0.5)) + ((n / x) * 0.25)));
	else
		tmp = 0.0 / n;
	end
	tmp_2 = tmp;
end
code[x_, n_] := Block[{t$95$0 = N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 5.9e-248], t$95$0, If[LessEqual[x, 1.85e-244], t$95$1, If[LessEqual[x, 2.8e-241], t$95$0, If[LessEqual[x, 1.5e-221], t$95$1, If[LessEqual[x, 4.4e-78], t$95$0, If[LessEqual[x, 9.2e-51], t$95$1, If[LessEqual[x, 0.52], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 9e+166], N[(1.0 / N[(N[(-0.3333333333333333 * N[(n / x), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(n * x), $MachinePrecision] + N[(n * 0.5), $MachinePrecision]), $MachinePrecision] + N[(N[(n / x), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.0 / n), $MachinePrecision]]]]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq 1.85 \cdot 10^{-244}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 2.8 \cdot 10^{-241}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 1.5 \cdot 10^{-221}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 4.4 \cdot 10^{-78}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 9.2 \cdot 10^{-51}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;x \leq 9 \cdot 10^{+166}:\\
\;\;\;\;\frac{1}{-0.3333333333333333 \cdot \frac{n}{x} + \left(\left(n \cdot x + n \cdot 0.5\right) + \frac{n}{x} \cdot 0.25\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if x < 5.89999999999999986e-248 or 1.8500000000000001e-244 < x < 2.7999999999999999e-241 or 1.5000000000000001e-221 < x < 4.3999999999999998e-78

    1. Initial program 29.8%

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

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

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

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

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

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

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

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

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

    if 5.89999999999999986e-248 < x < 1.8500000000000001e-244 or 2.7999999999999999e-241 < x < 1.5000000000000001e-221 or 4.3999999999999998e-78 < x < 9.20000000000000007e-51

    1. Initial program 86.3%

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

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

    if 9.20000000000000007e-51 < x < 0.52000000000000002

    1. Initial program 29.6%

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

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

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

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

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

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

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

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

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

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

    if 0.52000000000000002 < x < 9.00000000000000061e166

    1. Initial program 51.5%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{{\left(\frac{n}{\mathsf{log1p}\left(x\right) - \log x}\right)}^{-1}} \]
    6. Applied egg-rr53.1%

      \[\leadsto \color{blue}{{\left(\frac{n}{\mathsf{log1p}\left(x\right) - \log x}\right)}^{-1}} \]
    7. Step-by-step derivation
      1. unpow-153.1%

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

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

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

    if 9.00000000000000061e166 < x

    1. Initial program 84.7%

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\log \left(1 + x\right)} - \log x}{n} \]
      2. diff-log84.7%

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

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

      \[\leadsto \frac{\color{blue}{\log \left(\frac{x + 1}{x}\right)}}{n} \]
    7. Taylor expanded in x around inf 84.7%

      \[\leadsto \frac{\log \color{blue}{1}}{n} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification72.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 5.9 \cdot 10^{-248}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 1.85 \cdot 10^{-244}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 2.8 \cdot 10^{-241}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{-221}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 4.4 \cdot 10^{-78}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 9.2 \cdot 10^{-51}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 0.52:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{elif}\;x \leq 9 \cdot 10^{+166}:\\ \;\;\;\;\frac{1}{-0.3333333333333333 \cdot \frac{n}{x} + \left(\left(n \cdot x + n \cdot 0.5\right) + \frac{n}{x} \cdot 0.25\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{0}{n}\\ \end{array} \]

Alternative 15: 61.1% accurate, 2.0× speedup?

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

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

\mathbf{elif}\;x \leq 1.45 \cdot 10^{+167}:\\
\;\;\;\;\frac{1}{-0.3333333333333333 \cdot \frac{n}{x} + \left(\left(n \cdot x + n \cdot 0.5\right) + \frac{n}{x} \cdot 0.25\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\


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

    1. Initial program 40.8%

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

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

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

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

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

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

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

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

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

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

    if 0.52000000000000002 < x < 1.44999999999999987e167

    1. Initial program 51.5%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{{\left(\frac{n}{\mathsf{log1p}\left(x\right) - \log x}\right)}^{-1}} \]
    6. Applied egg-rr53.1%

      \[\leadsto \color{blue}{{\left(\frac{n}{\mathsf{log1p}\left(x\right) - \log x}\right)}^{-1}} \]
    7. Step-by-step derivation
      1. unpow-153.1%

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

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

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

    if 1.44999999999999987e167 < x

    1. Initial program 84.7%

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\log \left(1 + x\right)} - \log x}{n} \]
      2. diff-log84.7%

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

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

      \[\leadsto \frac{\color{blue}{\log \left(\frac{x + 1}{x}\right)}}{n} \]
    7. Taylor expanded in x around inf 84.7%

      \[\leadsto \frac{\log \color{blue}{1}}{n} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification65.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 0.52:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{elif}\;x \leq 1.45 \cdot 10^{+167}:\\ \;\;\;\;\frac{1}{-0.3333333333333333 \cdot \frac{n}{x} + \left(\left(n \cdot x + n \cdot 0.5\right) + \frac{n}{x} \cdot 0.25\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{0}{n}\\ \end{array} \]

Alternative 16: 60.8% accurate, 2.0× speedup?

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

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

\mathbf{elif}\;x \leq 2.2 \cdot 10^{+166}:\\
\;\;\;\;\frac{1}{-0.3333333333333333 \cdot \frac{n}{x} + \left(\left(n \cdot x + n \cdot 0.5\right) + \frac{n}{x} \cdot 0.25\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\


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

    1. Initial program 40.8%

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

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

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

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

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

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

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

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

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

    if 0.330000000000000016 < x < 2.1999999999999999e166

    1. Initial program 51.5%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Taylor expanded in n around inf 53.1%

      \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
    3. Step-by-step derivation
      1. +-rgt-identity53.1%

        \[\leadsto \frac{\color{blue}{\left(\log \left(1 + x\right) + 0\right)} - \log x}{n} \]
      2. +-rgt-identity53.1%

        \[\leadsto \frac{\color{blue}{\log \left(1 + x\right)} - \log x}{n} \]
      3. log1p-def53.1%

        \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(x\right)} - \log x}{n} \]
    4. Simplified53.1%

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Step-by-step derivation
      1. clear-num53.1%

        \[\leadsto \color{blue}{\frac{1}{\frac{n}{\mathsf{log1p}\left(x\right) - \log x}}} \]
      2. inv-pow53.1%

        \[\leadsto \color{blue}{{\left(\frac{n}{\mathsf{log1p}\left(x\right) - \log x}\right)}^{-1}} \]
    6. Applied egg-rr53.1%

      \[\leadsto \color{blue}{{\left(\frac{n}{\mathsf{log1p}\left(x\right) - \log x}\right)}^{-1}} \]
    7. Step-by-step derivation
      1. unpow-153.1%

        \[\leadsto \color{blue}{\frac{1}{\frac{n}{\mathsf{log1p}\left(x\right) - \log x}}} \]
    8. Simplified53.1%

      \[\leadsto \color{blue}{\frac{1}{\frac{n}{\mathsf{log1p}\left(x\right) - \log x}}} \]
    9. Taylor expanded in x around -inf 68.6%

      \[\leadsto \frac{1}{\color{blue}{-0.3333333333333333 \cdot \frac{n}{x} + \left(0.25 \cdot \frac{n}{x} + \left(0.5 \cdot n + n \cdot x\right)\right)}} \]

    if 2.1999999999999999e166 < x

    1. Initial program 84.7%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Taylor expanded in n around inf 84.7%

      \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
    3. Step-by-step derivation
      1. +-rgt-identity84.7%

        \[\leadsto \frac{\color{blue}{\left(\log \left(1 + x\right) + 0\right)} - \log x}{n} \]
      2. +-rgt-identity84.7%

        \[\leadsto \frac{\color{blue}{\log \left(1 + x\right)} - \log x}{n} \]
      3. log1p-def84.7%

        \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(x\right)} - \log x}{n} \]
    4. Simplified84.7%

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Step-by-step derivation
      1. log1p-udef84.7%

        \[\leadsto \frac{\color{blue}{\log \left(1 + x\right)} - \log x}{n} \]
      2. diff-log84.7%

        \[\leadsto \frac{\color{blue}{\log \left(\frac{1 + x}{x}\right)}}{n} \]
      3. +-commutative84.7%

        \[\leadsto \frac{\log \left(\frac{\color{blue}{x + 1}}{x}\right)}{n} \]
    6. Applied egg-rr84.7%

      \[\leadsto \frac{\color{blue}{\log \left(\frac{x + 1}{x}\right)}}{n} \]
    7. Taylor expanded in x around inf 84.7%

      \[\leadsto \frac{\log \color{blue}{1}}{n} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification65.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 0.33:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 2.2 \cdot 10^{+166}:\\ \;\;\;\;\frac{1}{-0.3333333333333333 \cdot \frac{n}{x} + \left(\left(n \cdot x + n \cdot 0.5\right) + \frac{n}{x} \cdot 0.25\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{0}{n}\\ \end{array} \]

Alternative 17: 48.8% accurate, 12.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -10000000000000:\\ \;\;\;\;\frac{0}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+185}:\\ \;\;\;\;\frac{1}{n \cdot x + n \cdot 0.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= (/ 1.0 n) -10000000000000.0)
   (/ 0.0 n)
   (if (<= (/ 1.0 n) 5e+185) (/ 1.0 (+ (* n x) (* n 0.5))) (/ 1.0 (* n x)))))
double code(double x, double n) {
	double tmp;
	if ((1.0 / n) <= -10000000000000.0) {
		tmp = 0.0 / n;
	} else if ((1.0 / n) <= 5e+185) {
		tmp = 1.0 / ((n * x) + (n * 0.5));
	} else {
		tmp = 1.0 / (n * x);
	}
	return tmp;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    real(8) :: tmp
    if ((1.0d0 / n) <= (-10000000000000.0d0)) then
        tmp = 0.0d0 / n
    else if ((1.0d0 / n) <= 5d+185) then
        tmp = 1.0d0 / ((n * x) + (n * 0.5d0))
    else
        tmp = 1.0d0 / (n * x)
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double tmp;
	if ((1.0 / n) <= -10000000000000.0) {
		tmp = 0.0 / n;
	} else if ((1.0 / n) <= 5e+185) {
		tmp = 1.0 / ((n * x) + (n * 0.5));
	} else {
		tmp = 1.0 / (n * x);
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if (1.0 / n) <= -10000000000000.0:
		tmp = 0.0 / n
	elif (1.0 / n) <= 5e+185:
		tmp = 1.0 / ((n * x) + (n * 0.5))
	else:
		tmp = 1.0 / (n * x)
	return tmp
function code(x, n)
	tmp = 0.0
	if (Float64(1.0 / n) <= -10000000000000.0)
		tmp = Float64(0.0 / n);
	elseif (Float64(1.0 / n) <= 5e+185)
		tmp = Float64(1.0 / Float64(Float64(n * x) + Float64(n * 0.5)));
	else
		tmp = Float64(1.0 / Float64(n * x));
	end
	return tmp
end
function tmp_2 = code(x, n)
	tmp = 0.0;
	if ((1.0 / n) <= -10000000000000.0)
		tmp = 0.0 / n;
	elseif ((1.0 / n) <= 5e+185)
		tmp = 1.0 / ((n * x) + (n * 0.5));
	else
		tmp = 1.0 / (n * x);
	end
	tmp_2 = tmp;
end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -10000000000000.0], N[(0.0 / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+185], N[(1.0 / N[(N[(n * x), $MachinePrecision] + N[(n * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -10000000000000:\\
\;\;\;\;\frac{0}{n}\\

\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+185}:\\
\;\;\;\;\frac{1}{n \cdot x + n \cdot 0.5}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 1 n) < -1e13

    1. Initial program 100.0%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Taylor expanded in n around inf 48.6%

      \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
    3. Step-by-step derivation
      1. +-rgt-identity48.6%

        \[\leadsto \frac{\color{blue}{\left(\log \left(1 + x\right) + 0\right)} - \log x}{n} \]
      2. +-rgt-identity48.6%

        \[\leadsto \frac{\color{blue}{\log \left(1 + x\right)} - \log x}{n} \]
      3. log1p-def48.6%

        \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(x\right)} - \log x}{n} \]
    4. Simplified48.6%

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Step-by-step derivation
      1. log1p-udef48.6%

        \[\leadsto \frac{\color{blue}{\log \left(1 + x\right)} - \log x}{n} \]
      2. diff-log48.6%

        \[\leadsto \frac{\color{blue}{\log \left(\frac{1 + x}{x}\right)}}{n} \]
      3. +-commutative48.6%

        \[\leadsto \frac{\log \left(\frac{\color{blue}{x + 1}}{x}\right)}{n} \]
    6. Applied egg-rr48.6%

      \[\leadsto \frac{\color{blue}{\log \left(\frac{x + 1}{x}\right)}}{n} \]
    7. Taylor expanded in x around inf 48.4%

      \[\leadsto \frac{\log \color{blue}{1}}{n} \]

    if -1e13 < (/.f64 1 n) < 4.9999999999999999e185

    1. Initial program 37.0%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Taylor expanded in n around inf 69.7%

      \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
    3. Step-by-step derivation
      1. +-rgt-identity69.7%

        \[\leadsto \frac{\color{blue}{\left(\log \left(1 + x\right) + 0\right)} - \log x}{n} \]
      2. +-rgt-identity69.7%

        \[\leadsto \frac{\color{blue}{\log \left(1 + x\right)} - \log x}{n} \]
      3. log1p-def69.7%

        \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(x\right)} - \log x}{n} \]
    4. Simplified69.7%

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Step-by-step derivation
      1. clear-num69.7%

        \[\leadsto \color{blue}{\frac{1}{\frac{n}{\mathsf{log1p}\left(x\right) - \log x}}} \]
      2. inv-pow69.7%

        \[\leadsto \color{blue}{{\left(\frac{n}{\mathsf{log1p}\left(x\right) - \log x}\right)}^{-1}} \]
    6. Applied egg-rr69.7%

      \[\leadsto \color{blue}{{\left(\frac{n}{\mathsf{log1p}\left(x\right) - \log x}\right)}^{-1}} \]
    7. Step-by-step derivation
      1. unpow-169.7%

        \[\leadsto \color{blue}{\frac{1}{\frac{n}{\mathsf{log1p}\left(x\right) - \log x}}} \]
    8. Simplified69.7%

      \[\leadsto \color{blue}{\frac{1}{\frac{n}{\mathsf{log1p}\left(x\right) - \log x}}} \]
    9. Taylor expanded in x around inf 45.3%

      \[\leadsto \frac{1}{\color{blue}{0.5 \cdot n + n \cdot x}} \]

    if 4.9999999999999999e185 < (/.f64 1 n)

    1. Initial program 24.7%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Taylor expanded in n around inf 6.4%

      \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
    3. Step-by-step derivation
      1. +-rgt-identity6.4%

        \[\leadsto \frac{\color{blue}{\left(\log \left(1 + x\right) + 0\right)} - \log x}{n} \]
      2. +-rgt-identity6.4%

        \[\leadsto \frac{\color{blue}{\log \left(1 + x\right)} - \log x}{n} \]
      3. log1p-def6.4%

        \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(x\right)} - \log x}{n} \]
    4. Simplified6.4%

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Taylor expanded in x around inf 59.1%

      \[\leadsto \color{blue}{\frac{1}{n \cdot x}} \]
    6. Step-by-step derivation
      1. *-commutative59.1%

        \[\leadsto \frac{1}{\color{blue}{x \cdot n}} \]
    7. Simplified59.1%

      \[\leadsto \color{blue}{\frac{1}{x \cdot n}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification46.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -10000000000000:\\ \;\;\;\;\frac{0}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+185}:\\ \;\;\;\;\frac{1}{n \cdot x + n \cdot 0.5}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \end{array} \]

Alternative 18: 42.0% accurate, 19.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq 2.8 \cdot 10^{-186}:\\ \;\;\;\;\frac{\frac{1}{x}}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{n \cdot x + n \cdot 0.5}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= n 2.8e-186) (/ (/ 1.0 x) n) (/ 1.0 (+ (* n x) (* n 0.5)))))
double code(double x, double n) {
	double tmp;
	if (n <= 2.8e-186) {
		tmp = (1.0 / x) / n;
	} else {
		tmp = 1.0 / ((n * x) + (n * 0.5));
	}
	return tmp;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    real(8) :: tmp
    if (n <= 2.8d-186) then
        tmp = (1.0d0 / x) / n
    else
        tmp = 1.0d0 / ((n * x) + (n * 0.5d0))
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double tmp;
	if (n <= 2.8e-186) {
		tmp = (1.0 / x) / n;
	} else {
		tmp = 1.0 / ((n * x) + (n * 0.5));
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if n <= 2.8e-186:
		tmp = (1.0 / x) / n
	else:
		tmp = 1.0 / ((n * x) + (n * 0.5))
	return tmp
function code(x, n)
	tmp = 0.0
	if (n <= 2.8e-186)
		tmp = Float64(Float64(1.0 / x) / n);
	else
		tmp = Float64(1.0 / Float64(Float64(n * x) + Float64(n * 0.5)));
	end
	return tmp
end
function tmp_2 = code(x, n)
	tmp = 0.0;
	if (n <= 2.8e-186)
		tmp = (1.0 / x) / n;
	else
		tmp = 1.0 / ((n * x) + (n * 0.5));
	end
	tmp_2 = tmp;
end
code[x_, n_] := If[LessEqual[n, 2.8e-186], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], N[(1.0 / N[(N[(n * x), $MachinePrecision] + N[(n * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;n \leq 2.8 \cdot 10^{-186}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x + n \cdot 0.5}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if n < 2.79999999999999983e-186

    1. Initial program 58.5%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Taylor expanded in n around inf 59.8%

      \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
    3. Step-by-step derivation
      1. +-rgt-identity59.8%

        \[\leadsto \frac{\color{blue}{\left(\log \left(1 + x\right) + 0\right)} - \log x}{n} \]
      2. +-rgt-identity59.8%

        \[\leadsto \frac{\color{blue}{\log \left(1 + x\right)} - \log x}{n} \]
      3. log1p-def59.8%

        \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(x\right)} - \log x}{n} \]
    4. Simplified59.8%

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Taylor expanded in x around inf 39.8%

      \[\leadsto \frac{\color{blue}{\frac{1}{x}}}{n} \]

    if 2.79999999999999983e-186 < n

    1. Initial program 41.5%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Taylor expanded in n around inf 66.4%

      \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
    3. Step-by-step derivation
      1. +-rgt-identity66.4%

        \[\leadsto \frac{\color{blue}{\left(\log \left(1 + x\right) + 0\right)} - \log x}{n} \]
      2. +-rgt-identity66.4%

        \[\leadsto \frac{\color{blue}{\log \left(1 + x\right)} - \log x}{n} \]
      3. log1p-def66.4%

        \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(x\right)} - \log x}{n} \]
    4. Simplified66.4%

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Step-by-step derivation
      1. clear-num66.4%

        \[\leadsto \color{blue}{\frac{1}{\frac{n}{\mathsf{log1p}\left(x\right) - \log x}}} \]
      2. inv-pow66.4%

        \[\leadsto \color{blue}{{\left(\frac{n}{\mathsf{log1p}\left(x\right) - \log x}\right)}^{-1}} \]
    6. Applied egg-rr66.4%

      \[\leadsto \color{blue}{{\left(\frac{n}{\mathsf{log1p}\left(x\right) - \log x}\right)}^{-1}} \]
    7. Step-by-step derivation
      1. unpow-166.4%

        \[\leadsto \color{blue}{\frac{1}{\frac{n}{\mathsf{log1p}\left(x\right) - \log x}}} \]
    8. Simplified66.4%

      \[\leadsto \color{blue}{\frac{1}{\frac{n}{\mathsf{log1p}\left(x\right) - \log x}}} \]
    9. Taylor expanded in x around inf 39.9%

      \[\leadsto \frac{1}{\color{blue}{0.5 \cdot n + n \cdot x}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification39.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq 2.8 \cdot 10^{-186}:\\ \;\;\;\;\frac{\frac{1}{x}}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{n \cdot x + n \cdot 0.5}\\ \end{array} \]

Alternative 19: 40.2% 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.6%

    \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
  2. Taylor expanded in n around inf 62.5%

    \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
  3. Step-by-step derivation
    1. +-rgt-identity62.5%

      \[\leadsto \frac{\color{blue}{\left(\log \left(1 + x\right) + 0\right)} - \log x}{n} \]
    2. +-rgt-identity62.5%

      \[\leadsto \frac{\color{blue}{\log \left(1 + x\right)} - \log x}{n} \]
    3. log1p-def62.5%

      \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(x\right)} - \log x}{n} \]
  4. Simplified62.5%

    \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
  5. Taylor expanded in x around inf 37.7%

    \[\leadsto \color{blue}{\frac{1}{n \cdot x}} \]
  6. Step-by-step derivation
    1. *-commutative37.7%

      \[\leadsto \frac{1}{\color{blue}{x \cdot n}} \]
  7. Simplified37.7%

    \[\leadsto \color{blue}{\frac{1}{x \cdot n}} \]
  8. Final simplification37.7%

    \[\leadsto \frac{1}{n \cdot x} \]

Alternative 20: 40.8% 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.6%

    \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
  2. Taylor expanded in n around inf 62.5%

    \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
  3. Step-by-step derivation
    1. +-rgt-identity62.5%

      \[\leadsto \frac{\color{blue}{\left(\log \left(1 + x\right) + 0\right)} - \log x}{n} \]
    2. +-rgt-identity62.5%

      \[\leadsto \frac{\color{blue}{\log \left(1 + x\right)} - \log x}{n} \]
    3. log1p-def62.5%

      \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(x\right)} - \log x}{n} \]
  4. Simplified62.5%

    \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
  5. Step-by-step derivation
    1. log1p-udef62.5%

      \[\leadsto \frac{\color{blue}{\log \left(1 + x\right)} - \log x}{n} \]
    2. diff-log62.6%

      \[\leadsto \frac{\color{blue}{\log \left(\frac{1 + x}{x}\right)}}{n} \]
    3. +-commutative62.6%

      \[\leadsto \frac{\log \left(\frac{\color{blue}{x + 1}}{x}\right)}{n} \]
  6. Applied egg-rr62.6%

    \[\leadsto \frac{\color{blue}{\log \left(\frac{x + 1}{x}\right)}}{n} \]
  7. Step-by-step derivation
    1. clear-num62.5%

      \[\leadsto \color{blue}{\frac{1}{\frac{n}{\log \left(\frac{x + 1}{x}\right)}}} \]
    2. log-div62.5%

      \[\leadsto \frac{1}{\frac{n}{\color{blue}{\log \left(x + 1\right) - \log x}}} \]
    3. +-commutative62.5%

      \[\leadsto \frac{1}{\frac{n}{\log \color{blue}{\left(1 + x\right)} - \log x}} \]
    4. log1p-udef62.5%

      \[\leadsto \frac{1}{\frac{n}{\color{blue}{\mathsf{log1p}\left(x\right)} - \log x}} \]
    5. frac-2neg62.5%

      \[\leadsto \frac{1}{\color{blue}{\frac{-n}{-\left(\mathsf{log1p}\left(x\right) - \log x\right)}}} \]
    6. associate-/r/62.5%

      \[\leadsto \color{blue}{\frac{1}{-n} \cdot \left(-\left(\mathsf{log1p}\left(x\right) - \log x\right)\right)} \]
    7. log1p-udef62.5%

      \[\leadsto \frac{1}{-n} \cdot \left(-\left(\color{blue}{\log \left(1 + x\right)} - \log x\right)\right) \]
    8. +-commutative62.5%

      \[\leadsto \frac{1}{-n} \cdot \left(-\left(\log \color{blue}{\left(x + 1\right)} - \log x\right)\right) \]
    9. log-div62.6%

      \[\leadsto \frac{1}{-n} \cdot \left(-\color{blue}{\log \left(\frac{x + 1}{x}\right)}\right) \]
    10. neg-log62.6%

      \[\leadsto \frac{1}{-n} \cdot \color{blue}{\log \left(\frac{1}{\frac{x + 1}{x}}\right)} \]
    11. clear-num62.6%

      \[\leadsto \frac{1}{-n} \cdot \log \color{blue}{\left(\frac{x}{x + 1}\right)} \]
  8. Applied egg-rr62.6%

    \[\leadsto \color{blue}{\frac{1}{-n} \cdot \log \left(\frac{x}{x + 1}\right)} \]
  9. Taylor expanded in x around inf 37.7%

    \[\leadsto \color{blue}{\frac{1}{n \cdot x}} \]
  10. Step-by-step derivation
    1. associate-/r*38.1%

      \[\leadsto \color{blue}{\frac{\frac{1}{n}}{x}} \]
  11. Simplified38.1%

    \[\leadsto \color{blue}{\frac{\frac{1}{n}}{x}} \]
  12. Final simplification38.1%

    \[\leadsto \frac{\frac{1}{n}}{x} \]

Alternative 21: 40.8% 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.6%

    \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
  2. Taylor expanded in n around inf 62.5%

    \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
  3. Step-by-step derivation
    1. +-rgt-identity62.5%

      \[\leadsto \frac{\color{blue}{\left(\log \left(1 + x\right) + 0\right)} - \log x}{n} \]
    2. +-rgt-identity62.5%

      \[\leadsto \frac{\color{blue}{\log \left(1 + x\right)} - \log x}{n} \]
    3. log1p-def62.5%

      \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(x\right)} - \log x}{n} \]
  4. Simplified62.5%

    \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
  5. Taylor expanded in x around inf 38.1%

    \[\leadsto \frac{\color{blue}{\frac{1}{x}}}{n} \]
  6. Final simplification38.1%

    \[\leadsto \frac{\frac{1}{x}}{n} \]

Alternative 22: 4.6% 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.6%

    \[{\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 5.0%

    \[\leadsto \color{blue}{\frac{x}{n}} \]
  4. Final simplification5.0%

    \[\leadsto \frac{x}{n} \]

Reproduce

?
herbie shell --seed 2023333 
(FPCore (x n)
  :name "2nthrt (problem 3.4.6)"
  :precision binary64
  (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))