2nthrt (problem 3.4.6)

Percentage Accurate: 53.3% → 85.4%
Time: 23.7s
Alternatives: 18
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 18 alternatives:

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

Initial Program: 53.3% accurate, 1.0× speedup?

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

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

Alternative 1: 85.4% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-102}:\\ \;\;\;\;\frac{t_0}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 5000:\\ \;\;\;\;\mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, \frac{\mathsf{log1p}\left(x\right)}{n}\right) - \mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{n \cdot n}, \frac{\log x}{n}\right)\\ \mathbf{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) -2e-102)
     (/ t_0 (* n x))
     (if (<= (/ 1.0 n) 5000.0)
       (-
        (fma 0.5 (/ (pow (log1p x) 2.0) (* n n)) (/ (log1p x) n))
        (fma 0.5 (/ (pow (log x) 2.0) (* n n)) (/ (log x) n)))
       (- (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) <= -2e-102) {
		tmp = t_0 / (n * x);
	} else if ((1.0 / n) <= 5000.0) {
		tmp = fma(0.5, (pow(log1p(x), 2.0) / (n * n)), (log1p(x) / n)) - fma(0.5, (pow(log(x), 2.0) / (n * n)), (log(x) / n));
	} else {
		tmp = 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) <= -2e-102)
		tmp = Float64(t_0 / Float64(n * x));
	elseif (Float64(1.0 / n) <= 5000.0)
		tmp = Float64(fma(0.5, Float64((log1p(x) ^ 2.0) / Float64(n * n)), Float64(log1p(x) / n)) - fma(0.5, Float64((log(x) ^ 2.0) / Float64(n * n)), Float64(log(x) / n)));
	else
		tmp = Float64(exp(Float64(x / n)) - t_0);
	end
	return tmp
end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-102], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5000.0], N[(N[(0.5 * N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision] + N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] - N[(0.5 * N[(N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision] + N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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 -2 \cdot 10^{-102}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\

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

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


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

    1. Initial program 76.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.99999999999999987e-102 < (/.f64 1 n) < 5e3

    1. Initial program 32.7%

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

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

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

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

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

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

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

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

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

    if 5e3 < (/.f64 1 n)

    1. Initial program 62.8%

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

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

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

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

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

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

Alternative 2: 80.6% accurate, 1.0× speedup?

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

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

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

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

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


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

    1. Initial program 76.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.99999999999999987e-102 < (/.f64 1 n) < 4.99999999999999973e-21

    1. Initial program 32.7%

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

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

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

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

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

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

    if 4.99999999999999973e-21 < (/.f64 1 n) < 1.00000000000000008e218

    1. Initial program 79.5%

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

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

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

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

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

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

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

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

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

    if 1.00000000000000008e218 < (/.f64 1 n)

    1. Initial program 19.3%

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

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

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

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

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

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

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

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

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

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

Alternative 3: 80.6% accurate, 1.0× speedup?

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

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

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

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

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


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

    1. Initial program 76.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.99999999999999987e-102 < (/.f64 1 n) < 4.99999999999999973e-21

    1. Initial program 32.7%

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

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

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

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

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

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

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

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

    if 4.99999999999999973e-21 < (/.f64 1 n) < 1.00000000000000008e218

    1. Initial program 79.5%

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

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

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

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

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

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

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

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

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

    if 1.00000000000000008e218 < (/.f64 1 n)

    1. Initial program 19.3%

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

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

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

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

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

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

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

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

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

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

Alternative 4: 85.3% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-21}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right)}{n} - \frac{\log x}{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) < -1.99999999999999987e-102

    1. Initial program 76.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.99999999999999987e-102 < (/.f64 1 n) < 4.99999999999999973e-21

    1. Initial program 32.7%

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

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

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

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

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

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

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

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

    if 4.99999999999999973e-21 < (/.f64 1 n)

    1. Initial program 61.5%

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

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

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

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

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

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

Alternative 5: 80.5% accurate, 1.0× speedup?

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

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

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

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

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


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

    1. Initial program 76.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.99999999999999987e-102 < (/.f64 1 n) < 4.99999999999999973e-21

    1. Initial program 32.7%

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

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

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

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

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

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

    if 4.99999999999999973e-21 < (/.f64 1 n) < 1.00000000000000008e218

    1. Initial program 79.5%

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

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

    if 1.00000000000000008e218 < (/.f64 1 n)

    1. Initial program 19.3%

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

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

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

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

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

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

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

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

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

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

Alternative 6: 52.2% accurate, 1.6× speedup?

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

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

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

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if (/.f64 1 n) < -2e5 or -1.6000000000000001e-258 < (/.f64 1 n) < 5.00000000000000018e-285 or 4.99999999999999954e-22 < (/.f64 1 n) < 1.00000000000000008e218

    1. Initial program 90.7%

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

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

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

    1. Initial program 9.5%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{{\left(x \cdot n\right)}^{-1}} \]
      2. unpow-prod-down62.1%

        \[\leadsto \color{blue}{{x}^{-1} \cdot {n}^{-1}} \]
      3. inv-pow62.1%

        \[\leadsto \color{blue}{\frac{1}{x}} \cdot {n}^{-1} \]
      4. inv-pow62.1%

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

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

    if -2e-140 < (/.f64 1 n) < -1.6000000000000001e-258

    1. Initial program 21.8%

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

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

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

        \[\leadsto \color{blue}{\frac{-1 \cdot \log x}{n}} \]
      2. mul-1-neg78.9%

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

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

    if 5.00000000000000018e-285 < (/.f64 1 n) < 4.99999999999999954e-22

    1. Initial program 24.0%

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

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

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

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

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

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

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

    if 1.00000000000000008e218 < (/.f64 1 n)

    1. Initial program 19.3%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -200000:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-140}:\\ \;\;\;\;\frac{1}{n} \cdot \frac{1}{x}\\ \mathbf{elif}\;\frac{1}{n} \leq -1.6 \cdot 10^{-258}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-285}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-22}:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{+218}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \end{array} \]

Alternative 7: 66.4% accurate, 1.6× speedup?

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

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

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

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

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

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

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


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

    1. Initial program 75.2%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Taylor expanded in x around inf 89.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-neg89.9%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{{x}^{\left(\frac{1}{n}\right)}}}{n \cdot x} \]
      4. *-commutative89.9%

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

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

    if -2e-140 < (/.f64 1 n) < -1.6000000000000001e-258

    1. Initial program 21.8%

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

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

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

        \[\leadsto \color{blue}{\frac{-1 \cdot \log x}{n}} \]
      2. mul-1-neg78.9%

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

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

    if -1.6000000000000001e-258 < (/.f64 1 n) < 5.00000000000000018e-285

    1. Initial program 71.4%

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

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

    if 5.00000000000000018e-285 < (/.f64 1 n) < 4.99999999999999973e-21

    1. Initial program 24.9%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x}{n} + -1 \cdot \frac{\log x}{n}} \]
      2. mul-1-neg62.0%

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

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

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

    if 4.99999999999999973e-21 < (/.f64 1 n) < 1.00000000000000008e218

    1. Initial program 79.5%

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

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

    if 1.00000000000000008e218 < (/.f64 1 n)

    1. Initial program 19.3%

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

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

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

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

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

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

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

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

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

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

Alternative 8: 66.2% accurate, 1.6× speedup?

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

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

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

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

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

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

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


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

    1. Initial program 75.2%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Taylor expanded in x around inf 89.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-neg89.9%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{{x}^{\left(\frac{1}{n}\right)}}}{n \cdot x} \]
      4. *-commutative89.9%

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

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

    if -2e-140 < (/.f64 1 n) < -1.6000000000000001e-258

    1. Initial program 21.8%

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

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

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

        \[\leadsto \color{blue}{\frac{-1 \cdot \log x}{n}} \]
      2. mul-1-neg78.9%

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

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

    if -1.6000000000000001e-258 < (/.f64 1 n) < 5.00000000000000018e-285

    1. Initial program 71.4%

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

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

    if 5.00000000000000018e-285 < (/.f64 1 n) < 4.99999999999999973e-21

    1. Initial program 24.9%

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

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

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

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

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

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

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

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

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

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

    if 4.99999999999999973e-21 < (/.f64 1 n) < 1.00000000000000008e218

    1. Initial program 79.5%

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

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

    if 1.00000000000000008e218 < (/.f64 1 n)

    1. Initial program 19.3%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-140}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq -1.6 \cdot 10^{-258}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-285}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-21}:\\ \;\;\;\;\frac{\left(x + \left(x \cdot x\right) \cdot -0.5\right) - \log x}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{+218}:\\ \;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \end{array} \]

Alternative 9: 66.3% accurate, 1.7× speedup?

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

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

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq 10^{+218}:\\
\;\;\;\;t_1\\

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


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

    1. Initial program 75.2%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Taylor expanded in x around inf 89.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-neg89.9%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{{x}^{\left(\frac{1}{n}\right)}}}{n \cdot x} \]
      4. *-commutative89.9%

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

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

    if -2e-140 < (/.f64 1 n) < -1.6000000000000001e-258

    1. Initial program 21.8%

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

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

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

        \[\leadsto \color{blue}{\frac{-1 \cdot \log x}{n}} \]
      2. mul-1-neg78.9%

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

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

    if -1.6000000000000001e-258 < (/.f64 1 n) < 5.00000000000000018e-285 or 4.99999999999999954e-22 < (/.f64 1 n) < 1.00000000000000008e218

    1. Initial program 75.3%

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

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

    if 5.00000000000000018e-285 < (/.f64 1 n) < 4.99999999999999954e-22

    1. Initial program 24.0%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x}{n} + -1 \cdot \frac{\log x}{n}} \]
      2. mul-1-neg62.4%

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

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

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

    if 1.00000000000000008e218 < (/.f64 1 n)

    1. Initial program 19.3%

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

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

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

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

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

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

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

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

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

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

Alternative 10: 60.2% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq -3.1 \cdot 10^{+139}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;n \leq -14.5:\\ \;\;\;\;\frac{1}{n} \cdot \frac{1}{x}\\ \mathbf{elif}\;n \leq 8 \cdot 10^{-219}:\\ \;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\ \mathbf{elif}\;n \leq 5 \cdot 10^{+20} \lor \neg \left(n \leq 3.9 \cdot 10^{+284}\right):\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{n} \cdot \left(x - \log x\right)\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= n -3.1e+139)
   (/ (- (log x)) n)
   (if (<= n -14.5)
     (* (/ 1.0 n) (/ 1.0 x))
     (if (<= n 8e-219)
       (/ 0.3333333333333333 (* n (pow x 3.0)))
       (if (or (<= n 5e+20) (not (<= n 3.9e+284)))
         (- 1.0 (pow x (/ 1.0 n)))
         (* (/ 1.0 n) (- x (log x))))))))
double code(double x, double n) {
	double tmp;
	if (n <= -3.1e+139) {
		tmp = -log(x) / n;
	} else if (n <= -14.5) {
		tmp = (1.0 / n) * (1.0 / x);
	} else if (n <= 8e-219) {
		tmp = 0.3333333333333333 / (n * pow(x, 3.0));
	} else if ((n <= 5e+20) || !(n <= 3.9e+284)) {
		tmp = 1.0 - pow(x, (1.0 / n));
	} else {
		tmp = (1.0 / n) * (x - log(x));
	}
	return tmp;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    real(8) :: tmp
    if (n <= (-3.1d+139)) then
        tmp = -log(x) / n
    else if (n <= (-14.5d0)) then
        tmp = (1.0d0 / n) * (1.0d0 / x)
    else if (n <= 8d-219) then
        tmp = 0.3333333333333333d0 / (n * (x ** 3.0d0))
    else if ((n <= 5d+20) .or. (.not. (n <= 3.9d+284))) then
        tmp = 1.0d0 - (x ** (1.0d0 / n))
    else
        tmp = (1.0d0 / n) * (x - log(x))
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double tmp;
	if (n <= -3.1e+139) {
		tmp = -Math.log(x) / n;
	} else if (n <= -14.5) {
		tmp = (1.0 / n) * (1.0 / x);
	} else if (n <= 8e-219) {
		tmp = 0.3333333333333333 / (n * Math.pow(x, 3.0));
	} else if ((n <= 5e+20) || !(n <= 3.9e+284)) {
		tmp = 1.0 - Math.pow(x, (1.0 / n));
	} else {
		tmp = (1.0 / n) * (x - Math.log(x));
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if n <= -3.1e+139:
		tmp = -math.log(x) / n
	elif n <= -14.5:
		tmp = (1.0 / n) * (1.0 / x)
	elif n <= 8e-219:
		tmp = 0.3333333333333333 / (n * math.pow(x, 3.0))
	elif (n <= 5e+20) or not (n <= 3.9e+284):
		tmp = 1.0 - math.pow(x, (1.0 / n))
	else:
		tmp = (1.0 / n) * (x - math.log(x))
	return tmp
function code(x, n)
	tmp = 0.0
	if (n <= -3.1e+139)
		tmp = Float64(Float64(-log(x)) / n);
	elseif (n <= -14.5)
		tmp = Float64(Float64(1.0 / n) * Float64(1.0 / x));
	elseif (n <= 8e-219)
		tmp = Float64(0.3333333333333333 / Float64(n * (x ^ 3.0)));
	elseif ((n <= 5e+20) || !(n <= 3.9e+284))
		tmp = Float64(1.0 - (x ^ Float64(1.0 / n)));
	else
		tmp = Float64(Float64(1.0 / n) * Float64(x - log(x)));
	end
	return tmp
end
function tmp_2 = code(x, n)
	tmp = 0.0;
	if (n <= -3.1e+139)
		tmp = -log(x) / n;
	elseif (n <= -14.5)
		tmp = (1.0 / n) * (1.0 / x);
	elseif (n <= 8e-219)
		tmp = 0.3333333333333333 / (n * (x ^ 3.0));
	elseif ((n <= 5e+20) || ~((n <= 3.9e+284)))
		tmp = 1.0 - (x ^ (1.0 / n));
	else
		tmp = (1.0 / n) * (x - log(x));
	end
	tmp_2 = tmp;
end
code[x_, n_] := If[LessEqual[n, -3.1e+139], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[n, -14.5], N[(N[(1.0 / n), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 8e-219], N[(0.3333333333333333 / N[(n * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[n, 5e+20], N[Not[LessEqual[n, 3.9e+284]], $MachinePrecision]], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / n), $MachinePrecision] * N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;n \leq -3.1 \cdot 10^{+139}:\\
\;\;\;\;\frac{-\log x}{n}\\

\mathbf{elif}\;n \leq -14.5:\\
\;\;\;\;\frac{1}{n} \cdot \frac{1}{x}\\

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

\mathbf{elif}\;n \leq 5 \cdot 10^{+20} \lor \neg \left(n \leq 3.9 \cdot 10^{+284}\right):\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if n < -3.1e139

    1. Initial program 33.7%

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

      \[\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. associate-*r/69.6%

        \[\leadsto \color{blue}{\frac{-1 \cdot \log x}{n}} \]
      2. mul-1-neg69.6%

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

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

    if -3.1e139 < n < -14.5

    1. Initial program 9.5%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{{\left(x \cdot n\right)}^{-1}} \]
      2. unpow-prod-down62.1%

        \[\leadsto \color{blue}{{x}^{-1} \cdot {n}^{-1}} \]
      3. inv-pow62.1%

        \[\leadsto \color{blue}{\frac{1}{x}} \cdot {n}^{-1} \]
      4. inv-pow62.1%

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

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

    if -14.5 < n < 8.0000000000000003e-219

    1. Initial program 89.7%

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

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

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

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

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

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

      \[\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-neg29.2%

        \[\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. +-commutative29.2%

        \[\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+29.2%

        \[\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/29.2%

        \[\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-eval29.2%

        \[\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/29.2%

        \[\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-eval29.2%

        \[\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-frac29.2%

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

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

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

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

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

    if 8.0000000000000003e-219 < n < 5e20 or 3.89999999999999976e284 < n

    1. Initial program 80.1%

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

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

    if 5e20 < n < 3.89999999999999976e284

    1. Initial program 24.0%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -3.1 \cdot 10^{+139}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;n \leq -14.5:\\ \;\;\;\;\frac{1}{n} \cdot \frac{1}{x}\\ \mathbf{elif}\;n \leq 8 \cdot 10^{-219}:\\ \;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\ \mathbf{elif}\;n \leq 5 \cdot 10^{+20} \lor \neg \left(n \leq 3.9 \cdot 10^{+284}\right):\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{n} \cdot \left(x - \log x\right)\\ \end{array} \]

Alternative 11: 60.3% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq -1.15 \cdot 10^{+141}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;n \leq -15.2:\\ \;\;\;\;\frac{1}{n} \cdot \frac{1}{x}\\ \mathbf{elif}\;n \leq 10^{-218}:\\ \;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\ \mathbf{elif}\;n \leq 5 \cdot 10^{+20} \lor \neg \left(n \leq 2.5 \cdot 10^{+284}\right):\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{n} - \frac{\log x}{n}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= n -1.15e+141)
   (/ (- (log x)) n)
   (if (<= n -15.2)
     (* (/ 1.0 n) (/ 1.0 x))
     (if (<= n 1e-218)
       (/ 0.3333333333333333 (* n (pow x 3.0)))
       (if (or (<= n 5e+20) (not (<= n 2.5e+284)))
         (- 1.0 (pow x (/ 1.0 n)))
         (- (/ x n) (/ (log x) n)))))))
double code(double x, double n) {
	double tmp;
	if (n <= -1.15e+141) {
		tmp = -log(x) / n;
	} else if (n <= -15.2) {
		tmp = (1.0 / n) * (1.0 / x);
	} else if (n <= 1e-218) {
		tmp = 0.3333333333333333 / (n * pow(x, 3.0));
	} else if ((n <= 5e+20) || !(n <= 2.5e+284)) {
		tmp = 1.0 - pow(x, (1.0 / n));
	} else {
		tmp = (x / n) - (log(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 <= (-1.15d+141)) then
        tmp = -log(x) / n
    else if (n <= (-15.2d0)) then
        tmp = (1.0d0 / n) * (1.0d0 / x)
    else if (n <= 1d-218) then
        tmp = 0.3333333333333333d0 / (n * (x ** 3.0d0))
    else if ((n <= 5d+20) .or. (.not. (n <= 2.5d+284))) then
        tmp = 1.0d0 - (x ** (1.0d0 / n))
    else
        tmp = (x / n) - (log(x) / n)
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double tmp;
	if (n <= -1.15e+141) {
		tmp = -Math.log(x) / n;
	} else if (n <= -15.2) {
		tmp = (1.0 / n) * (1.0 / x);
	} else if (n <= 1e-218) {
		tmp = 0.3333333333333333 / (n * Math.pow(x, 3.0));
	} else if ((n <= 5e+20) || !(n <= 2.5e+284)) {
		tmp = 1.0 - Math.pow(x, (1.0 / n));
	} else {
		tmp = (x / n) - (Math.log(x) / n);
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if n <= -1.15e+141:
		tmp = -math.log(x) / n
	elif n <= -15.2:
		tmp = (1.0 / n) * (1.0 / x)
	elif n <= 1e-218:
		tmp = 0.3333333333333333 / (n * math.pow(x, 3.0))
	elif (n <= 5e+20) or not (n <= 2.5e+284):
		tmp = 1.0 - math.pow(x, (1.0 / n))
	else:
		tmp = (x / n) - (math.log(x) / n)
	return tmp
function code(x, n)
	tmp = 0.0
	if (n <= -1.15e+141)
		tmp = Float64(Float64(-log(x)) / n);
	elseif (n <= -15.2)
		tmp = Float64(Float64(1.0 / n) * Float64(1.0 / x));
	elseif (n <= 1e-218)
		tmp = Float64(0.3333333333333333 / Float64(n * (x ^ 3.0)));
	elseif ((n <= 5e+20) || !(n <= 2.5e+284))
		tmp = Float64(1.0 - (x ^ Float64(1.0 / n)));
	else
		tmp = Float64(Float64(x / n) - Float64(log(x) / n));
	end
	return tmp
end
function tmp_2 = code(x, n)
	tmp = 0.0;
	if (n <= -1.15e+141)
		tmp = -log(x) / n;
	elseif (n <= -15.2)
		tmp = (1.0 / n) * (1.0 / x);
	elseif (n <= 1e-218)
		tmp = 0.3333333333333333 / (n * (x ^ 3.0));
	elseif ((n <= 5e+20) || ~((n <= 2.5e+284)))
		tmp = 1.0 - (x ^ (1.0 / n));
	else
		tmp = (x / n) - (log(x) / n);
	end
	tmp_2 = tmp;
end
code[x_, n_] := If[LessEqual[n, -1.15e+141], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[n, -15.2], N[(N[(1.0 / n), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1e-218], N[(0.3333333333333333 / N[(n * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[n, 5e+20], N[Not[LessEqual[n, 2.5e+284]], $MachinePrecision]], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(x / n), $MachinePrecision] - N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.15 \cdot 10^{+141}:\\
\;\;\;\;\frac{-\log x}{n}\\

\mathbf{elif}\;n \leq -15.2:\\
\;\;\;\;\frac{1}{n} \cdot \frac{1}{x}\\

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

\mathbf{elif}\;n \leq 5 \cdot 10^{+20} \lor \neg \left(n \leq 2.5 \cdot 10^{+284}\right):\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if n < -1.1500000000000001e141

    1. Initial program 33.7%

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

      \[\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. associate-*r/69.6%

        \[\leadsto \color{blue}{\frac{-1 \cdot \log x}{n}} \]
      2. mul-1-neg69.6%

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

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

    if -1.1500000000000001e141 < n < -15.199999999999999

    1. Initial program 9.5%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{{\left(x \cdot n\right)}^{-1}} \]
      2. unpow-prod-down62.1%

        \[\leadsto \color{blue}{{x}^{-1} \cdot {n}^{-1}} \]
      3. inv-pow62.1%

        \[\leadsto \color{blue}{\frac{1}{x}} \cdot {n}^{-1} \]
      4. inv-pow62.1%

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

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

    if -15.199999999999999 < n < 1e-218

    1. Initial program 89.7%

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

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

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

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

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

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

      \[\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-neg29.2%

        \[\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. +-commutative29.2%

        \[\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+29.2%

        \[\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/29.2%

        \[\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-eval29.2%

        \[\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/29.2%

        \[\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-eval29.2%

        \[\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-frac29.2%

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

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

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

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

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

    if 1e-218 < n < 5e20 or 2.5e284 < n

    1. Initial program 80.1%

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

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

    if 5e20 < n < 2.5e284

    1. Initial program 24.0%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{x}{n} + -1 \cdot \frac{\log x}{n}} \]
      2. mul-1-neg62.4%

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

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

      \[\leadsto \color{blue}{\frac{x}{n} - \frac{\log x}{n}} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification71.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -1.15 \cdot 10^{+141}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;n \leq -15.2:\\ \;\;\;\;\frac{1}{n} \cdot \frac{1}{x}\\ \mathbf{elif}\;n \leq 10^{-218}:\\ \;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\ \mathbf{elif}\;n \leq 5 \cdot 10^{+20} \lor \neg \left(n \leq 2.5 \cdot 10^{+284}\right):\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{n} - \frac{\log x}{n}\\ \end{array} \]

Alternative 12: 60.3% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq -2.8 \cdot 10^{+141}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;n \leq -5.4:\\ \;\;\;\;\frac{1}{n} \cdot \frac{1}{x}\\ \mathbf{elif}\;n \leq 1.35 \cdot 10^{-219}:\\ \;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\ \mathbf{elif}\;n \leq 5 \cdot 10^{+20} \lor \neg \left(n \leq 3.3 \cdot 10^{+284}\right):\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{x - \log x}{n}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= n -2.8e+141)
   (/ (- (log x)) n)
   (if (<= n -5.4)
     (* (/ 1.0 n) (/ 1.0 x))
     (if (<= n 1.35e-219)
       (/ 0.3333333333333333 (* n (pow x 3.0)))
       (if (or (<= n 5e+20) (not (<= n 3.3e+284)))
         (- 1.0 (pow x (/ 1.0 n)))
         (/ (- x (log x)) n))))))
double code(double x, double n) {
	double tmp;
	if (n <= -2.8e+141) {
		tmp = -log(x) / n;
	} else if (n <= -5.4) {
		tmp = (1.0 / n) * (1.0 / x);
	} else if (n <= 1.35e-219) {
		tmp = 0.3333333333333333 / (n * pow(x, 3.0));
	} else if ((n <= 5e+20) || !(n <= 3.3e+284)) {
		tmp = 1.0 - pow(x, (1.0 / n));
	} else {
		tmp = (x - log(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 <= (-2.8d+141)) then
        tmp = -log(x) / n
    else if (n <= (-5.4d0)) then
        tmp = (1.0d0 / n) * (1.0d0 / x)
    else if (n <= 1.35d-219) then
        tmp = 0.3333333333333333d0 / (n * (x ** 3.0d0))
    else if ((n <= 5d+20) .or. (.not. (n <= 3.3d+284))) then
        tmp = 1.0d0 - (x ** (1.0d0 / n))
    else
        tmp = (x - log(x)) / n
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double tmp;
	if (n <= -2.8e+141) {
		tmp = -Math.log(x) / n;
	} else if (n <= -5.4) {
		tmp = (1.0 / n) * (1.0 / x);
	} else if (n <= 1.35e-219) {
		tmp = 0.3333333333333333 / (n * Math.pow(x, 3.0));
	} else if ((n <= 5e+20) || !(n <= 3.3e+284)) {
		tmp = 1.0 - Math.pow(x, (1.0 / n));
	} else {
		tmp = (x - Math.log(x)) / n;
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if n <= -2.8e+141:
		tmp = -math.log(x) / n
	elif n <= -5.4:
		tmp = (1.0 / n) * (1.0 / x)
	elif n <= 1.35e-219:
		tmp = 0.3333333333333333 / (n * math.pow(x, 3.0))
	elif (n <= 5e+20) or not (n <= 3.3e+284):
		tmp = 1.0 - math.pow(x, (1.0 / n))
	else:
		tmp = (x - math.log(x)) / n
	return tmp
function code(x, n)
	tmp = 0.0
	if (n <= -2.8e+141)
		tmp = Float64(Float64(-log(x)) / n);
	elseif (n <= -5.4)
		tmp = Float64(Float64(1.0 / n) * Float64(1.0 / x));
	elseif (n <= 1.35e-219)
		tmp = Float64(0.3333333333333333 / Float64(n * (x ^ 3.0)));
	elseif ((n <= 5e+20) || !(n <= 3.3e+284))
		tmp = Float64(1.0 - (x ^ Float64(1.0 / n)));
	else
		tmp = Float64(Float64(x - log(x)) / n);
	end
	return tmp
end
function tmp_2 = code(x, n)
	tmp = 0.0;
	if (n <= -2.8e+141)
		tmp = -log(x) / n;
	elseif (n <= -5.4)
		tmp = (1.0 / n) * (1.0 / x);
	elseif (n <= 1.35e-219)
		tmp = 0.3333333333333333 / (n * (x ^ 3.0));
	elseif ((n <= 5e+20) || ~((n <= 3.3e+284)))
		tmp = 1.0 - (x ^ (1.0 / n));
	else
		tmp = (x - log(x)) / n;
	end
	tmp_2 = tmp;
end
code[x_, n_] := If[LessEqual[n, -2.8e+141], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[n, -5.4], N[(N[(1.0 / n), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.35e-219], N[(0.3333333333333333 / N[(n * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[n, 5e+20], N[Not[LessEqual[n, 3.3e+284]], $MachinePrecision]], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;n \leq -2.8 \cdot 10^{+141}:\\
\;\;\;\;\frac{-\log x}{n}\\

\mathbf{elif}\;n \leq -5.4:\\
\;\;\;\;\frac{1}{n} \cdot \frac{1}{x}\\

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

\mathbf{elif}\;n \leq 5 \cdot 10^{+20} \lor \neg \left(n \leq 3.3 \cdot 10^{+284}\right):\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if n < -2.79999999999999991e141

    1. Initial program 33.7%

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

      \[\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. associate-*r/69.6%

        \[\leadsto \color{blue}{\frac{-1 \cdot \log x}{n}} \]
      2. mul-1-neg69.6%

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

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

    if -2.79999999999999991e141 < n < -5.4000000000000004

    1. Initial program 9.5%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{{\left(x \cdot n\right)}^{-1}} \]
      2. unpow-prod-down62.1%

        \[\leadsto \color{blue}{{x}^{-1} \cdot {n}^{-1}} \]
      3. inv-pow62.1%

        \[\leadsto \color{blue}{\frac{1}{x}} \cdot {n}^{-1} \]
      4. inv-pow62.1%

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

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

    if -5.4000000000000004 < n < 1.35e-219

    1. Initial program 89.7%

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

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

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

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

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

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

      \[\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-neg29.2%

        \[\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. +-commutative29.2%

        \[\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+29.2%

        \[\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/29.2%

        \[\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-eval29.2%

        \[\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/29.2%

        \[\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-eval29.2%

        \[\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-frac29.2%

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

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

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

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

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

    if 1.35e-219 < n < 5e20 or 3.2999999999999997e284 < n

    1. Initial program 80.1%

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

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

    if 5e20 < n < 3.2999999999999997e284

    1. Initial program 24.0%

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{x} - \log x}{n} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification71.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -2.8 \cdot 10^{+141}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;n \leq -5.4:\\ \;\;\;\;\frac{1}{n} \cdot \frac{1}{x}\\ \mathbf{elif}\;n \leq 1.35 \cdot 10^{-219}:\\ \;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\ \mathbf{elif}\;n \leq 5 \cdot 10^{+20} \lor \neg \left(n \leq 3.3 \cdot 10^{+284}\right):\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{x - \log x}{n}\\ \end{array} \]

Alternative 13: 55.2% accurate, 1.9× speedup?

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

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

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

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

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


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

    1. Initial program 45.3%

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

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

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

        \[\leadsto \color{blue}{\frac{-1 \cdot \log x}{n}} \]
      2. mul-1-neg59.6%

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

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

    if 1.5e-278 < x < 1.4e-225

    1. Initial program 89.9%

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

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

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

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

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

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

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

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

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

    if 1.4e-225 < x < 0.94999999999999996

    1. Initial program 44.2%

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

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

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

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

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

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

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

    if 0.94999999999999996 < x

    1. Initial program 67.2%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.5 \cdot 10^{-278}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{-225}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \mathbf{elif}\;x \leq 0.95:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\ \end{array} \]

Alternative 14: 54.9% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{-\log x}{n}\\
\mathbf{if}\;x \leq 8.2 \cdot 10^{-279}:\\
\;\;\;\;t_0\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 8.20000000000000034e-279 or 2.5999999999999998e-226 < x < 0.680000000000000049

    1. Initial program 44.3%

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

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

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

        \[\leadsto \color{blue}{\frac{-1 \cdot \log x}{n}} \]
      2. mul-1-neg51.6%

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

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

    if 8.20000000000000034e-279 < x < 2.5999999999999998e-226

    1. Initial program 89.9%

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

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

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

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

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

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

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

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

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

    if 0.680000000000000049 < x

    1. Initial program 67.2%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 8.2 \cdot 10^{-279}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 2.6 \cdot 10^{-226}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \mathbf{elif}\;x \leq 0.68:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\ \end{array} \]

Alternative 15: 40.8% accurate, 30.1× speedup?

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{1}{x \cdot n}} \]
  8. Step-by-step derivation
    1. inv-pow41.7%

      \[\leadsto \color{blue}{{\left(x \cdot n\right)}^{-1}} \]
    2. unpow-prod-down41.9%

      \[\leadsto \color{blue}{{x}^{-1} \cdot {n}^{-1}} \]
    3. inv-pow41.9%

      \[\leadsto \color{blue}{\frac{1}{x}} \cdot {n}^{-1} \]
    4. inv-pow41.9%

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

    \[\leadsto \color{blue}{\frac{1}{x} \cdot \frac{1}{n}} \]
  10. Final simplification41.9%

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

Alternative 16: 40.3% 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 56.0%

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

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

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

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

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

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

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

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

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

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

Alternative 17: 40.8% accurate, 42.2× speedup?

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\color{blue}{\frac{1}{x}}}{n} \]
  6. Final simplification41.9%

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

Alternative 18: 4.6% accurate, 70.3× speedup?

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\color{blue}{x} - \log x}{n} \]
  6. Taylor expanded in x around inf 4.8%

    \[\leadsto \color{blue}{\frac{x}{n}} \]
  7. Final simplification4.8%

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

Reproduce

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