2nthrt (problem 3.4.6)

Percentage Accurate: 57.9% → 86.6%
Time: 47.3s
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.9% 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: 86.6% accurate, 0.9× speedup?

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

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

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

\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) < -2.0000000000000001e-135 or 9.99999999999999985e-119 < (/.f64 #s(literal 1 binary64) n) < 400

    1. Initial program 71.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 33.6%

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

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

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

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

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

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

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

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

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

    1. Initial program 54.6%

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

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

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

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

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

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

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

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

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

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

Alternative 2: 73.6% accurate, 0.9× speedup?

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

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

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

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

\mathbf{elif}\;x \leq 1.85 \cdot 10^{-23}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{n \cdot x}\right)\right)\\

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


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

    1. Initial program 69.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-log-exp69.3%

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

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

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

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

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

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

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

    if -1.24999999999999997e-150 < x < 7.50000000000000049e-246

    1. Initial program 80.3%

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

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

    if 7.50000000000000049e-246 < x < 1.65000000000000002e-107

    1. Initial program 38.8%

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

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

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

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

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

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

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

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

    if 1.65000000000000002e-107 < x < 1.8500000000000001e-23

    1. Initial program 32.9%

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

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

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

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

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

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

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

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

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

    if 1.8500000000000001e-23 < x

    1. Initial program 62.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.25 \cdot 10^{-150}:\\ \;\;\;\;0\\ \mathbf{elif}\;x \leq 7.5 \cdot 10^{-246}:\\ \;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 1.65 \cdot 10^{-107}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{elif}\;x \leq 1.85 \cdot 10^{-23}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{n \cdot x}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n} \cdot \frac{1}{x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 76.7% accurate, 1.5× speedup?

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

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

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

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

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

\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (/.f64 #s(literal 1 binary64) n) < -2.0000000000000001e-135 or 9.99999999999999985e-119 < (/.f64 #s(literal 1 binary64) n) < 400

    1. Initial program 71.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 33.6%

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

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

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

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

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

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

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

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

    if 400 < (/.f64 #s(literal 1 binary64) n) < 9.9999999999999996e274

    1. Initial program 60.6%

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

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

    if 9.9999999999999996e274 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 7.7%

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

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

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

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

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

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

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

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

Alternative 4: 76.5% accurate, 1.6× speedup?

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

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

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

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

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

\mathbf{else}:\\
\;\;\;\;\frac{1}{n \cdot x}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (/.f64 #s(literal 1 binary64) n) < -2.0000000000000001e-135 or 9.99999999999999985e-119 < (/.f64 #s(literal 1 binary64) n) < 400

    1. Initial program 71.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 33.6%

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

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

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

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

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

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

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

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

    if 400 < (/.f64 #s(literal 1 binary64) n) < 9.9999999999999996e274

    1. Initial program 60.6%

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

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

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

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

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

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

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

    if 9.9999999999999996e274 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 7.7%

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

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

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

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

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

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

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

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

Alternative 5: 73.4% accurate, 1.6× speedup?

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

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

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

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

\mathbf{elif}\;x \leq 1.85 \cdot 10^{-23}:\\
\;\;\;\;\frac{\mathsf{expm1}\left(\frac{1 + \frac{-1 + \frac{1.1666666666666667}{x}}{x}}{x}\right)}{n}\\

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


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

    1. Initial program 69.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-log-exp69.3%

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

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

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

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

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

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

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

    if -2.9000000000000001e-152 < x < 7.50000000000000049e-246

    1. Initial program 80.3%

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

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

    if 7.50000000000000049e-246 < x < 1e-100

    1. Initial program 37.6%

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

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

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

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

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

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

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

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

    if 1e-100 < x < 1.8500000000000001e-23

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

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

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

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

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

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

      \[\leadsto \frac{\mathsf{expm1}\left(\color{blue}{\frac{\left(1 + \frac{1.1666666666666667}{{x}^{2}}\right) - \frac{1}{x}}{x}}\right)}{n} \]
    9. Step-by-step derivation
      1. associate--l+65.1%

        \[\leadsto \frac{\mathsf{expm1}\left(\frac{\color{blue}{1 + \left(\frac{1.1666666666666667}{{x}^{2}} - \frac{1}{x}\right)}}{x}\right)}{n} \]
      2. unpow265.1%

        \[\leadsto \frac{\mathsf{expm1}\left(\frac{1 + \left(\frac{1.1666666666666667}{\color{blue}{x \cdot x}} - \frac{1}{x}\right)}{x}\right)}{n} \]
      3. associate-/r*65.1%

        \[\leadsto \frac{\mathsf{expm1}\left(\frac{1 + \left(\color{blue}{\frac{\frac{1.1666666666666667}{x}}{x}} - \frac{1}{x}\right)}{x}\right)}{n} \]
      4. metadata-eval65.1%

        \[\leadsto \frac{\mathsf{expm1}\left(\frac{1 + \left(\frac{\frac{\color{blue}{1.1666666666666667 \cdot 1}}{x}}{x} - \frac{1}{x}\right)}{x}\right)}{n} \]
      5. associate-*r/65.1%

        \[\leadsto \frac{\mathsf{expm1}\left(\frac{1 + \left(\frac{\color{blue}{1.1666666666666667 \cdot \frac{1}{x}}}{x} - \frac{1}{x}\right)}{x}\right)}{n} \]
      6. div-sub65.1%

        \[\leadsto \frac{\mathsf{expm1}\left(\frac{1 + \color{blue}{\frac{1.1666666666666667 \cdot \frac{1}{x} - 1}{x}}}{x}\right)}{n} \]
      7. sub-neg65.1%

        \[\leadsto \frac{\mathsf{expm1}\left(\frac{1 + \frac{\color{blue}{1.1666666666666667 \cdot \frac{1}{x} + \left(-1\right)}}{x}}{x}\right)}{n} \]
      8. metadata-eval65.1%

        \[\leadsto \frac{\mathsf{expm1}\left(\frac{1 + \frac{1.1666666666666667 \cdot \frac{1}{x} + \color{blue}{-1}}{x}}{x}\right)}{n} \]
      9. +-commutative65.1%

        \[\leadsto \frac{\mathsf{expm1}\left(\frac{1 + \frac{\color{blue}{-1 + 1.1666666666666667 \cdot \frac{1}{x}}}{x}}{x}\right)}{n} \]
      10. associate-*r/65.1%

        \[\leadsto \frac{\mathsf{expm1}\left(\frac{1 + \frac{-1 + \color{blue}{\frac{1.1666666666666667 \cdot 1}{x}}}{x}}{x}\right)}{n} \]
      11. metadata-eval65.1%

        \[\leadsto \frac{\mathsf{expm1}\left(\frac{1 + \frac{-1 + \frac{\color{blue}{1.1666666666666667}}{x}}{x}}{x}\right)}{n} \]
    10. Simplified65.1%

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

    if 1.8500000000000001e-23 < x

    1. Initial program 62.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.9 \cdot 10^{-152}:\\ \;\;\;\;0\\ \mathbf{elif}\;x \leq 7.5 \cdot 10^{-246}:\\ \;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 10^{-100}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{elif}\;x \leq 1.85 \cdot 10^{-23}:\\ \;\;\;\;\frac{\mathsf{expm1}\left(\frac{1 + \frac{-1 + \frac{1.1666666666666667}{x}}{x}}{x}\right)}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n} \cdot \frac{1}{x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 63.8% accurate, 1.6× speedup?

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

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

\mathbf{elif}\;x \leq 2.3 \cdot 10^{-246}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 3.2 \cdot 10^{-81}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 5.5 \cdot 10^{-40}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 7.6 \cdot 10^{+36}:\\
\;\;\;\;t\_0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -2.00000000000000013e-158 or 1.94999999999999997e228 < x

    1. Initial program 78.9%

      \[{\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-log-exp78.9%

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

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

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

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

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

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

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

    if -2.00000000000000013e-158 < x < 2.2999999999999998e-246 or 3.2e-81 < x < 5.50000000000000002e-40

    1. Initial program 77.3%

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

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

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

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

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

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

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

    if 2.2999999999999998e-246 < x < 3.2e-81 or 5.50000000000000002e-40 < x < 7.6000000000000005e36

    1. Initial program 37.8%

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

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

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

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

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

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

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

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

    if 7.6000000000000005e36 < x < 1.94999999999999997e228

    1. Initial program 49.5%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2 \cdot 10^{-158}:\\ \;\;\;\;0\\ \mathbf{elif}\;x \leq 2.3 \cdot 10^{-246}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 3.2 \cdot 10^{-81}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{elif}\;x \leq 5.5 \cdot 10^{-40}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 7.6 \cdot 10^{+36}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{elif}\;x \leq 1.95 \cdot 10^{+228}:\\ \;\;\;\;\frac{\frac{1}{x}}{n}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 63.4% accurate, 1.7× speedup?

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

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

\mathbf{elif}\;x \leq 1.25 \cdot 10^{-248}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 6.5 \cdot 10^{-83}:\\
\;\;\;\;\frac{\log x}{-n}\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -7.5e-153 or 1.94999999999999997e228 < x

    1. Initial program 78.9%

      \[{\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-log-exp78.9%

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

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

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

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

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

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

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

    if -7.5e-153 < x < 1.25e-248 or 6.5e-83 < x < 1

    1. Initial program 65.4%

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

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

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

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

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

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

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

    if 1.25e-248 < x < 6.5e-83

    1. Initial program 35.4%

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

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

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

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

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

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

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

    if 1 < x < 1.94999999999999997e228

    1. Initial program 50.8%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -7.5 \cdot 10^{-153}:\\ \;\;\;\;0\\ \mathbf{elif}\;x \leq 1.25 \cdot 10^{-248}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 6.5 \cdot 10^{-83}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 1.95 \cdot 10^{+228}:\\ \;\;\;\;\frac{\frac{1 - \frac{0.5 - \frac{0.3333333333333333 + \frac{-0.25}{x}}{x}}{x}}{x}}{n}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 63.3% accurate, 1.8× speedup?

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

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

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

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

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


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

    1. Initial program 80.0%

      \[{\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-log-exp80.0%

        \[\leadsto \color{blue}{\log \left(e^{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}}\right)} \]
      2. pow-to-exp50.0%

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

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

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

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

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

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

    if -3.999999999999988e-310 < x < 0.880000000000000004

    1. Initial program 45.6%

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

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

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

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

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

    if 0.880000000000000004 < x < 4.8000000000000002e229

    1. Initial program 50.8%

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

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

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

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

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

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

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

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

Alternative 9: 63.2% accurate, 1.9× speedup?

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

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

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

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

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


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

    1. Initial program 80.0%

      \[{\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-log-exp80.0%

        \[\leadsto \color{blue}{\log \left(e^{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}}\right)} \]
      2. pow-to-exp50.0%

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

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

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

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

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

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

    if -3.999999999999988e-310 < x < 0.70999999999999996

    1. Initial program 45.6%

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

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

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

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

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

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

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

    if 0.70999999999999996 < x < 9.59999999999999954e228

    1. Initial program 50.8%

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

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

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

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

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

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

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

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

Alternative 10: 54.4% accurate, 7.8× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 8.50000000000000044e-293 or 1.94999999999999997e228 < x

    1. Initial program 79.6%

      \[{\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-log-exp79.6%

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

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

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

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

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

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

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

    if 8.50000000000000044e-293 < x < 1.94999999999999997e228

    1. Initial program 46.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 36.8% accurate, 12.4× speedup?

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

\\
\frac{1}{x} \cdot \left(\frac{1}{n} + \frac{\frac{\frac{0.3333333333333333}{x} - 0.5}{n}}{x}\right)
\end{array}
Derivation
  1. Initial program 57.7%

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

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

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

    \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
  6. Taylor expanded in x around -inf 35.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}} \]
  7. Step-by-step derivation
    1. mul-1-neg35.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-neg35.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/35.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-eval35.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. *-commutative35.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/35.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-eval35.1%

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

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

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

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

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

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

Alternative 12: 36.8% accurate, 14.1× speedup?

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

\\
\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x} + -0.5}{n \cdot x}}{x}
\end{array}
Derivation
  1. Initial program 57.7%

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

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

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

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

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

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

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

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

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

    Alternative 13: 36.8% accurate, 16.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1 + \frac{\color{blue}{-0.5 + 0.3333333333333333 \cdot \frac{1}{x}}}{x}}{n}}{x} \]
      11. associate-*r/35.1%

        \[\leadsto \frac{\frac{1 + \frac{-0.5 + \color{blue}{\frac{0.3333333333333333 \cdot 1}{x}}}{x}}{n}}{x} \]
      12. metadata-eval35.1%

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

      \[\leadsto \frac{\color{blue}{\frac{1 + \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{n}}}{x} \]
    10. Final simplification35.1%

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

    Alternative 14: 32.0% accurate, 42.2× speedup?

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

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

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

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

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

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

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

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

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

    Alternative 15: 32.3% accurate, 42.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 16: 32.3% accurate, 42.2× speedup?

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

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

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

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

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

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

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

    Reproduce

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