2nthrt (problem 3.4.6)

Percentage Accurate: 53.7% → 85.9%
Time: 55.9s
Alternatives: 15
Speedup: 1.7×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 15 alternatives:

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

Initial Program: 53.7% 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: 85.9% accurate, 0.3× speedup?

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

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

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

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

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


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

    1. Initial program 86.8%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]

    if -3.9999999999999999e-48 < (/.f64 #s(literal 1 binary64) n) < 1.00000000000000004e-10

    1. Initial program 35.6%

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

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

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

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

        \[\leadsto \frac{\mathsf{log1p}\left(x\right) + \left(0.5 \cdot \frac{{\log \left(1 + x\right)}^{2}}{n} - \color{blue}{\left(0.5 \cdot \frac{{\log x}^{2}}{n} + \log x\right)}\right)}{n} \]
      4. associate--r+80.5%

        \[\leadsto \frac{\mathsf{log1p}\left(x\right) + \color{blue}{\left(\left(0.5 \cdot \frac{{\log \left(1 + x\right)}^{2}}{n} - 0.5 \cdot \frac{{\log x}^{2}}{n}\right) - \log x\right)}}{n} \]
      5. distribute-lft-out--80.5%

        \[\leadsto \frac{\mathsf{log1p}\left(x\right) + \left(\color{blue}{0.5 \cdot \left(\frac{{\log \left(1 + x\right)}^{2}}{n} - \frac{{\log x}^{2}}{n}\right)} - \log x\right)}{n} \]
      6. div-sub80.5%

        \[\leadsto \frac{\mathsf{log1p}\left(x\right) + \left(0.5 \cdot \color{blue}{\frac{{\log \left(1 + x\right)}^{2} - {\log x}^{2}}{n}} - \log x\right)}{n} \]
      7. log1p-define80.5%

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

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

    if 1.00000000000000004e-10 < (/.f64 #s(literal 1 binary64) n) < 5e3

    1. Initial program 6.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

    1. Initial program 86.8%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]

    if -3.9999999999999999e-48 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999991e-57

    1. Initial program 37.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 83.7%

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

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

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

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

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

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

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

    if 1.99999999999999991e-57 < (/.f64 #s(literal 1 binary64) n) < 5e3

    1. Initial program 14.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 82.0% accurate, 1.0× speedup?

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

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

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

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

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

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


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

    1. Initial program 86.8%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]

    if -3.9999999999999999e-48 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999991e-57

    1. Initial program 37.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 83.7%

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

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

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

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

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

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

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

    if 1.99999999999999991e-57 < (/.f64 #s(literal 1 binary64) n) < 5e3

    1. Initial program 14.1%

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

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

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

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

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

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

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

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

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

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

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

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

    if 5e3 < (/.f64 #s(literal 1 binary64) n) < 1.00000000000000002e141

    1. Initial program 76.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -\frac{\left(-\frac{\color{blue}{\frac{\frac{0.3333333333333333}{x}}{n}} - \frac{0.5}{n}}{x}\right) - \frac{1}{n}}{x} \]
      2. frac-2neg82.5%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -4 \cdot 10^{-48}:\\ \;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-57}:\\ \;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 5000:\\ \;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{+141}:\\ \;\;\;\;\left(\frac{x}{n} + 1\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{n} + \frac{\frac{n \cdot -0.5 + n \cdot \frac{0.3333333333333333}{x}}{n \cdot n}}{x}}{x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 61.1% accurate, 1.5× speedup?

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

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq 10^{-18}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1e14 < (/.f64 #s(literal 1 binary64) n) < 2e-237

    1. Initial program 39.9%

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{x \cdot n}} \]
    9. Taylor expanded in x around 0 57.7%

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

        \[\leadsto \color{blue}{\frac{\frac{1}{n}}{x}} \]
    11. Simplified58.0%

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

    if 2e-237 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999985e-76

    1. Initial program 23.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 83.2%

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

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

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

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

    if 1.99999999999999985e-76 < (/.f64 #s(literal 1 binary64) n) < 1.0000000000000001e-18

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

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

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

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

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

    if 1.0000000000000001e-18 < (/.f64 #s(literal 1 binary64) n) < 1.00000000000000002e141

    1. Initial program 59.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 55.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -\frac{\left(-\frac{\color{blue}{\frac{\frac{0.3333333333333333}{x}}{n}} - \frac{0.5}{n}}{x}\right) - \frac{1}{n}}{x} \]
      2. frac-2neg82.5%

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

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

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

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

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

Alternative 5: 82.0% accurate, 1.5× speedup?

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq 5000:\\
\;\;\;\;t\_1\\

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

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


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

    1. Initial program 72.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.9999999999999999e-48 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999991e-57

    1. Initial program 37.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 83.7%

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

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

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

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

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

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

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

    if 5e3 < (/.f64 #s(literal 1 binary64) n) < 1.00000000000000002e141

    1. Initial program 76.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -\frac{\left(-\frac{\color{blue}{\frac{\frac{0.3333333333333333}{x}}{n}} - \frac{0.5}{n}}{x}\right) - \frac{1}{n}}{x} \]
      2. frac-2neg82.5%

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

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

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

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

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

Alternative 6: 81.9% accurate, 1.6× speedup?

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq 5000:\\
\;\;\;\;t\_1\\

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

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


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

    1. Initial program 72.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.9999999999999999e-48 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999991e-57

    1. Initial program 37.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 83.7%

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

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

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

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

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

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

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

    if 5e3 < (/.f64 #s(literal 1 binary64) n) < 1.00000000000000002e141

    1. Initial program 76.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -\frac{\left(-\frac{\color{blue}{\frac{\frac{0.3333333333333333}{x}}{n}} - \frac{0.5}{n}}{x}\right) - \frac{1}{n}}{x} \]
      2. frac-2neg82.5%

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

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

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

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

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

Alternative 7: 59.2% accurate, 1.6× speedup?

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

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

\mathbf{elif}\;x \leq 2.8 \cdot 10^{-217}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 3.1 \cdot 10^{-189}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 2.5 \cdot 10^{-169}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 9.2 \cdot 10^{-32}:\\
\;\;\;\;t\_0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < 3.49999999999999992e-273 or 2.8e-217 < x < 3.1e-189 or 2.5000000000000001e-169 < x < 9.2000000000000002e-32

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

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

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

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

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

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

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

    if 3.49999999999999992e-273 < x < 2.8e-217 or 3.1e-189 < x < 2.5000000000000001e-169

    1. Initial program 65.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 65.5%

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

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

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

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

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

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

    if 9.2000000000000002e-32 < x < 1.02e195

    1. Initial program 50.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.02e195 < x

    1. Initial program 88.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 3.5 \cdot 10^{-273}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 2.8 \cdot 10^{-217}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 3.1 \cdot 10^{-189}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 2.5 \cdot 10^{-169}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 9.2 \cdot 10^{-32}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 1.02 \cdot 10^{+195}:\\ \;\;\;\;\frac{\frac{1}{n} + \frac{\frac{n \cdot -0.5 + n \cdot \frac{0.3333333333333333}{x}}{n \cdot n}}{x}}{x}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 58.5% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\log x}{-n}\\ t_1 := \frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{n \cdot x}\\ \mathbf{if}\;x \leq 2.4 \cdot 10^{-228}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 2.8 \cdot 10^{-217}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 4.2 \cdot 10^{-189}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{-169}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 9.2 \cdot 10^{-32}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{+195}:\\ \;\;\;\;\frac{\frac{1}{n} + \frac{\frac{n \cdot -0.5 + n \cdot \frac{0.3333333333333333}{x}}{n \cdot n}}{x}}{x}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (/ (log x) (- n)))
        (t_1 (/ (- 1.0 (/ (+ 0.5 (/ -0.3333333333333333 x)) x)) (* n x))))
   (if (<= x 2.4e-228)
     t_0
     (if (<= x 2.8e-217)
       t_1
       (if (<= x 4.2e-189)
         t_0
         (if (<= x 1.3e-169)
           t_1
           (if (<= x 9.2e-32)
             t_0
             (if (<= x 1.5e+195)
               (/
                (+
                 (/ 1.0 n)
                 (/
                  (/ (+ (* n -0.5) (* n (/ 0.3333333333333333 x))) (* n n))
                  x))
                x)
               0.0))))))))
double code(double x, double n) {
	double t_0 = log(x) / -n;
	double t_1 = (1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / (n * x);
	double tmp;
	if (x <= 2.4e-228) {
		tmp = t_0;
	} else if (x <= 2.8e-217) {
		tmp = t_1;
	} else if (x <= 4.2e-189) {
		tmp = t_0;
	} else if (x <= 1.3e-169) {
		tmp = t_1;
	} else if (x <= 9.2e-32) {
		tmp = t_0;
	} else if (x <= 1.5e+195) {
		tmp = ((1.0 / n) + ((((n * -0.5) + (n * (0.3333333333333333 / x))) / (n * n)) / x)) / x;
	} else {
		tmp = 0.0;
	}
	return tmp;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = log(x) / -n
    t_1 = (1.0d0 - ((0.5d0 + ((-0.3333333333333333d0) / x)) / x)) / (n * x)
    if (x <= 2.4d-228) then
        tmp = t_0
    else if (x <= 2.8d-217) then
        tmp = t_1
    else if (x <= 4.2d-189) then
        tmp = t_0
    else if (x <= 1.3d-169) then
        tmp = t_1
    else if (x <= 9.2d-32) then
        tmp = t_0
    else if (x <= 1.5d+195) then
        tmp = ((1.0d0 / n) + ((((n * (-0.5d0)) + (n * (0.3333333333333333d0 / x))) / (n * n)) / x)) / x
    else
        tmp = 0.0d0
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double t_0 = Math.log(x) / -n;
	double t_1 = (1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / (n * x);
	double tmp;
	if (x <= 2.4e-228) {
		tmp = t_0;
	} else if (x <= 2.8e-217) {
		tmp = t_1;
	} else if (x <= 4.2e-189) {
		tmp = t_0;
	} else if (x <= 1.3e-169) {
		tmp = t_1;
	} else if (x <= 9.2e-32) {
		tmp = t_0;
	} else if (x <= 1.5e+195) {
		tmp = ((1.0 / n) + ((((n * -0.5) + (n * (0.3333333333333333 / x))) / (n * n)) / x)) / x;
	} else {
		tmp = 0.0;
	}
	return tmp;
}
def code(x, n):
	t_0 = math.log(x) / -n
	t_1 = (1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / (n * x)
	tmp = 0
	if x <= 2.4e-228:
		tmp = t_0
	elif x <= 2.8e-217:
		tmp = t_1
	elif x <= 4.2e-189:
		tmp = t_0
	elif x <= 1.3e-169:
		tmp = t_1
	elif x <= 9.2e-32:
		tmp = t_0
	elif x <= 1.5e+195:
		tmp = ((1.0 / n) + ((((n * -0.5) + (n * (0.3333333333333333 / x))) / (n * n)) / x)) / x
	else:
		tmp = 0.0
	return tmp
function code(x, n)
	t_0 = Float64(log(x) / Float64(-n))
	t_1 = Float64(Float64(1.0 - Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / x)) / Float64(n * x))
	tmp = 0.0
	if (x <= 2.4e-228)
		tmp = t_0;
	elseif (x <= 2.8e-217)
		tmp = t_1;
	elseif (x <= 4.2e-189)
		tmp = t_0;
	elseif (x <= 1.3e-169)
		tmp = t_1;
	elseif (x <= 9.2e-32)
		tmp = t_0;
	elseif (x <= 1.5e+195)
		tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(Float64(n * -0.5) + Float64(n * Float64(0.3333333333333333 / x))) / Float64(n * n)) / x)) / x);
	else
		tmp = 0.0;
	end
	return tmp
end
function tmp_2 = code(x, n)
	t_0 = log(x) / -n;
	t_1 = (1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / (n * x);
	tmp = 0.0;
	if (x <= 2.4e-228)
		tmp = t_0;
	elseif (x <= 2.8e-217)
		tmp = t_1;
	elseif (x <= 4.2e-189)
		tmp = t_0;
	elseif (x <= 1.3e-169)
		tmp = t_1;
	elseif (x <= 9.2e-32)
		tmp = t_0;
	elseif (x <= 1.5e+195)
		tmp = ((1.0 / n) + ((((n * -0.5) + (n * (0.3333333333333333 / x))) / (n * n)) / x)) / x;
	else
		tmp = 0.0;
	end
	tmp_2 = tmp;
end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision]}, Block[{t$95$1 = N[(N[(1.0 - N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 2.4e-228], t$95$0, If[LessEqual[x, 2.8e-217], t$95$1, If[LessEqual[x, 4.2e-189], t$95$0, If[LessEqual[x, 1.3e-169], t$95$1, If[LessEqual[x, 9.2e-32], t$95$0, If[LessEqual[x, 1.5e+195], N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(N[(n * -0.5), $MachinePrecision] + N[(n * N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], 0.0]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\log x}{-n}\\
t_1 := \frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{n \cdot x}\\
\mathbf{if}\;x \leq 2.4 \cdot 10^{-228}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 2.8 \cdot 10^{-217}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 4.2 \cdot 10^{-189}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 1.3 \cdot 10^{-169}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 9.2 \cdot 10^{-32}:\\
\;\;\;\;t\_0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < 2.40000000000000002e-228 or 2.8e-217 < x < 4.20000000000000033e-189 or 1.30000000000000007e-169 < x < 9.2000000000000002e-32

    1. Initial program 34.1%

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

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

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

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

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

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

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

    if 2.40000000000000002e-228 < x < 2.8e-217 or 4.20000000000000033e-189 < x < 1.30000000000000007e-169

    1. Initial program 84.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 10.3%

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

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

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

      \[\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. Taylor expanded in n around 0 74.5%

      \[\leadsto -1 \cdot \color{blue}{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{n \cdot x}} \]
    8. Step-by-step derivation
      1. sub-neg74.5%

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

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

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

        \[\leadsto -1 \cdot \frac{\frac{-1 \cdot \left(0.3333333333333333 \cdot \frac{1}{x} + \color{blue}{-0.5}\right)}{x} + \left(-1\right)}{n \cdot x} \]
      5. distribute-lft-in74.5%

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

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

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

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

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

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

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

        \[\leadsto -1 \cdot \frac{\frac{\frac{-0.3333333333333333}{x} + 0.5}{x} + \color{blue}{-1}}{n \cdot x} \]
      13. *-commutative74.5%

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

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

    if 9.2000000000000002e-32 < x < 1.5e195

    1. Initial program 50.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.5e195 < x

    1. Initial program 88.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 2.4 \cdot 10^{-228}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 2.8 \cdot 10^{-217}:\\ \;\;\;\;\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{n \cdot x}\\ \mathbf{elif}\;x \leq 4.2 \cdot 10^{-189}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{-169}:\\ \;\;\;\;\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{n \cdot x}\\ \mathbf{elif}\;x \leq 9.2 \cdot 10^{-32}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{+195}:\\ \;\;\;\;\frac{\frac{1}{n} + \frac{\frac{n \cdot -0.5 + n \cdot \frac{0.3333333333333333}{x}}{n \cdot n}}{x}}{x}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 75.3% accurate, 1.7× speedup?

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

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

\mathbf{elif}\;\frac{1}{n} \leq 5000:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\

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

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


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

    1. Initial program 99.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 47.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 33.2%

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

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

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

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

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

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

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

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

    if 5e3 < (/.f64 #s(literal 1 binary64) n) < 1.00000000000000002e141

    1. Initial program 76.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -\frac{\left(-\frac{\color{blue}{\frac{\frac{0.3333333333333333}{x}}{n}} - \frac{0.5}{n}}{x}\right) - \frac{1}{n}}{x} \]
      2. frac-2neg82.5%

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

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

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

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

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

Alternative 10: 50.3% accurate, 8.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 5.5 \cdot 10^{+123}:\\ \;\;\;\;\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{n \cdot x}\\ \mathbf{elif}\;x \leq 4.1 \cdot 10^{+150}:\\ \;\;\;\;0\\ \mathbf{elif}\;x \leq 5.6 \cdot 10^{+194}:\\ \;\;\;\;\frac{\frac{1}{n} - \frac{0.5}{n \cdot x}}{x}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= x 5.5e+123)
   (/ (- 1.0 (/ (+ 0.5 (/ -0.3333333333333333 x)) x)) (* n x))
   (if (<= x 4.1e+150)
     0.0
     (if (<= x 5.6e+194) (/ (- (/ 1.0 n) (/ 0.5 (* n x))) x) 0.0))))
double code(double x, double n) {
	double tmp;
	if (x <= 5.5e+123) {
		tmp = (1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / (n * x);
	} else if (x <= 4.1e+150) {
		tmp = 0.0;
	} else if (x <= 5.6e+194) {
		tmp = ((1.0 / n) - (0.5 / (n * x))) / x;
	} else {
		tmp = 0.0;
	}
	return tmp;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    real(8) :: tmp
    if (x <= 5.5d+123) then
        tmp = (1.0d0 - ((0.5d0 + ((-0.3333333333333333d0) / x)) / x)) / (n * x)
    else if (x <= 4.1d+150) then
        tmp = 0.0d0
    else if (x <= 5.6d+194) then
        tmp = ((1.0d0 / n) - (0.5d0 / (n * x))) / x
    else
        tmp = 0.0d0
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double tmp;
	if (x <= 5.5e+123) {
		tmp = (1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / (n * x);
	} else if (x <= 4.1e+150) {
		tmp = 0.0;
	} else if (x <= 5.6e+194) {
		tmp = ((1.0 / n) - (0.5 / (n * x))) / x;
	} else {
		tmp = 0.0;
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if x <= 5.5e+123:
		tmp = (1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / (n * x)
	elif x <= 4.1e+150:
		tmp = 0.0
	elif x <= 5.6e+194:
		tmp = ((1.0 / n) - (0.5 / (n * x))) / x
	else:
		tmp = 0.0
	return tmp
function code(x, n)
	tmp = 0.0
	if (x <= 5.5e+123)
		tmp = Float64(Float64(1.0 - Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / x)) / Float64(n * x));
	elseif (x <= 4.1e+150)
		tmp = 0.0;
	elseif (x <= 5.6e+194)
		tmp = Float64(Float64(Float64(1.0 / n) - Float64(0.5 / Float64(n * x))) / x);
	else
		tmp = 0.0;
	end
	return tmp
end
function tmp_2 = code(x, n)
	tmp = 0.0;
	if (x <= 5.5e+123)
		tmp = (1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / (n * x);
	elseif (x <= 4.1e+150)
		tmp = 0.0;
	elseif (x <= 5.6e+194)
		tmp = ((1.0 / n) - (0.5 / (n * x))) / x;
	else
		tmp = 0.0;
	end
	tmp_2 = tmp;
end
code[x_, n_] := If[LessEqual[x, 5.5e+123], N[(N[(1.0 - N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4.1e+150], 0.0, If[LessEqual[x, 5.6e+194], N[(N[(N[(1.0 / n), $MachinePrecision] - N[(0.5 / N[(n * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], 0.0]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq 4.1 \cdot 10^{+150}:\\
\;\;\;\;0\\

\mathbf{elif}\;x \leq 5.6 \cdot 10^{+194}:\\
\;\;\;\;\frac{\frac{1}{n} - \frac{0.5}{n \cdot x}}{x}\\

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


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

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

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

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

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

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

      \[\leadsto -1 \cdot \color{blue}{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{n \cdot x}} \]
    8. Step-by-step derivation
      1. sub-neg44.8%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto -1 \cdot \frac{\frac{\frac{-0.3333333333333333}{x} + 0.5}{x} + \color{blue}{-1}}{n \cdot x} \]
      13. *-commutative44.8%

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

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

    if 5.5000000000000002e123 < x < 4.09999999999999994e150 or 5.60000000000000021e194 < x

    1. Initial program 83.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 1 - \color{blue}{1} \]

    if 4.09999999999999994e150 < x < 5.60000000000000021e194

    1. Initial program 59.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 59.4%

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{n} - \frac{\color{blue}{0.5}}{n \cdot x}}{x} \]
      3. *-commutative92.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 5.5 \cdot 10^{+123}:\\ \;\;\;\;\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{n \cdot x}\\ \mathbf{elif}\;x \leq 4.1 \cdot 10^{+150}:\\ \;\;\;\;0\\ \mathbf{elif}\;x \leq 5.6 \cdot 10^{+194}:\\ \;\;\;\;\frac{\frac{1}{n} - \frac{0.5}{n \cdot x}}{x}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 51.3% accurate, 8.1× speedup?

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

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

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


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

    1. Initial program 44.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.5e195 < x

    1. Initial program 88.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 1 - \color{blue}{1} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification55.9%

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

Alternative 12: 44.2% accurate, 8.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;n \leq -1.06 \cdot 10^{-32} \lor \neg \left(n \leq -2.2 \cdot 10^{-153} \lor \neg \left(n \leq -1.08 \cdot 10^{-219}\right) \land n \leq -1.1 \cdot 10^{-263}\right):\\
\;\;\;\;\frac{1}{n \cdot x}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if n < -1.05999999999999994e-32 or -2.20000000000000001e-153 < n < -1.08e-219 or -1.1e-263 < n

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

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

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

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

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

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

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

    if -1.05999999999999994e-32 < n < -2.20000000000000001e-153 or -1.08e-219 < n < -1.1e-263

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 1 - \color{blue}{1} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification50.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -1.06 \cdot 10^{-32} \lor \neg \left(n \leq -2.2 \cdot 10^{-153} \lor \neg \left(n \leq -1.08 \cdot 10^{-219}\right) \land n \leq -1.1 \cdot 10^{-263}\right):\\ \;\;\;\;\frac{1}{n \cdot x}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 50.8% accurate, 10.5× speedup?

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

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

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


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

    1. Initial program 44.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if 5.30000000000000005e194 < x

      1. Initial program 88.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 1 - \color{blue}{1} \]
    11. Recombined 2 regimes into one program.
    12. Final simplification55.4%

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

    Alternative 14: 45.6% accurate, 17.6× speedup?

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

      1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 1 - \color{blue}{1} \]

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

      1. Initial program 37.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 58.5%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1}{x \cdot n}} \]
      9. Taylor expanded in x around 0 46.7%

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

          \[\leadsto \color{blue}{\frac{\frac{1}{n}}{x}} \]
      11. Simplified47.3%

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

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

    Alternative 15: 31.0% accurate, 211.0× speedup?

    \[\begin{array}{l} \\ 0 \end{array} \]
    (FPCore (x n) :precision binary64 0.0)
    double code(double x, double n) {
    	return 0.0;
    }
    
    real(8) function code(x, n)
        real(8), intent (in) :: x
        real(8), intent (in) :: n
        code = 0.0d0
    end function
    
    public static double code(double x, double n) {
    	return 0.0;
    }
    
    def code(x, n):
    	return 0.0
    
    function code(x, n)
    	return 0.0
    end
    
    function tmp = code(x, n)
    	tmp = 0.0;
    end
    
    code[x_, n_] := 0.0
    
    \begin{array}{l}
    
    \\
    0
    \end{array}
    
    Derivation
    1. Initial program 51.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 40.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 1 - \color{blue}{1} \]
    11. Final simplification30.7%

      \[\leadsto 0 \]
    12. Add Preprocessing

    Reproduce

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