2nthrt (problem 3.4.6)

Percentage Accurate: 53.9% → 85.5%
Time: 44.6s
Alternatives: 15
Speedup: 1.9×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 15 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.9% accurate, 1.0× speedup?

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

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

Alternative 1: 85.5% accurate, 0.9× speedup?

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq 5:\\
\;\;\;\;\frac{{e}^{\left(\frac{\log x}{n}\right)}}{x \cdot n}\\

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


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

    1. Initial program 92.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 96.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. mul-1-neg96.5%

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

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

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

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

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

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

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

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

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

    if -2.4999999999999999e-20 < (/.f64 #s(literal 1 binary64) n) < 2e-51

    1. Initial program 27.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 inf 82.4%

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

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

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

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

    1. Initial program 4.9%

      \[{\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 76.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-neg76.9%

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 62.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 62.0%

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

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

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

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

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

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

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

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

Alternative 2: 85.7% accurate, 0.2× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 7.9999999999999997e-269

    1. Initial program 67.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 67.1%

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

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

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

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

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

    if 7.9999999999999997e-269 < x < 18

    1. Initial program 35.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 -inf 84.4%

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

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

    if 18 < x

    1. Initial program 66.2%

      \[{\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 97.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-neg97.9%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(\sqrt[3]{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \cdot \sqrt[3]{\frac{e^{\frac{\log x}{n}}}{x \cdot n}}\right) \cdot \sqrt[3]{\frac{e^{\frac{\log x}{n}}}{x \cdot n}}} \]
      2. pow397.4%

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

        \[\leadsto {\left(\sqrt[3]{\color{blue}{\frac{\frac{e^{\frac{\log x}{n}}}{x}}{n}}}\right)}^{3} \]
      4. div-inv98.6%

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

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

        \[\leadsto {\left(\sqrt[3]{\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{\color{blue}{{x}^{1}}}}{n}}\right)}^{3} \]
      7. pow-div98.2%

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

      \[\leadsto \color{blue}{{\left(\sqrt[3]{\frac{{x}^{\left(\frac{1}{n} - 1\right)}}{n}}\right)}^{3}} \]
    8. Step-by-step derivation
      1. rem-cube-cbrt98.7%

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

        \[\leadsto \color{blue}{{x}^{\left(\frac{1}{n} - 1\right)} \cdot \frac{1}{n}} \]
      3. pow-sub99.0%

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

        \[\leadsto \frac{{x}^{\left(\frac{1}{n}\right)}}{\color{blue}{x}} \cdot \frac{1}{n} \]
      5. associate-*l/99.0%

        \[\leadsto \color{blue}{\frac{{x}^{\left(\frac{1}{n}\right)} \cdot \frac{1}{n}}{x}} \]
    9. Applied egg-rr99.0%

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

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

Alternative 3: 85.1% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;x \leq 0.68:\\
\;\;\;\;\frac{\frac{-0.16666666666666666 \cdot \frac{{\log x}^{3}}{n} + {\log x}^{2} \cdot -0.5}{n} - \log x}{n}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 1.0200000000000001e-268

    1. Initial program 67.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 67.1%

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

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

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

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

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

    if 1.0200000000000001e-268 < x < 0.680000000000000049

    1. Initial program 35.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 33.0%

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot \frac{-0.16666666666666666 \cdot \frac{{\log x}^{3}}{n} - 0.5 \cdot {\log x}^{2}}{n} - -1 \cdot \log x}{n}} \]
    7. Step-by-step derivation
      1. mul-1-neg84.0%

        \[\leadsto \color{blue}{-\frac{-1 \cdot \frac{-0.16666666666666666 \cdot \frac{{\log x}^{3}}{n} - 0.5 \cdot {\log x}^{2}}{n} - -1 \cdot \log x}{n}} \]
    8. Simplified84.0%

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

    if 0.680000000000000049 < x

    1. Initial program 65.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 inf 97.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-neg97.2%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Step-by-step derivation
      1. add-cube-cbrt96.8%

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

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

        \[\leadsto {\left(\sqrt[3]{\color{blue}{\frac{\frac{e^{\frac{\log x}{n}}}{x}}{n}}}\right)}^{3} \]
      4. div-inv97.9%

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

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

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

        \[\leadsto {\left(\sqrt[3]{\frac{\color{blue}{{x}^{\left(\frac{1}{n} - 1\right)}}}{n}}\right)}^{3} \]
    7. Applied egg-rr97.5%

      \[\leadsto \color{blue}{{\left(\sqrt[3]{\frac{{x}^{\left(\frac{1}{n} - 1\right)}}{n}}\right)}^{3}} \]
    8. Step-by-step derivation
      1. rem-cube-cbrt98.0%

        \[\leadsto \color{blue}{\frac{{x}^{\left(\frac{1}{n} - 1\right)}}{n}} \]
      2. div-inv98.0%

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

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

        \[\leadsto \frac{{x}^{\left(\frac{1}{n}\right)}}{\color{blue}{x}} \cdot \frac{1}{n} \]
      5. associate-*l/98.4%

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

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

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

Alternative 4: 81.5% accurate, 0.9× speedup?

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq 5:\\
\;\;\;\;\frac{1}{x} \cdot \frac{t\_0}{n}\\

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

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


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

    1. Initial program 92.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 96.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. mul-1-neg96.5%

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

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

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

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

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

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

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

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

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

    if -2.4999999999999999e-20 < (/.f64 #s(literal 1 binary64) n) < 2e-51

    1. Initial program 27.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 inf 82.4%

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

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

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

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

    1. Initial program 4.9%

      \[{\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 76.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-neg76.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999981e187

    1. Initial program 84.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 0 84.9%

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

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

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

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

        \[\leadsto \frac{x}{n} + \color{blue}{\left(1 - e^{\frac{\log x}{n}}\right)} \]
      5. *-rgt-identity84.9%

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

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

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

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

    if 1.99999999999999981e187 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 41.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 0 29.6%

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

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

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

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

        \[\leadsto \frac{x}{n} + \color{blue}{\left(1 - e^{\frac{\log x}{n}}\right)} \]
      5. *-rgt-identity29.6%

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

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

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

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

      \[\leadsto \color{blue}{\frac{x}{n}} \]
    7. Step-by-step derivation
      1. log1p-expm1-u76.0%

        \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x}{n}\right)\right)} \]
    8. Applied egg-rr76.0%

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

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

Alternative 5: 85.6% accurate, 0.9× speedup?

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq 5:\\
\;\;\;\;\frac{1}{x} \cdot \frac{t\_0}{n}\\

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


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

    1. Initial program 92.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 96.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. mul-1-neg96.5%

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

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

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

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

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

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

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

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

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

    if -2.4999999999999999e-20 < (/.f64 #s(literal 1 binary64) n) < 2e-51

    1. Initial program 27.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 inf 82.4%

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

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

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

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

    1. Initial program 4.9%

      \[{\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 76.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-neg76.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 62.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 62.0%

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

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

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

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

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

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

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

Alternative 6: 71.8% accurate, 1.0× speedup?

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

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

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

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

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


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

    1. Initial program 67.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 67.1%

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

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

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

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

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

    if 5.1999999999999999e-266 < x < 1.15e-65

    1. Initial program 30.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 30.4%

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

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

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

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

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

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

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

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

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

    if 1.15e-65 < x < 1

    1. Initial program 57.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 45.3%

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

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

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

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

        \[\leadsto \frac{x}{n} + \color{blue}{\left(1 - e^{\frac{\log x}{n}}\right)} \]
      5. *-rgt-identity46.1%

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x}{n}\right)\right)} \]
    8. Applied egg-rr66.8%

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

    if 1 < x

    1. Initial program 65.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 inf 97.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-neg97.2%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Step-by-step derivation
      1. add-cube-cbrt96.8%

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

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

        \[\leadsto {\left(\sqrt[3]{\color{blue}{\frac{\frac{e^{\frac{\log x}{n}}}{x}}{n}}}\right)}^{3} \]
      4. div-inv97.9%

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

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

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

        \[\leadsto {\left(\sqrt[3]{\frac{\color{blue}{{x}^{\left(\frac{1}{n} - 1\right)}}}{n}}\right)}^{3} \]
    7. Applied egg-rr97.5%

      \[\leadsto \color{blue}{{\left(\sqrt[3]{\frac{{x}^{\left(\frac{1}{n} - 1\right)}}{n}}\right)}^{3}} \]
    8. Step-by-step derivation
      1. rem-cube-cbrt98.0%

        \[\leadsto \color{blue}{\frac{{x}^{\left(\frac{1}{n} - 1\right)}}{n}} \]
      2. div-inv98.0%

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

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

        \[\leadsto \frac{{x}^{\left(\frac{1}{n}\right)}}{\color{blue}{x}} \cdot \frac{1}{n} \]
      5. associate-*l/98.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 5.2 \cdot 10^{-266}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 1.15 \cdot 10^{-65}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x}{n}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{n} \cdot {x}^{\left(\frac{1}{n}\right)}}{x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 70.4% accurate, 1.8× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 2.69999999999999996e-266

    1. Initial program 67.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 67.1%

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

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

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

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

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

    if 2.69999999999999996e-266 < x < 2.8e-40

    1. Initial program 31.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 0 31.8%

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

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

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

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

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

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

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

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

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

    if 2.8e-40 < x

    1. Initial program 65.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 91.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-neg91.3%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(\sqrt[3]{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \cdot \sqrt[3]{\frac{e^{\frac{\log x}{n}}}{x \cdot n}}\right) \cdot \sqrt[3]{\frac{e^{\frac{\log x}{n}}}{x \cdot n}}} \]
      2. pow390.9%

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

        \[\leadsto {\left(\sqrt[3]{\color{blue}{\frac{\frac{e^{\frac{\log x}{n}}}{x}}{n}}}\right)}^{3} \]
      4. div-inv91.9%

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

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

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

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

      \[\leadsto \color{blue}{{\left(\sqrt[3]{\frac{{x}^{\left(\frac{1}{n} - 1\right)}}{n}}\right)}^{3}} \]
    8. Step-by-step derivation
      1. rem-cube-cbrt92.0%

        \[\leadsto \color{blue}{\frac{{x}^{\left(\frac{1}{n} - 1\right)}}{n}} \]
      2. div-inv92.0%

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

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

        \[\leadsto \frac{{x}^{\left(\frac{1}{n}\right)}}{\color{blue}{x}} \cdot \frac{1}{n} \]
      5. associate-*l/92.3%

        \[\leadsto \color{blue}{\frac{{x}^{\left(\frac{1}{n}\right)} \cdot \frac{1}{n}}{x}} \]
    9. Applied egg-rr92.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 2.7 \cdot 10^{-266}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 2.8 \cdot 10^{-40}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{n} \cdot {x}^{\left(\frac{1}{n}\right)}}{x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 70.4% accurate, 1.8× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 2.89999999999999996e-266

    1. Initial program 67.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 67.1%

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

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

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

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

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

    if 2.89999999999999996e-266 < x < 2.6000000000000001e-40

    1. Initial program 31.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 0 31.8%

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

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

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

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

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

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

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

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

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

    if 2.6000000000000001e-40 < x

    1. Initial program 65.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 91.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-neg91.3%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1}{x} \cdot \frac{{x}^{\left(\frac{1}{n}\right)}}{n}} \]
    7. Applied egg-rr92.3%

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

Alternative 9: 70.3% accurate, 1.8× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 1.4999999999999999e-268

    1. Initial program 67.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 67.1%

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

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

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

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

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

    if 1.4999999999999999e-268 < x < 1.1799999999999999e-40

    1. Initial program 31.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 0 31.8%

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

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

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

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

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

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

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

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

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

    if 1.1799999999999999e-40 < x

    1. Initial program 65.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 91.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-neg91.3%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 1 \cdot \frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{\color{blue}{{x}^{1}}}}{n} \]
      6. pow-div92.0%

        \[\leadsto 1 \cdot \frac{\color{blue}{{x}^{\left(\frac{1}{n} - 1\right)}}}{n} \]
    7. Applied egg-rr92.0%

      \[\leadsto \color{blue}{1 \cdot \frac{{x}^{\left(\frac{1}{n} - 1\right)}}{n}} \]
    8. Step-by-step derivation
      1. *-lft-identity92.0%

        \[\leadsto \color{blue}{\frac{{x}^{\left(\frac{1}{n} - 1\right)}}{n}} \]
      2. sub-neg92.0%

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

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

      \[\leadsto \color{blue}{\frac{{x}^{\left(\frac{1}{n} + -1\right)}}{n}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 10: 57.2% accurate, 1.8× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 1.75000000000000008e-265

    1. Initial program 67.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 67.1%

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

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

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

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

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

    if 1.75000000000000008e-265 < x < 1.1000000000000001e-6

    1. Initial program 33.2%

      \[{\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 33.5%

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

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

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

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

        \[\leadsto \frac{x}{n} + \color{blue}{\left(1 - e^{\frac{\log x}{n}}\right)} \]
      5. *-rgt-identity33.9%

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

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

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

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

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

    if 1.1000000000000001e-6 < x

    1. Initial program 66.9%

      \[{\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 94.7%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{n \cdot x}} \]
    7. Step-by-step derivation
      1. associate-/l/55.0%

        \[\leadsto \color{blue}{\frac{\frac{1}{x}}{n}} \]
    8. Simplified55.0%

      \[\leadsto \color{blue}{\frac{\frac{1}{x}}{n}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 11: 56.6% accurate, 1.9× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 1.1000000000000001e-6

    1. Initial program 40.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 40.4%

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

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

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

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

        \[\leadsto \frac{x}{n} + \color{blue}{\left(1 - e^{\frac{\log x}{n}}\right)} \]
      5. *-rgt-identity40.6%

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

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

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

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

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

    if 1.1000000000000001e-6 < x

    1. Initial program 66.9%

      \[{\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 94.7%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{n \cdot x}} \]
    7. Step-by-step derivation
      1. associate-/l/55.0%

        \[\leadsto \color{blue}{\frac{\frac{1}{x}}{n}} \]
    8. Simplified55.0%

      \[\leadsto \color{blue}{\frac{\frac{1}{x}}{n}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 12: 56.5% accurate, 1.9× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 1.1000000000000001e-6

    1. Initial program 40.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 40.1%

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

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

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

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

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

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

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

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

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

    if 1.1000000000000001e-6 < x

    1. Initial program 66.9%

      \[{\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 94.7%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{n \cdot x}} \]
    7. Step-by-step derivation
      1. associate-/l/55.0%

        \[\leadsto \color{blue}{\frac{\frac{1}{x}}{n}} \]
    8. Simplified55.0%

      \[\leadsto \color{blue}{\frac{\frac{1}{x}}{n}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 13: 40.9% 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 x around inf 54.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-neg54.3%

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{1}{n \cdot x}} \]
  7. Step-by-step derivation
    1. associate-/l/36.2%

      \[\leadsto \color{blue}{\frac{\frac{1}{x}}{n}} \]
  8. Simplified36.2%

    \[\leadsto \color{blue}{\frac{\frac{1}{x}}{n}} \]
  9. Add Preprocessing

Alternative 14: 40.4% accurate, 42.2× speedup?

\[\begin{array}{l} \\ \frac{1}{x \cdot 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(1.0 / Float64(x * n))
end
function tmp = code(x, n)
	tmp = 1.0 / (x * n);
end
code[x_, n_] := N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1}{x \cdot 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 x around inf 54.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-neg54.3%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{1}{x \cdot n}} \]
  9. Add Preprocessing

Alternative 15: 4.6% accurate, 70.3× speedup?

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

\\
\frac{x}{n}
\end{array}
Derivation
  1. Initial program 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 0 28.2%

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{x}{n}} \]
  7. Add Preprocessing

Reproduce

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