2nthrt (problem 3.4.6)

Percentage Accurate: 54.6% → 84.4%
Time: 43.6s
Alternatives: 20
Speedup: 1.7×

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 20 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: 54.6% accurate, 1.0× speedup?

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

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

Alternative 1: 84.4% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-173}:\\ \;\;\;\;\frac{{x}^{\left(-1 - \frac{-1}{n}\right)}}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-15}:\\ \;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\ \mathbf{else}:\\ \;\;\;\;{\left(\sqrt[3]{e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}}\right)}^{3}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= (/ 1.0 n) -1e-173)
   (/ (pow x (- -1.0 (/ -1.0 n))) n)
   (if (<= (/ 1.0 n) 5e-15)
     (/ (log (/ (+ x 1.0) x)) n)
     (pow (cbrt (- (exp (/ (log1p x) n)) (pow x (/ 1.0 n)))) 3.0))))
double code(double x, double n) {
	double tmp;
	if ((1.0 / n) <= -1e-173) {
		tmp = pow(x, (-1.0 - (-1.0 / n))) / n;
	} else if ((1.0 / n) <= 5e-15) {
		tmp = log(((x + 1.0) / x)) / n;
	} else {
		tmp = pow(cbrt((exp((log1p(x) / n)) - pow(x, (1.0 / n)))), 3.0);
	}
	return tmp;
}
public static double code(double x, double n) {
	double tmp;
	if ((1.0 / n) <= -1e-173) {
		tmp = Math.pow(x, (-1.0 - (-1.0 / n))) / n;
	} else if ((1.0 / n) <= 5e-15) {
		tmp = Math.log(((x + 1.0) / x)) / n;
	} else {
		tmp = Math.pow(Math.cbrt((Math.exp((Math.log1p(x) / n)) - Math.pow(x, (1.0 / n)))), 3.0);
	}
	return tmp;
}
function code(x, n)
	tmp = 0.0
	if (Float64(1.0 / n) <= -1e-173)
		tmp = Float64((x ^ Float64(-1.0 - Float64(-1.0 / n))) / n);
	elseif (Float64(1.0 / n) <= 5e-15)
		tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n);
	else
		tmp = cbrt(Float64(exp(Float64(log1p(x) / n)) - (x ^ Float64(1.0 / n)))) ^ 3.0;
	end
	return tmp
end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-173], N[(N[Power[x, N[(-1.0 - N[(-1.0 / n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-15], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[Power[N[Power[N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision]]]
\begin{array}{l}

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 1 n) < -1e-173

    1. Initial program 72.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1e-173 < (/.f64 1 n) < 4.99999999999999999e-15

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

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

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

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

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

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

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

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

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

    if 4.99999999999999999e-15 < (/.f64 1 n)

    1. Initial program 48.3%

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

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

        \[\leadsto \color{blue}{{\left(\sqrt[3]{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}}\right)}^{3}} \]
      3. pow-to-exp48.3%

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

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

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

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

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

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

Alternative 2: 86.5% accurate, 0.2× speedup?

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

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

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


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

    1. Initial program 45.2%

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

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

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

    if 0.0519999999999999976 < x

    1. Initial program 70.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 84.4% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-173}:\\ \;\;\;\;\frac{{x}^{\left(-1 - \frac{-1}{n}\right)}}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-15}:\\ \;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{{\left(e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}\right)}^{3}}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= (/ 1.0 n) -1e-173)
   (/ (pow x (- -1.0 (/ -1.0 n))) n)
   (if (<= (/ 1.0 n) 5e-15)
     (/ (log (/ (+ x 1.0) x)) n)
     (cbrt (pow (- (exp (/ (log1p x) n)) (pow x (/ 1.0 n))) 3.0)))))
double code(double x, double n) {
	double tmp;
	if ((1.0 / n) <= -1e-173) {
		tmp = pow(x, (-1.0 - (-1.0 / n))) / n;
	} else if ((1.0 / n) <= 5e-15) {
		tmp = log(((x + 1.0) / x)) / n;
	} else {
		tmp = cbrt(pow((exp((log1p(x) / n)) - pow(x, (1.0 / n))), 3.0));
	}
	return tmp;
}
public static double code(double x, double n) {
	double tmp;
	if ((1.0 / n) <= -1e-173) {
		tmp = Math.pow(x, (-1.0 - (-1.0 / n))) / n;
	} else if ((1.0 / n) <= 5e-15) {
		tmp = Math.log(((x + 1.0) / x)) / n;
	} else {
		tmp = Math.cbrt(Math.pow((Math.exp((Math.log1p(x) / n)) - Math.pow(x, (1.0 / n))), 3.0));
	}
	return tmp;
}
function code(x, n)
	tmp = 0.0
	if (Float64(1.0 / n) <= -1e-173)
		tmp = Float64((x ^ Float64(-1.0 - Float64(-1.0 / n))) / n);
	elseif (Float64(1.0 / n) <= 5e-15)
		tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n);
	else
		tmp = cbrt((Float64(exp(Float64(log1p(x) / n)) - (x ^ Float64(1.0 / n))) ^ 3.0));
	end
	return tmp
end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-173], N[(N[Power[x, N[(-1.0 - N[(-1.0 / n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-15], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[Power[N[Power[N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision], 1/3], $MachinePrecision]]]
\begin{array}{l}

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 1 n) < -1e-173

    1. Initial program 72.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1e-173 < (/.f64 1 n) < 4.99999999999999999e-15

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

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

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

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

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

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

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

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

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

    if 4.99999999999999999e-15 < (/.f64 1 n)

    1. Initial program 48.3%

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

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

        \[\leadsto \sqrt[3]{\color{blue}{{\left({\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\right)}^{3}}} \]
      3. pow-to-exp48.3%

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

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

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

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

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

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

Alternative 4: 86.0% accurate, 0.4× speedup?

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

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

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


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

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

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

      \[\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}} \]
    5. Step-by-step derivation
      1. mul-1-neg75.5%

        \[\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}} \]
    6. Simplified75.5%

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

    if 0.025000000000000001 < x

    1. Initial program 70.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 84.4% accurate, 0.7× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 1 n) < -1e-173

    1. Initial program 72.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1e-173 < (/.f64 1 n) < 4.99999999999999999e-15

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

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

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

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

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

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

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

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

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

    if 4.99999999999999999e-15 < (/.f64 1 n)

    1. Initial program 48.3%

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

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

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

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

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

Alternative 6: 80.7% accurate, 0.9× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (/.f64 1 n) < -1e-173

    1. Initial program 72.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1e-173 < (/.f64 1 n) < 4.9999999999999999e-13

    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 n around inf 85.3%

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

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

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

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

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

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

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

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

    if 4.9999999999999999e-13 < (/.f64 1 n) < 2.0000000000000001e130

    1. Initial program 75.1%

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

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

    if 2.0000000000000001e130 < (/.f64 1 n)

    1. Initial program 22.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 84.4% accurate, 1.0× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 1 n) < -1e-173

    1. Initial program 72.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1e-173 < (/.f64 1 n) < 4.9999999999999999e-13

    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 n around inf 85.3%

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

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

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

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

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

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

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

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

    if 4.9999999999999999e-13 < (/.f64 1 n)

    1. Initial program 49.6%

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

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

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

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

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

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

Alternative 8: 64.1% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{x - \log x}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -5:\\
\;\;\;\;\frac{0.2}{n \cdot {x}^{5}}\\

\mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-179}:\\
\;\;\;\;\frac{\frac{1 + \frac{\left(\frac{0.3333333333333333}{x} + \frac{\frac{\frac{0.2}{x} + -0.25}{x}}{x}\right) - 0.5}{x}}{x}}{n}\\

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 6 regimes
  2. if (/.f64 1 n) < -5

    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 n around inf 50.7%

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

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.2 \cdot \frac{1}{x} - 0.25}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}}}{n} \]
    7. Taylor expanded in x around 0 79.5%

      \[\leadsto \color{blue}{\frac{0.2}{n \cdot {x}^{5}}} \]
    8. Step-by-step derivation
      1. *-commutative79.5%

        \[\leadsto \frac{0.2}{\color{blue}{{x}^{5} \cdot n}} \]
    9. Simplified79.5%

      \[\leadsto \color{blue}{\frac{0.2}{{x}^{5} \cdot n}} \]

    if -5 < (/.f64 1 n) < -1e-179

    1. Initial program 23.9%

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

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

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.2 \cdot \frac{1}{x} - 0.25}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}}}{n} \]
    7. Step-by-step derivation
      1. div-sub60.4%

        \[\leadsto \frac{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \color{blue}{\left(\frac{-1 \cdot \frac{0.2 \cdot \frac{1}{x} - 0.25}{x}}{x} - \frac{0.3333333333333333}{x}\right)} - 0.5}{x} - 1}{x}}{n} \]
      2. mul-1-neg60.4%

        \[\leadsto \frac{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \left(\frac{\color{blue}{-\frac{0.2 \cdot \frac{1}{x} - 0.25}{x}}}{x} - \frac{0.3333333333333333}{x}\right) - 0.5}{x} - 1}{x}}{n} \]
      3. sub-neg60.4%

        \[\leadsto \frac{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \left(\frac{-\frac{\color{blue}{0.2 \cdot \frac{1}{x} + \left(-0.25\right)}}{x}}{x} - \frac{0.3333333333333333}{x}\right) - 0.5}{x} - 1}{x}}{n} \]
      4. un-div-inv60.4%

        \[\leadsto \frac{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \left(\frac{-\frac{\color{blue}{\frac{0.2}{x}} + \left(-0.25\right)}{x}}{x} - \frac{0.3333333333333333}{x}\right) - 0.5}{x} - 1}{x}}{n} \]
      5. metadata-eval60.4%

        \[\leadsto \frac{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \left(\frac{-\frac{\frac{0.2}{x} + \color{blue}{-0.25}}{x}}{x} - \frac{0.3333333333333333}{x}\right) - 0.5}{x} - 1}{x}}{n} \]
    8. Applied egg-rr60.4%

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

    if -1e-179 < (/.f64 1 n) < -1.00000000000000002e-221 or 4.99999999999999963e-208 < (/.f64 1 n) < 4.99999999999999999e-15

    1. Initial program 20.0%

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

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

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

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

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

    if -1.00000000000000002e-221 < (/.f64 1 n) < 4.99999999999999963e-208

    1. Initial program 59.3%

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

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

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

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

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

    if 4.99999999999999999e-15 < (/.f64 1 n) < 2.0000000000000001e130

    1. Initial program 71.0%

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

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

    if 2.0000000000000001e130 < (/.f64 1 n)

    1. Initial program 22.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 6.1%

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

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.2 \cdot \frac{1}{x} - 0.25}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}}}{n} \]
    7. Taylor expanded in n around 0 80.9%

      \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.2 \cdot \frac{1}{x} - 0.25}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{n \cdot x}} \]
    8. Simplified80.9%

      \[\leadsto \color{blue}{\frac{1 - \frac{0.5 - \frac{0.3333333333333333 - \frac{0.25 + \frac{-0.2}{x}}{x}}{x}}{x}}{x \cdot n}} \]
  3. Recombined 6 regimes into one program.
  4. Final simplification70.0%

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

Alternative 9: 55.5% accurate, 1.6× speedup?

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

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

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

\mathbf{elif}\;x \leq 8.5 \cdot 10^{-164}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 1.65 \cdot 10^{-107}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 2.6 \cdot 10^{-68}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{\frac{\frac{0.2}{x \cdot n} - \frac{0.25}{n}}{x} + \frac{0.3333333333333333}{n}}{x} - \frac{0.5}{n}}{x}}{x}\\

\mathbf{elif}\;x \leq 0.86:\\
\;\;\;\;\frac{x - \log x}{n}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \frac{\frac{0.3333333333333333 + \frac{\frac{0.2 + 0.16666666666666666 \cdot \frac{-1}{x}}{x} - 0.25}{x}}{x} - 0.5}{x}}{x}}{n}\\


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if x < 4.50000000000000009e-302 or 4.4999999999999998e-209 < x < 8.50000000000000035e-164

    1. Initial program 76.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 76.2%

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

    if 4.50000000000000009e-302 < x < 4.4999999999999998e-209 or 8.50000000000000035e-164 < x < 1.65000000000000002e-107

    1. Initial program 38.9%

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{\log x}{n}} \]
    5. Step-by-step derivation
      1. neg-mul-164.0%

        \[\leadsto \color{blue}{-\frac{\log x}{n}} \]
      2. distribute-neg-frac264.0%

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

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

    if 1.65000000000000002e-107 < x < 2.5999999999999998e-68

    1. Initial program 38.4%

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.2 \cdot \frac{1}{n \cdot x} - 0.25 \cdot \frac{1}{n}}{x} - 0.3333333333333333 \cdot \frac{1}{n}}{x} - 0.5 \cdot \frac{1}{n}}{x} - \frac{1}{n}}{x}} \]
    7. Simplified65.7%

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

    if 2.5999999999999998e-68 < x < 0.859999999999999987

    1. Initial program 40.7%

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

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

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

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

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

    if 0.859999999999999987 < x

    1. Initial program 70.0%

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

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

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.16666666666666666 \cdot \frac{1}{x} - 0.2}{x} - 0.25}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}}}{n} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification63.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 4.5 \cdot 10^{-302}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 4.5 \cdot 10^{-209}:\\ \;\;\;\;-\frac{\log x}{n}\\ \mathbf{elif}\;x \leq 8.5 \cdot 10^{-164}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 1.65 \cdot 10^{-107}:\\ \;\;\;\;-\frac{\log x}{n}\\ \mathbf{elif}\;x \leq 2.6 \cdot 10^{-68}:\\ \;\;\;\;\frac{\frac{1}{n} + \frac{\frac{\frac{\frac{0.2}{x \cdot n} - \frac{0.25}{n}}{x} + \frac{0.3333333333333333}{n}}{x} - \frac{0.5}{n}}{x}}{x}\\ \mathbf{elif}\;x \leq 0.86:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1 + \frac{\frac{0.3333333333333333 + \frac{\frac{0.2 + 0.16666666666666666 \cdot \frac{-1}{x}}{x} - 0.25}{x}}{x} - 0.5}{x}}{x}}{n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 80.3% accurate, 1.6× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (/.f64 1 n) < -1e-173

    1. Initial program 72.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1e-173 < (/.f64 1 n) < 4.9999999999999999e-13

    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 n around inf 85.3%

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

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

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

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

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

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

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

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

    if 4.9999999999999999e-13 < (/.f64 1 n) < 2.0000000000000001e130

    1. Initial program 75.1%

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

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

    if 2.0000000000000001e130 < (/.f64 1 n)

    1. Initial program 22.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 6.1%

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

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.2 \cdot \frac{1}{x} - 0.25}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}}}{n} \]
    7. Taylor expanded in n around 0 80.9%

      \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.2 \cdot \frac{1}{x} - 0.25}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{n \cdot x}} \]
    8. Simplified80.9%

      \[\leadsto \color{blue}{\frac{1 - \frac{0.5 - \frac{0.3333333333333333 - \frac{0.25 + \frac{-0.2}{x}}{x}}{x}}{x}}{x \cdot n}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification85.2%

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

Alternative 11: 55.7% accurate, 1.6× speedup?

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

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

\mathbf{elif}\;x \leq 2.8 \cdot 10^{-164}:\\
\;\;\;\;\frac{\frac{1}{n} - \frac{\frac{0.5}{n} - \frac{0.3333333333333333}{x \cdot n}}{x}}{x}\\

\mathbf{elif}\;x \leq 1.2 \cdot 10^{-109}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 10^{-69}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{\frac{\frac{0.2}{x \cdot n} - \frac{0.25}{n}}{x} + \frac{0.3333333333333333}{n}}{x} - \frac{0.5}{n}}{x}}{x}\\

\mathbf{elif}\;x \leq 0.86:\\
\;\;\;\;\frac{x - \log x}{n}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \frac{\frac{0.3333333333333333 + \frac{\frac{0.2 + 0.16666666666666666 \cdot \frac{-1}{x}}{x} - 0.25}{x}}{x} - 0.5}{x}}{x}}{n}\\


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if x < 9.00000000000000019e-180 or 2.8000000000000001e-164 < x < 1.19999999999999994e-109

    1. Initial program 47.0%

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{\log x}{n}} \]
    5. Step-by-step derivation
      1. neg-mul-156.7%

        \[\leadsto \color{blue}{-\frac{\log x}{n}} \]
      2. distribute-neg-frac256.7%

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

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

    if 9.00000000000000019e-180 < x < 2.8000000000000001e-164

    1. Initial program 67.8%

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

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

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

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

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

        \[\leadsto \color{blue}{-\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{n \cdot x} - 0.5 \cdot \frac{1}{n}}{x} - \frac{1}{n}}{x}} \]
      2. mul-1-neg78.4%

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

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

        \[\leadsto -\frac{\left(-\frac{\frac{\color{blue}{0.3333333333333333}}{n \cdot x} - 0.5 \cdot \frac{1}{n}}{x}\right) - \frac{1}{n}}{x} \]
      5. *-commutative78.4%

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

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

        \[\leadsto -\frac{\left(-\frac{\frac{0.3333333333333333}{x \cdot n} - \frac{\color{blue}{0.5}}{n}}{x}\right) - \frac{1}{n}}{x} \]
    8. Simplified78.4%

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

    if 1.19999999999999994e-109 < x < 9.9999999999999996e-70

    1. Initial program 38.4%

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.2 \cdot \frac{1}{n \cdot x} - 0.25 \cdot \frac{1}{n}}{x} - 0.3333333333333333 \cdot \frac{1}{n}}{x} - 0.5 \cdot \frac{1}{n}}{x} - \frac{1}{n}}{x}} \]
    7. Simplified65.7%

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

    if 9.9999999999999996e-70 < x < 0.859999999999999987

    1. Initial program 40.7%

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

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

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

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

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

    if 0.859999999999999987 < x

    1. Initial program 70.0%

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

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

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.16666666666666666 \cdot \frac{1}{x} - 0.2}{x} - 0.25}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}}}{n} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification60.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 9 \cdot 10^{-180}:\\ \;\;\;\;-\frac{\log x}{n}\\ \mathbf{elif}\;x \leq 2.8 \cdot 10^{-164}:\\ \;\;\;\;\frac{\frac{1}{n} - \frac{\frac{0.5}{n} - \frac{0.3333333333333333}{x \cdot n}}{x}}{x}\\ \mathbf{elif}\;x \leq 1.2 \cdot 10^{-109}:\\ \;\;\;\;-\frac{\log x}{n}\\ \mathbf{elif}\;x \leq 10^{-69}:\\ \;\;\;\;\frac{\frac{1}{n} + \frac{\frac{\frac{\frac{0.2}{x \cdot n} - \frac{0.25}{n}}{x} + \frac{0.3333333333333333}{n}}{x} - \frac{0.5}{n}}{x}}{x}\\ \mathbf{elif}\;x \leq 0.86:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1 + \frac{\frac{0.3333333333333333 + \frac{\frac{0.2 + 0.16666666666666666 \cdot \frac{-1}{x}}{x} - 0.25}{x}}{x} - 0.5}{x}}{x}}{n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 55.5% accurate, 1.6× speedup?

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

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

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

\mathbf{elif}\;x \leq 9.5 \cdot 10^{-109}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 2.4 \cdot 10^{-68}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{\frac{\frac{0.2}{x \cdot n} - \frac{0.25}{n}}{x} + \frac{0.3333333333333333}{n}}{x} - \frac{0.5}{n}}{x}}{x}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1 + \frac{\frac{0.3333333333333333 + \frac{\frac{0.2 + 0.16666666666666666 \cdot \frac{-1}{x}}{x} - 0.25}{x}}{x} - 0.5}{x}}{x}}{n}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < 1.39999999999999999e-180 or 9.99999999999999954e-163 < x < 9.49999999999999933e-109 or 2.39999999999999991e-68 < x < 0.75

    1. Initial program 45.4%

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{\log x}{n}} \]
    5. Step-by-step derivation
      1. neg-mul-152.4%

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

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

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

    if 1.39999999999999999e-180 < x < 9.99999999999999954e-163

    1. Initial program 67.8%

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

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

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

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

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

        \[\leadsto \color{blue}{-\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{n \cdot x} - 0.5 \cdot \frac{1}{n}}{x} - \frac{1}{n}}{x}} \]
      2. mul-1-neg78.4%

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

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

        \[\leadsto -\frac{\left(-\frac{\frac{\color{blue}{0.3333333333333333}}{n \cdot x} - 0.5 \cdot \frac{1}{n}}{x}\right) - \frac{1}{n}}{x} \]
      5. *-commutative78.4%

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

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

        \[\leadsto -\frac{\left(-\frac{\frac{0.3333333333333333}{x \cdot n} - \frac{\color{blue}{0.5}}{n}}{x}\right) - \frac{1}{n}}{x} \]
    8. Simplified78.4%

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

    if 9.49999999999999933e-109 < x < 2.39999999999999991e-68

    1. Initial program 38.4%

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.2 \cdot \frac{1}{n \cdot x} - 0.25 \cdot \frac{1}{n}}{x} - 0.3333333333333333 \cdot \frac{1}{n}}{x} - 0.5 \cdot \frac{1}{n}}{x} - \frac{1}{n}}{x}} \]
    7. Simplified65.7%

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

    if 0.75 < x

    1. Initial program 70.0%

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

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

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.16666666666666666 \cdot \frac{1}{x} - 0.2}{x} - 0.25}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}}}{n} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification59.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.4 \cdot 10^{-180}:\\ \;\;\;\;-\frac{\log x}{n}\\ \mathbf{elif}\;x \leq 10^{-162}:\\ \;\;\;\;\frac{\frac{1}{n} - \frac{\frac{0.5}{n} - \frac{0.3333333333333333}{x \cdot n}}{x}}{x}\\ \mathbf{elif}\;x \leq 9.5 \cdot 10^{-109}:\\ \;\;\;\;-\frac{\log x}{n}\\ \mathbf{elif}\;x \leq 2.4 \cdot 10^{-68}:\\ \;\;\;\;\frac{\frac{1}{n} + \frac{\frac{\frac{\frac{0.2}{x \cdot n} - \frac{0.25}{n}}{x} + \frac{0.3333333333333333}{n}}{x} - \frac{0.5}{n}}{x}}{x}\\ \mathbf{elif}\;x \leq 0.75:\\ \;\;\;\;-\frac{\log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1 + \frac{\frac{0.3333333333333333 + \frac{\frac{0.2 + 0.16666666666666666 \cdot \frac{-1}{x}}{x} - 0.25}{x}}{x} - 0.5}{x}}{x}}{n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 77.8% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -10000:\\
\;\;\;\;\frac{0.2}{n \cdot {x}^{5}}\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (/.f64 1 n) < -1e4

    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 n around inf 49.4%

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

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.2 \cdot \frac{1}{x} - 0.25}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}}}{n} \]
    7. Taylor expanded in x around 0 79.0%

      \[\leadsto \color{blue}{\frac{0.2}{n \cdot {x}^{5}}} \]
    8. Step-by-step derivation
      1. *-commutative79.0%

        \[\leadsto \frac{0.2}{\color{blue}{{x}^{5} \cdot n}} \]
    9. Simplified79.0%

      \[\leadsto \color{blue}{\frac{0.2}{{x}^{5} \cdot n}} \]

    if -1e4 < (/.f64 1 n) < 4.9999999999999999e-13

    1. Initial program 34.6%

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

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

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

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

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

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

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

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

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

    if 4.9999999999999999e-13 < (/.f64 1 n) < 2.0000000000000001e130

    1. Initial program 75.1%

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

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

    if 2.0000000000000001e130 < (/.f64 1 n)

    1. Initial program 22.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 6.1%

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

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.2 \cdot \frac{1}{x} - 0.25}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}}}{n} \]
    7. Taylor expanded in n around 0 80.9%

      \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.2 \cdot \frac{1}{x} - 0.25}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{n \cdot x}} \]
    8. Simplified80.9%

      \[\leadsto \color{blue}{\frac{1 - \frac{0.5 - \frac{0.3333333333333333 - \frac{0.25 + \frac{-0.2}{x}}{x}}{x}}{x}}{x \cdot n}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification76.5%

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

Alternative 14: 80.2% accurate, 1.7× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (/.f64 1 n) < -1e-173

    1. Initial program 72.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1e-173 < (/.f64 1 n) < 4.9999999999999999e-13

    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 n around inf 85.3%

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

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

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

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

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

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

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

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

    if 4.9999999999999999e-13 < (/.f64 1 n) < 2.0000000000000001e130

    1. Initial program 75.1%

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

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

    if 2.0000000000000001e130 < (/.f64 1 n)

    1. Initial program 22.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 6.1%

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

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.2 \cdot \frac{1}{x} - 0.25}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}}}{n} \]
    7. Taylor expanded in n around 0 80.9%

      \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.2 \cdot \frac{1}{x} - 0.25}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{n \cdot x}} \]
    8. Simplified80.9%

      \[\leadsto \color{blue}{\frac{1 - \frac{0.5 - \frac{0.3333333333333333 - \frac{0.25 + \frac{-0.2}{x}}{x}}{x}}{x}}{x \cdot n}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification85.2%

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

Alternative 15: 47.8% accurate, 9.2× speedup?

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

\\
\frac{\frac{1 + \frac{\left(\frac{0.3333333333333333}{x} + \frac{\frac{\frac{0.2}{x} + -0.25}{x}}{x}\right) - 0.5}{x}}{x}}{n}
\end{array}
Derivation
  1. Initial program 57.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 58.5%

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

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

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

    \[\leadsto \frac{\color{blue}{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.2 \cdot \frac{1}{x} - 0.25}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}}}{n} \]
  7. Step-by-step derivation
    1. div-sub49.2%

      \[\leadsto \frac{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \color{blue}{\left(\frac{-1 \cdot \frac{0.2 \cdot \frac{1}{x} - 0.25}{x}}{x} - \frac{0.3333333333333333}{x}\right)} - 0.5}{x} - 1}{x}}{n} \]
    2. mul-1-neg49.2%

      \[\leadsto \frac{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \left(\frac{\color{blue}{-\frac{0.2 \cdot \frac{1}{x} - 0.25}{x}}}{x} - \frac{0.3333333333333333}{x}\right) - 0.5}{x} - 1}{x}}{n} \]
    3. sub-neg49.2%

      \[\leadsto \frac{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \left(\frac{-\frac{\color{blue}{0.2 \cdot \frac{1}{x} + \left(-0.25\right)}}{x}}{x} - \frac{0.3333333333333333}{x}\right) - 0.5}{x} - 1}{x}}{n} \]
    4. un-div-inv49.2%

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

      \[\leadsto \frac{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \left(\frac{-\frac{\frac{0.2}{x} + \color{blue}{-0.25}}{x}}{x} - \frac{0.3333333333333333}{x}\right) - 0.5}{x} - 1}{x}}{n} \]
  8. Applied egg-rr49.2%

    \[\leadsto \frac{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \color{blue}{\left(\frac{-\frac{\frac{0.2}{x} + -0.25}{x}}{x} - \frac{0.3333333333333333}{x}\right)} - 0.5}{x} - 1}{x}}{n} \]
  9. Final simplification49.2%

    \[\leadsto \frac{\frac{1 + \frac{\left(\frac{0.3333333333333333}{x} + \frac{\frac{\frac{0.2}{x} + -0.25}{x}}{x}\right) - 0.5}{x}}{x}}{n} \]
  10. Add Preprocessing

Alternative 16: 46.7% accurate, 12.4× speedup?

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

\\
\frac{\frac{1}{n} - \frac{\frac{0.5}{n} - \frac{0.3333333333333333}{x \cdot n}}{x}}{x}
\end{array}
Derivation
  1. Initial program 57.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 58.5%

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

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

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

    \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{n \cdot x} - 0.5 \cdot \frac{1}{n}}{x} - \frac{1}{n}}{x}} \]
  7. Step-by-step derivation
    1. mul-1-neg48.9%

      \[\leadsto \color{blue}{-\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{n \cdot x} - 0.5 \cdot \frac{1}{n}}{x} - \frac{1}{n}}{x}} \]
    2. mul-1-neg48.9%

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

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

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

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

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

      \[\leadsto -\frac{\left(-\frac{\frac{0.3333333333333333}{x \cdot n} - \frac{\color{blue}{0.5}}{n}}{x}\right) - \frac{1}{n}}{x} \]
  8. Simplified48.9%

    \[\leadsto \color{blue}{-\frac{\left(-\frac{\frac{0.3333333333333333}{x \cdot n} - \frac{0.5}{n}}{x}\right) - \frac{1}{n}}{x}} \]
  9. Final simplification48.9%

    \[\leadsto \frac{\frac{1}{n} - \frac{\frac{0.5}{n} - \frac{0.3333333333333333}{x \cdot n}}{x}}{x} \]
  10. Add Preprocessing

Alternative 17: 46.6% accurate, 16.2× speedup?

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

\\
\frac{\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{x}}{n}
\end{array}
Derivation
  1. Initial program 57.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 58.5%

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

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

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

    \[\leadsto \frac{\color{blue}{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.2 \cdot \frac{1}{x} - 0.25}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}}}{n} \]
  7. Taylor expanded in x around inf 48.9%

    \[\leadsto \frac{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \color{blue}{\frac{-0.3333333333333333}{x}} - 0.5}{x} - 1}{x}}{n} \]
  8. Final simplification48.9%

    \[\leadsto \frac{\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{x}}{n} \]
  9. Add Preprocessing

Alternative 18: 40.3% 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 57.1%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{1}{x \cdot n}} \]
  9. Final simplification41.1%

    \[\leadsto \frac{1}{x \cdot n} \]
  10. Add Preprocessing

Alternative 19: 40.8% 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 57.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 58.5%

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

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

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

    \[\leadsto \frac{\color{blue}{\frac{1}{x}}}{n} \]
  7. Final simplification42.1%

    \[\leadsto \frac{\frac{1}{x}}{n} \]
  8. Add Preprocessing

Alternative 20: 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 57.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 58.5%

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

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

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

    \[\leadsto \color{blue}{-1 \cdot \frac{\log x}{n} + \frac{x}{n}} \]
  7. Taylor expanded in x around inf 4.3%

    \[\leadsto \color{blue}{\frac{x}{n}} \]
  8. Final simplification4.3%

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

Reproduce

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