2nthrt (problem 3.4.6)

Percentage Accurate: 53.4% → 89.5%
Time: 1.0min
Alternatives: 13
Speedup: 1.9×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 13 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.4% 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: 89.5% accurate, 0.2× speedup?

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

    1. Initial program 40.1%

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

        \[\leadsto \frac{\color{blue}{\sqrt[3]{\left(\left(\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)\right) \cdot \left(\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)\right)\right) \cdot \left(\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)\right)}}}{-n} \]
      2. pow384.6%

        \[\leadsto \frac{\sqrt[3]{\color{blue}{{\left(\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)\right)}^{3}}}}{-n} \]
    6. Applied egg-rr84.6%

      \[\leadsto \frac{\color{blue}{\sqrt[3]{{\left(\left(\log x - \mathsf{log1p}\left(x\right)\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)}^{3}}}}{-n} \]
    7. Taylor expanded in x around 0 84.6%

      \[\leadsto \frac{\sqrt[3]{{\left(\left(\log x - \mathsf{log1p}\left(x\right)\right) - \frac{\mathsf{fma}\left({\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}, 0.5, \frac{0.16666666666666666 \cdot \color{blue}{\left(-1 \cdot {\log x}^{3}\right)}}{n}\right)}{n}\right)}^{3}}}{-n} \]
    8. Step-by-step derivation
      1. neg-mul-184.6%

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

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

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

    if 320 < x

    1. Initial program 61.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 86.9% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 250:\\ \;\;\;\;\frac{\left(\mathsf{log1p}\left(x\right) + \frac{\left({\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}\right) \cdot 0.5 + 0.16666666666666666 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}}{n}}{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 250.0)
   (/
    (-
     (+
      (log1p x)
      (/
       (+
        (* (- (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))
     (log x))
    n)
   (/ (/ (pow x (/ 1.0 n)) n) x)))
double code(double x, double n) {
	double tmp;
	if (x <= 250.0) {
		tmp = ((log1p(x) + ((((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)) - 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 <= 250.0) {
		tmp = ((Math.log1p(x) + ((((Math.pow(Math.log1p(x), 2.0) - Math.pow(Math.log(x), 2.0)) * 0.5) + (0.16666666666666666 * ((Math.pow(Math.log1p(x), 3.0) - Math.pow(Math.log(x), 3.0)) / n))) / 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 <= 250.0:
		tmp = ((math.log1p(x) + ((((math.pow(math.log1p(x), 2.0) - math.pow(math.log(x), 2.0)) * 0.5) + (0.16666666666666666 * ((math.pow(math.log1p(x), 3.0) - math.pow(math.log(x), 3.0)) / n))) / 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 <= 250.0)
		tmp = Float64(Float64(Float64(log1p(x) + Float64(Float64(Float64(Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0)) * 0.5) + Float64(0.16666666666666666 * Float64(Float64((log1p(x) ^ 3.0) - (log(x) ^ 3.0)) / n))) / 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, 250.0], N[(N[(N[(N[Log[1 + x], $MachinePrecision] + N[(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), $MachinePrecision] + 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]), $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 250:\\
\;\;\;\;\frac{\left(\mathsf{log1p}\left(x\right) + \frac{\left({\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}\right) \cdot 0.5 + 0.16666666666666666 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}}{n}}{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 < 250

    1. Initial program 40.1%

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

    1. Initial program 61.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 82.6% accurate, 0.6× speedup?

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

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if x < 1.8999999999999999e-158

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \left(\frac{1}{n} + \left(\frac{1}{x} - \frac{e^{\frac{\log x}{n}}}{x}\right)\right)} \]
    7. Taylor expanded in n around inf 82.2%

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

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

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

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

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

    if 1.8999999999999999e-158 < x < 2.0999999999999999e-61

    1. Initial program 33.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 39.8%

      \[\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)} \]
    4. Taylor expanded in n around inf 53.0%

      \[\leadsto \color{blue}{\frac{x \cdot \left(1 + -0.5 \cdot x\right) - \log x}{n}} \]
    5. Step-by-step derivation
      1. *-commutative53.0%

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

      \[\leadsto \color{blue}{\frac{x \cdot \left(1 + x \cdot -0.5\right) - \log x}{n}} \]
    7. Taylor expanded in x around inf 80.3%

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

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

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

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

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

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

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

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

    if 2.0999999999999999e-61 < x < 1.30000000000000002e-35

    1. Initial program 51.1%

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

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

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

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

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

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

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

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

    if 1.30000000000000002e-35 < x < 2.39999999999999986e-17

    1. Initial program 5.1%

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

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

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

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

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

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

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

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

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

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

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

    if 2.39999999999999986e-17 < x

    1. Initial program 62.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.9 \cdot 10^{-158}:\\ \;\;\;\;x \cdot \left(\frac{1}{n} - \frac{\log x}{x \cdot n}\right)\\ \mathbf{elif}\;x \leq 2.1 \cdot 10^{-61}:\\ \;\;\;\;\left(\frac{1}{x \cdot n} - \left(\frac{0.5}{n} + \frac{\log x}{n \cdot {x}^{2}}\right)\right) \cdot {x}^{2}\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{-35}:\\ \;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 2.4 \cdot 10^{-17}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 85.6% 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^{-19}:\\ \;\;\;\;\frac{\frac{t\_0}{n}}{x}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-25}:\\ \;\;\;\;\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-19)
     (/ (/ t_0 n) x)
     (if (<= (/ 1.0 n) 5e-25)
       (/ (- (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-19) {
		tmp = (t_0 / n) / x;
	} else if ((1.0 / n) <= 5e-25) {
		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-19) {
		tmp = (t_0 / n) / x;
	} else if ((1.0 / n) <= 5e-25) {
		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-19:
		tmp = (t_0 / n) / x
	elif (1.0 / n) <= 5e-25:
		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-19)
		tmp = Float64(Float64(t_0 / n) / x);
	elseif (Float64(1.0 / n) <= 5e-25)
		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-19], N[(N[(t$95$0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-25], 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^{-19}:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\

\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-25}:\\
\;\;\;\;\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) < -2e-19

    1. Initial program 92.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 96.0%

      \[\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*96.1%

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 26.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 75.6%

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

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

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

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

    1. Initial program 50.1%

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

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

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

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

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

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

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

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

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

Alternative 5: 85.6% accurate, 0.7× speedup?

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

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

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

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


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

    1. Initial program 92.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 96.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 26.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 75.6%

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

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

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

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

    1. Initial program 50.1%

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

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

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

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

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

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

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

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

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

Alternative 6: 69.7% accurate, 1.7× 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.5 \cdot 10^{-166}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 1.6 \cdot 10^{-108}:\\ \;\;\;\;1 - t\_1\\ \mathbf{elif}\;x \leq 9.6 \cdot 10^{-19}:\\ \;\;\;\;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.5e-166)
     t_0
     (if (<= x 1.6e-108)
       (- 1.0 t_1)
       (if (<= x 9.6e-19) 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.5e-166) {
		tmp = t_0;
	} else if (x <= 1.6e-108) {
		tmp = 1.0 - t_1;
	} else if (x <= 9.6e-19) {
		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.5d-166) then
        tmp = t_0
    else if (x <= 1.6d-108) then
        tmp = 1.0d0 - t_1
    else if (x <= 9.6d-19) 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.5e-166) {
		tmp = t_0;
	} else if (x <= 1.6e-108) {
		tmp = 1.0 - t_1;
	} else if (x <= 9.6e-19) {
		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.5e-166:
		tmp = t_0
	elif x <= 1.6e-108:
		tmp = 1.0 - t_1
	elif x <= 9.6e-19:
		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.5e-166)
		tmp = t_0;
	elseif (x <= 1.6e-108)
		tmp = Float64(1.0 - t_1);
	elseif (x <= 9.6e-19)
		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.5e-166)
		tmp = t_0;
	elseif (x <= 1.6e-108)
		tmp = 1.0 - t_1;
	elseif (x <= 9.6e-19)
		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.5e-166], t$95$0, If[LessEqual[x, 1.6e-108], N[(1.0 - t$95$1), $MachinePrecision], If[LessEqual[x, 9.6e-19], 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.5 \cdot 10^{-166}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;x \leq 9.6 \cdot 10^{-19}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 1.5000000000000001e-166 or 1.6e-108 < x < 9.60000000000000092e-19

    1. Initial program 34.0%

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

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

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

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

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

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

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

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

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

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

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

    if 1.5000000000000001e-166 < x < 1.6e-108

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

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

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

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

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

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

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

    if 9.60000000000000092e-19 < x

    1. Initial program 62.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.5 \cdot 10^{-166}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 1.6 \cdot 10^{-108}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 9.6 \cdot 10^{-19}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 57.8% accurate, 1.8× speedup?

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

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

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

\mathbf{elif}\;x \leq 2.9 \cdot 10^{-17}:\\
\;\;\;\;t\_0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < 1.5000000000000001e-166 or 1.6500000000000001e-108 < x < 2.9000000000000003e-17

    1. Initial program 34.0%

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

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

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

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

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

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

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

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

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

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

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

    if 1.5000000000000001e-166 < x < 1.6500000000000001e-108

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

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

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

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

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

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

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

    if 2.9000000000000003e-17 < x < 8.7000000000000005e83

    1. Initial program 39.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 87.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-neg87.8%

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

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

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

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

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

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

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

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

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

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

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

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

    if 8.7000000000000005e83 < x

    1. Initial program 79.9%

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

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

        \[\leadsto \color{blue}{\left(-{x}^{\left(\frac{1}{n}\right)}\right) + {\left(x + 1\right)}^{\left(\frac{1}{n}\right)}} \]
      3. add-cube-cbrt79.6%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}} \cdot \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, {\left(x + 1\right)}^{\left(\frac{1}{n}\right)}\right)} \]
      5. pow-to-exp79.6%

        \[\leadsto \mathsf{fma}\left(\sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}} \cdot \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, \color{blue}{e^{\log \left(x + 1\right) \cdot \frac{1}{n}}}\right) \]
      6. un-div-inv79.6%

        \[\leadsto \mathsf{fma}\left(\sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}} \cdot \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, e^{\color{blue}{\frac{\log \left(x + 1\right)}{n}}}\right) \]
      7. +-commutative79.6%

        \[\leadsto \mathsf{fma}\left(\sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}} \cdot \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, e^{\frac{\log \color{blue}{\left(1 + x\right)}}{n}}\right) \]
      8. log1p-define79.6%

        \[\leadsto \mathsf{fma}\left(\sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}} \cdot \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, e^{\frac{\color{blue}{\mathsf{log1p}\left(x\right)}}{n}}\right) \]
    4. Applied egg-rr79.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}} \cdot \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, e^{\frac{\mathsf{log1p}\left(x\right)}{n}}\right)} \]
    5. Taylor expanded in x around inf 79.9%

      \[\leadsto \color{blue}{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}} + {\left(\sqrt[3]{-1}\right)}^{3} \cdot e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}}} \]
    6. Step-by-step derivation
      1. rem-cube-cbrt79.9%

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

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

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

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

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

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

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

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

        \[\leadsto 0 \cdot e^{\color{blue}{\frac{1}{n} \cdot \log x}} \]
      10. *-commutative79.9%

        \[\leadsto 0 \cdot e^{\color{blue}{\log x \cdot \frac{1}{n}}} \]
      11. metadata-eval79.9%

        \[\leadsto 0 \cdot e^{\log x \cdot \frac{\color{blue}{3 \cdot 0.3333333333333333}}{n}} \]
      12. associate-*l/79.9%

        \[\leadsto 0 \cdot e^{\log x \cdot \color{blue}{\left(\frac{3}{n} \cdot 0.3333333333333333\right)}} \]
      13. associate-*l*79.9%

        \[\leadsto 0 \cdot e^{\color{blue}{\left(\log x \cdot \frac{3}{n}\right) \cdot 0.3333333333333333}} \]
      14. exp-prod79.9%

        \[\leadsto 0 \cdot \color{blue}{{\left(e^{\log x \cdot \frac{3}{n}}\right)}^{0.3333333333333333}} \]
      15. exp-to-pow79.9%

        \[\leadsto 0 \cdot {\color{blue}{\left({x}^{\left(\frac{3}{n}\right)}\right)}}^{0.3333333333333333} \]
      16. unpow1/379.9%

        \[\leadsto 0 \cdot \color{blue}{\sqrt[3]{{x}^{\left(\frac{3}{n}\right)}}} \]
      17. mul0-lft79.9%

        \[\leadsto \color{blue}{0} \]
    7. Simplified79.9%

      \[\leadsto \color{blue}{0} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification66.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.5 \cdot 10^{-166}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 1.65 \cdot 10^{-108}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 2.9 \cdot 10^{-17}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 8.7 \cdot 10^{+83}:\\ \;\;\;\;\frac{\frac{1}{x}}{n}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 80.8% accurate, 1.8× speedup?

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

\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 < 2.9000000000000003e-17

    1. Initial program 38.0%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \left(\frac{1}{n} + \left(\frac{1}{x} - \frac{e^{\frac{\log x}{n}}}{x}\right)\right)} \]
    7. Taylor expanded in n around inf 73.2%

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

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

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

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

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

    if 2.9000000000000003e-17 < x

    1. Initial program 62.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 80.6% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 2.6 \cdot 10^{-17}:\\ \;\;\;\;x \cdot \frac{1 - \frac{\log x}{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 2.6e-17)
   (* x (/ (- 1.0 (/ (log x) x)) n))
   (/ (/ (pow x (/ 1.0 n)) n) x)))
double code(double x, double n) {
	double tmp;
	if (x <= 2.6e-17) {
		tmp = x * ((1.0 - (log(x) / x)) / n);
	} else {
		tmp = (pow(x, (1.0 / n)) / n) / x;
	}
	return tmp;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    real(8) :: tmp
    if (x <= 2.6d-17) then
        tmp = x * ((1.0d0 - (log(x) / x)) / n)
    else
        tmp = ((x ** (1.0d0 / n)) / n) / x
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double tmp;
	if (x <= 2.6e-17) {
		tmp = x * ((1.0 - (Math.log(x) / x)) / n);
	} else {
		tmp = (Math.pow(x, (1.0 / n)) / n) / x;
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if x <= 2.6e-17:
		tmp = x * ((1.0 - (math.log(x) / x)) / n)
	else:
		tmp = (math.pow(x, (1.0 / n)) / n) / x
	return tmp
function code(x, n)
	tmp = 0.0
	if (x <= 2.6e-17)
		tmp = Float64(x * Float64(Float64(1.0 - Float64(log(x) / x)) / n));
	else
		tmp = Float64(Float64((x ^ Float64(1.0 / n)) / n) / x);
	end
	return tmp
end
function tmp_2 = code(x, n)
	tmp = 0.0;
	if (x <= 2.6e-17)
		tmp = x * ((1.0 - (log(x) / x)) / n);
	else
		tmp = ((x ^ (1.0 / n)) / n) / x;
	end
	tmp_2 = tmp;
end
code[x_, n_] := If[LessEqual[x, 2.6e-17], N[(x * N[(N[(1.0 - N[(N[Log[x], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $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 2.6 \cdot 10^{-17}:\\
\;\;\;\;x \cdot \frac{1 - \frac{\log x}{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 < 2.60000000000000003e-17

    1. Initial program 38.0%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{x \cdot \left(\frac{1}{n} + \left(\frac{1}{x} - \frac{e^{\frac{\log x}{n}}}{x}\right)\right)} \]
    7. Taylor expanded in n around inf 54.6%

      \[\leadsto \color{blue}{\frac{x \cdot \left(1 - \frac{\log x}{x}\right)}{n}} \]
    8. Step-by-step derivation
      1. associate-/l*72.5%

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

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

    if 2.60000000000000003e-17 < x

    1. Initial program 62.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 10: 59.0% accurate, 1.9× speedup?

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

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

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

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


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

    1. Initial program 38.0%

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

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

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

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

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

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

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

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

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

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

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

    if 2.9000000000000003e-17 < x < 7.49999999999999989e83

    1. Initial program 39.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 87.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-neg87.8%

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

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

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

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

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

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

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

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

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

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

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

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

    if 7.49999999999999989e83 < x

    1. Initial program 79.9%

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

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

        \[\leadsto \color{blue}{\left(-{x}^{\left(\frac{1}{n}\right)}\right) + {\left(x + 1\right)}^{\left(\frac{1}{n}\right)}} \]
      3. add-cube-cbrt79.6%

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}} \cdot \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, {\left(x + 1\right)}^{\left(\frac{1}{n}\right)}\right)} \]
      5. pow-to-exp79.6%

        \[\leadsto \mathsf{fma}\left(\sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}} \cdot \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, \color{blue}{e^{\log \left(x + 1\right) \cdot \frac{1}{n}}}\right) \]
      6. un-div-inv79.6%

        \[\leadsto \mathsf{fma}\left(\sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}} \cdot \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, e^{\color{blue}{\frac{\log \left(x + 1\right)}{n}}}\right) \]
      7. +-commutative79.6%

        \[\leadsto \mathsf{fma}\left(\sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}} \cdot \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, e^{\frac{\log \color{blue}{\left(1 + x\right)}}{n}}\right) \]
      8. log1p-define79.6%

        \[\leadsto \mathsf{fma}\left(\sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}} \cdot \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, e^{\frac{\color{blue}{\mathsf{log1p}\left(x\right)}}{n}}\right) \]
    4. Applied egg-rr79.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}} \cdot \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, e^{\frac{\mathsf{log1p}\left(x\right)}{n}}\right)} \]
    5. Taylor expanded in x around inf 79.9%

      \[\leadsto \color{blue}{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}} + {\left(\sqrt[3]{-1}\right)}^{3} \cdot e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}}} \]
    6. Step-by-step derivation
      1. rem-cube-cbrt79.9%

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

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

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

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

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

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

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

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

        \[\leadsto 0 \cdot e^{\color{blue}{\frac{1}{n} \cdot \log x}} \]
      10. *-commutative79.9%

        \[\leadsto 0 \cdot e^{\color{blue}{\log x \cdot \frac{1}{n}}} \]
      11. metadata-eval79.9%

        \[\leadsto 0 \cdot e^{\log x \cdot \frac{\color{blue}{3 \cdot 0.3333333333333333}}{n}} \]
      12. associate-*l/79.9%

        \[\leadsto 0 \cdot e^{\log x \cdot \color{blue}{\left(\frac{3}{n} \cdot 0.3333333333333333\right)}} \]
      13. associate-*l*79.9%

        \[\leadsto 0 \cdot e^{\color{blue}{\left(\log x \cdot \frac{3}{n}\right) \cdot 0.3333333333333333}} \]
      14. exp-prod79.9%

        \[\leadsto 0 \cdot \color{blue}{{\left(e^{\log x \cdot \frac{3}{n}}\right)}^{0.3333333333333333}} \]
      15. exp-to-pow79.9%

        \[\leadsto 0 \cdot {\color{blue}{\left({x}^{\left(\frac{3}{n}\right)}\right)}}^{0.3333333333333333} \]
      16. unpow1/379.9%

        \[\leadsto 0 \cdot \color{blue}{\sqrt[3]{{x}^{\left(\frac{3}{n}\right)}}} \]
      17. mul0-lft79.9%

        \[\leadsto \color{blue}{0} \]
    7. Simplified79.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 2.9 \cdot 10^{-17}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 7.5 \cdot 10^{+83}:\\ \;\;\;\;\frac{\frac{1}{x}}{n}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 45.3% accurate, 14.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq -4.1 \lor \neg \left(n \leq -1.75 \cdot 10^{-196}\right):\\ \;\;\;\;\frac{1}{x \cdot n}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (or (<= n -4.1) (not (<= n -1.75e-196))) (/ 1.0 (* x n)) 0.0))
double code(double x, double n) {
	double tmp;
	if ((n <= -4.1) || !(n <= -1.75e-196)) {
		tmp = 1.0 / (x * n);
	} else {
		tmp = 0.0;
	}
	return tmp;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    real(8) :: tmp
    if ((n <= (-4.1d0)) .or. (.not. (n <= (-1.75d-196)))) then
        tmp = 1.0d0 / (x * n)
    else
        tmp = 0.0d0
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double tmp;
	if ((n <= -4.1) || !(n <= -1.75e-196)) {
		tmp = 1.0 / (x * n);
	} else {
		tmp = 0.0;
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if (n <= -4.1) or not (n <= -1.75e-196):
		tmp = 1.0 / (x * n)
	else:
		tmp = 0.0
	return tmp
function code(x, n)
	tmp = 0.0
	if ((n <= -4.1) || !(n <= -1.75e-196))
		tmp = Float64(1.0 / Float64(x * n));
	else
		tmp = 0.0;
	end
	return tmp
end
function tmp_2 = code(x, n)
	tmp = 0.0;
	if ((n <= -4.1) || ~((n <= -1.75e-196)))
		tmp = 1.0 / (x * n);
	else
		tmp = 0.0;
	end
	tmp_2 = tmp;
end
code[x_, n_] := If[Or[LessEqual[n, -4.1], N[Not[LessEqual[n, -1.75e-196]], $MachinePrecision]], N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if n < -4.0999999999999996 or -1.75000000000000002e-196 < n

    1. Initial program 39.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 48.0%

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

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

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

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

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

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

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

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

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

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

    if -4.0999999999999996 < n < -1.75000000000000002e-196

    1. Initial program 97.8%

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

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

        \[\leadsto \color{blue}{\left(-{x}^{\left(\frac{1}{n}\right)}\right) + {\left(x + 1\right)}^{\left(\frac{1}{n}\right)}} \]
      3. add-cube-cbrt97.8%

        \[\leadsto \color{blue}{\left(\sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}} \cdot \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}\right) \cdot \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}} + {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} \]
      4. fma-define97.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}} \cdot \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, {\left(x + 1\right)}^{\left(\frac{1}{n}\right)}\right)} \]
      5. pow-to-exp97.8%

        \[\leadsto \mathsf{fma}\left(\sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}} \cdot \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, \color{blue}{e^{\log \left(x + 1\right) \cdot \frac{1}{n}}}\right) \]
      6. un-div-inv97.9%

        \[\leadsto \mathsf{fma}\left(\sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}} \cdot \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, e^{\color{blue}{\frac{\log \left(x + 1\right)}{n}}}\right) \]
      7. +-commutative97.9%

        \[\leadsto \mathsf{fma}\left(\sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}} \cdot \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, e^{\frac{\log \color{blue}{\left(1 + x\right)}}{n}}\right) \]
      8. log1p-define97.9%

        \[\leadsto \mathsf{fma}\left(\sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}} \cdot \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, e^{\frac{\color{blue}{\mathsf{log1p}\left(x\right)}}{n}}\right) \]
    4. Applied egg-rr97.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}} \cdot \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, e^{\frac{\mathsf{log1p}\left(x\right)}{n}}\right)} \]
    5. Taylor expanded in x around inf 55.0%

      \[\leadsto \color{blue}{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}} + {\left(\sqrt[3]{-1}\right)}^{3} \cdot e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}}} \]
    6. Step-by-step derivation
      1. rem-cube-cbrt55.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto 0 \cdot e^{\color{blue}{\log x \cdot \frac{1}{n}}} \]
      11. metadata-eval55.0%

        \[\leadsto 0 \cdot e^{\log x \cdot \frac{\color{blue}{3 \cdot 0.3333333333333333}}{n}} \]
      12. associate-*l/55.0%

        \[\leadsto 0 \cdot e^{\log x \cdot \color{blue}{\left(\frac{3}{n} \cdot 0.3333333333333333\right)}} \]
      13. associate-*l*55.0%

        \[\leadsto 0 \cdot e^{\color{blue}{\left(\log x \cdot \frac{3}{n}\right) \cdot 0.3333333333333333}} \]
      14. exp-prod55.0%

        \[\leadsto 0 \cdot \color{blue}{{\left(e^{\log x \cdot \frac{3}{n}}\right)}^{0.3333333333333333}} \]
      15. exp-to-pow55.0%

        \[\leadsto 0 \cdot {\color{blue}{\left({x}^{\left(\frac{3}{n}\right)}\right)}}^{0.3333333333333333} \]
      16. unpow1/355.0%

        \[\leadsto 0 \cdot \color{blue}{\sqrt[3]{{x}^{\left(\frac{3}{n}\right)}}} \]
      17. mul0-lft55.6%

        \[\leadsto \color{blue}{0} \]
    7. Simplified55.6%

      \[\leadsto \color{blue}{0} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification48.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -4.1 \lor \neg \left(n \leq -1.75 \cdot 10^{-196}\right):\\ \;\;\;\;\frac{1}{x \cdot n}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 47.1% accurate, 17.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -10:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x}}{n}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= (/ 1.0 n) -10.0) 0.0 (/ (/ 1.0 x) n)))
double code(double x, double n) {
	double tmp;
	if ((1.0 / n) <= -10.0) {
		tmp = 0.0;
	} 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 ((1.0d0 / n) <= (-10.0d0)) then
        tmp = 0.0d0
    else
        tmp = (1.0d0 / x) / n
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double tmp;
	if ((1.0 / n) <= -10.0) {
		tmp = 0.0;
	} else {
		tmp = (1.0 / x) / n;
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if (1.0 / n) <= -10.0:
		tmp = 0.0
	else:
		tmp = (1.0 / x) / n
	return tmp
function code(x, n)
	tmp = 0.0
	if (Float64(1.0 / n) <= -10.0)
		tmp = 0.0;
	else
		tmp = Float64(Float64(1.0 / x) / n);
	end
	return tmp
end
function tmp_2 = code(x, n)
	tmp = 0.0;
	if ((1.0 / n) <= -10.0)
		tmp = 0.0;
	else
		tmp = (1.0 / x) / n;
	end
	tmp_2 = tmp;
end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -10.0], 0.0, N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -10:\\
\;\;\;\;0\\

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


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

    1. Initial program 98.6%

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

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

        \[\leadsto \color{blue}{\left(-{x}^{\left(\frac{1}{n}\right)}\right) + {\left(x + 1\right)}^{\left(\frac{1}{n}\right)}} \]
      3. add-cube-cbrt98.6%

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

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

        \[\leadsto \mathsf{fma}\left(\sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}} \cdot \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, \color{blue}{e^{\log \left(x + 1\right) \cdot \frac{1}{n}}}\right) \]
      6. un-div-inv98.7%

        \[\leadsto \mathsf{fma}\left(\sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}} \cdot \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, e^{\color{blue}{\frac{\log \left(x + 1\right)}{n}}}\right) \]
      7. +-commutative98.7%

        \[\leadsto \mathsf{fma}\left(\sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}} \cdot \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, e^{\frac{\log \color{blue}{\left(1 + x\right)}}{n}}\right) \]
      8. log1p-define98.7%

        \[\leadsto \mathsf{fma}\left(\sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}} \cdot \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, e^{\frac{\color{blue}{\mathsf{log1p}\left(x\right)}}{n}}\right) \]
    4. Applied egg-rr98.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}} \cdot \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, e^{\frac{\mathsf{log1p}\left(x\right)}{n}}\right)} \]
    5. Taylor expanded in x around inf 50.9%

      \[\leadsto \color{blue}{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}} + {\left(\sqrt[3]{-1}\right)}^{3} \cdot e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}}} \]
    6. Step-by-step derivation
      1. rem-cube-cbrt50.9%

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

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

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

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

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

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

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

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

        \[\leadsto 0 \cdot e^{\color{blue}{\frac{1}{n} \cdot \log x}} \]
      10. *-commutative50.9%

        \[\leadsto 0 \cdot e^{\color{blue}{\log x \cdot \frac{1}{n}}} \]
      11. metadata-eval50.9%

        \[\leadsto 0 \cdot e^{\log x \cdot \frac{\color{blue}{3 \cdot 0.3333333333333333}}{n}} \]
      12. associate-*l/50.9%

        \[\leadsto 0 \cdot e^{\log x \cdot \color{blue}{\left(\frac{3}{n} \cdot 0.3333333333333333\right)}} \]
      13. associate-*l*50.9%

        \[\leadsto 0 \cdot e^{\color{blue}{\left(\log x \cdot \frac{3}{n}\right) \cdot 0.3333333333333333}} \]
      14. exp-prod50.9%

        \[\leadsto 0 \cdot \color{blue}{{\left(e^{\log x \cdot \frac{3}{n}}\right)}^{0.3333333333333333}} \]
      15. exp-to-pow50.9%

        \[\leadsto 0 \cdot {\color{blue}{\left({x}^{\left(\frac{3}{n}\right)}\right)}}^{0.3333333333333333} \]
      16. unpow1/350.9%

        \[\leadsto 0 \cdot \color{blue}{\sqrt[3]{{x}^{\left(\frac{3}{n}\right)}}} \]
      17. mul0-lft51.6%

        \[\leadsto \color{blue}{0} \]
    7. Simplified51.6%

      \[\leadsto \color{blue}{0} \]

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

    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 inf 41.1%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{1}{x}}{n}} \]
    8. Simplified46.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -10:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x}}{n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 30.5% accurate, 211.0× speedup?

\[\begin{array}{l} \\ 0 \end{array} \]
(FPCore (x n) :precision binary64 0.0)
double code(double x, double n) {
	return 0.0;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    code = 0.0d0
end function
public static double code(double x, double n) {
	return 0.0;
}
def code(x, n):
	return 0.0
function code(x, n)
	return 0.0
end
function tmp = code(x, n)
	tmp = 0.0;
end
code[x_, n_] := 0.0
\begin{array}{l}

\\
0
\end{array}
Derivation
  1. Initial program 49.4%

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

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

      \[\leadsto \color{blue}{\left(-{x}^{\left(\frac{1}{n}\right)}\right) + {\left(x + 1\right)}^{\left(\frac{1}{n}\right)}} \]
    3. add-cube-cbrt49.3%

      \[\leadsto \color{blue}{\left(\sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}} \cdot \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}\right) \cdot \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}} + {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} \]
    4. fma-define49.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}} \cdot \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, {\left(x + 1\right)}^{\left(\frac{1}{n}\right)}\right)} \]
    5. pow-to-exp49.3%

      \[\leadsto \mathsf{fma}\left(\sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}} \cdot \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, \color{blue}{e^{\log \left(x + 1\right) \cdot \frac{1}{n}}}\right) \]
    6. un-div-inv49.3%

      \[\leadsto \mathsf{fma}\left(\sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}} \cdot \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, e^{\color{blue}{\frac{\log \left(x + 1\right)}{n}}}\right) \]
    7. +-commutative49.3%

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

      \[\leadsto \mathsf{fma}\left(\sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}} \cdot \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, e^{\frac{\color{blue}{\mathsf{log1p}\left(x\right)}}{n}}\right) \]
  4. Applied egg-rr56.1%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}} \cdot \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, \sqrt[3]{-{x}^{\left(\frac{1}{n}\right)}}, e^{\frac{\mathsf{log1p}\left(x\right)}{n}}\right)} \]
  5. Taylor expanded in x around inf 28.5%

    \[\leadsto \color{blue}{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}} + {\left(\sqrt[3]{-1}\right)}^{3} \cdot e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}}} \]
  6. Step-by-step derivation
    1. rem-cube-cbrt28.5%

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

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

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

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

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

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

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

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

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

      \[\leadsto 0 \cdot e^{\color{blue}{\log x \cdot \frac{1}{n}}} \]
    11. metadata-eval28.5%

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

      \[\leadsto 0 \cdot e^{\log x \cdot \color{blue}{\left(\frac{3}{n} \cdot 0.3333333333333333\right)}} \]
    13. associate-*l*28.5%

      \[\leadsto 0 \cdot e^{\color{blue}{\left(\log x \cdot \frac{3}{n}\right) \cdot 0.3333333333333333}} \]
    14. exp-prod28.5%

      \[\leadsto 0 \cdot \color{blue}{{\left(e^{\log x \cdot \frac{3}{n}}\right)}^{0.3333333333333333}} \]
    15. exp-to-pow28.5%

      \[\leadsto 0 \cdot {\color{blue}{\left({x}^{\left(\frac{3}{n}\right)}\right)}}^{0.3333333333333333} \]
    16. unpow1/328.5%

      \[\leadsto 0 \cdot \color{blue}{\sqrt[3]{{x}^{\left(\frac{3}{n}\right)}}} \]
    17. mul0-lft28.7%

      \[\leadsto \color{blue}{0} \]
  7. Simplified28.7%

    \[\leadsto \color{blue}{0} \]
  8. Final simplification28.7%

    \[\leadsto 0 \]
  9. Add Preprocessing

Reproduce

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