2nthrt (problem 3.4.6)

Percentage Accurate: 55.1% → 88.2%
Time: 50.3s
Alternatives: 21
Speedup: 1.8×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 21 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: 55.1% accurate, 1.0× speedup?

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

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

Alternative 1: 88.2% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\log x}{n}\\ \mathbf{if}\;x \leq 6.2 \cdot 10^{-53}:\\ \;\;\;\;x \cdot \mathsf{fma}\left(x, \frac{-0.5 + \frac{0.5}{n}}{n}, \frac{1}{n}\right) - \mathsf{expm1}\left(t\_0\right)\\ \mathbf{elif}\;x \leq 32000000:\\ \;\;\;\;\frac{\left(\mathsf{log1p}\left(x\right) - \frac{0.5 \cdot \left({\log x}^{2} - {\left(\mathsf{log1p}\left(x\right)\right)}^{2}\right) - 0.16666666666666666 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}}{n}}{n}\right) - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{e^{t\_0}}{x \cdot n}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (/ (log x) n)))
   (if (<= x 6.2e-53)
     (- (* x (fma x (/ (+ -0.5 (/ 0.5 n)) n) (/ 1.0 n))) (expm1 t_0))
     (if (<= x 32000000.0)
       (/
        (-
         (-
          (log1p x)
          (/
           (-
            (* 0.5 (- (pow (log x) 2.0) (pow (log1p x) 2.0)))
            (*
             0.16666666666666666
             (/ (- (pow (log1p x) 3.0) (pow (log x) 3.0)) n)))
           n))
         (log x))
        n)
       (/ (exp t_0) (* x n))))))
double code(double x, double n) {
	double t_0 = log(x) / n;
	double tmp;
	if (x <= 6.2e-53) {
		tmp = (x * fma(x, ((-0.5 + (0.5 / n)) / n), (1.0 / n))) - expm1(t_0);
	} else if (x <= 32000000.0) {
		tmp = ((log1p(x) - (((0.5 * (pow(log(x), 2.0) - pow(log1p(x), 2.0))) - (0.16666666666666666 * ((pow(log1p(x), 3.0) - pow(log(x), 3.0)) / n))) / n)) - log(x)) / n;
	} else {
		tmp = exp(t_0) / (x * n);
	}
	return tmp;
}
function code(x, n)
	t_0 = Float64(log(x) / n)
	tmp = 0.0
	if (x <= 6.2e-53)
		tmp = Float64(Float64(x * fma(x, Float64(Float64(-0.5 + Float64(0.5 / n)) / n), Float64(1.0 / n))) - expm1(t_0));
	elseif (x <= 32000000.0)
		tmp = Float64(Float64(Float64(log1p(x) - Float64(Float64(Float64(0.5 * Float64((log(x) ^ 2.0) - (log1p(x) ^ 2.0))) - Float64(0.16666666666666666 * Float64(Float64((log1p(x) ^ 3.0) - (log(x) ^ 3.0)) / n))) / n)) - log(x)) / n);
	else
		tmp = Float64(exp(t_0) / Float64(x * n));
	end
	return tmp
end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[x, 6.2e-53], N[(N[(x * N[(x * N[(N[(-0.5 + N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] + N[(1.0 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(Exp[t$95$0] - 1), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 32000000.0], N[(N[(N[(N[Log[1 + x], $MachinePrecision] - N[(N[(N[(0.5 * N[(N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.16666666666666666 * N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 3.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[t$95$0], $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\log x}{n}\\
\mathbf{if}\;x \leq 6.2 \cdot 10^{-53}:\\
\;\;\;\;x \cdot \mathsf{fma}\left(x, \frac{-0.5 + \frac{0.5}{n}}{n}, \frac{1}{n}\right) - \mathsf{expm1}\left(t\_0\right)\\

\mathbf{elif}\;x \leq 32000000:\\
\;\;\;\;\frac{\left(\mathsf{log1p}\left(x\right) - \frac{0.5 \cdot \left({\log x}^{2} - {\left(\mathsf{log1p}\left(x\right)\right)}^{2}\right) - 0.16666666666666666 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}}{n}}{n}\right) - \log x}{n}\\

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


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

    1. Initial program 44.5%

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

      \[\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 44.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)} \]
    5. Taylor expanded in x around 0 44.5%

      \[\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) - e^{\frac{\log x}{n}}} \]
    6. Simplified87.9%

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

    if 6.20000000000000031e-53 < x < 3.2e7

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

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

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

    if 3.2e7 < x

    1. Initial program 69.6%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification94.1%

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

Alternative 2: 87.3% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\log x}{n}\\ \mathbf{if}\;x \leq 0.002:\\ \;\;\;\;x \cdot \mathsf{fma}\left(x, \frac{-0.5 + \frac{0.5}{n}}{n}, \frac{1}{n}\right) - \mathsf{expm1}\left(t\_0\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{e^{t\_0}}{x \cdot n}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (/ (log x) n)))
   (if (<= x 0.002)
     (- (* x (fma x (/ (+ -0.5 (/ 0.5 n)) n) (/ 1.0 n))) (expm1 t_0))
     (/ (exp t_0) (* x n)))))
double code(double x, double n) {
	double t_0 = log(x) / n;
	double tmp;
	if (x <= 0.002) {
		tmp = (x * fma(x, ((-0.5 + (0.5 / n)) / n), (1.0 / n))) - expm1(t_0);
	} else {
		tmp = exp(t_0) / (x * n);
	}
	return tmp;
}
function code(x, n)
	t_0 = Float64(log(x) / n)
	tmp = 0.0
	if (x <= 0.002)
		tmp = Float64(Float64(x * fma(x, Float64(Float64(-0.5 + Float64(0.5 / n)) / n), Float64(1.0 / n))) - expm1(t_0));
	else
		tmp = Float64(exp(t_0) / Float64(x * n));
	end
	return tmp
end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[x, 0.002], N[(N[(x * N[(x * N[(N[(-0.5 + N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] + N[(1.0 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(Exp[t$95$0] - 1), $MachinePrecision]), $MachinePrecision], N[(N[Exp[t$95$0], $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\log x}{n}\\
\mathbf{if}\;x \leq 0.002:\\
\;\;\;\;x \cdot \mathsf{fma}\left(x, \frac{-0.5 + \frac{0.5}{n}}{n}, \frac{1}{n}\right) - \mathsf{expm1}\left(t\_0\right)\\

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


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

    1. Initial program 43.1%

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

      \[\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 41.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)} \]
    5. Taylor expanded in x around 0 41.5%

      \[\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) - e^{\frac{\log x}{n}}} \]
    6. Simplified87.3%

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

    if 2e-3 < x

    1. Initial program 68.9%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 3: 82.0% accurate, 0.8× speedup?

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

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

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

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

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

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


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

    1. Initial program 92.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.00000000000000015e-42 < (/.f64 #s(literal 1 binary64) n) < -4.99999999999999979e-104

    1. Initial program 17.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 95.7%

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

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

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

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

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

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

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

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

    if -4.99999999999999979e-104 < (/.f64 #s(literal 1 binary64) n) < -4.9999999999999998e-145

    1. Initial program 20.9%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{x} + \frac{\log x}{\color{blue}{x \cdot n}}}{n} \]
    8. Simplified92.4%

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

    if -4.9999999999999998e-145 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-13

    1. Initial program 32.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 79.2%

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

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

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

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

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

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

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

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

    if 2.0000000000000001e-13 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 56.3%

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

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

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

Alternative 4: 82.3% accurate, 0.9× speedup?

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

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

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

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

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

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

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


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

    1. Initial program 92.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.00000000000000015e-42 < (/.f64 #s(literal 1 binary64) n) < -4.99999999999999979e-104

    1. Initial program 17.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 95.7%

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

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

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

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

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

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

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

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

    if -4.99999999999999979e-104 < (/.f64 #s(literal 1 binary64) n) < -4.9999999999999998e-145

    1. Initial program 20.9%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{x} + \frac{\log x}{\color{blue}{x \cdot n}}}{n} \]
    8. Simplified92.4%

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

    if -4.9999999999999998e-145 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-13

    1. Initial program 32.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 79.2%

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

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

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

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

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

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

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

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

    if 2.0000000000000001e-13 < (/.f64 #s(literal 1 binary64) n) < 5e152

    1. Initial program 90.8%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Add Preprocessing

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

    1. Initial program 15.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 6.6%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{1}{x}}{n}} \]
      2. rem-exp-log71.5%

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

        \[\leadsto \frac{e^{\color{blue}{-\log x}}}{n} \]
      4. add-sqr-sqrt71.5%

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

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

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

        \[\leadsto \frac{e^{\sqrt{\color{blue}{{\log x}^{2}}}}}{n} \]
      8. sqrt-pow14.3%

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

        \[\leadsto \frac{e^{{\log x}^{\color{blue}{1}}}}{n} \]
      10. pow14.3%

        \[\leadsto \frac{e^{\color{blue}{\log x}}}{n} \]
      11. add-exp-log4.3%

        \[\leadsto \frac{\color{blue}{x}}{n} \]
      12. log1p-expm1-u94.1%

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

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

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

Alternative 5: 81.9% accurate, 0.9× speedup?

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

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

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

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

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

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

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


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

    1. Initial program 92.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.00000000000000015e-42 < (/.f64 #s(literal 1 binary64) n) < -4.99999999999999979e-104

    1. Initial program 17.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 95.7%

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

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

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

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

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

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

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

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

    if -4.99999999999999979e-104 < (/.f64 #s(literal 1 binary64) n) < -4.9999999999999998e-145

    1. Initial program 20.9%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{x} + \frac{\log x}{\color{blue}{x \cdot n}}}{n} \]
    8. Simplified92.4%

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

    if -4.9999999999999998e-145 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-13

    1. Initial program 32.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 79.2%

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

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

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

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

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

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

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

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

    if 2.0000000000000001e-13 < (/.f64 #s(literal 1 binary64) n) < 4.99999999999999981e134

    1. Initial program 89.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 91.7%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{1}{x}}{n}} \]
      2. rem-exp-log60.9%

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

        \[\leadsto \frac{e^{\color{blue}{-\log x}}}{n} \]
      4. add-sqr-sqrt60.9%

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

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

        \[\leadsto \frac{e^{\sqrt{\color{blue}{\log x \cdot \log x}}}}{n} \]
      7. unpow260.9%

        \[\leadsto \frac{e^{\sqrt{\color{blue}{{\log x}^{2}}}}}{n} \]
      8. sqrt-pow14.6%

        \[\leadsto \frac{e^{\color{blue}{{\log x}^{\left(\frac{2}{2}\right)}}}}{n} \]
      9. metadata-eval4.6%

        \[\leadsto \frac{e^{{\log x}^{\color{blue}{1}}}}{n} \]
      10. pow14.6%

        \[\leadsto \frac{e^{\color{blue}{\log x}}}{n} \]
      11. add-exp-log4.6%

        \[\leadsto \frac{\color{blue}{x}}{n} \]
      12. log1p-expm1-u90.3%

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

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

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

Alternative 6: 81.9% accurate, 0.9× speedup?

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

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

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

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

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

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

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


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

    1. Initial program 92.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.00000000000000015e-42 < (/.f64 #s(literal 1 binary64) n) < -4.99999999999999979e-104 or -4.9999999999999998e-145 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-13

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

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

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

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

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

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

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

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

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

    if -4.99999999999999979e-104 < (/.f64 #s(literal 1 binary64) n) < -4.9999999999999998e-145

    1. Initial program 20.9%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{x} + \frac{\log x}{\color{blue}{x \cdot n}}}{n} \]
    8. Simplified92.4%

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

    if 2.0000000000000001e-13 < (/.f64 #s(literal 1 binary64) n) < 4.99999999999999981e134

    1. Initial program 89.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 91.7%

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{1}{x}}{n}} \]
      2. rem-exp-log60.9%

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

        \[\leadsto \frac{e^{\color{blue}{-\log x}}}{n} \]
      4. add-sqr-sqrt60.9%

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

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

        \[\leadsto \frac{e^{\sqrt{\color{blue}{\log x \cdot \log x}}}}{n} \]
      7. unpow260.9%

        \[\leadsto \frac{e^{\sqrt{\color{blue}{{\log x}^{2}}}}}{n} \]
      8. sqrt-pow14.6%

        \[\leadsto \frac{e^{\color{blue}{{\log x}^{\left(\frac{2}{2}\right)}}}}{n} \]
      9. metadata-eval4.6%

        \[\leadsto \frac{e^{{\log x}^{\color{blue}{1}}}}{n} \]
      10. pow14.6%

        \[\leadsto \frac{e^{\color{blue}{\log x}}}{n} \]
      11. add-exp-log4.6%

        \[\leadsto \frac{\color{blue}{x}}{n} \]
      12. log1p-expm1-u90.3%

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

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

Alternative 7: 81.5% accurate, 1.3× speedup?

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

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

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

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

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

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


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

    1. Initial program 92.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.00000000000000015e-42 < (/.f64 #s(literal 1 binary64) n) < -4.99999999999999979e-104 or -4.9999999999999998e-145 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-13

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

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

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

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

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

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

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

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

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

    if -4.99999999999999979e-104 < (/.f64 #s(literal 1 binary64) n) < -4.9999999999999998e-145

    1. Initial program 20.9%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{x} + \frac{\log x}{\color{blue}{x \cdot n}}}{n} \]
    8. Simplified92.4%

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

    if 2.0000000000000001e-13 < (/.f64 #s(literal 1 binary64) n) < 5e152

    1. Initial program 90.8%

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

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

      \[\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)} \]

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

    1. Initial program 15.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 6.6%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -4 \cdot 10^{-42}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{x \cdot n}\\ \mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{-104}:\\ \;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{-145}:\\ \;\;\;\;\frac{\frac{1}{x} + \frac{\log x}{x \cdot n}}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-13}:\\ \;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+152}:\\ \;\;\;\;\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)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1 + \left(\frac{0.3333333333333333}{{x}^{2}} - \frac{0.5}{x}\right)}{x}}{n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 81.5% accurate, 1.4× speedup?

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

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

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

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

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

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


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

    1. Initial program 92.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.00000000000000015e-42 < (/.f64 #s(literal 1 binary64) n) < -4.99999999999999979e-104 or -4.9999999999999998e-145 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-13

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

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

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

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

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

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

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

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

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

    if -4.99999999999999979e-104 < (/.f64 #s(literal 1 binary64) n) < -4.9999999999999998e-145

    1. Initial program 20.9%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{x} + \frac{\log x}{\color{blue}{x \cdot n}}}{n} \]
    8. Simplified92.4%

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

    if 2.0000000000000001e-13 < (/.f64 #s(literal 1 binary64) n) < 5e152

    1. Initial program 90.8%

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

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

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

    1. Initial program 15.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 6.6%

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

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

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

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

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

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

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

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

Alternative 9: 81.5% accurate, 1.5× speedup?

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

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

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

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

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

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{0.3333333333333333}{n}}{{x}^{3}}\\


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

    1. Initial program 92.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.00000000000000015e-42 < (/.f64 #s(literal 1 binary64) n) < -4.99999999999999979e-104 or -4.9999999999999998e-145 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-13

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

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

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

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

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

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

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

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

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

    if -4.99999999999999979e-104 < (/.f64 #s(literal 1 binary64) n) < -4.9999999999999998e-145

    1. Initial program 20.9%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{x} + \frac{\log x}{\color{blue}{x \cdot n}}}{n} \]
    8. Simplified92.4%

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

    if 2.0000000000000001e-13 < (/.f64 #s(literal 1 binary64) n) < 5e152

    1. Initial program 90.8%

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

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

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

    1. Initial program 15.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 6.6%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{0.3333333333333333}{n}}{{x}^{3}}} \]
  3. Recombined 5 regimes into one program.
  4. Add Preprocessing

Alternative 10: 81.5% accurate, 1.5× speedup?

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

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

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

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

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

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{0.3333333333333333}{n}}{{x}^{3}}\\


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

    1. Initial program 92.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.00000000000000015e-42 < (/.f64 #s(literal 1 binary64) n) < -4.99999999999999979e-104 or -4.9999999999999998e-145 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-13

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

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

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

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

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

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

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

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

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

    if -4.99999999999999979e-104 < (/.f64 #s(literal 1 binary64) n) < -4.9999999999999998e-145

    1. Initial program 20.9%

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

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

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

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

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

    if 2.0000000000000001e-13 < (/.f64 #s(literal 1 binary64) n) < 5e152

    1. Initial program 90.8%

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

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

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

    1. Initial program 15.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 6.6%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{0.3333333333333333}{n}}{{x}^{3}}} \]
  3. Recombined 5 regimes into one program.
  4. Add Preprocessing

Alternative 11: 81.4% accurate, 1.5× speedup?

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

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

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

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

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

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{0.3333333333333333}{n}}{{x}^{3}}\\


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

    1. Initial program 92.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.00000000000000015e-42 < (/.f64 #s(literal 1 binary64) n) < -4.99999999999999979e-104 or -4.9999999999999998e-145 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-13

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

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

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

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

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

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

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

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

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

    if -4.99999999999999979e-104 < (/.f64 #s(literal 1 binary64) n) < -4.9999999999999998e-145

    1. Initial program 20.9%

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

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

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

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

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

    if 2.0000000000000001e-13 < (/.f64 #s(literal 1 binary64) n) < 5e152

    1. Initial program 90.8%

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

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

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

    1. Initial program 15.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 6.6%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{0.3333333333333333}{n}}{{x}^{3}}} \]
  3. Recombined 5 regimes into one program.
  4. Add Preprocessing

Alternative 12: 73.9% accurate, 1.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -5000000:\\
\;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\

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

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

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{0.3333333333333333}{n}}{{x}^{3}}\\


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

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

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

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

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

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

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

    if -5e6 < (/.f64 #s(literal 1 binary64) n) < -4.9999999999999998e-145

    1. Initial program 16.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 43.4%

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

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

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

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

    if -4.9999999999999998e-145 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-13

    1. Initial program 32.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 79.2%

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

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

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

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

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

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

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

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

    if 2.0000000000000001e-13 < (/.f64 #s(literal 1 binary64) n) < 5e152

    1. Initial program 90.8%

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

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

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

    1. Initial program 15.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 6.6%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{0.3333333333333333}{n}}{{x}^{3}}} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification78.0%

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

Alternative 13: 54.9% accurate, 1.6× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{x - \log x}{n}\\
\mathbf{if}\;x \leq 4.4 \cdot 10^{-186}:\\
\;\;\;\;\frac{\log x}{-n}\\

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

\mathbf{elif}\;x \leq 3.25 \cdot 10^{-72}:\\
\;\;\;\;t\_0\\

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

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

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


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

    1. Initial program 49.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 54.0%

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

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

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

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

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

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

    if 4.40000000000000026e-186 < x < 4.1999999999999998e-146

    1. Initial program 43.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 36.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.1999999999999998e-146 < x < 3.2499999999999998e-72 or 4.00000000000000009e-46 < x < 0.900000000000000022

    1. Initial program 32.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 65.1%

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

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

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

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

    if 3.2499999999999998e-72 < x < 4.00000000000000009e-46

    1. Initial program 76.2%

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

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

    if 0.900000000000000022 < x

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 4.4 \cdot 10^{-186}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 4.2 \cdot 10^{-146}:\\ \;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} - \frac{0.5}{n}}{x}}{x}\\ \mathbf{elif}\;x \leq 3.25 \cdot 10^{-72}:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{elif}\;x \leq 4 \cdot 10^{-46}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 0.9:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1 - \frac{0.5 - \frac{0.3333333333333333 + 0.25 \cdot \frac{-1}{x}}{x}}{x}}{x}}{n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 62.0% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;n \leq -12.2:\\
\;\;\;\;\frac{1 + \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{x \cdot n}\\

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

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

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

\mathbf{else}:\\
\;\;\;\;\frac{\log x}{-n}\\


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

    1. Initial program 30.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 68.7%

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

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

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

      \[\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 n around 0 61.1%

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

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

    if -12.199999999999999 < n < 1.29999999999999994e-157

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

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

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

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

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

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

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

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

    if 1.29999999999999994e-157 < n < 2.4e14

    1. Initial program 85.3%

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

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

    if 2.4e14 < n < 2.14999999999999985e268

    1. Initial program 25.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 68.3%

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

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

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

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

    if 2.14999999999999985e268 < n

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -12.2:\\ \;\;\;\;\frac{1 + \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{x \cdot n}\\ \mathbf{elif}\;n \leq 1.3 \cdot 10^{-157}:\\ \;\;\;\;\frac{\frac{0.3333333333333333}{n}}{{x}^{3}}\\ \mathbf{elif}\;n \leq 2.4 \cdot 10^{+14}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;n \leq 2.15 \cdot 10^{+268}:\\ \;\;\;\;\frac{\frac{1}{x}}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log x}{-n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 62.0% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;n \leq -5:\\
\;\;\;\;\frac{1 + \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{x \cdot n}\\

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

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

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

\mathbf{else}:\\
\;\;\;\;\frac{\log x}{-n}\\


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

    1. Initial program 30.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 68.7%

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

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

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

      \[\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 n around 0 61.1%

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

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

    if -5 < n < 6.9999999999999999e-156

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

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

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

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

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

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

    if 6.9999999999999999e-156 < n < 2.4e14

    1. Initial program 85.3%

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

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

    if 2.4e14 < n < 1.79999999999999996e262

    1. Initial program 25.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 68.3%

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

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

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

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

    if 1.79999999999999996e262 < n

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -5:\\ \;\;\;\;\frac{1 + \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{x \cdot n}\\ \mathbf{elif}\;n \leq 7 \cdot 10^{-156}:\\ \;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\ \mathbf{elif}\;n \leq 2.4 \cdot 10^{+14}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;n \leq 1.8 \cdot 10^{+262}:\\ \;\;\;\;\frac{\frac{1}{x}}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log x}{-n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 16: 55.7% accurate, 1.8× speedup?

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

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

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

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

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


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

    1. Initial program 49.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 54.0%

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

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

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

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

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

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

    if 4.40000000000000026e-186 < x < 5.70000000000000032e-145

    1. Initial program 43.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 36.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.70000000000000032e-145 < x < 0.880000000000000004

    1. Initial program 40.9%

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

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

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

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

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

    if 0.880000000000000004 < x

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 4.4 \cdot 10^{-186}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 5.7 \cdot 10^{-145}:\\ \;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} - \frac{0.5}{n}}{x}}{x}\\ \mathbf{elif}\;x \leq 0.88:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1 - \frac{0.5 - \frac{0.3333333333333333 + 0.25 \cdot \frac{-1}{x}}{x}}{x}}{x}}{n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 17: 55.4% accurate, 1.8× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 3.9999999999999996e-186 or 3.3e-146 < x < 0.71999999999999997

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

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

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

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

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

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

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

    if 3.9999999999999996e-186 < x < 3.3e-146

    1. Initial program 43.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 36.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.71999999999999997 < x

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 4 \cdot 10^{-186}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 3.3 \cdot 10^{-146}:\\ \;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} - \frac{0.5}{n}}{x}}{x}\\ \mathbf{elif}\;x \leq 0.72:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1 - \frac{0.5 - \frac{0.3333333333333333 + 0.25 \cdot \frac{-1}{x}}{x}}{x}}{x}}{n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 18: 47.2% accurate, 16.2× speedup?

\[\begin{array}{l} \\ \frac{1 + \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{x \cdot 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(1.0 + Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x)) / Float64(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[(1.0 + N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

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

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

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

    \[\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 n around 0 46.8%

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

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

Alternative 19: 41.7% accurate, 42.2× speedup?

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

\\
\frac{\frac{1}{x}}{n}
\end{array}
Derivation
  1. Initial program 56.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 59.9%

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

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

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

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

Alternative 20: 41.2% accurate, 42.2× speedup?

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

\\
\frac{1}{x \cdot n}
\end{array}
Derivation
  1. Initial program 56.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 59.9%

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

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

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

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

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

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

Alternative 21: 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 56.1%

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

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

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

Reproduce

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