2nthrt (problem 3.4.6)

Percentage Accurate: 53.1% → 91.7%
Time: 1.2min
Alternatives: 15
Speedup: 1.8×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

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

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

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

Alternative 1: 91.7% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 1500:\\ \;\;\;\;\frac{\log \left(\frac{x}{e^{\mathsf{log1p}\left(x\right) + \frac{\mathsf{fma}\left({\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}, 0.5, \frac{0.16666666666666666 \cdot \left({\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}\right)}{n}\right)}{n}}}\right)}{-n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= x 1500.0)
   (/
    (log
     (/
      x
      (exp
       (+
        (log1p x)
        (/
         (fma
          (- (pow (log1p x) 2.0) (pow (log x) 2.0))
          0.5
          (/
           (* 0.16666666666666666 (- (pow (log1p x) 3.0) (pow (log x) 3.0)))
           n))
         n)))))
    (- n))
   (/ (/ (pow x (/ 1.0 n)) n) x)))
double code(double x, double n) {
	double tmp;
	if (x <= 1500.0) {
		tmp = log((x / exp((log1p(x) + (fma((pow(log1p(x), 2.0) - pow(log(x), 2.0)), 0.5, ((0.16666666666666666 * (pow(log1p(x), 3.0) - pow(log(x), 3.0))) / n)) / n))))) / -n;
	} else {
		tmp = (pow(x, (1.0 / n)) / n) / x;
	}
	return tmp;
}
function code(x, n)
	tmp = 0.0
	if (x <= 1500.0)
		tmp = Float64(log(Float64(x / exp(Float64(log1p(x) + Float64(fma(Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0)), 0.5, Float64(Float64(0.16666666666666666 * Float64((log1p(x) ^ 3.0) - (log(x) ^ 3.0))) / n)) / n))))) / Float64(-n));
	else
		tmp = Float64(Float64((x ^ Float64(1.0 / n)) / n) / x);
	end
	return tmp
end
code[x_, n_] := If[LessEqual[x, 1500.0], N[(N[Log[N[(x / N[Exp[N[(N[Log[1 + x], $MachinePrecision] + N[(N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * 0.5 + 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]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision], N[(N[(N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 1500:\\
\;\;\;\;\frac{\log \left(\frac{x}{e^{\mathsf{log1p}\left(x\right) + \frac{\mathsf{fma}\left({\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}, 0.5, \frac{0.16666666666666666 \cdot \left({\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}\right)}{n}\right)}{n}}}\right)}{-n}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 1500

    1. Initial program 41.5%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in n around -inf 76.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. Simplified76.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) + 0.16666666666666666 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}}{n}}{n}\right)}{-n}} \]
    5. Step-by-step derivation
      1. add-log-exp84.3%

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

        \[\leadsto \frac{\color{blue}{\log \left(\frac{x}{e^{\mathsf{log1p}\left(x\right) + \frac{0.5 \cdot \left({\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}\right) + 0.16666666666666666 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}}{n}}{n}}}\right)}}{-n} \]
    6. Applied egg-rr84.3%

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

    if 1500 < x

    1. Initial program 66.3%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 87.2% accurate, 0.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 14500:\\
\;\;\;\;\frac{\left(\mathsf{log1p}\left(x\right) + \frac{0.16666666666666666 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}}{n} - 0.5 \cdot \left({\log x}^{2} - {\left(\mathsf{log1p}\left(x\right)\right)}^{2}\right)}{n}\right) - \log x}{n}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 14500

    1. Initial program 41.5%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in n around -inf 76.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. Simplified76.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) + 0.16666666666666666 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}}{n}}{n}\right)}{-n}} \]

    if 14500 < x

    1. Initial program 66.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 84.1% accurate, 0.4× speedup?

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

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

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

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


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

    1. Initial program 75.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 88.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. associate-/r*88.9%

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

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

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

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

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

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

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

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

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

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

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

    if -2.00000000000000002e-125 < (/.f64 #s(literal 1 binary64) n) < 9.99999999999999924e-25

    1. Initial program 33.0%

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

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

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

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

    if 9.99999999999999924e-25 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 52.2%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-exp-log52.2%

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

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

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

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

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

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

Alternative 4: 84.1% accurate, 0.7× speedup?

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

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

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

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


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

    1. Initial program 75.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 88.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. associate-/r*88.9%

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

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

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

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

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

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

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

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

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

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

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

    if -2.00000000000000002e-125 < (/.f64 #s(literal 1 binary64) n) < 9.99999999999999924e-25

    1. Initial program 33.0%

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

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

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

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

    if 9.99999999999999924e-25 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 52.2%

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

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

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

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

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

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

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

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

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

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

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

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


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

    1. Initial program 75.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 88.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. associate-/r*88.9%

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

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

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

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

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

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

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

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

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

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

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

    if -2.00000000000000002e-125 < (/.f64 #s(literal 1 binary64) n) < 9.99999999999999924e-25

    1. Initial program 33.0%

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

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

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

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

    if 9.99999999999999924e-25 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 52.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 91.6%

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

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

Alternative 6: 70.2% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {x}^{\left(\frac{1}{n}\right)}\\ t_1 := \frac{\log x}{-n}\\ t_2 := \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{x \cdot n}\right)\right)\\ \mathbf{if}\;x \leq 1.045 \cdot 10^{-286}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 8.2 \cdot 10^{-209}:\\ \;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\ \mathbf{elif}\;x \leq 6.2 \cdot 10^{-149}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 2.7 \cdot 10^{-117}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;x \leq 1.7 \cdot 10^{-85}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 1.72 \cdot 10^{-26}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;x \leq 0.0135:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{t\_0}{n}}{x}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (pow x (/ 1.0 n)))
        (t_1 (/ (log x) (- n)))
        (t_2 (log1p (expm1 (/ 1.0 (* x n))))))
   (if (<= x 1.045e-286)
     t_1
     (if (<= x 8.2e-209)
       (- (+ 1.0 (/ x n)) t_0)
       (if (<= x 6.2e-149)
         t_1
         (if (<= x 2.7e-117)
           t_2
           (if (<= x 1.7e-85)
             t_1
             (if (<= x 1.72e-26)
               t_2
               (if (<= x 0.0135) t_1 (/ (/ t_0 n) x))))))))))
double code(double x, double n) {
	double t_0 = pow(x, (1.0 / n));
	double t_1 = log(x) / -n;
	double t_2 = log1p(expm1((1.0 / (x * n))));
	double tmp;
	if (x <= 1.045e-286) {
		tmp = t_1;
	} else if (x <= 8.2e-209) {
		tmp = (1.0 + (x / n)) - t_0;
	} else if (x <= 6.2e-149) {
		tmp = t_1;
	} else if (x <= 2.7e-117) {
		tmp = t_2;
	} else if (x <= 1.7e-85) {
		tmp = t_1;
	} else if (x <= 1.72e-26) {
		tmp = t_2;
	} else if (x <= 0.0135) {
		tmp = t_1;
	} else {
		tmp = (t_0 / n) / x;
	}
	return tmp;
}
public static double code(double x, double n) {
	double t_0 = Math.pow(x, (1.0 / n));
	double t_1 = Math.log(x) / -n;
	double t_2 = Math.log1p(Math.expm1((1.0 / (x * n))));
	double tmp;
	if (x <= 1.045e-286) {
		tmp = t_1;
	} else if (x <= 8.2e-209) {
		tmp = (1.0 + (x / n)) - t_0;
	} else if (x <= 6.2e-149) {
		tmp = t_1;
	} else if (x <= 2.7e-117) {
		tmp = t_2;
	} else if (x <= 1.7e-85) {
		tmp = t_1;
	} else if (x <= 1.72e-26) {
		tmp = t_2;
	} else if (x <= 0.0135) {
		tmp = t_1;
	} else {
		tmp = (t_0 / n) / x;
	}
	return tmp;
}
def code(x, n):
	t_0 = math.pow(x, (1.0 / n))
	t_1 = math.log(x) / -n
	t_2 = math.log1p(math.expm1((1.0 / (x * n))))
	tmp = 0
	if x <= 1.045e-286:
		tmp = t_1
	elif x <= 8.2e-209:
		tmp = (1.0 + (x / n)) - t_0
	elif x <= 6.2e-149:
		tmp = t_1
	elif x <= 2.7e-117:
		tmp = t_2
	elif x <= 1.7e-85:
		tmp = t_1
	elif x <= 1.72e-26:
		tmp = t_2
	elif x <= 0.0135:
		tmp = t_1
	else:
		tmp = (t_0 / n) / x
	return tmp
function code(x, n)
	t_0 = x ^ Float64(1.0 / n)
	t_1 = Float64(log(x) / Float64(-n))
	t_2 = log1p(expm1(Float64(1.0 / Float64(x * n))))
	tmp = 0.0
	if (x <= 1.045e-286)
		tmp = t_1;
	elseif (x <= 8.2e-209)
		tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0);
	elseif (x <= 6.2e-149)
		tmp = t_1;
	elseif (x <= 2.7e-117)
		tmp = t_2;
	elseif (x <= 1.7e-85)
		tmp = t_1;
	elseif (x <= 1.72e-26)
		tmp = t_2;
	elseif (x <= 0.0135)
		tmp = t_1;
	else
		tmp = Float64(Float64(t_0 / n) / x);
	end
	return tmp
end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision]}, Block[{t$95$2 = N[Log[1 + N[(Exp[N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 1.045e-286], t$95$1, If[LessEqual[x, 8.2e-209], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[x, 6.2e-149], t$95$1, If[LessEqual[x, 2.7e-117], t$95$2, If[LessEqual[x, 1.7e-85], t$95$1, If[LessEqual[x, 1.72e-26], t$95$2, If[LessEqual[x, 0.0135], t$95$1, N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision]]]]]]]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;x \leq 6.2 \cdot 10^{-149}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 2.7 \cdot 10^{-117}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;x \leq 1.7 \cdot 10^{-85}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 1.72 \cdot 10^{-26}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;x \leq 0.0135:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < 1.04500000000000002e-286 or 8.19999999999999955e-209 < x < 6.19999999999999974e-149 or 2.70000000000000003e-117 < x < 1.7e-85 or 1.72000000000000001e-26 < x < 0.0134999999999999998

    1. Initial program 26.7%

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

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

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

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

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

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

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

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

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

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

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

    if 1.04500000000000002e-286 < x < 8.19999999999999955e-209

    1. Initial program 61.4%

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

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

    if 6.19999999999999974e-149 < x < 2.70000000000000003e-117 or 1.7e-85 < x < 1.72000000000000001e-26

    1. Initial program 45.5%

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.0134999999999999998 < x

    1. Initial program 66.3%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.045 \cdot 10^{-286}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 8.2 \cdot 10^{-209}:\\ \;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 6.2 \cdot 10^{-149}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 2.7 \cdot 10^{-117}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{x \cdot n}\right)\right)\\ \mathbf{elif}\;x \leq 1.7 \cdot 10^{-85}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 1.72 \cdot 10^{-26}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{x \cdot n}\right)\right)\\ \mathbf{elif}\;x \leq 0.0135:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}\\ \end{array} \]
  5. Add Preprocessing

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

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

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

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


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

    1. Initial program 75.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 88.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. associate-/r*88.9%

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

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

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

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

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

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

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

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

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

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

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

    if -2.00000000000000002e-125 < (/.f64 #s(literal 1 binary64) n) < 9.99999999999999924e-25

    1. Initial program 33.0%

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

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

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

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

    if 9.99999999999999924e-25 < (/.f64 #s(literal 1 binary64) n) < 5.00000000000000025e141

    1. Initial program 88.3%

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

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

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

    1. Initial program 8.5%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 0.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-neg0.7%

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 70.2% accurate, 1.5× speedup?

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

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

\mathbf{elif}\;x \leq 2.4 \cdot 10^{-209}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;x \leq 7.5 \cdot 10^{-148}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 5.2 \cdot 10^{-114}:\\
\;\;\;\;\frac{1 + \left(\frac{0.3333333333333333}{{x}^{2}} + \frac{-0.5}{x}\right)}{x \cdot n}\\

\mathbf{elif}\;x \leq 3.4 \cdot 10^{-44}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 2.25 \cdot 10^{-30}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;x \leq 0.013:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < 1.04500000000000002e-286 or 2.4000000000000001e-209 < x < 7.5000000000000005e-148 or 5.20000000000000026e-114 < x < 3.40000000000000016e-44 or 2.24999999999999984e-30 < x < 0.0129999999999999994

    1. Initial program 28.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 28.5%

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

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

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

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

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

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

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

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

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

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

    if 1.04500000000000002e-286 < x < 2.4000000000000001e-209 or 3.40000000000000016e-44 < x < 2.24999999999999984e-30

    1. Initial program 60.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 0 61.3%

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

    if 7.5000000000000005e-148 < x < 5.20000000000000026e-114

    1. Initial program 49.3%

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

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

      \[\leadsto \color{blue}{\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n} + {x}^{\left(\frac{1}{n}\right)} \cdot \left(\frac{\frac{0.5}{{n}^{2}} + \frac{-0.5}{n}}{x} + \frac{\frac{0.16666666666666666}{{n}^{3}} + \left(\frac{0.3333333333333333}{n} - \frac{0.5}{{n}^{2}}\right)}{{x}^{2}}\right)}{x}} \]
    5. Taylor expanded in n around inf 70.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.0129999999999999994 < x

    1. Initial program 66.3%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.045 \cdot 10^{-286}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 2.4 \cdot 10^{-209}:\\ \;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 7.5 \cdot 10^{-148}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 5.2 \cdot 10^{-114}:\\ \;\;\;\;\frac{1 + \left(\frac{0.3333333333333333}{{x}^{2}} + \frac{-0.5}{x}\right)}{x \cdot n}\\ \mathbf{elif}\;x \leq 3.4 \cdot 10^{-44}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 2.25 \cdot 10^{-30}:\\ \;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 0.013:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 70.7% accurate, 1.6× speedup?

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

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

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

\mathbf{elif}\;x \leq 1.5 \cdot 10^{-147}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;x \leq 0.0145:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < 1.04500000000000002e-286 or 2.2499999999999999e-209 < x < 1.5000000000000001e-147 or 5.8e-119 < x < 0.0145000000000000007

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

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

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

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

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

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

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

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

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

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

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

    if 1.04500000000000002e-286 < x < 2.2499999999999999e-209

    1. Initial program 61.4%

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

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

    if 1.5000000000000001e-147 < x < 5.8e-119

    1. Initial program 49.3%

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

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

      \[\leadsto \color{blue}{\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n} + {x}^{\left(\frac{1}{n}\right)} \cdot \left(\frac{\frac{0.5}{{n}^{2}} + \frac{-0.5}{n}}{x} + \frac{\frac{0.16666666666666666}{{n}^{3}} + \left(\frac{0.3333333333333333}{n} - \frac{0.5}{{n}^{2}}\right)}{{x}^{2}}\right)}{x}} \]
    5. Taylor expanded in n around inf 70.1%

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

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

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

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

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

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

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

    if 0.0145000000000000007 < x

    1. Initial program 66.3%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.045 \cdot 10^{-286}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 2.25 \cdot 10^{-209}:\\ \;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{-147}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 5.8 \cdot 10^{-119}:\\ \;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\ \mathbf{elif}\;x \leq 0.0145:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 70.7% accurate, 1.6× speedup?

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

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

\mathbf{elif}\;x \leq 6.6 \cdot 10^{-209}:\\
\;\;\;\;1 - t\_1\\

\mathbf{elif}\;x \leq 1.5 \cdot 10^{-147}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;x \leq 0.013:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{t\_1}{n}}{x}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < 1.04500000000000002e-286 or 6.59999999999999948e-209 < x < 1.5000000000000001e-147 or 6.0000000000000004e-119 < x < 0.0129999999999999994

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

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

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

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

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

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

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

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

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

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

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

    if 1.04500000000000002e-286 < x < 6.59999999999999948e-209

    1. Initial program 61.4%

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

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

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

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

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

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

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

    if 1.5000000000000001e-147 < x < 6.0000000000000004e-119

    1. Initial program 49.3%

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

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

      \[\leadsto \color{blue}{\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n} + {x}^{\left(\frac{1}{n}\right)} \cdot \left(\frac{\frac{0.5}{{n}^{2}} + \frac{-0.5}{n}}{x} + \frac{\frac{0.16666666666666666}{{n}^{3}} + \left(\frac{0.3333333333333333}{n} - \frac{0.5}{{n}^{2}}\right)}{{x}^{2}}\right)}{x}} \]
    5. Taylor expanded in n around inf 70.1%

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

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

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

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

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

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

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

    if 0.0129999999999999994 < x

    1. Initial program 66.3%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.045 \cdot 10^{-286}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 6.6 \cdot 10^{-209}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{-147}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 6 \cdot 10^{-119}:\\ \;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\ \mathbf{elif}\;x \leq 0.013:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 56.2% accurate, 1.6× speedup?

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

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

\mathbf{elif}\;x \leq 2.35 \cdot 10^{-209}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 3.4 \cdot 10^{-44}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 1.02 \cdot 10^{-30}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 0.68:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 1.04500000000000002e-286 or 2.35e-209 < x < 3.40000000000000016e-44 or 1.0199999999999999e-30 < x < 0.680000000000000049

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

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

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

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

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

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

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

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

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

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

    if 1.04500000000000002e-286 < x < 2.35e-209 or 3.40000000000000016e-44 < x < 1.0199999999999999e-30

    1. Initial program 60.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 0 60.9%

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

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

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

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

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

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

    if 0.680000000000000049 < x

    1. Initial program 66.3%

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

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

      \[\leadsto \color{blue}{\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n} + {x}^{\left(\frac{1}{n}\right)} \cdot \left(\frac{\frac{0.5}{{n}^{2}} + \frac{-0.5}{n}}{x} + \frac{\frac{0.16666666666666666}{{n}^{3}} + \left(\frac{0.3333333333333333}{n} - \frac{0.5}{{n}^{2}}\right)}{{x}^{2}}\right)}{x}} \]
    5. Taylor expanded in n around inf 77.7%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1 - \frac{\color{blue}{0.5}}{x}}{n}}{x} \]
    11. Simplified66.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.045 \cdot 10^{-286}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 2.35 \cdot 10^{-209}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 3.4 \cdot 10^{-44}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 1.02 \cdot 10^{-30}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 0.68:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1 - \frac{0.5}{x}}{n}}{x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 60.0% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;n \leq -5.8:\\
\;\;\;\;\frac{1}{n} \cdot \frac{1}{x}\\

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

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

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


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

    1. Initial program 31.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 55.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-neg55.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.79999999999999982 < n < 9.99999999999999923e-164

    1. Initial program 80.5%

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

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

      \[\leadsto \color{blue}{\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n} + {x}^{\left(\frac{1}{n}\right)} \cdot \left(\frac{\frac{0.5}{{n}^{2}} + \frac{-0.5}{n}}{x} + \frac{\frac{0.16666666666666666}{{n}^{3}} + \left(\frac{0.3333333333333333}{n} - \frac{0.5}{{n}^{2}}\right)}{{x}^{2}}\right)}{x}} \]
    5. Taylor expanded in n around inf 67.0%

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

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

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

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

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

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

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

    if 9.99999999999999923e-164 < n < 1.4e15

    1. Initial program 88.3%

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

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

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

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

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

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

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

    if 1.4e15 < n

    1. Initial program 28.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -5.8:\\ \;\;\;\;\frac{1}{n} \cdot \frac{1}{x}\\ \mathbf{elif}\;n \leq 10^{-163}:\\ \;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\ \mathbf{elif}\;n \leq 1.4 \cdot 10^{+15}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x}}{n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 57.0% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{\log x}{-n}\\
\mathbf{if}\;x \leq 1.045 \cdot 10^{-286}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;x \leq 0.68:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 1.04500000000000002e-286 or 7.20000000000000013e-281 < x < 0.680000000000000049

    1. Initial program 38.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 0 38.9%

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

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

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

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

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

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

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

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

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

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

    if 1.04500000000000002e-286 < x < 7.20000000000000013e-281

    1. Initial program 100.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 83.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-neg83.3%

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

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

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

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

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

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

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

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

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

    if 0.680000000000000049 < x

    1. Initial program 66.3%

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

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

      \[\leadsto \color{blue}{\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n} + {x}^{\left(\frac{1}{n}\right)} \cdot \left(\frac{\frac{0.5}{{n}^{2}} + \frac{-0.5}{n}}{x} + \frac{\frac{0.16666666666666666}{{n}^{3}} + \left(\frac{0.3333333333333333}{n} - \frac{0.5}{{n}^{2}}\right)}{{x}^{2}}\right)}{x}} \]
    5. Taylor expanded in n around inf 77.7%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1 - \frac{\color{blue}{0.5}}{x}}{n}}{x} \]
    11. Simplified66.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.045 \cdot 10^{-286}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 7.2 \cdot 10^{-281}:\\ \;\;\;\;\frac{1}{x \cdot n}\\ \mathbf{elif}\;x \leq 0.68:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1 - \frac{0.5}{x}}{n}}{x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 40.6% 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.8%

    \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
  2. Add Preprocessing
  3. Taylor expanded in x around inf 57.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-neg57.3%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 15: 40.0% 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.8%

    \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
  2. Add Preprocessing
  3. Taylor expanded in x around inf 57.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-neg57.3%

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

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

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

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

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

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

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

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

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

Reproduce

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