2nthrt (problem 3.4.6)

Percentage Accurate: 54.1% → 86.8%
Time: 21.6s
Alternatives: 17
Speedup: 1.9×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 17 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: 54.1% 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: 86.8% accurate, 0.3× speedup?

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

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

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

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


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

    1. Initial program 95.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 26.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 45.1%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -6 \cdot 10^{-23}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-10}:\\ \;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n} + 0.5 \cdot \left(\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{{n}^{2}} - \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 2: 86.6% accurate, 0.4× speedup?

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

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

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

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


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

    1. Initial program 97.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 26.3%

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

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

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

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

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

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

        \[\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} \]
    7. Step-by-step derivation
      1. clear-num80.7%

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

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

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

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

    1. Initial program 45.6%

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

        \[\leadsto \color{blue}{\log \left(e^{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}}\right)} \]
      2. add-exp-log45.7%

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

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

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

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

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

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

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

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

Alternative 3: 86.7% accurate, 0.7× speedup?

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

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

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

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


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

    1. Initial program 97.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 26.3%

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

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

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

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

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

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

        \[\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} \]
    7. Step-by-step derivation
      1. clear-num80.7%

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

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

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

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

    1. Initial program 45.6%

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

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

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

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

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

Alternative 4: 82.8% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+125}:\\
\;\;\;\;\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 4 regimes
  2. if (/.f64 1 n) < -5.00000000000000018e-11

    1. Initial program 97.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 26.3%

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

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

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

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

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

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

        \[\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} \]
    7. Step-by-step derivation
      1. clear-num80.7%

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

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

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

    if 1.99999999999999988e-11 < (/.f64 1 n) < 4.99999999999999962e125

    1. Initial program 73.8%

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

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

    if 4.99999999999999962e125 < (/.f64 1 n)

    1. Initial program 18.8%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \sqrt{\color{blue}{{\left(n \cdot x\right)}^{\left(-1 + -1\right)}}} \]
      6. *-commutative85.5%

        \[\leadsto \sqrt{{\color{blue}{\left(x \cdot n\right)}}^{\left(-1 + -1\right)}} \]
      7. metadata-eval85.5%

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

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

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

Alternative 5: 86.7% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 97.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 26.3%

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

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

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

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

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

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

        \[\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} \]
    7. Step-by-step derivation
      1. clear-num80.7%

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

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

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

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

    1. Initial program 45.6%

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

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

        \[\leadsto e^{\frac{\color{blue}{\mathsf{log1p}\left(x\right)}}{n}} - {x}^{\left(\frac{1}{n}\right)} \]
    4. Simplified96.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 96.6%

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

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

Alternative 6: 56.3% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\ t_1 := \frac{-\log x}{n}\\ \mathbf{if}\;x \leq 4 \cdot 10^{-272}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.1 \cdot 10^{-241}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.04 \cdot 10^{-232}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \mathbf{elif}\;x \leq 2.5 \cdot 10^{-196}:\\ \;\;\;\;\log x \cdot \frac{1}{-n}\\ \mathbf{elif}\;x \leq 6 \cdot 10^{-167}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 3.1 \cdot 10^{-103}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 3.9 \cdot 10^{-75}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.6 \cdot 10^{-35}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{0}{n}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))) (t_1 (/ (- (log x)) n)))
   (if (<= x 4e-272)
     t_0
     (if (<= x 1.1e-241)
       t_1
       (if (<= x 1.04e-232)
         (/ 1.0 (* n x))
         (if (<= x 2.5e-196)
           (* (log x) (/ 1.0 (- n)))
           (if (<= x 6e-167)
             t_0
             (if (<= x 3.1e-103)
               t_1
               (if (<= x 3.9e-75)
                 t_0
                 (if (<= x 2.6e-35) t_1 (if (<= x 1.0) t_0 (/ 0.0 n))))))))))))
double code(double x, double n) {
	double t_0 = 1.0 - pow(x, (1.0 / n));
	double t_1 = -log(x) / n;
	double tmp;
	if (x <= 4e-272) {
		tmp = t_0;
	} else if (x <= 1.1e-241) {
		tmp = t_1;
	} else if (x <= 1.04e-232) {
		tmp = 1.0 / (n * x);
	} else if (x <= 2.5e-196) {
		tmp = log(x) * (1.0 / -n);
	} else if (x <= 6e-167) {
		tmp = t_0;
	} else if (x <= 3.1e-103) {
		tmp = t_1;
	} else if (x <= 3.9e-75) {
		tmp = t_0;
	} else if (x <= 2.6e-35) {
		tmp = t_1;
	} else if (x <= 1.0) {
		tmp = t_0;
	} 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 = 1.0d0 - (x ** (1.0d0 / n))
    t_1 = -log(x) / n
    if (x <= 4d-272) then
        tmp = t_0
    else if (x <= 1.1d-241) then
        tmp = t_1
    else if (x <= 1.04d-232) then
        tmp = 1.0d0 / (n * x)
    else if (x <= 2.5d-196) then
        tmp = log(x) * (1.0d0 / -n)
    else if (x <= 6d-167) then
        tmp = t_0
    else if (x <= 3.1d-103) then
        tmp = t_1
    else if (x <= 3.9d-75) then
        tmp = t_0
    else if (x <= 2.6d-35) then
        tmp = t_1
    else if (x <= 1.0d0) then
        tmp = t_0
    else
        tmp = 0.0d0 / n
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double t_0 = 1.0 - Math.pow(x, (1.0 / n));
	double t_1 = -Math.log(x) / n;
	double tmp;
	if (x <= 4e-272) {
		tmp = t_0;
	} else if (x <= 1.1e-241) {
		tmp = t_1;
	} else if (x <= 1.04e-232) {
		tmp = 1.0 / (n * x);
	} else if (x <= 2.5e-196) {
		tmp = Math.log(x) * (1.0 / -n);
	} else if (x <= 6e-167) {
		tmp = t_0;
	} else if (x <= 3.1e-103) {
		tmp = t_1;
	} else if (x <= 3.9e-75) {
		tmp = t_0;
	} else if (x <= 2.6e-35) {
		tmp = t_1;
	} else if (x <= 1.0) {
		tmp = t_0;
	} else {
		tmp = 0.0 / n;
	}
	return tmp;
}
def code(x, n):
	t_0 = 1.0 - math.pow(x, (1.0 / n))
	t_1 = -math.log(x) / n
	tmp = 0
	if x <= 4e-272:
		tmp = t_0
	elif x <= 1.1e-241:
		tmp = t_1
	elif x <= 1.04e-232:
		tmp = 1.0 / (n * x)
	elif x <= 2.5e-196:
		tmp = math.log(x) * (1.0 / -n)
	elif x <= 6e-167:
		tmp = t_0
	elif x <= 3.1e-103:
		tmp = t_1
	elif x <= 3.9e-75:
		tmp = t_0
	elif x <= 2.6e-35:
		tmp = t_1
	elif x <= 1.0:
		tmp = t_0
	else:
		tmp = 0.0 / n
	return tmp
function code(x, n)
	t_0 = Float64(1.0 - (x ^ Float64(1.0 / n)))
	t_1 = Float64(Float64(-log(x)) / n)
	tmp = 0.0
	if (x <= 4e-272)
		tmp = t_0;
	elseif (x <= 1.1e-241)
		tmp = t_1;
	elseif (x <= 1.04e-232)
		tmp = Float64(1.0 / Float64(n * x));
	elseif (x <= 2.5e-196)
		tmp = Float64(log(x) * Float64(1.0 / Float64(-n)));
	elseif (x <= 6e-167)
		tmp = t_0;
	elseif (x <= 3.1e-103)
		tmp = t_1;
	elseif (x <= 3.9e-75)
		tmp = t_0;
	elseif (x <= 2.6e-35)
		tmp = t_1;
	elseif (x <= 1.0)
		tmp = t_0;
	else
		tmp = Float64(0.0 / n);
	end
	return tmp
end
function tmp_2 = code(x, n)
	t_0 = 1.0 - (x ^ (1.0 / n));
	t_1 = -log(x) / n;
	tmp = 0.0;
	if (x <= 4e-272)
		tmp = t_0;
	elseif (x <= 1.1e-241)
		tmp = t_1;
	elseif (x <= 1.04e-232)
		tmp = 1.0 / (n * x);
	elseif (x <= 2.5e-196)
		tmp = log(x) * (1.0 / -n);
	elseif (x <= 6e-167)
		tmp = t_0;
	elseif (x <= 3.1e-103)
		tmp = t_1;
	elseif (x <= 3.9e-75)
		tmp = t_0;
	elseif (x <= 2.6e-35)
		tmp = t_1;
	elseif (x <= 1.0)
		tmp = t_0;
	else
		tmp = 0.0 / n;
	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[x], $MachinePrecision]) / n), $MachinePrecision]}, If[LessEqual[x, 4e-272], t$95$0, If[LessEqual[x, 1.1e-241], t$95$1, If[LessEqual[x, 1.04e-232], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.5e-196], N[(N[Log[x], $MachinePrecision] * N[(1.0 / (-n)), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 6e-167], t$95$0, If[LessEqual[x, 3.1e-103], t$95$1, If[LessEqual[x, 3.9e-75], t$95$0, If[LessEqual[x, 2.6e-35], t$95$1, If[LessEqual[x, 1.0], t$95$0, N[(0.0 / n), $MachinePrecision]]]]]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq 1.1 \cdot 10^{-241}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;x \leq 2.5 \cdot 10^{-196}:\\
\;\;\;\;\log x \cdot \frac{1}{-n}\\

\mathbf{elif}\;x \leq 6 \cdot 10^{-167}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 3.1 \cdot 10^{-103}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 3.9 \cdot 10^{-75}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 2.6 \cdot 10^{-35}:\\
\;\;\;\;t_1\\

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

\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if x < 3.99999999999999972e-272 or 2.5000000000000002e-196 < x < 5.9999999999999996e-167 or 3.1000000000000001e-103 < x < 3.9000000000000001e-75 or 2.60000000000000005e-35 < x < 1

    1. Initial program 65.6%

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

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

    if 3.99999999999999972e-272 < x < 1.1e-241 or 5.9999999999999996e-167 < x < 3.1000000000000001e-103 or 3.9000000000000001e-75 < x < 2.60000000000000005e-35

    1. Initial program 23.6%

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

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

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

        \[\leadsto \color{blue}{-\frac{\log x}{n}} \]
      2. distribute-neg-frac73.0%

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

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

    if 1.1e-241 < x < 1.0399999999999999e-232

    1. Initial program 41.9%

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

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

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

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

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

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

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

    if 1.0399999999999999e-232 < x < 2.5000000000000002e-196

    1. Initial program 41.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\log \left(\frac{x}{x + 1}\right) \cdot \frac{1}{-n}} \]
    9. Taylor expanded in x around 0 65.7%

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

    if 1 < x

    1. Initial program 70.9%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\log \left(\frac{x + 1}{x}\right)}}{n} \]
    7. Step-by-step derivation
      1. add-cube-cbrt71.9%

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

        \[\leadsto \frac{\color{blue}{\log \left(\sqrt[3]{\frac{x + 1}{x}} \cdot \sqrt[3]{\frac{x + 1}{x}}\right) + \log \left(\sqrt[3]{\frac{x + 1}{x}}\right)}}{n} \]
      3. pow271.9%

        \[\leadsto \frac{\log \color{blue}{\left({\left(\sqrt[3]{\frac{x + 1}{x}}\right)}^{2}\right)} + \log \left(\sqrt[3]{\frac{x + 1}{x}}\right)}{n} \]
    8. Applied egg-rr71.9%

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

        \[\leadsto \frac{\color{blue}{2 \cdot \log \left(\sqrt[3]{\frac{x + 1}{x}}\right)} + \log \left(\sqrt[3]{\frac{x + 1}{x}}\right)}{n} \]
      2. distribute-lft1-in71.9%

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

        \[\leadsto \frac{\color{blue}{3} \cdot \log \left(\sqrt[3]{\frac{x + 1}{x}}\right)}{n} \]
    10. Simplified71.9%

      \[\leadsto \frac{\color{blue}{3 \cdot \log \left(\sqrt[3]{\frac{x + 1}{x}}\right)}}{n} \]
    11. Taylor expanded in x around inf 70.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 4 \cdot 10^{-272}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 1.1 \cdot 10^{-241}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 1.04 \cdot 10^{-232}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \mathbf{elif}\;x \leq 2.5 \cdot 10^{-196}:\\ \;\;\;\;\log x \cdot \frac{1}{-n}\\ \mathbf{elif}\;x \leq 6 \cdot 10^{-167}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 3.1 \cdot 10^{-103}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 3.9 \cdot 10^{-75}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 2.6 \cdot 10^{-35}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{0}{n}\\ \end{array} \]

Alternative 7: 82.4% accurate, 1.7× speedup?

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

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

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

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

\mathbf{else}:\\
\;\;\;\;\mathsf{log1p}\left(t_0 + -1\right) \cdot \frac{1}{-n}\\


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

    1. Initial program 97.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 26.3%

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

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

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

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

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

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

        \[\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} \]
    7. Step-by-step derivation
      1. clear-num80.7%

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

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

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

    if 1.99999999999999988e-11 < (/.f64 1 n) < 4.99999999999999962e125

    1. Initial program 73.8%

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

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

    if 4.99999999999999962e125 < (/.f64 1 n)

    1. Initial program 18.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{log1p}\left(\color{blue}{\frac{x}{x + 1}} - 1\right) \cdot \frac{1}{-n} \]
    10. Applied egg-rr81.2%

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

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

Alternative 8: 82.1% accurate, 1.7× speedup?

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

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

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

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

\mathbf{else}:\\
\;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\


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

    1. Initial program 97.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 26.3%

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

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

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

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

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

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

        \[\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} \]
    7. Step-by-step derivation
      1. clear-num80.7%

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

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

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

    if 1.99999999999999988e-11 < (/.f64 1 n) < 4.99999999999999962e125

    1. Initial program 73.8%

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

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

    if 4.99999999999999962e125 < (/.f64 1 n)

    1. Initial program 18.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{1}{x} + \left(\frac{0.3333333333333333}{{x}^{3}} + \frac{-0.5}{{x}^{2}}\right)}}{n} \]
    8. Taylor expanded in x around 0 80.8%

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

        \[\leadsto \frac{0.3333333333333333}{\color{blue}{{x}^{3} \cdot n}} \]
    10. Simplified80.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-11}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-11}:\\ \;\;\;\;\frac{-\log \left(\frac{x}{1 + x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+125}:\\ \;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\ \end{array} \]

Alternative 9: 60.2% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{x - \log x}{n}\\
\mathbf{if}\;n \leq -1.02 \cdot 10^{+189}:\\
\;\;\;\;\log x \cdot \frac{1}{-n}\\

\mathbf{elif}\;n \leq -2.5 \cdot 10^{+143}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\

\mathbf{elif}\;n \leq -2.45:\\
\;\;\;\;t_0\\

\mathbf{elif}\;n \leq 3.5 \cdot 10^{-128}:\\
\;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\

\mathbf{elif}\;n \leq 58000000000:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\

\mathbf{elif}\;n \leq 7.6 \cdot 10^{+103}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;n \leq 3.1 \cdot 10^{+187}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\

\mathbf{else}:\\
\;\;\;\;\frac{-\log x}{n}\\


\end{array}
\end{array}
Derivation
  1. Split input into 7 regimes
  2. if n < -1.02e189

    1. Initial program 34.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\log \left(\frac{1}{\frac{x + 1}{x}}\right)} \cdot \frac{1}{-n} \]
      10. clear-num91.0%

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

      \[\leadsto \color{blue}{\log \left(\frac{x}{x + 1}\right) \cdot \frac{1}{-n}} \]
    9. Taylor expanded in x around 0 63.3%

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

    if -1.02e189 < n < -2.50000000000000006e143

    1. Initial program 26.1%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{1}{n}}{x}} \]
    7. Simplified81.3%

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

    if -2.50000000000000006e143 < n < -2.4500000000000002 or 5.8e10 < n < 7.5999999999999994e103

    1. Initial program 11.1%

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

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

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

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

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

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

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

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

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

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

    if -2.4500000000000002 < n < 3.5e-128

    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 41.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{1}{x} + \left(\frac{0.3333333333333333}{{x}^{3}} + \frac{-0.5}{{x}^{2}}\right)}}{n} \]
    8. Taylor expanded in x around 0 68.5%

      \[\leadsto \color{blue}{\frac{0.3333333333333333}{n \cdot {x}^{3}}} \]
    9. Step-by-step derivation
      1. *-commutative68.5%

        \[\leadsto \frac{0.3333333333333333}{\color{blue}{{x}^{3} \cdot n}} \]
    10. Simplified68.5%

      \[\leadsto \color{blue}{\frac{0.3333333333333333}{{x}^{3} \cdot n}} \]

    if 3.5e-128 < n < 5.8e10

    1. Initial program 73.8%

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

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

    if 7.5999999999999994e103 < n < 3.10000000000000012e187

    1. Initial program 43.9%

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

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

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

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

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

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

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

    if 3.10000000000000012e187 < n

    1. Initial program 32.5%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{-\log x}{n}} \]
  3. Recombined 7 regimes into one program.
  4. Final simplification69.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -1.02 \cdot 10^{+189}:\\ \;\;\;\;\log x \cdot \frac{1}{-n}\\ \mathbf{elif}\;n \leq -2.5 \cdot 10^{+143}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \mathbf{elif}\;n \leq -2.45:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{elif}\;n \leq 3.5 \cdot 10^{-128}:\\ \;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\ \mathbf{elif}\;n \leq 58000000000:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;n \leq 7.6 \cdot 10^{+103}:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{elif}\;n \leq 3.1 \cdot 10^{+187}:\\ \;\;\;\;\frac{\frac{1}{x}}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\log x}{n}\\ \end{array} \]

Alternative 10: 82.0% accurate, 1.8× speedup?

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

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

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

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

\mathbf{else}:\\
\;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\


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

    1. Initial program 97.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 26.3%

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

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

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

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

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

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

        \[\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} \]
    7. Step-by-step derivation
      1. clear-num80.7%

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

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

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

    if 1.99999999999999988e-11 < (/.f64 1 n) < 4.99999999999999962e125

    1. Initial program 73.8%

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

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

    if 4.99999999999999962e125 < (/.f64 1 n)

    1. Initial program 18.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{1}{x} + \left(\frac{0.3333333333333333}{{x}^{3}} + \frac{-0.5}{{x}^{2}}\right)}}{n} \]
    8. Taylor expanded in x around 0 80.8%

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

        \[\leadsto \frac{0.3333333333333333}{\color{blue}{{x}^{3} \cdot n}} \]
    10. Simplified80.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-11}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-11}:\\ \;\;\;\;\frac{-\log \left(\frac{x}{1 + x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+125}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\ \end{array} \]

Alternative 11: 72.2% accurate, 1.8× speedup?

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

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

\mathbf{elif}\;n \leq 3.3 \cdot 10^{-130}:\\
\;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\

\mathbf{elif}\;n \leq 16200000000:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if n < -4.7999999999999997e-135

    1. Initial program 54.3%

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

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

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

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

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

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

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

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

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

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

    if -4.7999999999999997e-135 < n < 3.2999999999999998e-130

    1. Initial program 73.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{1}{x} + \left(\frac{0.3333333333333333}{{x}^{3}} + \frac{-0.5}{{x}^{2}}\right)}}{n} \]
    8. Taylor expanded in x around 0 81.5%

      \[\leadsto \color{blue}{\frac{0.3333333333333333}{n \cdot {x}^{3}}} \]
    9. Step-by-step derivation
      1. *-commutative81.5%

        \[\leadsto \frac{0.3333333333333333}{\color{blue}{{x}^{3} \cdot n}} \]
    10. Simplified81.5%

      \[\leadsto \color{blue}{\frac{0.3333333333333333}{{x}^{3} \cdot n}} \]

    if 3.2999999999999998e-130 < n < 1.62e10

    1. Initial program 73.8%

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

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

    if 1.62e10 < n

    1. Initial program 28.0%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{-\log \left(\frac{x}{x + 1}\right)}}{n} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification75.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -4.8 \cdot 10^{-135}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{elif}\;n \leq 3.3 \cdot 10^{-130}:\\ \;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\ \mathbf{elif}\;n \leq 16200000000:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\log \left(\frac{x}{1 + x}\right)}{n}\\ \end{array} \]

Alternative 12: 56.8% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{1}{n \cdot x}\\
\mathbf{if}\;x \leq 1.85 \cdot 10^{-274}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 1.7 \cdot 10^{-240}:\\
\;\;\;\;\frac{-\log x}{n}\\

\mathbf{elif}\;x \leq 10^{-232}:\\
\;\;\;\;t_0\\

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

\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < 1.84999999999999992e-274 or 1.69999999999999995e-240 < x < 1.00000000000000002e-232

    1. Initial program 64.9%

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

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

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

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

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

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

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

    if 1.84999999999999992e-274 < x < 1.69999999999999995e-240

    1. Initial program 23.6%

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

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

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

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

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

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

    if 1.00000000000000002e-232 < x < 6e12

    1. Initial program 42.2%

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

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

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

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

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

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

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

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

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

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

    if 6e12 < x

    1. Initial program 72.3%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\log \color{blue}{\left({\left(\sqrt[3]{\frac{x + 1}{x}}\right)}^{2}\right)} + \log \left(\sqrt[3]{\frac{x + 1}{x}}\right)}{n} \]
    8. Applied egg-rr72.3%

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

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

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

        \[\leadsto \frac{\color{blue}{3} \cdot \log \left(\sqrt[3]{\frac{x + 1}{x}}\right)}{n} \]
    10. Simplified72.3%

      \[\leadsto \frac{\color{blue}{3 \cdot \log \left(\sqrt[3]{\frac{x + 1}{x}}\right)}}{n} \]
    11. Taylor expanded in x around inf 72.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.85 \cdot 10^{-274}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \mathbf{elif}\;x \leq 1.7 \cdot 10^{-240}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 10^{-232}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \mathbf{elif}\;x \leq 6000000000000:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{0}{n}\\ \end{array} \]

Alternative 13: 72.2% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{if}\;n \leq -4.5 \cdot 10^{-135}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;n \leq 3.3 \cdot 10^{-130}:\\ \;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\ \mathbf{elif}\;n \leq 15000000000:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (/ (log (/ (+ 1.0 x) x)) n)))
   (if (<= n -4.5e-135)
     t_0
     (if (<= n 3.3e-130)
       (/ 0.3333333333333333 (* n (pow x 3.0)))
       (if (<= n 15000000000.0) (- 1.0 (pow x (/ 1.0 n))) t_0)))))
double code(double x, double n) {
	double t_0 = log(((1.0 + x) / x)) / n;
	double tmp;
	if (n <= -4.5e-135) {
		tmp = t_0;
	} else if (n <= 3.3e-130) {
		tmp = 0.3333333333333333 / (n * pow(x, 3.0));
	} else if (n <= 15000000000.0) {
		tmp = 1.0 - pow(x, (1.0 / n));
	} else {
		tmp = 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 = log(((1.0d0 + x) / x)) / n
    if (n <= (-4.5d-135)) then
        tmp = t_0
    else if (n <= 3.3d-130) then
        tmp = 0.3333333333333333d0 / (n * (x ** 3.0d0))
    else if (n <= 15000000000.0d0) then
        tmp = 1.0d0 - (x ** (1.0d0 / n))
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double t_0 = Math.log(((1.0 + x) / x)) / n;
	double tmp;
	if (n <= -4.5e-135) {
		tmp = t_0;
	} else if (n <= 3.3e-130) {
		tmp = 0.3333333333333333 / (n * Math.pow(x, 3.0));
	} else if (n <= 15000000000.0) {
		tmp = 1.0 - Math.pow(x, (1.0 / n));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, n):
	t_0 = math.log(((1.0 + x) / x)) / n
	tmp = 0
	if n <= -4.5e-135:
		tmp = t_0
	elif n <= 3.3e-130:
		tmp = 0.3333333333333333 / (n * math.pow(x, 3.0))
	elif n <= 15000000000.0:
		tmp = 1.0 - math.pow(x, (1.0 / n))
	else:
		tmp = t_0
	return tmp
function code(x, n)
	t_0 = Float64(log(Float64(Float64(1.0 + x) / x)) / n)
	tmp = 0.0
	if (n <= -4.5e-135)
		tmp = t_0;
	elseif (n <= 3.3e-130)
		tmp = Float64(0.3333333333333333 / Float64(n * (x ^ 3.0)));
	elseif (n <= 15000000000.0)
		tmp = Float64(1.0 - (x ^ Float64(1.0 / n)));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, n)
	t_0 = log(((1.0 + x) / x)) / n;
	tmp = 0.0;
	if (n <= -4.5e-135)
		tmp = t_0;
	elseif (n <= 3.3e-130)
		tmp = 0.3333333333333333 / (n * (x ^ 3.0));
	elseif (n <= 15000000000.0)
		tmp = 1.0 - (x ^ (1.0 / n));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[n, -4.5e-135], t$95$0, If[LessEqual[n, 3.3e-130], N[(0.3333333333333333 / N[(n * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 15000000000.0], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}

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

\mathbf{elif}\;n \leq 3.3 \cdot 10^{-130}:\\
\;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\

\mathbf{elif}\;n \leq 15000000000:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if n < -4.49999999999999987e-135 or 1.5e10 < n

    1. Initial program 45.0%

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

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

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

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

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

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

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

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

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

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

    if -4.49999999999999987e-135 < n < 3.2999999999999998e-130

    1. Initial program 73.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{1}{x} + \left(\frac{0.3333333333333333}{{x}^{3}} + \frac{-0.5}{{x}^{2}}\right)}}{n} \]
    8. Taylor expanded in x around 0 81.5%

      \[\leadsto \color{blue}{\frac{0.3333333333333333}{n \cdot {x}^{3}}} \]
    9. Step-by-step derivation
      1. *-commutative81.5%

        \[\leadsto \frac{0.3333333333333333}{\color{blue}{{x}^{3} \cdot n}} \]
    10. Simplified81.5%

      \[\leadsto \color{blue}{\frac{0.3333333333333333}{{x}^{3} \cdot n}} \]

    if 3.2999999999999998e-130 < n < 1.5e10

    1. Initial program 73.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -4.5 \cdot 10^{-135}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{elif}\;n \leq 3.3 \cdot 10^{-130}:\\ \;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\ \mathbf{elif}\;n \leq 15000000000:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \end{array} \]

Alternative 14: 53.8% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{1}{n \cdot x}\\ t_1 := \frac{-\log x}{n}\\ \mathbf{if}\;x \leq 6.5 \cdot 10^{-274}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 3.7 \cdot 10^{-240}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 10^{-232}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.85 \cdot 10^{-25}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (/ 1.0 (* n x))) (t_1 (/ (- (log x)) n)))
   (if (<= x 6.5e-274)
     t_0
     (if (<= x 3.7e-240)
       t_1
       (if (<= x 1e-232) t_0 (if (<= x 1.85e-25) t_1 (/ (/ 1.0 n) x)))))))
double code(double x, double n) {
	double t_0 = 1.0 / (n * x);
	double t_1 = -log(x) / n;
	double tmp;
	if (x <= 6.5e-274) {
		tmp = t_0;
	} else if (x <= 3.7e-240) {
		tmp = t_1;
	} else if (x <= 1e-232) {
		tmp = t_0;
	} else if (x <= 1.85e-25) {
		tmp = t_1;
	} 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 / (n * x)
    t_1 = -log(x) / n
    if (x <= 6.5d-274) then
        tmp = t_0
    else if (x <= 3.7d-240) then
        tmp = t_1
    else if (x <= 1d-232) then
        tmp = t_0
    else if (x <= 1.85d-25) then
        tmp = t_1
    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 / (n * x);
	double t_1 = -Math.log(x) / n;
	double tmp;
	if (x <= 6.5e-274) {
		tmp = t_0;
	} else if (x <= 3.7e-240) {
		tmp = t_1;
	} else if (x <= 1e-232) {
		tmp = t_0;
	} else if (x <= 1.85e-25) {
		tmp = t_1;
	} else {
		tmp = (1.0 / n) / x;
	}
	return tmp;
}
def code(x, n):
	t_0 = 1.0 / (n * x)
	t_1 = -math.log(x) / n
	tmp = 0
	if x <= 6.5e-274:
		tmp = t_0
	elif x <= 3.7e-240:
		tmp = t_1
	elif x <= 1e-232:
		tmp = t_0
	elif x <= 1.85e-25:
		tmp = t_1
	else:
		tmp = (1.0 / n) / x
	return tmp
function code(x, n)
	t_0 = Float64(1.0 / Float64(n * x))
	t_1 = Float64(Float64(-log(x)) / n)
	tmp = 0.0
	if (x <= 6.5e-274)
		tmp = t_0;
	elseif (x <= 3.7e-240)
		tmp = t_1;
	elseif (x <= 1e-232)
		tmp = t_0;
	elseif (x <= 1.85e-25)
		tmp = t_1;
	else
		tmp = Float64(Float64(1.0 / n) / x);
	end
	return tmp
end
function tmp_2 = code(x, n)
	t_0 = 1.0 / (n * x);
	t_1 = -log(x) / n;
	tmp = 0.0;
	if (x <= 6.5e-274)
		tmp = t_0;
	elseif (x <= 3.7e-240)
		tmp = t_1;
	elseif (x <= 1e-232)
		tmp = t_0;
	elseif (x <= 1.85e-25)
		tmp = t_1;
	else
		tmp = (1.0 / n) / x;
	end
	tmp_2 = tmp;
end
code[x_, n_] := Block[{t$95$0 = N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision]}, If[LessEqual[x, 6.5e-274], t$95$0, If[LessEqual[x, 3.7e-240], t$95$1, If[LessEqual[x, 1e-232], t$95$0, If[LessEqual[x, 1.85e-25], t$95$1, N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{1}{n \cdot x}\\
t_1 := \frac{-\log x}{n}\\
\mathbf{if}\;x \leq 6.5 \cdot 10^{-274}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 3.7 \cdot 10^{-240}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 10^{-232}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 1.85 \cdot 10^{-25}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 6.49999999999999959e-274 or 3.7000000000000002e-240 < x < 1.00000000000000002e-232

    1. Initial program 64.9%

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

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

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

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

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

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

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

    if 6.49999999999999959e-274 < x < 3.7000000000000002e-240 or 1.00000000000000002e-232 < x < 1.85000000000000004e-25

    1. Initial program 38.0%

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

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

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

        \[\leadsto \color{blue}{-\frac{\log x}{n}} \]
      2. distribute-neg-frac57.0%

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

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

    if 1.85000000000000004e-25 < x

    1. Initial program 71.7%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 6.5 \cdot 10^{-274}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \mathbf{elif}\;x \leq 3.7 \cdot 10^{-240}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 10^{-232}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \mathbf{elif}\;x \leq 1.85 \cdot 10^{-25}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \end{array} \]

Alternative 15: 57.1% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{1}{n \cdot x}\\
t_1 := \frac{-\log x}{n}\\
\mathbf{if}\;x \leq 2.4 \cdot 10^{-274}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 2.8 \cdot 10^{-240}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 10^{-232}:\\
\;\;\;\;t_0\\

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

\mathbf{else}:\\
\;\;\;\;\frac{0}{n}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 2.4e-274 or 2.7999999999999999e-240 < x < 1.00000000000000002e-232

    1. Initial program 64.9%

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

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

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

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

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

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

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

    if 2.4e-274 < x < 2.7999999999999999e-240 or 1.00000000000000002e-232 < x < 1

    1. Initial program 40.7%

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

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

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

        \[\leadsto \color{blue}{-\frac{\log x}{n}} \]
      2. distribute-neg-frac54.3%

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

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

    if 1 < x

    1. Initial program 70.9%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\log \left(\frac{x + 1}{x}\right)}}{n} \]
    7. Step-by-step derivation
      1. add-cube-cbrt71.9%

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

        \[\leadsto \frac{\color{blue}{\log \left(\sqrt[3]{\frac{x + 1}{x}} \cdot \sqrt[3]{\frac{x + 1}{x}}\right) + \log \left(\sqrt[3]{\frac{x + 1}{x}}\right)}}{n} \]
      3. pow271.9%

        \[\leadsto \frac{\log \color{blue}{\left({\left(\sqrt[3]{\frac{x + 1}{x}}\right)}^{2}\right)} + \log \left(\sqrt[3]{\frac{x + 1}{x}}\right)}{n} \]
    8. Applied egg-rr71.9%

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

        \[\leadsto \frac{\color{blue}{2 \cdot \log \left(\sqrt[3]{\frac{x + 1}{x}}\right)} + \log \left(\sqrt[3]{\frac{x + 1}{x}}\right)}{n} \]
      2. distribute-lft1-in71.9%

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

        \[\leadsto \frac{\color{blue}{3} \cdot \log \left(\sqrt[3]{\frac{x + 1}{x}}\right)}{n} \]
    10. Simplified71.9%

      \[\leadsto \frac{\color{blue}{3 \cdot \log \left(\sqrt[3]{\frac{x + 1}{x}}\right)}}{n} \]
    11. Taylor expanded in x around inf 70.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 2.4 \cdot 10^{-274}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \mathbf{elif}\;x \leq 2.8 \cdot 10^{-240}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 10^{-232}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{0}{n}\\ \end{array} \]

Alternative 16: 39.7% accurate, 42.2× speedup?

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{1}{n \cdot x}} \]
  6. Final simplification38.3%

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

Alternative 17: 40.3% accurate, 42.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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