2nthrt (problem 3.4.6)

Percentage Accurate: 53.0% → 92.0%
Time: 40.7s
Alternatives: 14
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 14 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.0% 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: 92.0% accurate, 0.2× speedup?

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

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

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


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

    1. Initial program 44.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 83.3%

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

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

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

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

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

    if 3.5e5 < x

    1. Initial program 70.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 98.7%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{{x}^{\left(\frac{1}{n}\right)}}{x \cdot n}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity98.7%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{{x}^{\left(\frac{1}{n} + -1\right)}}{n}} \]
    10. Step-by-step derivation
      1. unpow-prod-up99.6%

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

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

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

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

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

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

Alternative 2: 86.8% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 350000:\\ \;\;\;\;\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)}}{x}}{n}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= x 350000.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)) x) n)))
double code(double x, double n) {
	double tmp;
	if (x <= 350000.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)) / x) / n;
	}
	return tmp;
}
public static double code(double x, double n) {
	double tmp;
	if (x <= 350000.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)) / x) / n;
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if x <= 350000.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)) / x) / n
	return tmp
function code(x, n)
	tmp = 0.0
	if (x <= 350000.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)) / x) / n);
	end
	return tmp
end
code[x_, n_] := If[LessEqual[x, 350000.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] / x), $MachinePrecision] / n), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 350000:\\
\;\;\;\;\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)}}{x}}{n}\\


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

    1. Initial program 44.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 83.3%

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

      \[\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 3.5e5 < x

    1. Initial program 70.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 98.7%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{{x}^{\left(\frac{1}{n}\right)}}{x \cdot n}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity98.7%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{{x}^{\left(\frac{1}{n} + -1\right)}}{n}} \]
    10. Step-by-step derivation
      1. unpow-prod-up99.6%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 350000:\\ \;\;\;\;\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)}}{x}}{n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 86.3% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.32:\\
\;\;\;\;\frac{\frac{-0.16666666666666666 \cdot \frac{{\log x}^{3}}{n} + {\log x}^{2} \cdot -0.5}{n} - \log x}{n}\\

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


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

    1. Initial program 45.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 44.0%

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

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

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

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

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

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

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

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

    if 0.320000000000000007 < x

    1. Initial program 68.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 97.2%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{{x}^{\left(\frac{1}{n}\right)}}{x \cdot n}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity97.2%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{{x}^{\left(\frac{1}{n} + -1\right)}}{n}} \]
    10. Step-by-step derivation
      1. unpow-prod-up98.1%

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{{x}^{\left(\frac{1}{n}\right)} \cdot 1}{x}}}{n} \]
      2. *-rgt-identity98.0%

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

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

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

Alternative 4: 85.3% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-53}:\\ \;\;\;\;\frac{t\_0}{x \cdot n}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-23}:\\ \;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 50:\\ \;\;\;\;\frac{1}{\frac{x \cdot n}{t\_0}}\\ \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) -5e-53)
     (/ t_0 (* x n))
     (if (<= (/ 1.0 n) 2e-23)
       (/ (- (log1p x) (log x)) n)
       (if (<= (/ 1.0 n) 50.0)
         (/ 1.0 (/ (* x n) t_0))
         (- (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) <= -5e-53) {
		tmp = t_0 / (x * n);
	} else if ((1.0 / n) <= 2e-23) {
		tmp = (log1p(x) - log(x)) / n;
	} else if ((1.0 / n) <= 50.0) {
		tmp = 1.0 / ((x * n) / t_0);
	} 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) <= -5e-53) {
		tmp = t_0 / (x * n);
	} else if ((1.0 / n) <= 2e-23) {
		tmp = (Math.log1p(x) - Math.log(x)) / n;
	} else if ((1.0 / n) <= 50.0) {
		tmp = 1.0 / ((x * n) / t_0);
	} 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) <= -5e-53:
		tmp = t_0 / (x * n)
	elif (1.0 / n) <= 2e-23:
		tmp = (math.log1p(x) - math.log(x)) / n
	elif (1.0 / n) <= 50.0:
		tmp = 1.0 / ((x * n) / t_0)
	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) <= -5e-53)
		tmp = Float64(t_0 / Float64(x * n));
	elseif (Float64(1.0 / n) <= 2e-23)
		tmp = Float64(Float64(log1p(x) - log(x)) / n);
	elseif (Float64(1.0 / n) <= 50.0)
		tmp = Float64(1.0 / Float64(Float64(x * n) / t_0));
	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], -5e-53], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-23], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 50.0], N[(1.0 / N[(N[(x * n), $MachinePrecision] / t$95$0), $MachinePrecision]), $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 -5 \cdot 10^{-53}:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.99999999999999992e-23 < (/.f64 #s(literal 1 binary64) n) < 50

    1. Initial program 19.6%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{{x}^{\left(\frac{1}{n}\right)}}{x \cdot n}} \]
    6. Step-by-step derivation
      1. clear-num68.0%

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

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

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

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

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

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

    1. Initial program 48.2%

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

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

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

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

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

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

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

Alternative 5: 81.9% accurate, 1.0× speedup?

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.99999999999999992e-23 < (/.f64 #s(literal 1 binary64) n) < 50

    1. Initial program 19.6%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{{x}^{\left(\frac{1}{n}\right)}}{x \cdot n}} \]
    6. Step-by-step derivation
      1. clear-num68.0%

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

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

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

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

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

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

    1. Initial program 48.2%

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

      \[\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 81.0%

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

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

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

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

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

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

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

Alternative 6: 70.5% accurate, 1.0× speedup?

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

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

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

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

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


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

    1. Initial program 77.8%

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

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

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

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

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

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

    if 6.00000000000000007e-285 < x < 2e-100

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

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

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

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

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

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

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

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

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

    if 2e-100 < x < 1

    1. Initial program 50.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 46.1%

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

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

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

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

    if 1 < x

    1. Initial program 68.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 97.2%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{{x}^{\left(\frac{1}{n}\right)}}{x \cdot n}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity97.2%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{{x}^{\left(\frac{1}{n} + -1\right)}}{n}} \]
    10. Step-by-step derivation
      1. unpow-prod-up98.1%

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{{x}^{\left(\frac{1}{n}\right)} \cdot 1}{x}}}{n} \]
      2. *-rgt-identity98.0%

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

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

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

Alternative 7: 65.3% accurate, 1.6× speedup?

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

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

\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-282}:\\
\;\;\;\;\frac{\frac{1 - \frac{0.5}{x}}{n}}{x}\\

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

\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+175}:\\
\;\;\;\;1 - t\_0\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2e9 < (/.f64 #s(literal 1 binary64) n) < 4.0000000000000001e-282

    1. Initial program 39.2%

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

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

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

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

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

          \[\leadsto \frac{\frac{1 - \frac{\color{blue}{0.5}}{x}}{n}}{x} \]
      4. Simplified59.3%

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

      if 4.0000000000000001e-282 < (/.f64 #s(literal 1 binary64) n) < 1.49999999999999999e-9

      1. Initial program 23.8%

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

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

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

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

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

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

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

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

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

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

      1. Initial program 69.4%

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

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

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

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

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

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

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

      1. Initial program 10.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -2000000000:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-282}:\\ \;\;\;\;\frac{\frac{1 - \frac{0.5}{x}}{n}}{x}\\ \mathbf{elif}\;\frac{1}{n} \leq 1.5 \cdot 10^{-9}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+175}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x \cdot n}\\ \end{array} \]
    7. Add Preprocessing

    Alternative 8: 53.6% accurate, 1.7× speedup?

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

      1. Initial program 58.6%

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

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

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

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

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

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

      if 3.14999999999999994e-285 < x < 2.20000000000000021e-121

      1. Initial program 35.5%

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

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

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

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

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

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

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

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

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

      if 1 < x

      1. Initial program 68.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 89.0%

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

          \[\leadsto \color{blue}{\frac{\mathsf{fma}\left({x}^{\left(\frac{1}{n}\right)}, \frac{\mathsf{fma}\left(0.5, {n}^{-2}, \frac{-0.5}{n}\right)}{x}, \frac{{x}^{\left(\frac{1}{n}\right)}}{n}\right)}{x}} \]
        2. Taylor expanded in n around inf 63.6%

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

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

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

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

        \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 3.15 \cdot 10^{-285}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 2.2 \cdot 10^{-121}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1 - \frac{0.5}{x}}{n}}{x}\\ \end{array} \]
      7. Add Preprocessing

      Alternative 9: 66.9% accurate, 1.8× speedup?

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

        1. Initial program 77.8%

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

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

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

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

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

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

        if 8.0000000000000004e-286 < x < 4.19999999999999985e-122

        1. Initial program 35.5%

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

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

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

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

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

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

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

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

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

        if 4.19999999999999985e-122 < x

        1. Initial program 63.8%

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{\frac{{x}^{\left(\frac{1}{n}\right)}}{x \cdot n}} \]
        6. Step-by-step derivation
          1. *-un-lft-identity81.9%

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

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{\frac{{x}^{\left(\frac{1}{n} + -1\right)}}{n}} \]
        10. Step-by-step derivation
          1. unpow-prod-up82.5%

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

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

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

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

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

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

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

      Alternative 10: 57.5% accurate, 1.9× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 0.98:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1 - \frac{0.5}{x}}{n}}{x}\\ \end{array} \end{array} \]
      (FPCore (x n)
       :precision binary64
       (if (<= x 0.98) (/ (- x (log x)) n) (/ (/ (- 1.0 (/ 0.5 x)) n) x)))
      double code(double x, double n) {
      	double tmp;
      	if (x <= 0.98) {
      		tmp = (x - log(x)) / n;
      	} else {
      		tmp = ((1.0 - (0.5 / x)) / n) / x;
      	}
      	return tmp;
      }
      
      real(8) function code(x, n)
          real(8), intent (in) :: x
          real(8), intent (in) :: n
          real(8) :: tmp
          if (x <= 0.98d0) then
              tmp = (x - log(x)) / n
          else
              tmp = ((1.0d0 - (0.5d0 / x)) / n) / x
          end if
          code = tmp
      end function
      
      public static double code(double x, double n) {
      	double tmp;
      	if (x <= 0.98) {
      		tmp = (x - Math.log(x)) / n;
      	} else {
      		tmp = ((1.0 - (0.5 / x)) / n) / x;
      	}
      	return tmp;
      }
      
      def code(x, n):
      	tmp = 0
      	if x <= 0.98:
      		tmp = (x - math.log(x)) / n
      	else:
      		tmp = ((1.0 - (0.5 / x)) / n) / x
      	return tmp
      
      function code(x, n)
      	tmp = 0.0
      	if (x <= 0.98)
      		tmp = Float64(Float64(x - log(x)) / n);
      	else
      		tmp = Float64(Float64(Float64(1.0 - Float64(0.5 / x)) / n) / x);
      	end
      	return tmp
      end
      
      function tmp_2 = code(x, n)
      	tmp = 0.0;
      	if (x <= 0.98)
      		tmp = (x - log(x)) / n;
      	else
      		tmp = ((1.0 - (0.5 / x)) / n) / x;
      	end
      	tmp_2 = tmp;
      end
      
      code[x_, n_] := If[LessEqual[x, 0.98], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(1.0 - N[(0.5 / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;x \leq 0.98:\\
      \;\;\;\;\frac{x - \log x}{n}\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{\frac{1 - \frac{0.5}{x}}{n}}{x}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if x < 0.97999999999999998

        1. Initial program 45.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 44.2%

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

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

        if 0.97999999999999998 < x

        1. Initial program 68.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 89.0%

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

            \[\leadsto \color{blue}{\frac{\mathsf{fma}\left({x}^{\left(\frac{1}{n}\right)}, \frac{\mathsf{fma}\left(0.5, {n}^{-2}, \frac{-0.5}{n}\right)}{x}, \frac{{x}^{\left(\frac{1}{n}\right)}}{n}\right)}{x}} \]
          2. Taylor expanded in n around inf 63.6%

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

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

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

            \[\leadsto \frac{\color{blue}{\frac{1 - \frac{0.5}{x}}{n}}}{x} \]
        5. Recombined 2 regimes into one program.
        6. Add Preprocessing

        Alternative 11: 57.3% accurate, 1.9× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 0.66:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1 - \frac{0.5}{x}}{n}}{x}\\ \end{array} \end{array} \]
        (FPCore (x n)
         :precision binary64
         (if (<= x 0.66) (/ (log x) (- n)) (/ (/ (- 1.0 (/ 0.5 x)) n) x)))
        double code(double x, double n) {
        	double tmp;
        	if (x <= 0.66) {
        		tmp = log(x) / -n;
        	} else {
        		tmp = ((1.0 - (0.5 / x)) / n) / x;
        	}
        	return tmp;
        }
        
        real(8) function code(x, n)
            real(8), intent (in) :: x
            real(8), intent (in) :: n
            real(8) :: tmp
            if (x <= 0.66d0) then
                tmp = log(x) / -n
            else
                tmp = ((1.0d0 - (0.5d0 / x)) / n) / x
            end if
            code = tmp
        end function
        
        public static double code(double x, double n) {
        	double tmp;
        	if (x <= 0.66) {
        		tmp = Math.log(x) / -n;
        	} else {
        		tmp = ((1.0 - (0.5 / x)) / n) / x;
        	}
        	return tmp;
        }
        
        def code(x, n):
        	tmp = 0
        	if x <= 0.66:
        		tmp = math.log(x) / -n
        	else:
        		tmp = ((1.0 - (0.5 / x)) / n) / x
        	return tmp
        
        function code(x, n)
        	tmp = 0.0
        	if (x <= 0.66)
        		tmp = Float64(log(x) / Float64(-n));
        	else
        		tmp = Float64(Float64(Float64(1.0 - Float64(0.5 / x)) / n) / x);
        	end
        	return tmp
        end
        
        function tmp_2 = code(x, n)
        	tmp = 0.0;
        	if (x <= 0.66)
        		tmp = log(x) / -n;
        	else
        		tmp = ((1.0 - (0.5 / x)) / n) / x;
        	end
        	tmp_2 = tmp;
        end
        
        code[x_, n_] := If[LessEqual[x, 0.66], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], N[(N[(N[(1.0 - N[(0.5 / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;x \leq 0.66:\\
        \;\;\;\;\frac{\log x}{-n}\\
        
        \mathbf{else}:\\
        \;\;\;\;\frac{\frac{1 - \frac{0.5}{x}}{n}}{x}\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if x < 0.660000000000000031

          1. Initial program 45.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 44.0%

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

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

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

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

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

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

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

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

          if 0.660000000000000031 < x

          1. Initial program 68.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 89.0%

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

              \[\leadsto \color{blue}{\frac{\mathsf{fma}\left({x}^{\left(\frac{1}{n}\right)}, \frac{\mathsf{fma}\left(0.5, {n}^{-2}, \frac{-0.5}{n}\right)}{x}, \frac{{x}^{\left(\frac{1}{n}\right)}}{n}\right)}{x}} \]
            2. Taylor expanded in n around inf 63.6%

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

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

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

              \[\leadsto \frac{\color{blue}{\frac{1 - \frac{0.5}{x}}{n}}}{x} \]
          5. Recombined 2 regimes into one program.
          6. Final simplification56.0%

            \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 0.66:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1 - \frac{0.5}{x}}{n}}{x}\\ \end{array} \]
          7. Add Preprocessing

          Alternative 12: 41.1% accurate, 42.2× speedup?

          \[\begin{array}{l} \\ \frac{\frac{1}{x}}{n} \end{array} \]
          (FPCore (x n) :precision binary64 (/ (/ 1.0 x) n))
          double code(double x, double n) {
          	return (1.0 / x) / n;
          }
          
          real(8) function code(x, n)
              real(8), intent (in) :: x
              real(8), intent (in) :: n
              code = (1.0d0 / x) / n
          end function
          
          public static double code(double x, double n) {
          	return (1.0 / x) / n;
          }
          
          def code(x, n):
          	return (1.0 / x) / n
          
          function code(x, n)
          	return Float64(Float64(1.0 / x) / n)
          end
          
          function tmp = code(x, n)
          	tmp = (1.0 / x) / n;
          end
          
          code[x_, n_] := N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]
          
          \begin{array}{l}
          
          \\
          \frac{\frac{1}{x}}{n}
          \end{array}
          
          Derivation
          1. Initial program 55.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 61.2%

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \color{blue}{\frac{{x}^{\left(\frac{1}{n}\right)}}{x \cdot n}} \]
          6. Step-by-step derivation
            1. *-un-lft-identity61.2%

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

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

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

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

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

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

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

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

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

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

          Alternative 13: 40.5% accurate, 42.2× speedup?

          \[\begin{array}{l} \\ \frac{1}{x \cdot n} \end{array} \]
          (FPCore (x n) :precision binary64 (/ 1.0 (* x n)))
          double code(double x, double n) {
          	return 1.0 / (x * n);
          }
          
          real(8) function code(x, n)
              real(8), intent (in) :: x
              real(8), intent (in) :: n
              code = 1.0d0 / (x * n)
          end function
          
          public static double code(double x, double n) {
          	return 1.0 / (x * n);
          }
          
          def code(x, n):
          	return 1.0 / (x * n)
          
          function code(x, n)
          	return Float64(1.0 / Float64(x * n))
          end
          
          function tmp = code(x, n)
          	tmp = 1.0 / (x * n);
          end
          
          code[x_, n_] := N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision]
          
          \begin{array}{l}
          
          \\
          \frac{1}{x \cdot n}
          \end{array}
          
          Derivation
          1. Initial program 55.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 61.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          Alternative 14: 4.5% accurate, 70.3× speedup?

          \[\begin{array}{l} \\ \frac{x}{n} \end{array} \]
          (FPCore (x n) :precision binary64 (/ x n))
          double code(double x, double n) {
          	return x / n;
          }
          
          real(8) function code(x, n)
              real(8), intent (in) :: x
              real(8), intent (in) :: n
              code = x / n
          end function
          
          public static double code(double x, double n) {
          	return x / n;
          }
          
          def code(x, n):
          	return x / n
          
          function code(x, n)
          	return Float64(x / n)
          end
          
          function tmp = code(x, n)
          	tmp = x / n;
          end
          
          code[x_, n_] := N[(x / n), $MachinePrecision]
          
          \begin{array}{l}
          
          \\
          \frac{x}{n}
          \end{array}
          
          Derivation
          1. Initial program 55.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 32.9%

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

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

          Reproduce

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