2nthrt (problem 3.4.6)

Percentage Accurate: 53.5% → 84.7%
Time: 1.1min
Alternatives: 24
Speedup: 1.8×

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 24 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.5% 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: 84.7% accurate, 0.3× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{0.5}{{n}^{2}}\\
t_1 := {x}^{\left(\frac{1}{n}\right)}\\
t_2 := \frac{t\_1}{n}\\
t_3 := \frac{-0.5 \cdot \frac{{\log x}^{2} - {\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n} - \log \left(\frac{x}{1 + x}\right)}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-160}:\\
\;\;\;\;\frac{t\_2}{x}\\

\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-54}:\\
\;\;\;\;t\_3\\

\mathbf{elif}\;\frac{1}{n} \leq 10^{-11}:\\
\;\;\;\;\frac{t\_2 - t\_1 \cdot \left(\frac{\left(t\_0 - \frac{0.16666666666666666}{{n}^{3}}\right) - \frac{0.3333333333333333}{n}}{{x}^{2}} - \frac{t\_0 + \frac{-0.5}{n}}{x}\right)}{x}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (/.f64 #s(literal 1 binary64) n) < -9.9999999999999999e-161

    1. Initial program 74.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{e^{\frac{\color{blue}{\log x \cdot 1}}{n}}}{n}}{x} \]
      9. associate-/l*88.5%

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

        \[\leadsto \frac{\frac{\color{blue}{{x}^{\left(\frac{1}{n}\right)}}}{n}}{x} \]
    5. Simplified88.5%

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

    if -9.9999999999999999e-161 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-54 or 9.99999999999999939e-12 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000007e-10

    1. Initial program 33.7%

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

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

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

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

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

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

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

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

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

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

    if 2.0000000000000001e-54 < (/.f64 #s(literal 1 binary64) n) < 9.99999999999999939e-12

    1. Initial program 4.8%

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

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

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

    if 2.00000000000000007e-10 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 43.1%

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

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

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

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

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

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

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

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

Alternative 2: 84.7% accurate, 0.2× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{0.5}{{n}^{2}}\\
t_1 := {x}^{\left(\frac{1}{n}\right)}\\
t_2 := \frac{t\_1}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-160}:\\
\;\;\;\;\frac{t\_2}{x}\\

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

\mathbf{elif}\;\frac{1}{n} \leq 10^{-5}:\\
\;\;\;\;\frac{\mathsf{fma}\left(t\_1, \frac{t\_0 + \frac{-0.5}{n}}{x}, t\_2\right) - t\_1 \cdot \left(\frac{\left(t\_0 - \frac{0.16666666666666666}{{n}^{3}}\right) - \frac{0.3333333333333333}{n}}{{x}^{2}} - \frac{\frac{0.041666666666666664}{{n}^{4}} + \left(\left(\frac{0.4583333333333333}{{n}^{2}} + \frac{-0.25}{n}\right) + \frac{-0.25}{{n}^{3}}\right)}{{x}^{3}}\right)}{x}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (/.f64 #s(literal 1 binary64) n) < -9.9999999999999999e-161

    1. Initial program 74.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{e^{\frac{\color{blue}{\log x \cdot 1}}{n}}}{n}}{x} \]
      9. associate-/l*88.5%

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

        \[\leadsto \frac{\frac{\color{blue}{{x}^{\left(\frac{1}{n}\right)}}}{n}}{x} \]
    5. Simplified88.5%

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

    if -9.9999999999999999e-161 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-54

    1. Initial program 33.7%

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

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

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

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

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

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

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

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

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

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

    if 2.0000000000000001e-54 < (/.f64 #s(literal 1 binary64) n) < 1.00000000000000008e-5

    1. Initial program 15.6%

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

      \[\leadsto \color{blue}{\frac{\frac{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}}}{n} + \left(\frac{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}} \cdot \left(0.5 \cdot \frac{1}{{n}^{2}} - 0.5 \cdot \frac{1}{n}\right)}{x} + \left(\frac{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}} \cdot \left(\left(0.041666666666666664 \cdot \frac{1}{{n}^{4}} + 0.4583333333333333 \cdot \frac{1}{{n}^{2}}\right) - \left(0.25 \cdot \frac{1}{n} + 0.25 \cdot \frac{1}{{n}^{3}}\right)\right)}{{x}^{3}} + \frac{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}} \cdot \left(\left(0.16666666666666666 \cdot \frac{1}{{n}^{3}} + 0.3333333333333333 \cdot \frac{1}{n}\right) - 0.5 \cdot \frac{1}{{n}^{2}}\right)}{{x}^{2}}\right)\right)}{x}} \]
    4. Simplified77.5%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left({x}^{\left(\frac{1}{n}\right)}, \frac{\frac{0.5}{{n}^{2}} + \frac{-0.5}{n}}{x}, \frac{{x}^{\left(\frac{1}{n}\right)}}{n}\right) + {x}^{\left(\frac{1}{n}\right)} \cdot \left(\frac{\frac{0.3333333333333333}{n} + \left(\frac{0.16666666666666666}{{n}^{3}} - \frac{0.5}{{n}^{2}}\right)}{{x}^{2}} + \frac{\frac{0.041666666666666664}{{n}^{4}} + \left(\left(\frac{0.4583333333333333}{{n}^{2}} + \frac{-0.25}{n}\right) + \frac{-0.25}{{n}^{3}}\right)}{{x}^{3}}\right)}{x}} \]

    if 1.00000000000000008e-5 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 43.0%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-160}:\\ \;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-54}:\\ \;\;\;\;\frac{-0.5 \cdot \frac{{\log x}^{2} - {\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n} - \log \left(\frac{x}{1 + x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{-5}:\\ \;\;\;\;\frac{\mathsf{fma}\left({x}^{\left(\frac{1}{n}\right)}, \frac{\frac{0.5}{{n}^{2}} + \frac{-0.5}{n}}{x}, \frac{{x}^{\left(\frac{1}{n}\right)}}{n}\right) - {x}^{\left(\frac{1}{n}\right)} \cdot \left(\frac{\left(\frac{0.5}{{n}^{2}} - \frac{0.16666666666666666}{{n}^{3}}\right) - \frac{0.3333333333333333}{n}}{{x}^{2}} - \frac{\frac{0.041666666666666664}{{n}^{4}} + \left(\left(\frac{0.4583333333333333}{{n}^{2}} + \frac{-0.25}{n}\right) + \frac{-0.25}{{n}^{3}}\right)}{{x}^{3}}\right)}{x}\\ \mathbf{else}:\\ \;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 85.0% accurate, 0.3× speedup?

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

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

\mathbf{elif}\;n \leq -13000:\\
\;\;\;\;\frac{\frac{t\_0}{n} - t\_0 \cdot \left(\frac{\left(t\_1 - \frac{0.16666666666666666}{{n}^{3}}\right) - \frac{0.3333333333333333}{n}}{{x}^{2}} - \frac{t\_1 + \frac{-0.5}{n}}{x}\right)}{x}\\

\mathbf{elif}\;n \leq 8500000:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if n < -5.6000000000000002e159

    1. Initial program 28.0%

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

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

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

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

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

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

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

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

    if -5.6000000000000002e159 < n < -13000

    1. Initial program 16.0%

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

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

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

    if -13000 < n < 8.5e6

    1. Initial program 78.2%

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

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

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

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

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

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

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

    if 8.5e6 < n

    1. Initial program 33.4%

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

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

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

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

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

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

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

      \[\leadsto \frac{-0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n} + \color{blue}{\log \left(\frac{x}{1 + x}\right)}}{-n} \]
    8. Step-by-step derivation
      1. +-commutative82.4%

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

      \[\leadsto \frac{-0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n} + \color{blue}{\log \left(\frac{x}{x + 1}\right)}}{-n} \]
    10. Step-by-step derivation
      1. add-log-exp82.5%

        \[\leadsto \frac{-0.5 \cdot \color{blue}{\log \left(e^{\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}\right)} + \log \left(\frac{x}{x + 1}\right)}{-n} \]
    11. Applied egg-rr82.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -5.6 \cdot 10^{+159}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{elif}\;n \leq -13000:\\ \;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n} - {x}^{\left(\frac{1}{n}\right)} \cdot \left(\frac{\left(\frac{0.5}{{n}^{2}} - \frac{0.16666666666666666}{{n}^{3}}\right) - \frac{0.3333333333333333}{n}}{{x}^{2}} - \frac{\frac{0.5}{{n}^{2}} + \frac{-0.5}{n}}{x}\right)}{x}\\ \mathbf{elif}\;n \leq 8500000:\\ \;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \left(\frac{x}{1 + x}\right) + -0.5 \cdot \log \left(e^{\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}\right)}{-n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 84.7% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{-0.5 \cdot \frac{{\log x}^{2} - {\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n} - \log \left(\frac{x}{1 + x}\right)}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-160}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\

\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-54}:\\
\;\;\;\;t\_1\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (/.f64 #s(literal 1 binary64) n) < -9.9999999999999999e-161

    1. Initial program 74.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{e^{\frac{\color{blue}{\log x \cdot 1}}{n}}}{n}}{x} \]
      9. associate-/l*88.5%

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

        \[\leadsto \frac{\frac{\color{blue}{{x}^{\left(\frac{1}{n}\right)}}}{n}}{x} \]
    5. Simplified88.5%

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

    if -9.9999999999999999e-161 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-54 or 9.99999999999999939e-12 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000007e-10

    1. Initial program 33.7%

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

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

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

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

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

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

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

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

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

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

    if 2.0000000000000001e-54 < (/.f64 #s(literal 1 binary64) n) < 9.99999999999999939e-12

    1. Initial program 4.8%

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

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

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

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

      \[\leadsto \color{blue}{\frac{-0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n} + \left(\log x - \mathsf{log1p}\left(x\right)\right)}{-n}} \]
    6. Taylor expanded in x around inf 81.0%

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

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

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

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

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

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

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

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

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

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

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

    if 2.00000000000000007e-10 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 43.1%

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

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

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

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

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

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

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

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

Alternative 5: 84.6% accurate, 0.6× speedup?

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

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if (/.f64 #s(literal 1 binary64) n) < -9.9999999999999999e-161

    1. Initial program 74.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{e^{\frac{\color{blue}{\log x \cdot 1}}{n}}}{n}}{x} \]
      9. associate-/l*88.5%

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

        \[\leadsto \frac{\frac{\color{blue}{{x}^{\left(\frac{1}{n}\right)}}}{n}}{x} \]
    5. Simplified88.5%

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

    if -9.9999999999999999e-161 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-54

    1. Initial program 33.7%

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

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

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

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

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

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

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

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

    if 2.0000000000000001e-54 < (/.f64 #s(literal 1 binary64) n) < 9.99999999999999939e-12

    1. Initial program 4.8%

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

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

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

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

      \[\leadsto \color{blue}{\frac{-0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n} + \left(\log x - \mathsf{log1p}\left(x\right)\right)}{-n}} \]
    6. Taylor expanded in x around inf 81.0%

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

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

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

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

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

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

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

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

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

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

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

    if 9.99999999999999939e-12 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000007e-10

    1. Initial program 33.8%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{-0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n} + \color{blue}{\log \left(\frac{x}{x + 1}\right)}}{-n} \]
    10. Taylor expanded in x around inf 88.6%

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

    if 2.00000000000000007e-10 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 43.1%

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

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

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

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

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

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

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

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

Alternative 6: 84.6% accurate, 0.6× speedup?

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq 10^{-11}:\\
\;\;\;\;\frac{t\_0 - \frac{\frac{0.5}{x} + -1}{x}}{n}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if (/.f64 #s(literal 1 binary64) n) < -9.9999999999999999e-161

    1. Initial program 74.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{e^{\frac{\color{blue}{\log x \cdot 1}}{n}}}{n}}{x} \]
      9. associate-/l*88.5%

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

        \[\leadsto \frac{\frac{\color{blue}{{x}^{\left(\frac{1}{n}\right)}}}{n}}{x} \]
    5. Simplified88.5%

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

    if -9.9999999999999999e-161 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-54

    1. Initial program 33.7%

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

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

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

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

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

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

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

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

    if 2.0000000000000001e-54 < (/.f64 #s(literal 1 binary64) n) < 9.99999999999999939e-12

    1. Initial program 4.8%

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

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

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

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

      \[\leadsto \color{blue}{\frac{-0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n} + \left(\log x - \mathsf{log1p}\left(x\right)\right)}{-n}} \]
    6. Taylor expanded in x around inf 81.0%

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

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

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

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

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

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

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

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

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

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

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

    if 9.99999999999999939e-12 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000007e-10

    1. Initial program 33.8%

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

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

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

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

      \[\leadsto \color{blue}{\frac{-0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n} + \left(\log x - \mathsf{log1p}\left(x\right)\right)}{-n}} \]
    6. Taylor expanded in x around inf 82.0%

      \[\leadsto \frac{-0.5 \cdot \frac{\color{blue}{-2 \cdot \frac{\log \left(\frac{1}{x}\right)}{x}}}{n} + \left(\log x - \mathsf{log1p}\left(x\right)\right)}{-n} \]
    7. Step-by-step derivation
      1. associate-*r/47.3%

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

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

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

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

    if 2.00000000000000007e-10 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 43.1%

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

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

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

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

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

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

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

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

Alternative 7: 84.6% accurate, 0.6× speedup?

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq 10^{-11}:\\
\;\;\;\;\frac{t\_0 - \frac{\frac{0.5}{x} + -1}{x}}{n}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if (/.f64 #s(literal 1 binary64) n) < -9.9999999999999999e-161

    1. Initial program 74.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{e^{\frac{\color{blue}{\log x \cdot 1}}{n}}}{n}}{x} \]
      9. associate-/l*88.5%

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

        \[\leadsto \frac{\frac{\color{blue}{{x}^{\left(\frac{1}{n}\right)}}}{n}}{x} \]
    5. Simplified88.5%

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

    if -9.9999999999999999e-161 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-54

    1. Initial program 33.7%

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

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

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

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

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

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

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

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

    if 2.0000000000000001e-54 < (/.f64 #s(literal 1 binary64) n) < 9.99999999999999939e-12

    1. Initial program 4.8%

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

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

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

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

      \[\leadsto \color{blue}{\frac{-0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n} + \left(\log x - \mathsf{log1p}\left(x\right)\right)}{-n}} \]
    6. Taylor expanded in x around inf 81.0%

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

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

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

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

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

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

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

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

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

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

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

    if 9.99999999999999939e-12 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000007e-10

    1. Initial program 33.8%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{-0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n} + \color{blue}{\log \left(\frac{x}{x + 1}\right)}}{-n} \]
    10. Taylor expanded in x around inf 80.9%

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

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

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

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

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

    if 2.00000000000000007e-10 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 43.1%

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

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

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

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

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

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

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

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

Alternative 8: 80.9% accurate, 0.8× speedup?

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq 10^{-11}:\\
\;\;\;\;\frac{t\_0 - \frac{\frac{0.5}{x} + -1}{x}}{n}\\

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

\mathbf{else}:\\
\;\;\;\;\left(1 - x \cdot \left(\frac{-1}{n} - x \cdot \left(0.5 \cdot \frac{1}{{n}^{2}} + 0.5 \cdot \frac{-1}{n}\right)\right)\right) - t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if (/.f64 #s(literal 1 binary64) n) < -9.9999999999999999e-161

    1. Initial program 74.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{e^{\frac{\color{blue}{\log x \cdot 1}}{n}}}{n}}{x} \]
      9. associate-/l*88.5%

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

        \[\leadsto \frac{\frac{\color{blue}{{x}^{\left(\frac{1}{n}\right)}}}{n}}{x} \]
    5. Simplified88.5%

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

    if -9.9999999999999999e-161 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-54

    1. Initial program 33.7%

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

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

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

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

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

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

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

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

    if 2.0000000000000001e-54 < (/.f64 #s(literal 1 binary64) n) < 9.99999999999999939e-12

    1. Initial program 4.8%

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

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

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

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

      \[\leadsto \color{blue}{\frac{-0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n} + \left(\log x - \mathsf{log1p}\left(x\right)\right)}{-n}} \]
    6. Taylor expanded in x around inf 81.0%

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

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

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

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

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

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

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

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

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

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

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

    if 9.99999999999999939e-12 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000007e-10

    1. Initial program 33.8%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{-0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n} + \color{blue}{\log \left(\frac{x}{x + 1}\right)}}{-n} \]
    10. Taylor expanded in x around inf 80.9%

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

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

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

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

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

    if 2.00000000000000007e-10 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 43.1%

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

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

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

Alternative 9: 81.3% accurate, 0.9× speedup?

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

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

\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-54}:\\
\;\;\;\;t\_1\\

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if (/.f64 #s(literal 1 binary64) n) < -9.9999999999999999e-161

    1. Initial program 74.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{e^{\frac{\color{blue}{\log x \cdot 1}}{n}}}{n}}{x} \]
      9. associate-/l*88.5%

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

        \[\leadsto \frac{\frac{\color{blue}{{x}^{\left(\frac{1}{n}\right)}}}{n}}{x} \]
    5. Simplified88.5%

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

    if -9.9999999999999999e-161 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-54 or 9.99999999999999939e-12 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000007e-10

    1. Initial program 33.7%

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

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

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

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

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

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

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

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

    if 2.0000000000000001e-54 < (/.f64 #s(literal 1 binary64) n) < 9.99999999999999939e-12

    1. Initial program 4.8%

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

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

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

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

      \[\leadsto \color{blue}{\frac{-0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n} + \left(\log x - \mathsf{log1p}\left(x\right)\right)}{-n}} \]
    6. Taylor expanded in x around inf 81.0%

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

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

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

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

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

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

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

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

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

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

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

    if 2.00000000000000007e-10 < (/.f64 #s(literal 1 binary64) n) < 5.0000000000000003e181

    1. Initial program 67.6%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Add Preprocessing

    if 5.0000000000000003e181 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 3.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 81.3% accurate, 0.9× speedup?

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq 10^{-11}:\\
\;\;\;\;\frac{t\_0 - \frac{\frac{0.5}{x} + -1}{x}}{n}\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 6 regimes
  2. if (/.f64 #s(literal 1 binary64) n) < -9.9999999999999999e-161

    1. Initial program 74.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{e^{\frac{\color{blue}{\log x \cdot 1}}{n}}}{n}}{x} \]
      9. associate-/l*88.5%

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

        \[\leadsto \frac{\frac{\color{blue}{{x}^{\left(\frac{1}{n}\right)}}}{n}}{x} \]
    5. Simplified88.5%

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

    if -9.9999999999999999e-161 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-54

    1. Initial program 33.7%

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

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

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

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

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

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

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

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

    if 2.0000000000000001e-54 < (/.f64 #s(literal 1 binary64) n) < 9.99999999999999939e-12

    1. Initial program 4.8%

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

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

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

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

      \[\leadsto \color{blue}{\frac{-0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n} + \left(\log x - \mathsf{log1p}\left(x\right)\right)}{-n}} \]
    6. Taylor expanded in x around inf 81.0%

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

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

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

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

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

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

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

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

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

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

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

    if 9.99999999999999939e-12 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000007e-10

    1. Initial program 33.8%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{-0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n} + \color{blue}{\log \left(\frac{x}{x + 1}\right)}}{-n} \]
    10. Taylor expanded in x around inf 80.9%

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

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

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

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

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

    if 2.00000000000000007e-10 < (/.f64 #s(literal 1 binary64) n) < 5.0000000000000003e181

    1. Initial program 67.6%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Add Preprocessing

    if 5.0000000000000003e181 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 3.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 80.9% accurate, 0.9× speedup?

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

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

\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-54}:\\
\;\;\;\;t\_1\\

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if (/.f64 #s(literal 1 binary64) n) < -9.9999999999999999e-161

    1. Initial program 74.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{e^{\frac{\color{blue}{\log x \cdot 1}}{n}}}{n}}{x} \]
      9. associate-/l*88.5%

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

        \[\leadsto \frac{\frac{\color{blue}{{x}^{\left(\frac{1}{n}\right)}}}{n}}{x} \]
    5. Simplified88.5%

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

    if -9.9999999999999999e-161 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-54 or 9.99999999999999939e-12 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000007e-10

    1. Initial program 33.7%

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

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

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

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

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

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

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

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

    if 2.0000000000000001e-54 < (/.f64 #s(literal 1 binary64) n) < 9.99999999999999939e-12

    1. Initial program 4.8%

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

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

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

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

      \[\leadsto \color{blue}{\frac{-0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n} + \left(\log x - \mathsf{log1p}\left(x\right)\right)}{-n}} \]
    6. Taylor expanded in x around inf 81.0%

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

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

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

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

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

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

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

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

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

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

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

    if 2.00000000000000007e-10 < (/.f64 #s(literal 1 binary64) n) < 5.0000000000000003e181

    1. Initial program 67.6%

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

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

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

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

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

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

    if 5.0000000000000003e181 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 3.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 80.6% accurate, 1.5× speedup?

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

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

\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-54}:\\
\;\;\;\;t\_1\\

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if (/.f64 #s(literal 1 binary64) n) < -9.9999999999999999e-161

    1. Initial program 74.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{e^{\frac{\color{blue}{\log x \cdot 1}}{n}}}{n}}{x} \]
      9. associate-/l*88.5%

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

        \[\leadsto \frac{\frac{\color{blue}{{x}^{\left(\frac{1}{n}\right)}}}{n}}{x} \]
    5. Simplified88.5%

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

    if -9.9999999999999999e-161 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-54 or 9.99999999999999939e-12 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000007e-10

    1. Initial program 33.7%

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

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

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

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

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

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

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

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

    if 2.0000000000000001e-54 < (/.f64 #s(literal 1 binary64) n) < 9.99999999999999939e-12

    1. Initial program 4.8%

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

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

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

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

      \[\leadsto \color{blue}{\frac{-0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n} + \left(\log x - \mathsf{log1p}\left(x\right)\right)}{-n}} \]
    6. Taylor expanded in x around inf 81.0%

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

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

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

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

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

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

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

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

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

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

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

    if 2.00000000000000007e-10 < (/.f64 #s(literal 1 binary64) n) < 5.0000000000000003e181

    1. Initial program 67.6%

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

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

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

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

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

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

    if 5.0000000000000003e181 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 3.5%

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{x}}}{n} \]
    8. Recombined 5 regimes into one program.
    9. Final simplification86.6%

      \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-160}:\\ \;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-54}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{-11}:\\ \;\;\;\;\frac{-0.5 \cdot \frac{\frac{\log x \cdot -2}{x}}{n} - \frac{\frac{0.5}{x} + -1}{x}}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-10}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+181}:\\ \;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{x}}{n}\\ \end{array} \]
    10. Add Preprocessing

    Alternative 13: 66.6% accurate, 1.5× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\ t_1 := \frac{\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{x}}{n}\\ t_2 := \frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{+179}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-6}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-160}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-10}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+181}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
    (FPCore (x n)
     :precision binary64
     (let* ((t_0 (- 1.0 (pow x (/ 1.0 n))))
            (t_1 (/ (/ (- 1.0 (/ (+ 0.5 (/ -0.3333333333333333 x)) x)) x) n))
            (t_2 (/ (log (/ (+ 1.0 x) x)) n)))
       (if (<= (/ 1.0 n) -2e+179)
         t_2
         (if (<= (/ 1.0 n) -2e-6)
           t_0
           (if (<= (/ 1.0 n) -1e-160)
             t_1
             (if (<= (/ 1.0 n) 2e-10) t_2 (if (<= (/ 1.0 n) 5e+181) t_0 t_1)))))))
    double code(double x, double n) {
    	double t_0 = 1.0 - pow(x, (1.0 / n));
    	double t_1 = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n;
    	double t_2 = log(((1.0 + x) / x)) / n;
    	double tmp;
    	if ((1.0 / n) <= -2e+179) {
    		tmp = t_2;
    	} else if ((1.0 / n) <= -2e-6) {
    		tmp = t_0;
    	} else if ((1.0 / n) <= -1e-160) {
    		tmp = t_1;
    	} else if ((1.0 / n) <= 2e-10) {
    		tmp = t_2;
    	} else if ((1.0 / n) <= 5e+181) {
    		tmp = t_0;
    	} else {
    		tmp = t_1;
    	}
    	return tmp;
    }
    
    real(8) function code(x, n)
        real(8), intent (in) :: x
        real(8), intent (in) :: n
        real(8) :: t_0
        real(8) :: t_1
        real(8) :: t_2
        real(8) :: tmp
        t_0 = 1.0d0 - (x ** (1.0d0 / n))
        t_1 = ((1.0d0 - ((0.5d0 + ((-0.3333333333333333d0) / x)) / x)) / x) / n
        t_2 = log(((1.0d0 + x) / x)) / n
        if ((1.0d0 / n) <= (-2d+179)) then
            tmp = t_2
        else if ((1.0d0 / n) <= (-2d-6)) then
            tmp = t_0
        else if ((1.0d0 / n) <= (-1d-160)) then
            tmp = t_1
        else if ((1.0d0 / n) <= 2d-10) then
            tmp = t_2
        else if ((1.0d0 / n) <= 5d+181) then
            tmp = t_0
        else
            tmp = t_1
        end if
        code = tmp
    end function
    
    public static double code(double x, double n) {
    	double t_0 = 1.0 - Math.pow(x, (1.0 / n));
    	double t_1 = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n;
    	double t_2 = Math.log(((1.0 + x) / x)) / n;
    	double tmp;
    	if ((1.0 / n) <= -2e+179) {
    		tmp = t_2;
    	} else if ((1.0 / n) <= -2e-6) {
    		tmp = t_0;
    	} else if ((1.0 / n) <= -1e-160) {
    		tmp = t_1;
    	} else if ((1.0 / n) <= 2e-10) {
    		tmp = t_2;
    	} else if ((1.0 / n) <= 5e+181) {
    		tmp = t_0;
    	} else {
    		tmp = t_1;
    	}
    	return tmp;
    }
    
    def code(x, n):
    	t_0 = 1.0 - math.pow(x, (1.0 / n))
    	t_1 = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n
    	t_2 = math.log(((1.0 + x) / x)) / n
    	tmp = 0
    	if (1.0 / n) <= -2e+179:
    		tmp = t_2
    	elif (1.0 / n) <= -2e-6:
    		tmp = t_0
    	elif (1.0 / n) <= -1e-160:
    		tmp = t_1
    	elif (1.0 / n) <= 2e-10:
    		tmp = t_2
    	elif (1.0 / n) <= 5e+181:
    		tmp = t_0
    	else:
    		tmp = t_1
    	return tmp
    
    function code(x, n)
    	t_0 = Float64(1.0 - (x ^ Float64(1.0 / n)))
    	t_1 = Float64(Float64(Float64(1.0 - Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / x)) / x) / n)
    	t_2 = Float64(log(Float64(Float64(1.0 + x) / x)) / n)
    	tmp = 0.0
    	if (Float64(1.0 / n) <= -2e+179)
    		tmp = t_2;
    	elseif (Float64(1.0 / n) <= -2e-6)
    		tmp = t_0;
    	elseif (Float64(1.0 / n) <= -1e-160)
    		tmp = t_1;
    	elseif (Float64(1.0 / n) <= 2e-10)
    		tmp = t_2;
    	elseif (Float64(1.0 / n) <= 5e+181)
    		tmp = t_0;
    	else
    		tmp = t_1;
    	end
    	return tmp
    end
    
    function tmp_2 = code(x, n)
    	t_0 = 1.0 - (x ^ (1.0 / n));
    	t_1 = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n;
    	t_2 = log(((1.0 + x) / x)) / n;
    	tmp = 0.0;
    	if ((1.0 / n) <= -2e+179)
    		tmp = t_2;
    	elseif ((1.0 / n) <= -2e-6)
    		tmp = t_0;
    	elseif ((1.0 / n) <= -1e-160)
    		tmp = t_1;
    	elseif ((1.0 / n) <= 2e-10)
    		tmp = t_2;
    	elseif ((1.0 / n) <= 5e+181)
    		tmp = t_0;
    	else
    		tmp = t_1;
    	end
    	tmp_2 = tmp;
    end
    
    code[x_, n_] := Block[{t$95$0 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(1.0 - N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]}, Block[{t$95$2 = N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e+179], t$95$2, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-6], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-160], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-10], t$95$2, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+181], t$95$0, t$95$1]]]]]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
    t_1 := \frac{\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{x}}{n}\\
    t_2 := \frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
    \mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{+179}:\\
    \;\;\;\;t\_2\\
    
    \mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-6}:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-160}:\\
    \;\;\;\;t\_1\\
    
    \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-10}:\\
    \;\;\;\;t\_2\\
    
    \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+181}:\\
    \;\;\;\;t\_0\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_1\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if (/.f64 #s(literal 1 binary64) n) < -1.99999999999999996e179 or -9.9999999999999999e-161 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000007e-10

      1. Initial program 49.5%

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

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

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

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

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

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

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

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

      if -1.99999999999999996e179 < (/.f64 #s(literal 1 binary64) n) < -1.99999999999999991e-6 or 2.00000000000000007e-10 < (/.f64 #s(literal 1 binary64) n) < 5.0000000000000003e181

      1. Initial program 85.4%

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

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

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

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

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

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

      if -1.99999999999999991e-6 < (/.f64 #s(literal 1 binary64) n) < -9.9999999999999999e-161 or 5.0000000000000003e181 < (/.f64 #s(literal 1 binary64) n)

      1. Initial program 10.4%

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

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

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

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

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

          \[\leadsto \frac{\color{blue}{\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{x}}}{n} \]
      8. Recombined 3 regimes into one program.
      9. Final simplification72.1%

        \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{+179}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-6}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-160}:\\ \;\;\;\;\frac{\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{x}}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-10}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+181}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{x}}{n}\\ \end{array} \]
      10. Add Preprocessing

      Alternative 14: 80.9% accurate, 1.6× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-160}:\\ \;\;\;\;\frac{\frac{t\_0}{n}}{x}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-10}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+181}:\\ \;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{x}}{n}\\ \end{array} \end{array} \]
      (FPCore (x n)
       :precision binary64
       (let* ((t_0 (pow x (/ 1.0 n))))
         (if (<= (/ 1.0 n) -1e-160)
           (/ (/ t_0 n) x)
           (if (<= (/ 1.0 n) 2e-10)
             (/ (log (/ (+ 1.0 x) x)) n)
             (if (<= (/ 1.0 n) 5e+181)
               (- (+ 1.0 (/ x n)) t_0)
               (/ (/ (- 1.0 (/ (+ 0.5 (/ -0.3333333333333333 x)) x)) x) n))))))
      double code(double x, double n) {
      	double t_0 = pow(x, (1.0 / n));
      	double tmp;
      	if ((1.0 / n) <= -1e-160) {
      		tmp = (t_0 / n) / x;
      	} else if ((1.0 / n) <= 2e-10) {
      		tmp = log(((1.0 + x) / x)) / n;
      	} else if ((1.0 / n) <= 5e+181) {
      		tmp = (1.0 + (x / n)) - t_0;
      	} else {
      		tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / 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 = x ** (1.0d0 / n)
          if ((1.0d0 / n) <= (-1d-160)) then
              tmp = (t_0 / n) / x
          else if ((1.0d0 / n) <= 2d-10) then
              tmp = log(((1.0d0 + x) / x)) / n
          else if ((1.0d0 / n) <= 5d+181) then
              tmp = (1.0d0 + (x / n)) - t_0
          else
              tmp = ((1.0d0 - ((0.5d0 + ((-0.3333333333333333d0) / x)) / x)) / x) / n
          end if
          code = tmp
      end function
      
      public static double code(double x, double n) {
      	double t_0 = Math.pow(x, (1.0 / n));
      	double tmp;
      	if ((1.0 / n) <= -1e-160) {
      		tmp = (t_0 / n) / x;
      	} else if ((1.0 / n) <= 2e-10) {
      		tmp = Math.log(((1.0 + x) / x)) / n;
      	} else if ((1.0 / n) <= 5e+181) {
      		tmp = (1.0 + (x / n)) - t_0;
      	} else {
      		tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n;
      	}
      	return tmp;
      }
      
      def code(x, n):
      	t_0 = math.pow(x, (1.0 / n))
      	tmp = 0
      	if (1.0 / n) <= -1e-160:
      		tmp = (t_0 / n) / x
      	elif (1.0 / n) <= 2e-10:
      		tmp = math.log(((1.0 + x) / x)) / n
      	elif (1.0 / n) <= 5e+181:
      		tmp = (1.0 + (x / n)) - t_0
      	else:
      		tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n
      	return tmp
      
      function code(x, n)
      	t_0 = x ^ Float64(1.0 / n)
      	tmp = 0.0
      	if (Float64(1.0 / n) <= -1e-160)
      		tmp = Float64(Float64(t_0 / n) / x);
      	elseif (Float64(1.0 / n) <= 2e-10)
      		tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n);
      	elseif (Float64(1.0 / n) <= 5e+181)
      		tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0);
      	else
      		tmp = Float64(Float64(Float64(1.0 - Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / x)) / x) / n);
      	end
      	return tmp
      end
      
      function tmp_2 = code(x, n)
      	t_0 = x ^ (1.0 / n);
      	tmp = 0.0;
      	if ((1.0 / n) <= -1e-160)
      		tmp = (t_0 / n) / x;
      	elseif ((1.0 / n) <= 2e-10)
      		tmp = log(((1.0 + x) / x)) / n;
      	elseif ((1.0 / n) <= 5e+181)
      		tmp = (1.0 + (x / n)) - t_0;
      	else
      		tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n;
      	end
      	tmp_2 = tmp;
      end
      
      code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-160], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-10], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+181], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[(N[(N[(1.0 - N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]]]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := {x}^{\left(\frac{1}{n}\right)}\\
      \mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-160}:\\
      \;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
      
      \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-10}:\\
      \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
      
      \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+181}:\\
      \;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{x}}{n}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 4 regimes
      2. if (/.f64 #s(literal 1 binary64) n) < -9.9999999999999999e-161

        1. Initial program 74.0%

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

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

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

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

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

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

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

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

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

            \[\leadsto \frac{\frac{e^{\frac{\color{blue}{\log x \cdot 1}}{n}}}{n}}{x} \]
          9. associate-/l*88.5%

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

            \[\leadsto \frac{\frac{\color{blue}{{x}^{\left(\frac{1}{n}\right)}}}{n}}{x} \]
        5. Simplified88.5%

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

        if -9.9999999999999999e-161 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000007e-10

        1. Initial program 31.7%

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

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

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

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

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

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

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

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

        if 2.00000000000000007e-10 < (/.f64 #s(literal 1 binary64) n) < 5.0000000000000003e181

        1. Initial program 67.6%

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

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

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

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

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

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

        if 5.0000000000000003e181 < (/.f64 #s(literal 1 binary64) n)

        1. Initial program 3.5%

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

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

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

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

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

            \[\leadsto \frac{\color{blue}{\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{x}}}{n} \]
        8. Recombined 4 regimes into one program.
        9. Final simplification85.0%

          \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-160}:\\ \;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-10}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+181}:\\ \;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{x}}{n}\\ \end{array} \]
        10. Add Preprocessing

        Alternative 15: 80.8% accurate, 1.7× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-160}:\\ \;\;\;\;\frac{\frac{t\_0}{n}}{x}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-10}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+181}:\\ \;\;\;\;1 - t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{x}}{n}\\ \end{array} \end{array} \]
        (FPCore (x n)
         :precision binary64
         (let* ((t_0 (pow x (/ 1.0 n))))
           (if (<= (/ 1.0 n) -1e-160)
             (/ (/ t_0 n) x)
             (if (<= (/ 1.0 n) 2e-10)
               (/ (log (/ (+ 1.0 x) x)) n)
               (if (<= (/ 1.0 n) 5e+181)
                 (- 1.0 t_0)
                 (/ (/ (- 1.0 (/ (+ 0.5 (/ -0.3333333333333333 x)) x)) x) n))))))
        double code(double x, double n) {
        	double t_0 = pow(x, (1.0 / n));
        	double tmp;
        	if ((1.0 / n) <= -1e-160) {
        		tmp = (t_0 / n) / x;
        	} else if ((1.0 / n) <= 2e-10) {
        		tmp = log(((1.0 + x) / x)) / n;
        	} else if ((1.0 / n) <= 5e+181) {
        		tmp = 1.0 - t_0;
        	} else {
        		tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / 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 = x ** (1.0d0 / n)
            if ((1.0d0 / n) <= (-1d-160)) then
                tmp = (t_0 / n) / x
            else if ((1.0d0 / n) <= 2d-10) then
                tmp = log(((1.0d0 + x) / x)) / n
            else if ((1.0d0 / n) <= 5d+181) then
                tmp = 1.0d0 - t_0
            else
                tmp = ((1.0d0 - ((0.5d0 + ((-0.3333333333333333d0) / x)) / x)) / x) / n
            end if
            code = tmp
        end function
        
        public static double code(double x, double n) {
        	double t_0 = Math.pow(x, (1.0 / n));
        	double tmp;
        	if ((1.0 / n) <= -1e-160) {
        		tmp = (t_0 / n) / x;
        	} else if ((1.0 / n) <= 2e-10) {
        		tmp = Math.log(((1.0 + x) / x)) / n;
        	} else if ((1.0 / n) <= 5e+181) {
        		tmp = 1.0 - t_0;
        	} else {
        		tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n;
        	}
        	return tmp;
        }
        
        def code(x, n):
        	t_0 = math.pow(x, (1.0 / n))
        	tmp = 0
        	if (1.0 / n) <= -1e-160:
        		tmp = (t_0 / n) / x
        	elif (1.0 / n) <= 2e-10:
        		tmp = math.log(((1.0 + x) / x)) / n
        	elif (1.0 / n) <= 5e+181:
        		tmp = 1.0 - t_0
        	else:
        		tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n
        	return tmp
        
        function code(x, n)
        	t_0 = x ^ Float64(1.0 / n)
        	tmp = 0.0
        	if (Float64(1.0 / n) <= -1e-160)
        		tmp = Float64(Float64(t_0 / n) / x);
        	elseif (Float64(1.0 / n) <= 2e-10)
        		tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n);
        	elseif (Float64(1.0 / n) <= 5e+181)
        		tmp = Float64(1.0 - t_0);
        	else
        		tmp = Float64(Float64(Float64(1.0 - Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / x)) / x) / n);
        	end
        	return tmp
        end
        
        function tmp_2 = code(x, n)
        	t_0 = x ^ (1.0 / n);
        	tmp = 0.0;
        	if ((1.0 / n) <= -1e-160)
        		tmp = (t_0 / n) / x;
        	elseif ((1.0 / n) <= 2e-10)
        		tmp = log(((1.0 + x) / x)) / n;
        	elseif ((1.0 / n) <= 5e+181)
        		tmp = 1.0 - t_0;
        	else
        		tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n;
        	end
        	tmp_2 = tmp;
        end
        
        code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-160], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-10], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+181], N[(1.0 - t$95$0), $MachinePrecision], N[(N[(N[(1.0 - N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]]]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := {x}^{\left(\frac{1}{n}\right)}\\
        \mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-160}:\\
        \;\;\;\;\frac{\frac{t\_0}{n}}{x}\\
        
        \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-10}:\\
        \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
        
        \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+181}:\\
        \;\;\;\;1 - t\_0\\
        
        \mathbf{else}:\\
        \;\;\;\;\frac{\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{x}}{n}\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 4 regimes
        2. if (/.f64 #s(literal 1 binary64) n) < -9.9999999999999999e-161

          1. Initial program 74.0%

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

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

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

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

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

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

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

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

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

              \[\leadsto \frac{\frac{e^{\frac{\color{blue}{\log x \cdot 1}}{n}}}{n}}{x} \]
            9. associate-/l*88.5%

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

              \[\leadsto \frac{\frac{\color{blue}{{x}^{\left(\frac{1}{n}\right)}}}{n}}{x} \]
          5. Simplified88.5%

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

          if -9.9999999999999999e-161 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000007e-10

          1. Initial program 31.7%

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

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

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

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

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

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

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

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

          if 2.00000000000000007e-10 < (/.f64 #s(literal 1 binary64) n) < 5.0000000000000003e181

          1. Initial program 67.6%

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

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

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

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

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

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

          if 5.0000000000000003e181 < (/.f64 #s(literal 1 binary64) n)

          1. Initial program 3.5%

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

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

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

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

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

              \[\leadsto \frac{\color{blue}{\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{x}}}{n} \]
          8. Recombined 4 regimes into one program.
          9. Final simplification84.7%

            \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-160}:\\ \;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-10}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+181}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{x}}{n}\\ \end{array} \]
          10. Add Preprocessing

          Alternative 16: 60.3% accurate, 1.7× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 1.32 \cdot 10^{-220}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 5.2 \cdot 10^{-181}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 0.88:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{elif}\;x \leq 1.2 \cdot 10^{+178}:\\ \;\;\;\;\frac{\frac{1 + \frac{-0.5 - \frac{-0.3333333333333333 + \frac{0.25}{x}}{x}}{x}}{x}}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{-0.5}{n \cdot {x}^{2}}\\ \end{array} \end{array} \]
          (FPCore (x n)
           :precision binary64
           (if (<= x 1.32e-220)
             (/ (log x) (- n))
             (if (<= x 5.2e-181)
               (- 1.0 (pow x (/ 1.0 n)))
               (if (<= x 0.88)
                 (/ (- x (log x)) n)
                 (if (<= x 1.2e+178)
                   (/
                    (/ (+ 1.0 (/ (- -0.5 (/ (+ -0.3333333333333333 (/ 0.25 x)) x)) x)) x)
                    n)
                   (/ -0.5 (* n (pow x 2.0))))))))
          double code(double x, double n) {
          	double tmp;
          	if (x <= 1.32e-220) {
          		tmp = log(x) / -n;
          	} else if (x <= 5.2e-181) {
          		tmp = 1.0 - pow(x, (1.0 / n));
          	} else if (x <= 0.88) {
          		tmp = (x - log(x)) / n;
          	} else if (x <= 1.2e+178) {
          		tmp = ((1.0 + ((-0.5 - ((-0.3333333333333333 + (0.25 / x)) / x)) / x)) / x) / n;
          	} else {
          		tmp = -0.5 / (n * pow(x, 2.0));
          	}
          	return tmp;
          }
          
          real(8) function code(x, n)
              real(8), intent (in) :: x
              real(8), intent (in) :: n
              real(8) :: tmp
              if (x <= 1.32d-220) then
                  tmp = log(x) / -n
              else if (x <= 5.2d-181) then
                  tmp = 1.0d0 - (x ** (1.0d0 / n))
              else if (x <= 0.88d0) then
                  tmp = (x - log(x)) / n
              else if (x <= 1.2d+178) then
                  tmp = ((1.0d0 + (((-0.5d0) - (((-0.3333333333333333d0) + (0.25d0 / x)) / x)) / x)) / x) / n
              else
                  tmp = (-0.5d0) / (n * (x ** 2.0d0))
              end if
              code = tmp
          end function
          
          public static double code(double x, double n) {
          	double tmp;
          	if (x <= 1.32e-220) {
          		tmp = Math.log(x) / -n;
          	} else if (x <= 5.2e-181) {
          		tmp = 1.0 - Math.pow(x, (1.0 / n));
          	} else if (x <= 0.88) {
          		tmp = (x - Math.log(x)) / n;
          	} else if (x <= 1.2e+178) {
          		tmp = ((1.0 + ((-0.5 - ((-0.3333333333333333 + (0.25 / x)) / x)) / x)) / x) / n;
          	} else {
          		tmp = -0.5 / (n * Math.pow(x, 2.0));
          	}
          	return tmp;
          }
          
          def code(x, n):
          	tmp = 0
          	if x <= 1.32e-220:
          		tmp = math.log(x) / -n
          	elif x <= 5.2e-181:
          		tmp = 1.0 - math.pow(x, (1.0 / n))
          	elif x <= 0.88:
          		tmp = (x - math.log(x)) / n
          	elif x <= 1.2e+178:
          		tmp = ((1.0 + ((-0.5 - ((-0.3333333333333333 + (0.25 / x)) / x)) / x)) / x) / n
          	else:
          		tmp = -0.5 / (n * math.pow(x, 2.0))
          	return tmp
          
          function code(x, n)
          	tmp = 0.0
          	if (x <= 1.32e-220)
          		tmp = Float64(log(x) / Float64(-n));
          	elseif (x <= 5.2e-181)
          		tmp = Float64(1.0 - (x ^ Float64(1.0 / n)));
          	elseif (x <= 0.88)
          		tmp = Float64(Float64(x - log(x)) / n);
          	elseif (x <= 1.2e+178)
          		tmp = Float64(Float64(Float64(1.0 + Float64(Float64(-0.5 - Float64(Float64(-0.3333333333333333 + Float64(0.25 / x)) / x)) / x)) / x) / n);
          	else
          		tmp = Float64(-0.5 / Float64(n * (x ^ 2.0)));
          	end
          	return tmp
          end
          
          function tmp_2 = code(x, n)
          	tmp = 0.0;
          	if (x <= 1.32e-220)
          		tmp = log(x) / -n;
          	elseif (x <= 5.2e-181)
          		tmp = 1.0 - (x ^ (1.0 / n));
          	elseif (x <= 0.88)
          		tmp = (x - log(x)) / n;
          	elseif (x <= 1.2e+178)
          		tmp = ((1.0 + ((-0.5 - ((-0.3333333333333333 + (0.25 / x)) / x)) / x)) / x) / n;
          	else
          		tmp = -0.5 / (n * (x ^ 2.0));
          	end
          	tmp_2 = tmp;
          end
          
          code[x_, n_] := If[LessEqual[x, 1.32e-220], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 5.2e-181], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.88], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 1.2e+178], N[(N[(N[(1.0 + N[(N[(-0.5 - N[(N[(-0.3333333333333333 + N[(0.25 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], N[(-0.5 / N[(n * N[Power[x, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;x \leq 1.32 \cdot 10^{-220}:\\
          \;\;\;\;\frac{\log x}{-n}\\
          
          \mathbf{elif}\;x \leq 5.2 \cdot 10^{-181}:\\
          \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
          
          \mathbf{elif}\;x \leq 0.88:\\
          \;\;\;\;\frac{x - \log x}{n}\\
          
          \mathbf{elif}\;x \leq 1.2 \cdot 10^{+178}:\\
          \;\;\;\;\frac{\frac{1 + \frac{-0.5 - \frac{-0.3333333333333333 + \frac{0.25}{x}}{x}}{x}}{x}}{n}\\
          
          \mathbf{else}:\\
          \;\;\;\;\frac{-0.5}{n \cdot {x}^{2}}\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 5 regimes
          2. if x < 1.31999999999999996e-220

            1. Initial program 42.4%

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

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

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

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

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

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

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

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

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

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

            if 1.31999999999999996e-220 < x < 5.19999999999999998e-181

            1. Initial program 61.5%

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

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

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

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

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

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

            if 5.19999999999999998e-181 < x < 0.880000000000000004

            1. Initial program 36.5%

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

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

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

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

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

            if 0.880000000000000004 < x < 1.2e178

            1. Initial program 53.9%

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

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

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

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

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

              \[\leadsto \frac{\color{blue}{\frac{1 + \frac{-0.5 - \frac{-0.3333333333333333 + \frac{0.25}{x}}{x}}{x}}{x}}}{n} \]

            if 1.2e178 < x

            1. Initial program 87.3%

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

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

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

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

              \[\leadsto \color{blue}{\frac{-0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n} + \left(\log x - \mathsf{log1p}\left(x\right)\right)}{-n}} \]
            6. Taylor expanded in x around inf 62.0%

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

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

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

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

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

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

              \[\leadsto \color{blue}{\frac{-0.5}{n \cdot {x}^{2}}} \]
            10. Step-by-step derivation
              1. *-commutative87.3%

                \[\leadsto \frac{-0.5}{\color{blue}{{x}^{2} \cdot n}} \]
            11. Simplified87.3%

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

            \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.32 \cdot 10^{-220}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 5.2 \cdot 10^{-181}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 0.88:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{elif}\;x \leq 1.2 \cdot 10^{+178}:\\ \;\;\;\;\frac{\frac{1 + \frac{-0.5 - \frac{-0.3333333333333333 + \frac{0.25}{x}}{x}}{x}}{x}}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{-0.5}{n \cdot {x}^{2}}\\ \end{array} \]
          5. Add Preprocessing

          Alternative 17: 56.3% accurate, 1.8× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 4.9 \cdot 10^{-201}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 7.5 \cdot 10^{-181}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \mathbf{elif}\;x \leq 0.9:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1 + \frac{-0.5 - \frac{-0.3333333333333333 + \frac{0.25}{x}}{x}}{x}}{x}}{n}\\ \end{array} \end{array} \]
          (FPCore (x n)
           :precision binary64
           (if (<= x 4.9e-201)
             (/ (log x) (- n))
             (if (<= x 7.5e-181)
               (/ 1.0 (* n x))
               (if (<= x 0.9)
                 (/ (- x (log x)) n)
                 (/
                  (/ (+ 1.0 (/ (- -0.5 (/ (+ -0.3333333333333333 (/ 0.25 x)) x)) x)) x)
                  n)))))
          double code(double x, double n) {
          	double tmp;
          	if (x <= 4.9e-201) {
          		tmp = log(x) / -n;
          	} else if (x <= 7.5e-181) {
          		tmp = 1.0 / (n * x);
          	} else if (x <= 0.9) {
          		tmp = (x - log(x)) / n;
          	} else {
          		tmp = ((1.0 + ((-0.5 - ((-0.3333333333333333 + (0.25 / x)) / x)) / 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 <= 4.9d-201) then
                  tmp = log(x) / -n
              else if (x <= 7.5d-181) then
                  tmp = 1.0d0 / (n * x)
              else if (x <= 0.9d0) then
                  tmp = (x - log(x)) / n
              else
                  tmp = ((1.0d0 + (((-0.5d0) - (((-0.3333333333333333d0) + (0.25d0 / x)) / x)) / x)) / x) / n
              end if
              code = tmp
          end function
          
          public static double code(double x, double n) {
          	double tmp;
          	if (x <= 4.9e-201) {
          		tmp = Math.log(x) / -n;
          	} else if (x <= 7.5e-181) {
          		tmp = 1.0 / (n * x);
          	} else if (x <= 0.9) {
          		tmp = (x - Math.log(x)) / n;
          	} else {
          		tmp = ((1.0 + ((-0.5 - ((-0.3333333333333333 + (0.25 / x)) / x)) / x)) / x) / n;
          	}
          	return tmp;
          }
          
          def code(x, n):
          	tmp = 0
          	if x <= 4.9e-201:
          		tmp = math.log(x) / -n
          	elif x <= 7.5e-181:
          		tmp = 1.0 / (n * x)
          	elif x <= 0.9:
          		tmp = (x - math.log(x)) / n
          	else:
          		tmp = ((1.0 + ((-0.5 - ((-0.3333333333333333 + (0.25 / x)) / x)) / x)) / x) / n
          	return tmp
          
          function code(x, n)
          	tmp = 0.0
          	if (x <= 4.9e-201)
          		tmp = Float64(log(x) / Float64(-n));
          	elseif (x <= 7.5e-181)
          		tmp = Float64(1.0 / Float64(n * x));
          	elseif (x <= 0.9)
          		tmp = Float64(Float64(x - log(x)) / n);
          	else
          		tmp = Float64(Float64(Float64(1.0 + Float64(Float64(-0.5 - Float64(Float64(-0.3333333333333333 + Float64(0.25 / x)) / x)) / x)) / x) / n);
          	end
          	return tmp
          end
          
          function tmp_2 = code(x, n)
          	tmp = 0.0;
          	if (x <= 4.9e-201)
          		tmp = log(x) / -n;
          	elseif (x <= 7.5e-181)
          		tmp = 1.0 / (n * x);
          	elseif (x <= 0.9)
          		tmp = (x - log(x)) / n;
          	else
          		tmp = ((1.0 + ((-0.5 - ((-0.3333333333333333 + (0.25 / x)) / x)) / x)) / x) / n;
          	end
          	tmp_2 = tmp;
          end
          
          code[x_, n_] := If[LessEqual[x, 4.9e-201], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 7.5e-181], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.9], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(1.0 + N[(N[(-0.5 - N[(N[(-0.3333333333333333 + N[(0.25 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;x \leq 4.9 \cdot 10^{-201}:\\
          \;\;\;\;\frac{\log x}{-n}\\
          
          \mathbf{elif}\;x \leq 7.5 \cdot 10^{-181}:\\
          \;\;\;\;\frac{1}{n \cdot x}\\
          
          \mathbf{elif}\;x \leq 0.9:\\
          \;\;\;\;\frac{x - \log x}{n}\\
          
          \mathbf{else}:\\
          \;\;\;\;\frac{\frac{1 + \frac{-0.5 - \frac{-0.3333333333333333 + \frac{0.25}{x}}{x}}{x}}{x}}{n}\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 4 regimes
          2. if x < 4.8999999999999997e-201

            1. Initial program 44.4%

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

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

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

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

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

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

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

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

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

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

            if 4.8999999999999997e-201 < x < 7.5000000000000002e-181

            1. Initial program 61.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

            if 7.5000000000000002e-181 < x < 0.900000000000000022

            1. Initial program 36.5%

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

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

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

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

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

            if 0.900000000000000022 < x

            1. Initial program 66.8%

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

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

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

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

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

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

            \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 4.9 \cdot 10^{-201}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 7.5 \cdot 10^{-181}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \mathbf{elif}\;x \leq 0.9:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1 + \frac{-0.5 - \frac{-0.3333333333333333 + \frac{0.25}{x}}{x}}{x}}{x}}{n}\\ \end{array} \]
          5. Add Preprocessing

          Alternative 18: 56.6% accurate, 1.8× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 2.15 \cdot 10^{-220}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 2.4 \cdot 10^{-181}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 0.9:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1 + \frac{-0.5 - \frac{-0.3333333333333333 + \frac{0.25}{x}}{x}}{x}}{x}}{n}\\ \end{array} \end{array} \]
          (FPCore (x n)
           :precision binary64
           (if (<= x 2.15e-220)
             (/ (log x) (- n))
             (if (<= x 2.4e-181)
               (- 1.0 (pow x (/ 1.0 n)))
               (if (<= x 0.9)
                 (/ (- x (log x)) n)
                 (/
                  (/ (+ 1.0 (/ (- -0.5 (/ (+ -0.3333333333333333 (/ 0.25 x)) x)) x)) x)
                  n)))))
          double code(double x, double n) {
          	double tmp;
          	if (x <= 2.15e-220) {
          		tmp = log(x) / -n;
          	} else if (x <= 2.4e-181) {
          		tmp = 1.0 - pow(x, (1.0 / n));
          	} else if (x <= 0.9) {
          		tmp = (x - log(x)) / n;
          	} else {
          		tmp = ((1.0 + ((-0.5 - ((-0.3333333333333333 + (0.25 / x)) / x)) / 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 <= 2.15d-220) then
                  tmp = log(x) / -n
              else if (x <= 2.4d-181) then
                  tmp = 1.0d0 - (x ** (1.0d0 / n))
              else if (x <= 0.9d0) then
                  tmp = (x - log(x)) / n
              else
                  tmp = ((1.0d0 + (((-0.5d0) - (((-0.3333333333333333d0) + (0.25d0 / x)) / x)) / x)) / x) / n
              end if
              code = tmp
          end function
          
          public static double code(double x, double n) {
          	double tmp;
          	if (x <= 2.15e-220) {
          		tmp = Math.log(x) / -n;
          	} else if (x <= 2.4e-181) {
          		tmp = 1.0 - Math.pow(x, (1.0 / n));
          	} else if (x <= 0.9) {
          		tmp = (x - Math.log(x)) / n;
          	} else {
          		tmp = ((1.0 + ((-0.5 - ((-0.3333333333333333 + (0.25 / x)) / x)) / x)) / x) / n;
          	}
          	return tmp;
          }
          
          def code(x, n):
          	tmp = 0
          	if x <= 2.15e-220:
          		tmp = math.log(x) / -n
          	elif x <= 2.4e-181:
          		tmp = 1.0 - math.pow(x, (1.0 / n))
          	elif x <= 0.9:
          		tmp = (x - math.log(x)) / n
          	else:
          		tmp = ((1.0 + ((-0.5 - ((-0.3333333333333333 + (0.25 / x)) / x)) / x)) / x) / n
          	return tmp
          
          function code(x, n)
          	tmp = 0.0
          	if (x <= 2.15e-220)
          		tmp = Float64(log(x) / Float64(-n));
          	elseif (x <= 2.4e-181)
          		tmp = Float64(1.0 - (x ^ Float64(1.0 / n)));
          	elseif (x <= 0.9)
          		tmp = Float64(Float64(x - log(x)) / n);
          	else
          		tmp = Float64(Float64(Float64(1.0 + Float64(Float64(-0.5 - Float64(Float64(-0.3333333333333333 + Float64(0.25 / x)) / x)) / x)) / x) / n);
          	end
          	return tmp
          end
          
          function tmp_2 = code(x, n)
          	tmp = 0.0;
          	if (x <= 2.15e-220)
          		tmp = log(x) / -n;
          	elseif (x <= 2.4e-181)
          		tmp = 1.0 - (x ^ (1.0 / n));
          	elseif (x <= 0.9)
          		tmp = (x - log(x)) / n;
          	else
          		tmp = ((1.0 + ((-0.5 - ((-0.3333333333333333 + (0.25 / x)) / x)) / x)) / x) / n;
          	end
          	tmp_2 = tmp;
          end
          
          code[x_, n_] := If[LessEqual[x, 2.15e-220], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 2.4e-181], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.9], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(1.0 + N[(N[(-0.5 - N[(N[(-0.3333333333333333 + N[(0.25 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;x \leq 2.15 \cdot 10^{-220}:\\
          \;\;\;\;\frac{\log x}{-n}\\
          
          \mathbf{elif}\;x \leq 2.4 \cdot 10^{-181}:\\
          \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\
          
          \mathbf{elif}\;x \leq 0.9:\\
          \;\;\;\;\frac{x - \log x}{n}\\
          
          \mathbf{else}:\\
          \;\;\;\;\frac{\frac{1 + \frac{-0.5 - \frac{-0.3333333333333333 + \frac{0.25}{x}}{x}}{x}}{x}}{n}\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 4 regimes
          2. if x < 2.1499999999999999e-220

            1. Initial program 42.4%

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

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

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

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

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

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

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

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

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

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

            if 2.1499999999999999e-220 < x < 2.4000000000000001e-181

            1. Initial program 61.5%

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

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

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

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

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

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

            if 2.4000000000000001e-181 < x < 0.900000000000000022

            1. Initial program 36.5%

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

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

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

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

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

            if 0.900000000000000022 < x

            1. Initial program 66.8%

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

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

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

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

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

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

            \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 2.15 \cdot 10^{-220}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 2.4 \cdot 10^{-181}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 0.9:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1 + \frac{-0.5 - \frac{-0.3333333333333333 + \frac{0.25}{x}}{x}}{x}}{x}}{n}\\ \end{array} \]
          5. Add Preprocessing

          Alternative 19: 52.3% accurate, 1.8× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\log x}{-n}\\ \mathbf{if}\;x \leq 1.95 \cdot 10^{-199}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 2.25 \cdot 10^{-181}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \mathbf{elif}\;x \leq 4.5 \cdot 10^{-59}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{x}}{n}\\ \end{array} \end{array} \]
          (FPCore (x n)
           :precision binary64
           (let* ((t_0 (/ (log x) (- n))))
             (if (<= x 1.95e-199)
               t_0
               (if (<= x 2.25e-181)
                 (/ 1.0 (* n x))
                 (if (<= x 4.5e-59)
                   t_0
                   (/ (/ (- 1.0 (/ (+ 0.5 (/ -0.3333333333333333 x)) x)) x) n))))))
          double code(double x, double n) {
          	double t_0 = log(x) / -n;
          	double tmp;
          	if (x <= 1.95e-199) {
          		tmp = t_0;
          	} else if (x <= 2.25e-181) {
          		tmp = 1.0 / (n * x);
          	} else if (x <= 4.5e-59) {
          		tmp = t_0;
          	} else {
          		tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / 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 <= 1.95d-199) then
                  tmp = t_0
              else if (x <= 2.25d-181) then
                  tmp = 1.0d0 / (n * x)
              else if (x <= 4.5d-59) then
                  tmp = t_0
              else
                  tmp = ((1.0d0 - ((0.5d0 + ((-0.3333333333333333d0) / x)) / 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 <= 1.95e-199) {
          		tmp = t_0;
          	} else if (x <= 2.25e-181) {
          		tmp = 1.0 / (n * x);
          	} else if (x <= 4.5e-59) {
          		tmp = t_0;
          	} else {
          		tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n;
          	}
          	return tmp;
          }
          
          def code(x, n):
          	t_0 = math.log(x) / -n
          	tmp = 0
          	if x <= 1.95e-199:
          		tmp = t_0
          	elif x <= 2.25e-181:
          		tmp = 1.0 / (n * x)
          	elif x <= 4.5e-59:
          		tmp = t_0
          	else:
          		tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n
          	return tmp
          
          function code(x, n)
          	t_0 = Float64(log(x) / Float64(-n))
          	tmp = 0.0
          	if (x <= 1.95e-199)
          		tmp = t_0;
          	elseif (x <= 2.25e-181)
          		tmp = Float64(1.0 / Float64(n * x));
          	elseif (x <= 4.5e-59)
          		tmp = t_0;
          	else
          		tmp = Float64(Float64(Float64(1.0 - Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / x)) / x) / n);
          	end
          	return tmp
          end
          
          function tmp_2 = code(x, n)
          	t_0 = log(x) / -n;
          	tmp = 0.0;
          	if (x <= 1.95e-199)
          		tmp = t_0;
          	elseif (x <= 2.25e-181)
          		tmp = 1.0 / (n * x);
          	elseif (x <= 4.5e-59)
          		tmp = t_0;
          	else
          		tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / 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, 1.95e-199], t$95$0, If[LessEqual[x, 2.25e-181], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4.5e-59], t$95$0, N[(N[(N[(1.0 - N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]]]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_0 := \frac{\log x}{-n}\\
          \mathbf{if}\;x \leq 1.95 \cdot 10^{-199}:\\
          \;\;\;\;t\_0\\
          
          \mathbf{elif}\;x \leq 2.25 \cdot 10^{-181}:\\
          \;\;\;\;\frac{1}{n \cdot x}\\
          
          \mathbf{elif}\;x \leq 4.5 \cdot 10^{-59}:\\
          \;\;\;\;t\_0\\
          
          \mathbf{else}:\\
          \;\;\;\;\frac{\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{x}}{n}\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 3 regimes
          2. if x < 1.9500000000000001e-199 or 2.2499999999999999e-181 < x < 4.50000000000000012e-59

            1. Initial program 38.7%

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

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

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

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

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

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

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

                \[\leadsto \color{blue}{\frac{-1 \cdot \log x}{n}} \]
              2. neg-mul-155.5%

                \[\leadsto \frac{\color{blue}{-\log x}}{n} \]
            8. Simplified55.5%

              \[\leadsto \color{blue}{\frac{-\log x}{n}} \]

            if 1.9500000000000001e-199 < x < 2.2499999999999999e-181

            1. Initial program 61.4%

              \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
            2. Add Preprocessing
            3. Taylor expanded in x around inf 43.9%

              \[\leadsto \color{blue}{\frac{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}}}{n \cdot x}} \]
            4. Step-by-step derivation
              1. mul-1-neg43.9%

                \[\leadsto \frac{e^{\color{blue}{-\frac{\log \left(\frac{1}{x}\right)}{n}}}}{n \cdot x} \]
              2. log-rec43.9%

                \[\leadsto \frac{e^{-\frac{\color{blue}{-\log x}}{n}}}{n \cdot x} \]
              3. mul-1-neg43.9%

                \[\leadsto \frac{e^{-\frac{\color{blue}{-1 \cdot \log x}}{n}}}{n \cdot x} \]
              4. distribute-neg-frac43.9%

                \[\leadsto \frac{e^{\color{blue}{\frac{--1 \cdot \log x}{n}}}}{n \cdot x} \]
              5. mul-1-neg43.9%

                \[\leadsto \frac{e^{\frac{-\color{blue}{\left(-\log x\right)}}{n}}}{n \cdot x} \]
              6. remove-double-neg43.9%

                \[\leadsto \frac{e^{\frac{\color{blue}{\log x}}{n}}}{n \cdot x} \]
              7. *-commutative43.9%

                \[\leadsto \frac{e^{\frac{\log x}{n}}}{\color{blue}{x \cdot n}} \]
            5. Simplified43.9%

              \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
            6. Taylor expanded in n around inf 65.6%

              \[\leadsto \color{blue}{\frac{1}{n \cdot x}} \]
            7. Step-by-step derivation
              1. *-commutative65.6%

                \[\leadsto \frac{1}{\color{blue}{x \cdot n}} \]
            8. Simplified65.6%

              \[\leadsto \color{blue}{\frac{1}{x \cdot n}} \]

            if 4.50000000000000012e-59 < x

            1. Initial program 61.6%

              \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
            2. Add Preprocessing
            3. Taylor expanded in n around inf 59.5%

              \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
            4. Step-by-step derivation
              1. log1p-define59.5%

                \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(x\right)} - \log x}{n} \]
            5. Simplified59.5%

              \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
            6. Taylor expanded in x around inf 54.2%

              \[\leadsto \frac{\color{blue}{\frac{\left(1 + \frac{0.3333333333333333}{{x}^{2}}\right) - 0.5 \cdot \frac{1}{x}}{x}}}{n} \]
            7. Step-by-step derivation
              1. Simplified54.2%

                \[\leadsto \frac{\color{blue}{\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{x}}}{n} \]
            8. Recombined 3 regimes into one program.
            9. Final simplification55.4%

              \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.95 \cdot 10^{-199}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 2.25 \cdot 10^{-181}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \mathbf{elif}\;x \leq 4.5 \cdot 10^{-59}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{x}}{n}\\ \end{array} \]
            10. Add Preprocessing

            Alternative 20: 46.2% accurate, 12.4× speedup?

            \[\begin{array}{l} \\ \frac{\frac{1}{n} + \frac{\frac{-0.5}{n} + \frac{0.3333333333333333}{n \cdot x}}{x}}{x} \end{array} \]
            (FPCore (x n)
             :precision binary64
             (/ (+ (/ 1.0 n) (/ (+ (/ -0.5 n) (/ 0.3333333333333333 (* n x))) x)) x))
            double code(double x, double n) {
            	return ((1.0 / n) + (((-0.5 / n) + (0.3333333333333333 / (n * x))) / x)) / x;
            }
            
            real(8) function code(x, n)
                real(8), intent (in) :: x
                real(8), intent (in) :: n
                code = ((1.0d0 / n) + ((((-0.5d0) / n) + (0.3333333333333333d0 / (n * x))) / x)) / x
            end function
            
            public static double code(double x, double n) {
            	return ((1.0 / n) + (((-0.5 / n) + (0.3333333333333333 / (n * x))) / x)) / x;
            }
            
            def code(x, n):
            	return ((1.0 / n) + (((-0.5 / n) + (0.3333333333333333 / (n * x))) / x)) / x
            
            function code(x, n)
            	return Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(-0.5 / n) + Float64(0.3333333333333333 / Float64(n * x))) / x)) / x)
            end
            
            function tmp = code(x, n)
            	tmp = ((1.0 / n) + (((-0.5 / n) + (0.3333333333333333 / (n * x))) / x)) / x;
            end
            
            code[x_, n_] := N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(-0.5 / n), $MachinePrecision] + N[(0.3333333333333333 / N[(n * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]
            
            \begin{array}{l}
            
            \\
            \frac{\frac{1}{n} + \frac{\frac{-0.5}{n} + \frac{0.3333333333333333}{n \cdot x}}{x}}{x}
            \end{array}
            
            Derivation
            1. Initial program 52.0%

              \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
            2. Add Preprocessing
            3. Taylor expanded in n around inf 55.7%

              \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
            4. Step-by-step derivation
              1. log1p-define55.7%

                \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(x\right)} - \log x}{n} \]
            5. Simplified55.7%

              \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
            6. Taylor expanded in x around -inf 45.3%

              \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{n \cdot x} - 0.5 \cdot \frac{1}{n}}{x} - \frac{1}{n}}{x}} \]
            7. Step-by-step derivation
              1. associate-*r/45.3%

                \[\leadsto \color{blue}{\frac{-1 \cdot \left(-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{n \cdot x} - 0.5 \cdot \frac{1}{n}}{x} - \frac{1}{n}\right)}{x}} \]
            8. Simplified45.3%

              \[\leadsto \color{blue}{\frac{\frac{\frac{0.3333333333333333}{x \cdot n} + \frac{-0.5}{n}}{x} + \frac{1}{n}}{x}} \]
            9. Final simplification45.3%

              \[\leadsto \frac{\frac{1}{n} + \frac{\frac{-0.5}{n} + \frac{0.3333333333333333}{n \cdot x}}{x}}{x} \]
            10. Add Preprocessing

            Alternative 21: 46.2% accurate, 16.2× speedup?

            \[\begin{array}{l} \\ \frac{\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{x}}{n} \end{array} \]
            (FPCore (x n)
             :precision binary64
             (/ (/ (- 1.0 (/ (+ 0.5 (/ -0.3333333333333333 x)) x)) x) n))
            double code(double x, double n) {
            	return ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n;
            }
            
            real(8) function code(x, n)
                real(8), intent (in) :: x
                real(8), intent (in) :: n
                code = ((1.0d0 - ((0.5d0 + ((-0.3333333333333333d0) / x)) / x)) / x) / n
            end function
            
            public static double code(double x, double n) {
            	return ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n;
            }
            
            def code(x, n):
            	return ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n
            
            function code(x, n)
            	return Float64(Float64(Float64(1.0 - Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / x)) / x) / n)
            end
            
            function tmp = code(x, n)
            	tmp = ((1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / x) / n;
            end
            
            code[x_, n_] := N[(N[(N[(1.0 - N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision]
            
            \begin{array}{l}
            
            \\
            \frac{\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{x}}{n}
            \end{array}
            
            Derivation
            1. Initial program 52.0%

              \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
            2. Add Preprocessing
            3. Taylor expanded in n around inf 55.7%

              \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
            4. Step-by-step derivation
              1. log1p-define55.7%

                \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(x\right)} - \log x}{n} \]
            5. Simplified55.7%

              \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
            6. Taylor expanded in x around inf 45.3%

              \[\leadsto \frac{\color{blue}{\frac{\left(1 + \frac{0.3333333333333333}{{x}^{2}}\right) - 0.5 \cdot \frac{1}{x}}{x}}}{n} \]
            7. Step-by-step derivation
              1. Simplified45.3%

                \[\leadsto \frac{\color{blue}{\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{x}}}{n} \]
              2. Final simplification45.3%

                \[\leadsto \frac{\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{x}}{n} \]
              3. Add Preprocessing

              Alternative 22: 39.9% 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 52.0%

                \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
              2. Add Preprocessing
              3. Taylor expanded in x around inf 56.2%

                \[\leadsto \color{blue}{\frac{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}}}{n \cdot x}} \]
              4. Step-by-step derivation
                1. mul-1-neg56.2%

                  \[\leadsto \frac{e^{\color{blue}{-\frac{\log \left(\frac{1}{x}\right)}{n}}}}{n \cdot x} \]
                2. log-rec56.2%

                  \[\leadsto \frac{e^{-\frac{\color{blue}{-\log x}}{n}}}{n \cdot x} \]
                3. mul-1-neg56.2%

                  \[\leadsto \frac{e^{-\frac{\color{blue}{-1 \cdot \log x}}{n}}}{n \cdot x} \]
                4. distribute-neg-frac56.2%

                  \[\leadsto \frac{e^{\color{blue}{\frac{--1 \cdot \log x}{n}}}}{n \cdot x} \]
                5. mul-1-neg56.2%

                  \[\leadsto \frac{e^{\frac{-\color{blue}{\left(-\log x\right)}}{n}}}{n \cdot x} \]
                6. remove-double-neg56.2%

                  \[\leadsto \frac{e^{\frac{\color{blue}{\log x}}{n}}}{n \cdot x} \]
                7. *-commutative56.2%

                  \[\leadsto \frac{e^{\frac{\log x}{n}}}{\color{blue}{x \cdot n}} \]
              5. Simplified56.2%

                \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
              6. Taylor expanded in n around inf 40.5%

                \[\leadsto \color{blue}{\frac{1}{n \cdot x}} \]
              7. Step-by-step derivation
                1. *-commutative40.5%

                  \[\leadsto \frac{1}{\color{blue}{x \cdot n}} \]
              8. Simplified40.5%

                \[\leadsto \color{blue}{\frac{1}{x \cdot n}} \]
              9. Final simplification40.5%

                \[\leadsto \frac{1}{n \cdot x} \]
              10. Add Preprocessing

              Alternative 23: 40.5% accurate, 42.2× speedup?

              \[\begin{array}{l} \\ \frac{\frac{1}{n}}{x} \end{array} \]
              (FPCore (x n) :precision binary64 (/ (/ 1.0 n) x))
              double code(double x, double n) {
              	return (1.0 / n) / x;
              }
              
              real(8) function code(x, n)
                  real(8), intent (in) :: x
                  real(8), intent (in) :: n
                  code = (1.0d0 / n) / x
              end function
              
              public static double code(double x, double n) {
              	return (1.0 / n) / x;
              }
              
              def code(x, n):
              	return (1.0 / n) / x
              
              function code(x, n)
              	return Float64(Float64(1.0 / n) / x)
              end
              
              function tmp = code(x, n)
              	tmp = (1.0 / n) / x;
              end
              
              code[x_, n_] := N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]
              
              \begin{array}{l}
              
              \\
              \frac{\frac{1}{n}}{x}
              \end{array}
              
              Derivation
              1. Initial program 52.0%

                \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
              2. Add Preprocessing
              3. Taylor expanded in x around inf 56.2%

                \[\leadsto \color{blue}{\frac{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}}}{n \cdot x}} \]
              4. Step-by-step derivation
                1. mul-1-neg56.2%

                  \[\leadsto \frac{e^{\color{blue}{-\frac{\log \left(\frac{1}{x}\right)}{n}}}}{n \cdot x} \]
                2. log-rec56.2%

                  \[\leadsto \frac{e^{-\frac{\color{blue}{-\log x}}{n}}}{n \cdot x} \]
                3. mul-1-neg56.2%

                  \[\leadsto \frac{e^{-\frac{\color{blue}{-1 \cdot \log x}}{n}}}{n \cdot x} \]
                4. distribute-neg-frac56.2%

                  \[\leadsto \frac{e^{\color{blue}{\frac{--1 \cdot \log x}{n}}}}{n \cdot x} \]
                5. mul-1-neg56.2%

                  \[\leadsto \frac{e^{\frac{-\color{blue}{\left(-\log x\right)}}{n}}}{n \cdot x} \]
                6. remove-double-neg56.2%

                  \[\leadsto \frac{e^{\frac{\color{blue}{\log x}}{n}}}{n \cdot x} \]
                7. *-commutative56.2%

                  \[\leadsto \frac{e^{\frac{\log x}{n}}}{\color{blue}{x \cdot n}} \]
              5. Simplified56.2%

                \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
              6. Taylor expanded in n around inf 40.5%

                \[\leadsto \color{blue}{\frac{1}{n \cdot x}} \]
              7. Step-by-step derivation
                1. *-commutative40.5%

                  \[\leadsto \frac{1}{\color{blue}{x \cdot n}} \]
              8. Simplified40.5%

                \[\leadsto \color{blue}{\frac{1}{x \cdot n}} \]
              9. Step-by-step derivation
                1. associate-/r*40.7%

                  \[\leadsto \color{blue}{\frac{\frac{1}{x}}{n}} \]
                2. div-inv40.7%

                  \[\leadsto \color{blue}{\frac{1}{x} \cdot \frac{1}{n}} \]
              10. Applied egg-rr40.7%

                \[\leadsto \color{blue}{\frac{1}{x} \cdot \frac{1}{n}} \]
              11. Taylor expanded in x around 0 40.5%

                \[\leadsto \color{blue}{\frac{1}{n \cdot x}} \]
              12. Step-by-step derivation
                1. associate-/r*40.7%

                  \[\leadsto \color{blue}{\frac{\frac{1}{n}}{x}} \]
              13. Simplified40.7%

                \[\leadsto \color{blue}{\frac{\frac{1}{n}}{x}} \]
              14. Final simplification40.7%

                \[\leadsto \frac{\frac{1}{n}}{x} \]
              15. Add Preprocessing

              Alternative 24: 40.5% 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 52.0%

                \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
              2. Add Preprocessing
              3. Taylor expanded in n around inf 55.7%

                \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
              4. Step-by-step derivation
                1. log1p-define55.7%

                  \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(x\right)} - \log x}{n} \]
              5. Simplified55.7%

                \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
              6. Taylor expanded in x around inf 40.7%

                \[\leadsto \frac{\color{blue}{\frac{1}{x}}}{n} \]
              7. Final simplification40.7%

                \[\leadsto \frac{\frac{1}{x}}{n} \]
              8. Add Preprocessing

              Reproduce

              ?
              herbie shell --seed 2024100 
              (FPCore (x n)
                :name "2nthrt (problem 3.4.6)"
                :precision binary64
                (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))