2nthrt (problem 3.4.6)

Percentage Accurate: 53.6% → 84.9%
Time: 40.3s
Alternatives: 19
Speedup: 1.9×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 19 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 53.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.9% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-26}:\\ \;\;\;\;\frac{\frac{\sqrt[3]{{x}^{\left(\frac{3}{n}\right)}}}{n}}{x}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-134}:\\ \;\;\;\;\left(2 \cdot \log \left(\sqrt{\frac{x}{1 + x}}\right)\right) \cdot \frac{-1}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-79}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-22}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{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) -5e-26)
   (/ (/ (cbrt (pow x (/ 3.0 n))) n) x)
   (if (<= (/ 1.0 n) 5e-134)
     (* (* 2.0 (log (sqrt (/ x (+ 1.0 x))))) (/ -1.0 n))
     (if (<= (/ 1.0 n) 4e-79)
       (/ (/ 1.0 n) x)
       (if (<= (/ 1.0 n) 2e-22)
         (/ (log (/ (+ 1.0 x) x)) n)
         (- (exp (/ (log1p x) n)) (pow x (/ 1.0 n))))))))
double code(double x, double n) {
	double tmp;
	if ((1.0 / n) <= -5e-26) {
		tmp = (cbrt(pow(x, (3.0 / n))) / n) / x;
	} else if ((1.0 / n) <= 5e-134) {
		tmp = (2.0 * log(sqrt((x / (1.0 + x))))) * (-1.0 / n);
	} else if ((1.0 / n) <= 4e-79) {
		tmp = (1.0 / n) / x;
	} else if ((1.0 / n) <= 2e-22) {
		tmp = log(((1.0 + x) / 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) <= -5e-26) {
		tmp = (Math.cbrt(Math.pow(x, (3.0 / n))) / n) / x;
	} else if ((1.0 / n) <= 5e-134) {
		tmp = (2.0 * Math.log(Math.sqrt((x / (1.0 + x))))) * (-1.0 / n);
	} else if ((1.0 / n) <= 4e-79) {
		tmp = (1.0 / n) / x;
	} else if ((1.0 / n) <= 2e-22) {
		tmp = Math.log(((1.0 + x) / 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) <= -5e-26)
		tmp = Float64(Float64(cbrt((x ^ Float64(3.0 / n))) / n) / x);
	elseif (Float64(1.0 / n) <= 5e-134)
		tmp = Float64(Float64(2.0 * log(sqrt(Float64(x / Float64(1.0 + x))))) * Float64(-1.0 / n));
	elseif (Float64(1.0 / n) <= 4e-79)
		tmp = Float64(Float64(1.0 / n) / x);
	elseif (Float64(1.0 / n) <= 2e-22)
		tmp = Float64(log(Float64(Float64(1.0 + x) / 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], -5e-26], N[(N[(N[Power[N[Power[x, N[(3.0 / n), $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-134], N[(N[(2.0 * N[Log[N[Sqrt[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-1.0 / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-79], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-22], N[(N[Log[N[(N[(1.0 + x), $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 -5 \cdot 10^{-26}:\\
\;\;\;\;\frac{\frac{\sqrt[3]{{x}^{\left(\frac{3}{n}\right)}}}{n}}{x}\\

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

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

\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-22}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{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 5 regimes
  2. if (/.f64 1 n) < -5.00000000000000019e-26

    1. Initial program 89.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. associate-/r*97.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.00000000000000019e-26 < (/.f64 1 n) < 5.0000000000000003e-134

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\log \left(\frac{x}{x + 1}\right) \cdot \frac{-1}{n}} \]
    14. Step-by-step derivation
      1. add-sqr-sqrt87.9%

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

        \[\leadsto \color{blue}{\left(\log \left(\sqrt{\frac{x}{x + 1}}\right) + \log \left(\sqrt{\frac{x}{x + 1}}\right)\right)} \cdot \frac{-1}{n} \]
    15. Applied egg-rr88.0%

      \[\leadsto \color{blue}{\left(\log \left(\sqrt{\frac{x}{x + 1}}\right) + \log \left(\sqrt{\frac{x}{x + 1}}\right)\right)} \cdot \frac{-1}{n} \]
    16. Step-by-step derivation
      1. count-288.0%

        \[\leadsto \color{blue}{\left(2 \cdot \log \left(\sqrt{\frac{x}{x + 1}}\right)\right)} \cdot \frac{-1}{n} \]
    17. Simplified88.0%

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

    if 5.0000000000000003e-134 < (/.f64 1 n) < 4e-79

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4e-79 < (/.f64 1 n) < 2.0000000000000001e-22

    1. Initial program 19.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 79.7%

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

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

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

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

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

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

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

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

    if 2.0000000000000001e-22 < (/.f64 1 n)

    1. Initial program 54.1%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-26}:\\ \;\;\;\;\frac{\frac{\sqrt[3]{{x}^{\left(\frac{3}{n}\right)}}}{n}}{x}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-134}:\\ \;\;\;\;\left(2 \cdot \log \left(\sqrt{\frac{x}{1 + x}}\right)\right) \cdot \frac{-1}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-79}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-22}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{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 2: 81.8% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-26}:\\
\;\;\;\;\frac{\frac{\sqrt[3]{{x}^{\left(\frac{3}{n}\right)}}}{n}}{x}\\

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

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

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

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


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

    1. Initial program 89.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. associate-/r*97.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.00000000000000019e-26 < (/.f64 1 n) < 5.0000000000000003e-134

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\log \left(\frac{x}{x + 1}\right) \cdot \frac{-1}{n}} \]
    14. Step-by-step derivation
      1. add-sqr-sqrt87.9%

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

        \[\leadsto \color{blue}{\left(\log \left(\sqrt{\frac{x}{x + 1}}\right) + \log \left(\sqrt{\frac{x}{x + 1}}\right)\right)} \cdot \frac{-1}{n} \]
    15. Applied egg-rr88.0%

      \[\leadsto \color{blue}{\left(\log \left(\sqrt{\frac{x}{x + 1}}\right) + \log \left(\sqrt{\frac{x}{x + 1}}\right)\right)} \cdot \frac{-1}{n} \]
    16. Step-by-step derivation
      1. count-288.0%

        \[\leadsto \color{blue}{\left(2 \cdot \log \left(\sqrt{\frac{x}{x + 1}}\right)\right)} \cdot \frac{-1}{n} \]
    17. Simplified88.0%

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

    if 5.0000000000000003e-134 < (/.f64 1 n) < 4e-79

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4e-79 < (/.f64 1 n) < 4.0000000000000001e-8

    1. Initial program 18.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 76.0%

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

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

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

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

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

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

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

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

    if 4.0000000000000001e-8 < (/.f64 1 n)

    1. Initial program 55.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 80.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-26}:\\ \;\;\;\;\frac{\frac{\sqrt[3]{{x}^{\left(\frac{3}{n}\right)}}}{n}}{x}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-134}:\\ \;\;\;\;\left(2 \cdot \log \left(\sqrt{\frac{x}{1 + x}}\right)\right) \cdot \frac{-1}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-79}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-8}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{else}:\\ \;\;\;\;\left(1 + x \cdot \left(\frac{1}{n} + \frac{x \cdot -0.5 + 0.5 \cdot \frac{x}{n}}{n}\right)\right) - {x}^{\left(\frac{1}{n}\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 81.9% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-26}:\\
\;\;\;\;\frac{\frac{\sqrt[3]{{x}^{\left(\frac{3}{n}\right)}}}{n}}{x}\\

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

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

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

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


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

    1. Initial program 89.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. associate-/r*97.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.00000000000000019e-26 < (/.f64 1 n) < 5.0000000000000003e-134 or 4e-79 < (/.f64 1 n) < 4.0000000000000001e-8

    1. Initial program 33.2%

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

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

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

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

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

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

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

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

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

    if 5.0000000000000003e-134 < (/.f64 1 n) < 4e-79

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.0000000000000001e-8 < (/.f64 1 n)

    1. Initial program 55.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 80.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-26}:\\ \;\;\;\;\frac{\frac{\sqrt[3]{{x}^{\left(\frac{3}{n}\right)}}}{n}}{x}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-134}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-79}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-8}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{else}:\\ \;\;\;\;\left(1 + x \cdot \left(\frac{1}{n} + \frac{x \cdot -0.5 + 0.5 \cdot \frac{x}{n}}{n}\right)\right) - {x}^{\left(\frac{1}{n}\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 81.9% accurate, 1.4× speedup?

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

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

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

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

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

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


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

    1. Initial program 89.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. associate-/r*97.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.00000000000000019e-26 < (/.f64 1 n) < 5.0000000000000003e-134 or 4e-79 < (/.f64 1 n) < 4.0000000000000001e-8

    1. Initial program 33.2%

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

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

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

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

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

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

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

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

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

    if 5.0000000000000003e-134 < (/.f64 1 n) < 4e-79

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.0000000000000001e-8 < (/.f64 1 n)

    1. Initial program 55.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 80.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-26}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n} \cdot \frac{1}{x}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-134}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-79}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-8}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{else}:\\ \;\;\;\;\left(1 + x \cdot \left(\frac{1}{n} + \frac{x \cdot -0.5 + 0.5 \cdot \frac{x}{n}}{n}\right)\right) - {x}^{\left(\frac{1}{n}\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 81.0% accurate, 1.5× speedup?

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

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

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

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

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

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

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


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

    1. Initial program 89.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. associate-/r*97.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.00000000000000019e-26 < (/.f64 1 n) < 5.0000000000000003e-134 or 4e-79 < (/.f64 1 n) < 4.0000000000000001e-8

    1. Initial program 33.2%

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

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

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

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

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

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

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

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

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

    if 5.0000000000000003e-134 < (/.f64 1 n) < 4e-79

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.0000000000000001e-8 < (/.f64 1 n) < 4.99999999999999976e157

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

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

    if 4.99999999999999976e157 < (/.f64 1 n)

    1. Initial program 29.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 7.3%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-26}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n} \cdot \frac{1}{x}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-134}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-79}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-8}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+157}:\\ \;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1 + \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{x}}{n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 72.8% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{+48}:\\
\;\;\;\;\frac{\frac{0.3333333333333333}{n}}{{x}^{3}}\\

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

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

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

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

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


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

    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 58.2%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{0.3333333333333333}{n}}{{x}^{3}}} \]
    9. Simplified75.1%

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

    if -4.99999999999999973e48 < (/.f64 1 n) < 5.0000000000000003e-134 or 4e-79 < (/.f64 1 n) < 4.0000000000000001e-8

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

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

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

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

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

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

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

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

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

    if 5.0000000000000003e-134 < (/.f64 1 n) < 4e-79

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.0000000000000001e-8 < (/.f64 1 n) < 4.99999999999999976e157

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

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

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

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

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

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

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

    if 4.99999999999999976e157 < (/.f64 1 n)

    1. Initial program 29.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 7.3%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{+48}:\\ \;\;\;\;\frac{\frac{0.3333333333333333}{n}}{{x}^{3}}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-134}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-79}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-8}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+157}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1 + \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{x}}{n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 80.9% accurate, 1.5× speedup?

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

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-8}:\\
\;\;\;\;t\_1\\

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

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


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

    1. Initial program 89.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. associate-/r*97.0%

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

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

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

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

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

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

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

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

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

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

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

    if -5.00000000000000019e-26 < (/.f64 1 n) < 5.0000000000000003e-134 or 4e-79 < (/.f64 1 n) < 4.0000000000000001e-8

    1. Initial program 33.2%

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

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

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

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

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

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

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

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

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

    if 5.0000000000000003e-134 < (/.f64 1 n) < 4e-79

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.0000000000000001e-8 < (/.f64 1 n) < 4.99999999999999976e157

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

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

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

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

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

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

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

    if 4.99999999999999976e157 < (/.f64 1 n)

    1. Initial program 29.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 7.3%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-26}:\\ \;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-134}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-79}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-8}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+157}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1 + \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{x}}{n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 80.9% accurate, 1.5× speedup?

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

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

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

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

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

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

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


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

    1. Initial program 89.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. associate-/r*97.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.00000000000000019e-26 < (/.f64 1 n) < 5.0000000000000003e-134 or 4e-79 < (/.f64 1 n) < 4.0000000000000001e-8

    1. Initial program 33.2%

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

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

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

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

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

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

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

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

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

    if 5.0000000000000003e-134 < (/.f64 1 n) < 4e-79

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.0000000000000001e-8 < (/.f64 1 n) < 4.99999999999999976e157

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

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

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

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

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

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

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

    if 4.99999999999999976e157 < (/.f64 1 n)

    1. Initial program 29.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 7.3%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-26}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n} \cdot \frac{1}{x}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-134}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-79}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-8}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+157}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1 + \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{x}}{n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 59.2% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 21000:\\
\;\;\;\;\frac{x - \log x}{n}\\

\mathbf{elif}\;x \leq 1.05 \cdot 10^{+72} \lor \neg \left(x \leq 2.55 \cdot 10^{+173}\right):\\
\;\;\;\;\frac{0}{n}\\

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


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

    1. Initial program 33.0%

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

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

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

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

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

    if 21000 < x < 1.0500000000000001e72 or 2.54999999999999975e173 < x

    1. Initial program 83.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 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. Step-by-step derivation
      1. log1p-undefine79.6%

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

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

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

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

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

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

    if 1.0500000000000001e72 < x < 2.54999999999999975e173

    1. Initial program 42.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 42.6%

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{n} - \color{blue}{\frac{\frac{0.5}{n}}{x}}}{x} \]
    8. Simplified82.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 21000:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{elif}\;x \leq 1.05 \cdot 10^{+72} \lor \neg \left(x \leq 2.55 \cdot 10^{+173}\right):\\ \;\;\;\;\frac{0}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{n} - \frac{\frac{0.5}{n}}{x}}{x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 59.0% accurate, 1.9× speedup?

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

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

\mathbf{elif}\;x \leq 1.05 \cdot 10^{+72} \lor \neg \left(x \leq 5.5 \cdot 10^{+173}\right):\\
\;\;\;\;\frac{0}{n}\\

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


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

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

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

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

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

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

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

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

    if 1 < x < 1.0500000000000001e72 or 5.50000000000000049e173 < x

    1. Initial program 81.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 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. Step-by-step derivation
      1. log1p-undefine79.6%

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

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

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

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

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

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

    if 1.0500000000000001e72 < x < 5.50000000000000049e173

    1. Initial program 42.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 42.6%

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{n} - \color{blue}{\frac{\frac{0.5}{n}}{x}}}{x} \]
    8. Simplified82.8%

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

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

Alternative 11: 48.1% accurate, 8.8× speedup?

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

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

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


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

    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 63.3%

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

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

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

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

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

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

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

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

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

    if -5e5 < (/.f64 1 n)

    1. Initial program 36.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 64.6%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} + \frac{-0.5}{n}}{x}}{x}} \]
    12. Recombined 2 regimes into one program.
    13. Final simplification53.1%

      \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -500000:\\ \;\;\;\;\frac{0}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{n \cdot x} + \frac{-0.5}{n}}{x}}{x}\\ \end{array} \]
    14. Add Preprocessing

    Alternative 12: 48.3% accurate, 9.6× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}\\ \mathbf{if}\;x \leq 4.9 \cdot 10^{+173}:\\ \;\;\;\;\frac{\frac{1 + t\_0}{x}}{n}\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(1 - \frac{-1 + t\_0}{n \cdot x}\right)\\ \end{array} \end{array} \]
    (FPCore (x n)
     :precision binary64
     (let* ((t_0 (/ (+ -0.5 (/ 0.3333333333333333 x)) x)))
       (if (<= x 4.9e+173)
         (/ (/ (+ 1.0 t_0) x) n)
         (+ -1.0 (- 1.0 (/ (+ -1.0 t_0) (* n x)))))))
    double code(double x, double n) {
    	double t_0 = (-0.5 + (0.3333333333333333 / x)) / x;
    	double tmp;
    	if (x <= 4.9e+173) {
    		tmp = ((1.0 + t_0) / x) / n;
    	} else {
    		tmp = -1.0 + (1.0 - ((-1.0 + t_0) / (n * x)));
    	}
    	return tmp;
    }
    
    real(8) function code(x, n)
        real(8), intent (in) :: x
        real(8), intent (in) :: n
        real(8) :: t_0
        real(8) :: tmp
        t_0 = ((-0.5d0) + (0.3333333333333333d0 / x)) / x
        if (x <= 4.9d+173) then
            tmp = ((1.0d0 + t_0) / x) / n
        else
            tmp = (-1.0d0) + (1.0d0 - (((-1.0d0) + t_0) / (n * x)))
        end if
        code = tmp
    end function
    
    public static double code(double x, double n) {
    	double t_0 = (-0.5 + (0.3333333333333333 / x)) / x;
    	double tmp;
    	if (x <= 4.9e+173) {
    		tmp = ((1.0 + t_0) / x) / n;
    	} else {
    		tmp = -1.0 + (1.0 - ((-1.0 + t_0) / (n * x)));
    	}
    	return tmp;
    }
    
    def code(x, n):
    	t_0 = (-0.5 + (0.3333333333333333 / x)) / x
    	tmp = 0
    	if x <= 4.9e+173:
    		tmp = ((1.0 + t_0) / x) / n
    	else:
    		tmp = -1.0 + (1.0 - ((-1.0 + t_0) / (n * x)))
    	return tmp
    
    function code(x, n)
    	t_0 = Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x)
    	tmp = 0.0
    	if (x <= 4.9e+173)
    		tmp = Float64(Float64(Float64(1.0 + t_0) / x) / n);
    	else
    		tmp = Float64(-1.0 + Float64(1.0 - Float64(Float64(-1.0 + t_0) / Float64(n * x))));
    	end
    	return tmp
    end
    
    function tmp_2 = code(x, n)
    	t_0 = (-0.5 + (0.3333333333333333 / x)) / x;
    	tmp = 0.0;
    	if (x <= 4.9e+173)
    		tmp = ((1.0 + t_0) / x) / n;
    	else
    		tmp = -1.0 + (1.0 - ((-1.0 + t_0) / (n * x)));
    	end
    	tmp_2 = tmp;
    end
    
    code[x_, n_] := Block[{t$95$0 = N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[x, 4.9e+173], N[(N[(N[(1.0 + t$95$0), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], N[(-1.0 + N[(1.0 - N[(N[(-1.0 + t$95$0), $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}\\
    \mathbf{if}\;x \leq 4.9 \cdot 10^{+173}:\\
    \;\;\;\;\frac{\frac{1 + t\_0}{x}}{n}\\
    
    \mathbf{else}:\\
    \;\;\;\;-1 + \left(1 - \frac{-1 + t\_0}{n \cdot x}\right)\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if x < 4.9000000000000001e173

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

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

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

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

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

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

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

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

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

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

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

      if 4.9000000000000001e173 < x

      1. Initial program 87.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 87.5%

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

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

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

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

          \[\leadsto \frac{-1 \cdot \color{blue}{\left(\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}}{x} - \frac{1}{x}\right)}}{n} \]
        2. add-sqr-sqrt64.4%

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

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

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

          \[\leadsto \frac{-1 \cdot \left(\frac{\sqrt{\left(-\frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}\right) \cdot \color{blue}{\left(-\frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}\right)}}}{x} - \frac{1}{x}\right)}{n} \]
        6. sqr-neg64.4%

          \[\leadsto \frac{-1 \cdot \left(\frac{\sqrt{\color{blue}{\frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}}}}{x} - \frac{1}{x}\right)}{n} \]
        7. sqrt-unprod0.0%

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

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

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

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

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

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

          \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{-1 \cdot \left(\frac{\frac{\frac{0.3333333333333333}{x} + -0.5}{x}}{x} - \frac{1}{x}\right)}{n}\right)\right)} \]
        2. expm1-undefine77.3%

          \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{-1 \cdot \left(\frac{\frac{\frac{0.3333333333333333}{x} + -0.5}{x}}{x} - \frac{1}{x}\right)}{n}\right)} - 1} \]
        3. mul-1-neg77.3%

          \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{-\left(\frac{\frac{\frac{0.3333333333333333}{x} + -0.5}{x}}{x} - \frac{1}{x}\right)}}{n}\right)} - 1 \]
        4. sub-div77.3%

          \[\leadsto e^{\mathsf{log1p}\left(\frac{-\color{blue}{\frac{\frac{\frac{0.3333333333333333}{x} + -0.5}{x} - 1}{x}}}{n}\right)} - 1 \]
      10. Applied egg-rr77.3%

        \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{-\frac{\frac{\frac{0.3333333333333333}{x} + -0.5}{x} - 1}{x}}{n}\right)} - 1} \]
      11. Step-by-step derivation
        1. sub-neg77.3%

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

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

          \[\leadsto \color{blue}{-1 + e^{\mathsf{log1p}\left(\frac{-\frac{\frac{\frac{0.3333333333333333}{x} + -0.5}{x} - 1}{x}}{n}\right)}} \]
        4. log1p-undefine77.3%

          \[\leadsto -1 + e^{\color{blue}{\log \left(1 + \frac{-\frac{\frac{\frac{0.3333333333333333}{x} + -0.5}{x} - 1}{x}}{n}\right)}} \]
        5. rem-exp-log77.6%

          \[\leadsto -1 + \color{blue}{\left(1 + \frac{-\frac{\frac{\frac{0.3333333333333333}{x} + -0.5}{x} - 1}{x}}{n}\right)} \]
        6. distribute-frac-neg77.6%

          \[\leadsto -1 + \left(1 + \color{blue}{\left(-\frac{\frac{\frac{\frac{0.3333333333333333}{x} + -0.5}{x} - 1}{x}}{n}\right)}\right) \]
        7. unsub-neg77.6%

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

          \[\leadsto -1 + \left(1 - \color{blue}{\frac{\frac{\frac{0.3333333333333333}{x} + -0.5}{x} - 1}{x \cdot n}}\right) \]
        9. sub-neg77.6%

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

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

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

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

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

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

    Alternative 13: 48.3% accurate, 9.6× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 1.72 \cdot 10^{+179}:\\ \;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{n \cdot x} + \frac{-0.5}{n}}{x}}{x}\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(1 - \frac{-1 + \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{n \cdot x}\right)\\ \end{array} \end{array} \]
    (FPCore (x n)
     :precision binary64
     (if (<= x 1.72e+179)
       (/ (+ (/ 1.0 n) (/ (+ (/ 0.3333333333333333 (* n x)) (/ -0.5 n)) x)) x)
       (+
        -1.0
        (- 1.0 (/ (+ -1.0 (/ (+ -0.5 (/ 0.3333333333333333 x)) x)) (* n x))))))
    double code(double x, double n) {
    	double tmp;
    	if (x <= 1.72e+179) {
    		tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x;
    	} else {
    		tmp = -1.0 + (1.0 - ((-1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / (n * x)));
    	}
    	return tmp;
    }
    
    real(8) function code(x, n)
        real(8), intent (in) :: x
        real(8), intent (in) :: n
        real(8) :: tmp
        if (x <= 1.72d+179) then
            tmp = ((1.0d0 / n) + (((0.3333333333333333d0 / (n * x)) + ((-0.5d0) / n)) / x)) / x
        else
            tmp = (-1.0d0) + (1.0d0 - (((-1.0d0) + (((-0.5d0) + (0.3333333333333333d0 / x)) / x)) / (n * x)))
        end if
        code = tmp
    end function
    
    public static double code(double x, double n) {
    	double tmp;
    	if (x <= 1.72e+179) {
    		tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x;
    	} else {
    		tmp = -1.0 + (1.0 - ((-1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / (n * x)));
    	}
    	return tmp;
    }
    
    def code(x, n):
    	tmp = 0
    	if x <= 1.72e+179:
    		tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x
    	else:
    		tmp = -1.0 + (1.0 - ((-1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / (n * x)))
    	return tmp
    
    function code(x, n)
    	tmp = 0.0
    	if (x <= 1.72e+179)
    		tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(n * x)) + Float64(-0.5 / n)) / x)) / x);
    	else
    		tmp = Float64(-1.0 + Float64(1.0 - Float64(Float64(-1.0 + Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x)) / Float64(n * x))));
    	end
    	return tmp
    end
    
    function tmp_2 = code(x, n)
    	tmp = 0.0;
    	if (x <= 1.72e+179)
    		tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x;
    	else
    		tmp = -1.0 + (1.0 - ((-1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / (n * x)));
    	end
    	tmp_2 = tmp;
    end
    
    code[x_, n_] := If[LessEqual[x, 1.72e+179], N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(0.3333333333333333 / N[(n * x), $MachinePrecision]), $MachinePrecision] + N[(-0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], N[(-1.0 + N[(1.0 - N[(N[(-1.0 + N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;x \leq 1.72 \cdot 10^{+179}:\\
    \;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{n \cdot x} + \frac{-0.5}{n}}{x}}{x}\\
    
    \mathbf{else}:\\
    \;\;\;\;-1 + \left(1 - \frac{-1 + \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{n \cdot x}\right)\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if x < 1.7200000000000001e179

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

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

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

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

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

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

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

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

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

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

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

        if 1.7200000000000001e179 < x

        1. Initial program 86.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 86.8%

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

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

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

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

            \[\leadsto \frac{-1 \cdot \color{blue}{\left(\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}}{x} - \frac{1}{x}\right)}}{n} \]
          2. add-sqr-sqrt66.0%

            \[\leadsto \frac{-1 \cdot \left(\frac{\color{blue}{\sqrt{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}} \cdot \sqrt{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}}}}{x} - \frac{1}{x}\right)}{n} \]
          3. sqrt-unprod66.0%

            \[\leadsto \frac{-1 \cdot \left(\frac{\color{blue}{\sqrt{\left(-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}\right) \cdot \left(-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}\right)}}}{x} - \frac{1}{x}\right)}{n} \]
          4. mul-1-neg66.0%

            \[\leadsto \frac{-1 \cdot \left(\frac{\sqrt{\color{blue}{\left(-\frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}\right)} \cdot \left(-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}\right)}}{x} - \frac{1}{x}\right)}{n} \]
          5. mul-1-neg66.0%

            \[\leadsto \frac{-1 \cdot \left(\frac{\sqrt{\left(-\frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}\right) \cdot \color{blue}{\left(-\frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}\right)}}}{x} - \frac{1}{x}\right)}{n} \]
          6. sqr-neg66.0%

            \[\leadsto \frac{-1 \cdot \left(\frac{\sqrt{\color{blue}{\frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}}}}{x} - \frac{1}{x}\right)}{n} \]
          7. sqrt-unprod0.0%

            \[\leadsto \frac{-1 \cdot \left(\frac{\color{blue}{\sqrt{\frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}} \cdot \sqrt{\frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}}}}{x} - \frac{1}{x}\right)}{n} \]
          8. add-sqr-sqrt66.0%

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

            \[\leadsto \frac{-1 \cdot \left(\frac{\frac{\color{blue}{0.3333333333333333 \cdot \frac{1}{x} + \left(-0.5\right)}}{x}}{x} - \frac{1}{x}\right)}{n} \]
          10. un-div-inv66.0%

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

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

          \[\leadsto \frac{-1 \cdot \color{blue}{\left(\frac{\frac{\frac{0.3333333333333333}{x} + -0.5}{x}}{x} - \frac{1}{x}\right)}}{n} \]
        9. Step-by-step derivation
          1. expm1-log1p-u65.8%

            \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{-1 \cdot \left(\frac{\frac{\frac{0.3333333333333333}{x} + -0.5}{x}}{x} - \frac{1}{x}\right)}{n}\right)\right)} \]
          2. expm1-undefine79.7%

            \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{-1 \cdot \left(\frac{\frac{\frac{0.3333333333333333}{x} + -0.5}{x}}{x} - \frac{1}{x}\right)}{n}\right)} - 1} \]
          3. mul-1-neg79.7%

            \[\leadsto e^{\mathsf{log1p}\left(\frac{\color{blue}{-\left(\frac{\frac{\frac{0.3333333333333333}{x} + -0.5}{x}}{x} - \frac{1}{x}\right)}}{n}\right)} - 1 \]
          4. sub-div79.7%

            \[\leadsto e^{\mathsf{log1p}\left(\frac{-\color{blue}{\frac{\frac{\frac{0.3333333333333333}{x} + -0.5}{x} - 1}{x}}}{n}\right)} - 1 \]
        10. Applied egg-rr79.7%

          \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\frac{-\frac{\frac{\frac{0.3333333333333333}{x} + -0.5}{x} - 1}{x}}{n}\right)} - 1} \]
        11. Step-by-step derivation
          1. sub-neg79.7%

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

            \[\leadsto e^{\mathsf{log1p}\left(\frac{-\frac{\frac{\frac{0.3333333333333333}{x} + -0.5}{x} - 1}{x}}{n}\right)} + \color{blue}{-1} \]
          3. +-commutative79.7%

            \[\leadsto \color{blue}{-1 + e^{\mathsf{log1p}\left(\frac{-\frac{\frac{\frac{0.3333333333333333}{x} + -0.5}{x} - 1}{x}}{n}\right)}} \]
          4. log1p-undefine79.7%

            \[\leadsto -1 + e^{\color{blue}{\log \left(1 + \frac{-\frac{\frac{\frac{0.3333333333333333}{x} + -0.5}{x} - 1}{x}}{n}\right)}} \]
          5. rem-exp-log79.8%

            \[\leadsto -1 + \color{blue}{\left(1 + \frac{-\frac{\frac{\frac{0.3333333333333333}{x} + -0.5}{x} - 1}{x}}{n}\right)} \]
          6. distribute-frac-neg79.8%

            \[\leadsto -1 + \left(1 + \color{blue}{\left(-\frac{\frac{\frac{\frac{0.3333333333333333}{x} + -0.5}{x} - 1}{x}}{n}\right)}\right) \]
          7. unsub-neg79.8%

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

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

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

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

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

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

          \[\leadsto \color{blue}{-1 + \left(1 - \frac{-1 + \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{x \cdot n}\right)} \]
      12. Recombined 2 regimes into one program.
      13. Final simplification48.0%

        \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.72 \cdot 10^{+179}:\\ \;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{n \cdot x} + \frac{-0.5}{n}}{x}}{x}\\ \mathbf{else}:\\ \;\;\;\;-1 + \left(1 - \frac{-1 + \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{n \cdot x}\right)\\ \end{array} \]
      14. Add Preprocessing

      Alternative 14: 45.9% accurate, 14.1× speedup?

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

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

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

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

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

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

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

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

      Alternative 15: 45.9% 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 50.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 64.3%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\frac{1 + \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{x}}}{n} \]
      12. Final simplification44.9%

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

      Alternative 16: 44.0% accurate, 19.2× speedup?

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

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

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

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

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

          \[\leadsto \frac{-1 \cdot \color{blue}{\left(\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}}{x} - \frac{1}{x}\right)}}{n} \]
        2. add-sqr-sqrt30.9%

          \[\leadsto \frac{-1 \cdot \left(\frac{\color{blue}{\sqrt{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}} \cdot \sqrt{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}}}}{x} - \frac{1}{x}\right)}{n} \]
        3. sqrt-unprod31.5%

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

          \[\leadsto \frac{-1 \cdot \left(\frac{\sqrt{\color{blue}{\left(-\frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}\right)} \cdot \left(-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}\right)}}{x} - \frac{1}{x}\right)}{n} \]
        5. mul-1-neg31.5%

          \[\leadsto \frac{-1 \cdot \left(\frac{\sqrt{\left(-\frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}\right) \cdot \color{blue}{\left(-\frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}\right)}}}{x} - \frac{1}{x}\right)}{n} \]
        6. sqr-neg31.5%

          \[\leadsto \frac{-1 \cdot \left(\frac{\sqrt{\color{blue}{\frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}}}}{x} - \frac{1}{x}\right)}{n} \]
        7. sqrt-unprod0.6%

          \[\leadsto \frac{-1 \cdot \left(\frac{\color{blue}{\sqrt{\frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}} \cdot \sqrt{\frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}}}}{x} - \frac{1}{x}\right)}{n} \]
        8. add-sqr-sqrt31.2%

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

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

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

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

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

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

          \[\leadsto \frac{\frac{1}{n} + \color{blue}{\frac{0.5 \cdot 1}{n \cdot x}}}{x} \]
        2. metadata-eval43.7%

          \[\leadsto \frac{\frac{1}{n} + \frac{\color{blue}{0.5}}{n \cdot x}}{x} \]
        3. *-commutative43.7%

          \[\leadsto \frac{\frac{1}{n} + \frac{0.5}{\color{blue}{x \cdot n}}}{x} \]
      11. Simplified43.7%

        \[\leadsto \color{blue}{\frac{\frac{1}{n} + \frac{0.5}{x \cdot n}}{x}} \]
      12. Final simplification43.7%

        \[\leadsto \frac{\frac{1}{n} + \frac{0.5}{n \cdot x}}{x} \]
      13. Add Preprocessing

      Alternative 17: 39.5% accurate, 42.2× speedup?

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

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

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

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

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

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

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

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

      Alternative 18: 40.1% accurate, 42.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      Alternative 19: 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 50.5%

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

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

        \[\leadsto \color{blue}{\frac{x}{n}} \]
      5. Final simplification4.6%

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

      Reproduce

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