2nthrt (problem 3.4.6)

Percentage Accurate: 57.4% → 87.6%
Time: 38.1s
Alternatives: 16
Speedup: 1.9×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 16 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: 57.4% 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: 87.6% accurate, 0.3× speedup?

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

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

\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-6}:\\
\;\;\;\;\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{else}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_0\\


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

    1. Initial program 85.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 74.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.9999999999999999e-75 < (/.f64 #s(literal 1 binary64) n) < 3.99999999999999982e-6

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

      \[\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+79.9%

        \[\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-define79.9%

        \[\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. +-commutative79.9%

        \[\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+79.9%

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

        \[\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-sub79.9%

        \[\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-define79.9%

        \[\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. Simplified79.9%

      \[\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 3.99999999999999982e-6 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 51.1%

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

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

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

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

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

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

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

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

Alternative 2: 87.5% accurate, 0.7× speedup?

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

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

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

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


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

    1. Initial program 85.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 74.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.9999999999999999e-75 < (/.f64 #s(literal 1 binary64) n) < 3.99999999999999982e-6

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

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

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

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

    if 3.99999999999999982e-6 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 51.1%

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

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

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

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

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

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

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

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

Alternative 3: 87.5% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 85.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 74.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.9999999999999999e-75 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000016e-5

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

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

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

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

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

    1. Initial program 51.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 0 35.1%

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

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

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

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

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

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

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

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

Alternative 4: 76.3% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 85.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 74.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.9999999999999999e-75 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000016e-5

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

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

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

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

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

    1. Initial program 51.8%

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

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

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

Alternative 5: 74.5% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq -3.1 \cdot 10^{-192}:\\
\;\;\;\;0\\

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

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

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


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

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

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

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

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

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

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

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

        \[\leadsto e^{\color{blue}{\frac{\log x}{n}}} - {x}^{\left(\frac{1}{n}\right)} \]
      7. *-rgt-identity0.0%

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

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

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

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

      \[\leadsto \color{blue}{0} \]

    if -3.1e-192 < x < 2.3e-247

    1. Initial program 64.7%

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

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

    if 2.3e-247 < x < 0.25

    1. Initial program 37.1%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{\left(\sqrt{e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}}\right)}^{2}} \]
    5. Taylor expanded in n around inf 30.9%

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

        \[\leadsto {\left(\sqrt{\frac{\color{blue}{\mathsf{log1p}\left(x\right)} - \log x}{n}}\right)}^{2} \]
    7. Simplified30.9%

      \[\leadsto {\color{blue}{\left(\sqrt{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}}\right)}}^{2} \]
    8. Taylor expanded in x around 0 56.1%

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

    if 0.25 < x

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 74.4% accurate, 1.6× speedup?

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

\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq -4.9 \cdot 10^{-206}:\\
\;\;\;\;0\\

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

\mathbf{elif}\;x \leq 0.22:\\
\;\;\;\;x \cdot \left(\frac{1}{n} + \frac{x}{n} \cdot -0.5\right) - \frac{\log x}{n}\\

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


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

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

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

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

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

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

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

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

        \[\leadsto e^{\color{blue}{\frac{\log x}{n}}} - {x}^{\left(\frac{1}{n}\right)} \]
      7. *-rgt-identity0.0%

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

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

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

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

      \[\leadsto \color{blue}{0} \]

    if -4.9e-206 < x < 2.3e-247

    1. Initial program 64.7%

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

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

    if 2.3e-247 < x < 0.220000000000000001

    1. Initial program 37.1%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{\left(\sqrt{e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}}\right)}^{2}} \]
    5. Taylor expanded in n around inf 30.9%

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

        \[\leadsto {\left(\sqrt{\frac{\color{blue}{\mathsf{log1p}\left(x\right)} - \log x}{n}}\right)}^{2} \]
    7. Simplified30.9%

      \[\leadsto {\color{blue}{\left(\sqrt{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}}\right)}}^{2} \]
    8. Taylor expanded in x around 0 56.0%

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

    if 0.220000000000000001 < x

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4.9 \cdot 10^{-206}:\\ \;\;\;\;0\\ \mathbf{elif}\;x \leq 2.3 \cdot 10^{-247}:\\ \;\;\;\;\left(\frac{x}{n} + 1\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 0.22:\\ \;\;\;\;x \cdot \left(\frac{1}{n} + \frac{x}{n} \cdot -0.5\right) - \frac{\log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 74.4% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq -2.95 \cdot 10^{-192}:\\
\;\;\;\;0\\

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

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

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


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

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

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

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

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

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

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

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

        \[\leadsto e^{\color{blue}{\frac{\log x}{n}}} - {x}^{\left(\frac{1}{n}\right)} \]
      7. *-rgt-identity0.0%

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

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

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

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

      \[\leadsto \color{blue}{0} \]

    if -2.9499999999999998e-192 < x < 1.39999999999999993e-247

    1. Initial program 64.7%

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

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

    if 1.39999999999999993e-247 < x < 0.220000000000000001

    1. Initial program 37.1%

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

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

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

    if 0.220000000000000001 < x

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.95 \cdot 10^{-192}:\\ \;\;\;\;0\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{-247}:\\ \;\;\;\;\left(\frac{x}{n} + 1\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 0.22:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 74.3% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq -2.4 \cdot 10^{-198}:\\
\;\;\;\;0\\

\mathbf{elif}\;x \leq 1.55 \cdot 10^{-247}:\\
\;\;\;\;1 - t\_0\\

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

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


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

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

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

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

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

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

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

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

        \[\leadsto e^{\color{blue}{\frac{\log x}{n}}} - {x}^{\left(\frac{1}{n}\right)} \]
      7. *-rgt-identity0.0%

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

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

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

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

      \[\leadsto \color{blue}{0} \]

    if -2.39999999999999986e-198 < x < 1.55000000000000008e-247

    1. Initial program 64.7%

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

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

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

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

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

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

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

    if 1.55000000000000008e-247 < x < 0.220000000000000001

    1. Initial program 37.1%

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

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

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

    if 0.220000000000000001 < x

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 66.4% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2 \cdot 10^{-192}:\\
\;\;\;\;0\\

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -2.0000000000000002e-192 or 2.09999999999999997e160 < x

    1. Initial program 73.7%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0} \]

    if -2.0000000000000002e-192 < x < 1.4999999999999999e-247

    1. Initial program 64.7%

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

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

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

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

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

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

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

    if 1.4999999999999999e-247 < x < 0.849999999999999978

    1. Initial program 37.1%

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

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

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

    if 0.849999999999999978 < x < 2.09999999999999997e160

    1. Initial program 39.8%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{\left(\sqrt{e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}}\right)}^{2}} \]
    5. Taylor expanded in n around inf 38.7%

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

        \[\leadsto {\left(\sqrt{\frac{\color{blue}{\mathsf{log1p}\left(x\right)} - \log x}{n}}\right)}^{2} \]
    7. Simplified38.7%

      \[\leadsto {\color{blue}{\left(\sqrt{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}}\right)}}^{2} \]
    8. Taylor expanded in x around -inf 74.1%

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

        \[\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-neg74.1%

        \[\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/74.1%

        \[\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-eval74.1%

        \[\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. *-commutative74.1%

        \[\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/74.1%

        \[\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-eval74.1%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2 \cdot 10^{-192}:\\ \;\;\;\;0\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{-247}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 0.85:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{elif}\;x \leq 2.1 \cdot 10^{+160}:\\ \;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{n \cdot x} - \frac{0.5}{n}}{x}}{x}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 64.9% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -4 \cdot 10^{-310}:\\ \;\;\;\;0\\ \mathbf{elif}\;x \leq 0.85:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{elif}\;x \leq 1.95 \cdot 10^{+160}:\\ \;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{n \cdot x} - \frac{0.5}{n}}{x}}{x}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= x -4e-310)
   0.0
   (if (<= x 0.85)
     (/ (- x (log x)) n)
     (if (<= x 1.95e+160)
       (/ (+ (/ 1.0 n) (/ (- (/ 0.3333333333333333 (* n x)) (/ 0.5 n)) x)) x)
       0.0))))
double code(double x, double n) {
	double tmp;
	if (x <= -4e-310) {
		tmp = 0.0;
	} else if (x <= 0.85) {
		tmp = (x - log(x)) / n;
	} else if (x <= 1.95e+160) {
		tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) - (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 <= (-4d-310)) then
        tmp = 0.0d0
    else if (x <= 0.85d0) then
        tmp = (x - log(x)) / n
    else if (x <= 1.95d+160) then
        tmp = ((1.0d0 / n) + (((0.3333333333333333d0 / (n * x)) - (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 <= -4e-310) {
		tmp = 0.0;
	} else if (x <= 0.85) {
		tmp = (x - Math.log(x)) / n;
	} else if (x <= 1.95e+160) {
		tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) - (0.5 / n)) / x)) / x;
	} else {
		tmp = 0.0;
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if x <= -4e-310:
		tmp = 0.0
	elif x <= 0.85:
		tmp = (x - math.log(x)) / n
	elif x <= 1.95e+160:
		tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) - (0.5 / n)) / x)) / x
	else:
		tmp = 0.0
	return tmp
function code(x, n)
	tmp = 0.0
	if (x <= -4e-310)
		tmp = 0.0;
	elseif (x <= 0.85)
		tmp = Float64(Float64(x - log(x)) / n);
	elseif (x <= 1.95e+160)
		tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(n * x)) - Float64(0.5 / n)) / x)) / x);
	else
		tmp = 0.0;
	end
	return tmp
end
function tmp_2 = code(x, n)
	tmp = 0.0;
	if (x <= -4e-310)
		tmp = 0.0;
	elseif (x <= 0.85)
		tmp = (x - log(x)) / n;
	elseif (x <= 1.95e+160)
		tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) - (0.5 / n)) / x)) / x;
	else
		tmp = 0.0;
	end
	tmp_2 = tmp;
end
code[x_, n_] := If[LessEqual[x, -4e-310], 0.0, If[LessEqual[x, 0.85], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 1.95e+160], N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(0.3333333333333333 / N[(n * x), $MachinePrecision]), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], 0.0]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{-310}:\\
\;\;\;\;0\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -3.999999999999988e-310 or 1.95000000000000004e160 < x

    1. Initial program 72.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 40.6%

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

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

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

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

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

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

        \[\leadsto e^{\color{blue}{\frac{\log x}{n}}} - {x}^{\left(\frac{1}{n}\right)} \]
      7. *-rgt-identity40.6%

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

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

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

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

      \[\leadsto \color{blue}{0} \]

    if -3.999999999999988e-310 < x < 0.849999999999999978

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

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

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

    if 0.849999999999999978 < x < 1.95000000000000004e160

    1. Initial program 39.8%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{\left(\sqrt{e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}}\right)}^{2}} \]
    5. Taylor expanded in n around inf 38.7%

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

        \[\leadsto {\left(\sqrt{\frac{\color{blue}{\mathsf{log1p}\left(x\right)} - \log x}{n}}\right)}^{2} \]
    7. Simplified38.7%

      \[\leadsto {\color{blue}{\left(\sqrt{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}}\right)}}^{2} \]
    8. Taylor expanded in x around -inf 74.1%

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

        \[\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-neg74.1%

        \[\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/74.1%

        \[\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-eval74.1%

        \[\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. *-commutative74.1%

        \[\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/74.1%

        \[\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-eval74.1%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4 \cdot 10^{-310}:\\ \;\;\;\;0\\ \mathbf{elif}\;x \leq 0.85:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{elif}\;x \leq 1.95 \cdot 10^{+160}:\\ \;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{n \cdot x} - \frac{0.5}{n}}{x}}{x}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 64.7% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{-310}:\\
\;\;\;\;0\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -3.999999999999988e-310 or 2.00000000000000001e160 < x

    1. Initial program 72.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 40.6%

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

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

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

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

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

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

        \[\leadsto e^{\color{blue}{\frac{\log x}{n}}} - {x}^{\left(\frac{1}{n}\right)} \]
      7. *-rgt-identity40.6%

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

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

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

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

      \[\leadsto \color{blue}{0} \]

    if -3.999999999999988e-310 < x < 0.599999999999999978

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

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

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

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

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

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

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

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

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

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

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

    if 0.599999999999999978 < x < 2.00000000000000001e160

    1. Initial program 39.8%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{\left(\sqrt{e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}}\right)}^{2}} \]
    5. Taylor expanded in n around inf 38.7%

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

        \[\leadsto {\left(\sqrt{\frac{\color{blue}{\mathsf{log1p}\left(x\right)} - \log x}{n}}\right)}^{2} \]
    7. Simplified38.7%

      \[\leadsto {\color{blue}{\left(\sqrt{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}}\right)}}^{2} \]
    8. Taylor expanded in x around -inf 74.1%

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

        \[\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-neg74.1%

        \[\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/74.1%

        \[\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-eval74.1%

        \[\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. *-commutative74.1%

        \[\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/74.1%

        \[\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-eval74.1%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4 \cdot 10^{-310}:\\ \;\;\;\;0\\ \mathbf{elif}\;x \leq 0.6:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 2 \cdot 10^{+160}:\\ \;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{n \cdot x} - \frac{0.5}{n}}{x}}{x}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 56.0% accurate, 7.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.16 \cdot 10^{-292}:\\
\;\;\;\;0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 1.16e-292 or 1.95000000000000004e160 < x

    1. Initial program 70.5%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0} \]

    if 1.16e-292 < x < 1.95000000000000004e160

    1. Initial program 43.3%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{\left(\sqrt{e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}}\right)}^{2}} \]
    5. Taylor expanded in n around inf 28.8%

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

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

      \[\leadsto {\color{blue}{\left(\sqrt{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}}\right)}}^{2} \]
    8. Taylor expanded in x around -inf 40.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}} \]
    9. Step-by-step derivation
      1. mul-1-neg40.9%

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

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

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

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

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

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

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

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

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

Alternative 13: 51.5% accurate, 14.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 1.16 \cdot 10^{-292}:\\ \;\;\;\;0\\ \mathbf{elif}\;x \leq 1.95 \cdot 10^{+160}:\\ \;\;\;\;\frac{\frac{1}{x}}{n}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= x 1.16e-292) 0.0 (if (<= x 1.95e+160) (/ (/ 1.0 x) n) 0.0)))
double code(double x, double n) {
	double tmp;
	if (x <= 1.16e-292) {
		tmp = 0.0;
	} else if (x <= 1.95e+160) {
		tmp = (1.0 / x) / n;
	} 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.16d-292) then
        tmp = 0.0d0
    else if (x <= 1.95d+160) then
        tmp = (1.0d0 / x) / n
    else
        tmp = 0.0d0
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double tmp;
	if (x <= 1.16e-292) {
		tmp = 0.0;
	} else if (x <= 1.95e+160) {
		tmp = (1.0 / x) / n;
	} else {
		tmp = 0.0;
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if x <= 1.16e-292:
		tmp = 0.0
	elif x <= 1.95e+160:
		tmp = (1.0 / x) / n
	else:
		tmp = 0.0
	return tmp
function code(x, n)
	tmp = 0.0
	if (x <= 1.16e-292)
		tmp = 0.0;
	elseif (x <= 1.95e+160)
		tmp = Float64(Float64(1.0 / x) / n);
	else
		tmp = 0.0;
	end
	return tmp
end
function tmp_2 = code(x, n)
	tmp = 0.0;
	if (x <= 1.16e-292)
		tmp = 0.0;
	elseif (x <= 1.95e+160)
		tmp = (1.0 / x) / n;
	else
		tmp = 0.0;
	end
	tmp_2 = tmp;
end
code[x_, n_] := If[LessEqual[x, 1.16e-292], 0.0, If[LessEqual[x, 1.95e+160], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], 0.0]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.16 \cdot 10^{-292}:\\
\;\;\;\;0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 1.16e-292 or 1.95000000000000004e160 < x

    1. Initial program 70.5%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0} \]

    if 1.16e-292 < x < 1.95000000000000004e160

    1. Initial program 43.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1 \cdot \frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}} \]
      2. *-un-lft-identity45.9%

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{1}{x}}{n}} \]
    12. Simplified32.5%

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

Alternative 14: 51.5% accurate, 14.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 1.16 \cdot 10^{-292}:\\ \;\;\;\;0\\ \mathbf{elif}\;x \leq 1.95 \cdot 10^{+160}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= x 1.16e-292) 0.0 (if (<= x 1.95e+160) (/ (/ 1.0 n) x) 0.0)))
double code(double x, double n) {
	double tmp;
	if (x <= 1.16e-292) {
		tmp = 0.0;
	} else if (x <= 1.95e+160) {
		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 (x <= 1.16d-292) then
        tmp = 0.0d0
    else if (x <= 1.95d+160) 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 (x <= 1.16e-292) {
		tmp = 0.0;
	} else if (x <= 1.95e+160) {
		tmp = (1.0 / n) / x;
	} else {
		tmp = 0.0;
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if x <= 1.16e-292:
		tmp = 0.0
	elif x <= 1.95e+160:
		tmp = (1.0 / n) / x
	else:
		tmp = 0.0
	return tmp
function code(x, n)
	tmp = 0.0
	if (x <= 1.16e-292)
		tmp = 0.0;
	elseif (x <= 1.95e+160)
		tmp = Float64(Float64(1.0 / n) / x);
	else
		tmp = 0.0;
	end
	return tmp
end
function tmp_2 = code(x, n)
	tmp = 0.0;
	if (x <= 1.16e-292)
		tmp = 0.0;
	elseif (x <= 1.95e+160)
		tmp = (1.0 / n) / x;
	else
		tmp = 0.0;
	end
	tmp_2 = tmp;
end
code[x_, n_] := If[LessEqual[x, 1.16e-292], 0.0, If[LessEqual[x, 1.95e+160], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], 0.0]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.16 \cdot 10^{-292}:\\
\;\;\;\;0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 1.16e-292 or 1.95000000000000004e160 < x

    1. Initial program 70.5%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0} \]

    if 1.16e-292 < x < 1.95000000000000004e160

    1. Initial program 43.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1 \cdot \frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}} \]
      2. *-un-lft-identity45.9%

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

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

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

Alternative 15: 51.4% accurate, 14.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 1.16 \cdot 10^{-292}:\\ \;\;\;\;0\\ \mathbf{elif}\;x \leq 1.95 \cdot 10^{+160}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= x 1.16e-292) 0.0 (if (<= x 1.95e+160) (/ 1.0 (* n x)) 0.0)))
double code(double x, double n) {
	double tmp;
	if (x <= 1.16e-292) {
		tmp = 0.0;
	} else if (x <= 1.95e+160) {
		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 (x <= 1.16d-292) then
        tmp = 0.0d0
    else if (x <= 1.95d+160) 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 (x <= 1.16e-292) {
		tmp = 0.0;
	} else if (x <= 1.95e+160) {
		tmp = 1.0 / (n * x);
	} else {
		tmp = 0.0;
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if x <= 1.16e-292:
		tmp = 0.0
	elif x <= 1.95e+160:
		tmp = 1.0 / (n * x)
	else:
		tmp = 0.0
	return tmp
function code(x, n)
	tmp = 0.0
	if (x <= 1.16e-292)
		tmp = 0.0;
	elseif (x <= 1.95e+160)
		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 (x <= 1.16e-292)
		tmp = 0.0;
	elseif (x <= 1.95e+160)
		tmp = 1.0 / (n * x);
	else
		tmp = 0.0;
	end
	tmp_2 = tmp;
end
code[x_, n_] := If[LessEqual[x, 1.16e-292], 0.0, If[LessEqual[x, 1.95e+160], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision], 0.0]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.16 \cdot 10^{-292}:\\
\;\;\;\;0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 1.16e-292 or 1.95000000000000004e160 < x

    1. Initial program 70.5%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0} \]

    if 1.16e-292 < x < 1.95000000000000004e160

    1. Initial program 43.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 16: 41.2% 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 53.6%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{0} \]
  7. Add Preprocessing

Reproduce

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