2nthrt (problem 3.4.6)

Percentage Accurate: 53.2% → 85.0%
Time: 46.7s
Alternatives: 10
Speedup: 1.7×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 10 alternatives:

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

Initial Program: 53.2% accurate, 1.0× speedup?

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

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

Alternative 1: 85.0% accurate, 0.2× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) < -inf.0

    1. Initial program 100.0%

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

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

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

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

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

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

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

    if -inf.0 < (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) < 0.0

    1. Initial program 40.3%

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

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

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

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

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

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

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

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

    if 0.0 < (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n)))

    1. Initial program 51.3%

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

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

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

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

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

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

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

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

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

Alternative 2: 85.0% accurate, 0.3× speedup?

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

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

\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) < -inf.0

    1. Initial program 100.0%

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

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

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

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

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

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

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

    if -inf.0 < (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) < 0.0

    1. Initial program 40.3%

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

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

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

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

    if 0.0 < (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n)))

    1. Initial program 51.3%

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

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

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

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

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

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

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

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

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

Alternative 3: 78.9% accurate, 0.3× speedup?

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

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

\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) < -inf.0

    1. Initial program 100.0%

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

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

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

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

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

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

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

    if -inf.0 < (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) < 0.0

    1. Initial program 40.3%

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

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

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

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

    if 0.0 < (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n)))

    1. Initial program 51.3%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Add Preprocessing
  3. Recombined 3 regimes into one program.
  4. Final simplification77.6%

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

Alternative 4: 80.9% accurate, 0.9× speedup?

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

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

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

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

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

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

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


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

    1. Initial program 96.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 100.0%

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

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

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

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

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

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

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

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

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

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

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

    if -1.00000000000000004e-10 < (/.f64 1 n) < -5.0000000000000001e-59 or -1.00000000000000001e-119 < (/.f64 1 n) < 1e-3

    1. Initial program 31.4%

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

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

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

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

    if -5.0000000000000001e-59 < (/.f64 1 n) < -1.00000000000000001e-119

    1. Initial program 12.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 71.2%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{n \cdot x}} + \frac{\frac{0.3333333333333333}{x} + -0.5}{{x}^{2} \cdot n} \]
    9. Step-by-step derivation
      1. *-commutative71.7%

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

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

    if 1e-3 < (/.f64 1 n) < 1.03e214

    1. Initial program 63.8%

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

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

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

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

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

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

        \[\leadsto \left(\frac{x}{n} + 1\right) - \color{blue}{{x}^{\left(\frac{1}{n}\right)}} \]
      6. associate-+r-61.9%

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

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

    if 1.03e214 < (/.f64 1 n)

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{{x}^{\left(\frac{1}{n}\right)}}{x \cdot n} + \color{blue}{\frac{\frac{0.3333333333333333}{n}}{{x}^{3}}} \]
    10. Simplified19.1%

      \[\leadsto \frac{{x}^{\left(\frac{1}{n}\right)}}{x \cdot n} + \color{blue}{\frac{\frac{0.3333333333333333}{n}}{{x}^{3}}} \]
    11. Taylor expanded in n around inf 74.2%

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

        \[\leadsto \frac{\frac{1}{x} + \color{blue}{\frac{0.3333333333333333 \cdot 1}{{x}^{3}}}}{n} \]
      2. metadata-eval74.2%

        \[\leadsto \frac{\frac{1}{x} + \frac{\color{blue}{0.3333333333333333}}{{x}^{3}}}{n} \]
    13. Simplified74.2%

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

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

Alternative 5: 50.3% accurate, 1.6× speedup?

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

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

\mathbf{elif}\;n \leq -60000:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;n \leq 1400:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;n \leq 10^{+280}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;n \leq 8 \cdot 10^{+295}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if n < -2.2e195 or -6e4 < n < 1400 or 1e280 < n < 7.9999999999999999e295

    1. Initial program 75.9%

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

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

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

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

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

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

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

    if -2.2e195 < n < -6e4 or 1400 < n < 1e280

    1. Initial program 20.1%

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

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

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

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

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

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

        \[\leadsto \left(\frac{x}{n} + 1\right) - \color{blue}{{x}^{\left(\frac{1}{n}\right)}} \]
      6. associate-+r-6.1%

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

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

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

    if 7.9999999999999999e295 < n

    1. Initial program 33.4%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -2.2 \cdot 10^{+195}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;n \leq -60000:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{elif}\;n \leq 1400:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;n \leq 10^{+280}:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{elif}\;n \leq 8 \cdot 10^{+295}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log x}{-n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 71.2% accurate, 1.7× speedup?

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

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

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

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

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


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

    1. Initial program 35.9%

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

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

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

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

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

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

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

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

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

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

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

    if 8.7999999999999996e-243 < x < 1.8000000000000001e-202

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

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

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

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

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

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

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

    if 1.8000000000000001e-202 < x < 1.55000000000000007e-5

    1. Initial program 32.1%

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

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

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

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

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

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

        \[\leadsto \left(\frac{x}{n} + 1\right) - \color{blue}{{x}^{\left(\frac{1}{n}\right)}} \]
      6. associate-+r-32.6%

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

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

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

    if 1.55000000000000007e-5 < x

    1. Initial program 62.5%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 8.8 \cdot 10^{-243}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 1.8 \cdot 10^{-202}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 1.55 \cdot 10^{-5}:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{x \cdot n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 71.2% accurate, 1.7× speedup?

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

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

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

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

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


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

    1. Initial program 35.9%

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

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

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

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

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

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

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

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

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

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

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

    if 8e-242 < x < 1.50000000000000005e-202

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

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

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

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

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

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

        \[\leadsto \left(\frac{x}{n} + 1\right) - \color{blue}{{x}^{\left(\frac{1}{n}\right)}} \]
      6. associate-+r-61.5%

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

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

    if 1.50000000000000005e-202 < x < 1.36000000000000002e-5

    1. Initial program 32.1%

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

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

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

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

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

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

        \[\leadsto \left(\frac{x}{n} + 1\right) - \color{blue}{{x}^{\left(\frac{1}{n}\right)}} \]
      6. associate-+r-32.6%

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

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

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

    if 1.36000000000000002e-5 < x

    1. Initial program 62.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 31.2% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \frac{x - \log x}{n} \end{array} \]
(FPCore (x n) :precision binary64 (/ (- x (log x)) n))
double code(double x, double n) {
	return (x - log(x)) / n;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    code = (x - log(x)) / n
end function
public static double code(double x, double n) {
	return (x - Math.log(x)) / n;
}
def code(x, n):
	return (x - math.log(x)) / n
function code(x, n)
	return Float64(Float64(x - log(x)) / n)
end
function tmp = code(x, n)
	tmp = (x - log(x)) / n;
end
code[x_, n_] := N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]
\begin{array}{l}

\\
\frac{x - \log x}{n}
\end{array}
Derivation
  1. Initial program 48.7%

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

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

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

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

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

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

      \[\leadsto \left(\frac{x}{n} + 1\right) - \color{blue}{{x}^{\left(\frac{1}{n}\right)}} \]
    6. associate-+r-22.9%

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

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

    \[\leadsto \color{blue}{\frac{x - \log x}{n}} \]
  7. Final simplification33.2%

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

Alternative 9: 31.2% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \frac{\log x}{-n} \end{array} \]
(FPCore (x n) :precision binary64 (/ (log x) (- n)))
double code(double x, double n) {
	return log(x) / -n;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    code = log(x) / -n
end function
public static double code(double x, double n) {
	return Math.log(x) / -n;
}
def code(x, n):
	return math.log(x) / -n
function code(x, n)
	return Float64(log(x) / Float64(-n))
end
function tmp = code(x, n)
	tmp = log(x) / -n;
end
code[x_, n_] := N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision]
\begin{array}{l}

\\
\frac{\log x}{-n}
\end{array}
Derivation
  1. Initial program 48.7%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\log x}{-n} \]
  10. Add Preprocessing

Alternative 10: 4.6% accurate, 70.3× speedup?

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

\\
\frac{x}{n}
\end{array}
Derivation
  1. Initial program 48.7%

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

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

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

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

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

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

      \[\leadsto \left(\frac{x}{n} + 1\right) - \color{blue}{{x}^{\left(\frac{1}{n}\right)}} \]
    6. associate-+r-22.9%

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

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

    \[\leadsto \color{blue}{\frac{x}{n}} \]
  7. Final simplification4.8%

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

Reproduce

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