2nthrt (problem 3.4.6)

Percentage Accurate: 53.4% → 86.2%
Time: 44.1s
Alternatives: 12
Speedup: 1.8×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 12 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.4% accurate, 1.0× speedup?

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

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

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

\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - t\_0\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{-7}:\\
\;\;\;\;1 - \sqrt[3]{\mathsf{expm1}\left(\mathsf{log1p}\left({x}^{\left(\frac{3}{n}\right)}\right)\right)}\\

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

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


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

    1. Initial program 99.2%

      \[{\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-cbrt-cube99.2%

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

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

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

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

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

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

      \[\leadsto {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - \color{blue}{\sqrt[3]{{x}^{\left(\frac{3}{n}\right)}}} \]
    7. Taylor expanded in x around 0 99.2%

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

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

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

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

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

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

      \[\leadsto \color{blue}{1 - \sqrt[3]{{x}^{\left(\frac{3}{n}\right)}}} \]
    10. Step-by-step derivation
      1. expm1-log1p-u99.3%

        \[\leadsto 1 - \sqrt[3]{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({x}^{\left(\frac{3}{n}\right)}\right)\right)}} \]
      2. expm1-undefine99.3%

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

      \[\leadsto 1 - \sqrt[3]{\color{blue}{e^{\mathsf{log1p}\left({x}^{\left(\frac{3}{n}\right)}\right)} - 1}} \]
    12. Step-by-step derivation
      1. expm1-define99.3%

        \[\leadsto 1 - \sqrt[3]{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({x}^{\left(\frac{3}{n}\right)}\right)\right)}} \]
    13. Simplified99.3%

      \[\leadsto 1 - \sqrt[3]{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({x}^{\left(\frac{3}{n}\right)}\right)\right)}} \]

    if -9.9999999999999995e-8 < (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) < 1e-13

    1. Initial program 40.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 82.3%

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

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

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

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

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

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

    1. Initial program 44.5%

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

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

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

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

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

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - \color{blue}{{x}^{\left(\frac{1}{n}\right)}} \]
    5. Simplified99.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 99.6%

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

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

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

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

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

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


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

    1. Initial program 99.2%

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

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

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

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

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

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

    if -9.9999999999999995e-8 < (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) < 1e-13

    1. Initial program 40.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 82.3%

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

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

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

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

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

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

    1. Initial program 44.5%

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

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

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

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

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

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - \color{blue}{{x}^{\left(\frac{1}{n}\right)}} \]
    5. Simplified99.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 99.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \leq -1 \cdot 10^{-7}:\\ \;\;\;\;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 10^{-13}:\\ \;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;e^{\frac{x}{n}} - {x}^{\left(\frac{1}{n}\right)}\\ \end{array} \]
  5. Add Preprocessing

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

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

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

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


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

    1. Initial program 99.2%

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

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

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

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

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

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

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

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

      \[\leadsto 1 - \color{blue}{\left(e^{\mathsf{log1p}\left({x}^{\left(\frac{1}{n}\right)}\right)} - 1\right)} \]
    8. Step-by-step derivation
      1. expm1-define99.2%

        \[\leadsto 1 - \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({x}^{\left(\frac{1}{n}\right)}\right)\right)} \]
    9. Simplified99.2%

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

    if -9.9999999999999995e-8 < (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) < 1e-13

    1. Initial program 40.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 82.3%

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

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

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

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

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

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

    1. Initial program 44.5%

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

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

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

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

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

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - \color{blue}{{x}^{\left(\frac{1}{n}\right)}} \]
    5. Simplified99.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 99.6%

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

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

Alternative 4: 83.2% accurate, 0.9× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (/.f64 1 n) < -4.99999999999999977e-7

    1. Initial program 97.6%

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

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

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

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

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

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

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

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

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

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

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

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

    if -4.99999999999999977e-7 < (/.f64 1 n) < 4.99999999999999999e-15

    1. Initial program 30.1%

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

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

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

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

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

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

    if 4.99999999999999999e-15 < (/.f64 1 n) < 2.00000000000000007e121

    1. Initial program 65.8%

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

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

    if 2.00000000000000007e121 < (/.f64 1 n)

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

      \[\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. Taylor expanded in x around inf 0.1%

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{n} + \frac{\color{blue}{\log x}}{{n}^{2}}}{x} \]
    6. Simplified0.1%

      \[\leadsto \color{blue}{\frac{\frac{1}{n} + \frac{\log x}{{n}^{2}}}{x}} \]
    7. Taylor expanded in n around inf 55.0%

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

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

      \[\leadsto \color{blue}{\frac{1}{x \cdot n}} \]
    10. Step-by-step derivation
      1. log1p-expm1-u79.6%

        \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{x \cdot n}\right)\right)} \]
      2. associate-/r*79.6%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\frac{\frac{1}{x}}{n}}\right)\right) \]
      3. rem-exp-log79.6%

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

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{e^{\color{blue}{-\log x}}}{n}\right)\right) \]
      5. add-sqr-sqrt79.6%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{e^{\color{blue}{\sqrt{-\log x} \cdot \sqrt{-\log x}}}}{n}\right)\right) \]
      6. sqrt-unprod79.6%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{e^{\color{blue}{\sqrt{\left(-\log x\right) \cdot \left(-\log x\right)}}}}{n}\right)\right) \]
      7. sqr-neg79.6%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{e^{\sqrt{\color{blue}{\log x \cdot \log x}}}}{n}\right)\right) \]
      8. sqrt-unprod0.0%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{e^{\color{blue}{\sqrt{\log x} \cdot \sqrt{\log x}}}}{n}\right)\right) \]
      9. add-sqr-sqrt80.8%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{e^{\color{blue}{\log x}}}{n}\right)\right) \]
      10. add-exp-log80.8%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\color{blue}{x}}{n}\right)\right) \]
    11. Applied egg-rr80.8%

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

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

Alternative 5: 67.2% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{\log x}{-n}\\
\mathbf{if}\;x \leq 8.5 \cdot 10^{-190}:\\
\;\;\;\;t\_0\\

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

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

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

\mathbf{elif}\;x \leq 2.2 \cdot 10^{-60}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if x < 8.5000000000000003e-190 or 2.80000000000000012e-73 < x < 2.1999999999999999e-60

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

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

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

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

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

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

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

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

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

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

    if 8.5000000000000003e-190 < x < 4.1999999999999999e-172

    1. Initial program 83.9%

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

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

    if 4.1999999999999999e-172 < x < 3.1e-136

    1. Initial program 36.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 36.9%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{-\log x}{n}} \]
    9. Step-by-step derivation
      1. div-inv63.3%

        \[\leadsto \color{blue}{\left(-\log x\right) \cdot \frac{1}{n}} \]
    10. Applied egg-rr63.3%

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

    if 3.1e-136 < x < 2.80000000000000012e-73

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

      \[\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. Taylor expanded in x around inf 27.4%

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

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

        \[\leadsto \frac{\frac{1}{n} + \color{blue}{\left(-\frac{\log \left(\frac{1}{x}\right)}{{n}^{2}}\right)}}{x} \]
      3. distribute-frac-neg27.4%

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

        \[\leadsto \frac{\frac{1}{n} + \frac{-\color{blue}{\left(-\log x\right)}}{{n}^{2}}}{x} \]
      5. remove-double-neg27.4%

        \[\leadsto \frac{\frac{1}{n} + \frac{\color{blue}{\log x}}{{n}^{2}}}{x} \]
    6. Simplified27.4%

      \[\leadsto \color{blue}{\frac{\frac{1}{n} + \frac{\log x}{{n}^{2}}}{x}} \]
    7. Taylor expanded in n around inf 37.6%

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

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

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

        \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{x \cdot n}\right)\right)} \]
      2. associate-/r*60.1%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\frac{\frac{1}{x}}{n}}\right)\right) \]
      3. rem-exp-log60.1%

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

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{e^{\color{blue}{-\log x}}}{n}\right)\right) \]
      5. add-sqr-sqrt60.1%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{e^{\color{blue}{\sqrt{-\log x} \cdot \sqrt{-\log x}}}}{n}\right)\right) \]
      6. sqrt-unprod60.1%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{e^{\color{blue}{\sqrt{\left(-\log x\right) \cdot \left(-\log x\right)}}}}{n}\right)\right) \]
      7. sqr-neg60.1%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{e^{\sqrt{\color{blue}{\log x \cdot \log x}}}}{n}\right)\right) \]
      8. sqrt-unprod0.0%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{e^{\color{blue}{\sqrt{\log x} \cdot \sqrt{\log x}}}}{n}\right)\right) \]
      9. add-sqr-sqrt57.2%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{e^{\color{blue}{\log x}}}{n}\right)\right) \]
      10. add-exp-log57.2%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\color{blue}{x}}{n}\right)\right) \]
    11. Applied egg-rr57.2%

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

    if 2.1999999999999999e-60 < x

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{{x}^{\color{blue}{\left(\frac{1}{n} + \left(-1\right)\right)}}}{n} \]
      3. metadata-eval84.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 8.5 \cdot 10^{-190}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 4.2 \cdot 10^{-172}:\\ \;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 3.1 \cdot 10^{-136}:\\ \;\;\;\;\log x \cdot \frac{-1}{n}\\ \mathbf{elif}\;x \leq 2.8 \cdot 10^{-73}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x}{n}\right)\right)\\ \mathbf{elif}\;x \leq 2.2 \cdot 10^{-60}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{else}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n} + -1\right)}}{n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 54.6% accurate, 1.7× speedup?

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

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

\mathbf{elif}\;x \leq 2.4 \cdot 10^{-171}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 2.3 \cdot 10^{-60}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 435:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 1.00000000000000007e-189 or 2.39999999999999987e-171 < x < 2.3000000000000001e-60

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

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

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

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

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

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

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

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

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

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

    if 1.00000000000000007e-189 < x < 2.39999999999999987e-171 or 2.3000000000000001e-60 < x < 435

    1. Initial program 62.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 56.0%

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

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

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

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

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

    if 435 < x

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

      \[\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. Taylor expanded in x around inf 68.9%

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

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

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

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

        \[\leadsto \frac{\frac{1}{n} + \frac{-\color{blue}{\left(-\log x\right)}}{{n}^{2}}}{x} \]
      5. remove-double-neg68.9%

        \[\leadsto \frac{\frac{1}{n} + \frac{\color{blue}{\log x}}{{n}^{2}}}{x} \]
    6. Simplified68.9%

      \[\leadsto \color{blue}{\frac{\frac{1}{n} + \frac{\log x}{{n}^{2}}}{x}} \]
    7. Taylor expanded in n around inf 67.9%

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

        \[\leadsto \color{blue}{\frac{\frac{1}{n}}{x}} \]
    9. Simplified68.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 10^{-189}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 2.4 \cdot 10^{-171}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 2.3 \cdot 10^{-60}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 435:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 68.8% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{\log x}{-n}\\
\mathbf{if}\;x \leq 2.6 \cdot 10^{-190}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;x \leq 2.3 \cdot 10^{-60}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 2.5999999999999998e-190 or 4.1e-171 < x < 2.3000000000000001e-60

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

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

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

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

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

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

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

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

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

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

    if 2.5999999999999998e-190 < x < 4.1e-171

    1. Initial program 83.9%

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

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

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

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

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

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

    if 2.3000000000000001e-60 < x

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{{x}^{\color{blue}{\left(\frac{1}{n} + \left(-1\right)\right)}}}{n} \]
      3. metadata-eval84.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 2.6 \cdot 10^{-190}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 4.1 \cdot 10^{-171}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 2.3 \cdot 10^{-60}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{else}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n} + -1\right)}}{n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 69.0% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{\log x}{-n}\\
\mathbf{if}\;x \leq 6.4 \cdot 10^{-190}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;x \leq 2.3 \cdot 10^{-60}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 6.4000000000000001e-190 or 4.2999999999999997e-172 < x < 2.3000000000000001e-60

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

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

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

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

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

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

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

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

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

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

    if 6.4000000000000001e-190 < x < 4.2999999999999997e-172

    1. Initial program 83.9%

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

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

    if 2.3000000000000001e-60 < x

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{{x}^{\color{blue}{\left(\frac{1}{n} + \left(-1\right)\right)}}}{n} \]
      3. metadata-eval84.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 6.4 \cdot 10^{-190}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 4.3 \cdot 10^{-172}:\\ \;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 2.3 \cdot 10^{-60}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{else}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n} + -1\right)}}{n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 56.6% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\log x}{-n}\\ \mathbf{if}\;x \leq 4.7 \cdot 10^{-237}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 5.4 \cdot 10^{-229}:\\ \;\;\;\;\frac{1}{x \cdot n}\\ \mathbf{elif}\;x \leq 7.8 \cdot 10^{-7}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (/ (log x) (- n))))
   (if (<= x 4.7e-237)
     t_0
     (if (<= x 5.4e-229)
       (/ 1.0 (* x n))
       (if (<= x 7.8e-7) t_0 (/ (/ 1.0 n) x))))))
double code(double x, double n) {
	double t_0 = log(x) / -n;
	double tmp;
	if (x <= 4.7e-237) {
		tmp = t_0;
	} else if (x <= 5.4e-229) {
		tmp = 1.0 / (x * n);
	} else if (x <= 7.8e-7) {
		tmp = 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) :: tmp
    t_0 = log(x) / -n
    if (x <= 4.7d-237) then
        tmp = t_0
    else if (x <= 5.4d-229) then
        tmp = 1.0d0 / (x * n)
    else if (x <= 7.8d-7) then
        tmp = 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.log(x) / -n;
	double tmp;
	if (x <= 4.7e-237) {
		tmp = t_0;
	} else if (x <= 5.4e-229) {
		tmp = 1.0 / (x * n);
	} else if (x <= 7.8e-7) {
		tmp = t_0;
	} else {
		tmp = (1.0 / n) / x;
	}
	return tmp;
}
def code(x, n):
	t_0 = math.log(x) / -n
	tmp = 0
	if x <= 4.7e-237:
		tmp = t_0
	elif x <= 5.4e-229:
		tmp = 1.0 / (x * n)
	elif x <= 7.8e-7:
		tmp = t_0
	else:
		tmp = (1.0 / n) / x
	return tmp
function code(x, n)
	t_0 = Float64(log(x) / Float64(-n))
	tmp = 0.0
	if (x <= 4.7e-237)
		tmp = t_0;
	elseif (x <= 5.4e-229)
		tmp = Float64(1.0 / Float64(x * n));
	elseif (x <= 7.8e-7)
		tmp = t_0;
	else
		tmp = Float64(Float64(1.0 / n) / x);
	end
	return tmp
end
function tmp_2 = code(x, n)
	t_0 = log(x) / -n;
	tmp = 0.0;
	if (x <= 4.7e-237)
		tmp = t_0;
	elseif (x <= 5.4e-229)
		tmp = 1.0 / (x * n);
	elseif (x <= 7.8e-7)
		tmp = t_0;
	else
		tmp = (1.0 / n) / x;
	end
	tmp_2 = tmp;
end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision]}, If[LessEqual[x, 4.7e-237], t$95$0, If[LessEqual[x, 5.4e-229], N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 7.8e-7], t$95$0, N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\log x}{-n}\\
\mathbf{if}\;x \leq 4.7 \cdot 10^{-237}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;x \leq 7.8 \cdot 10^{-7}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 4.6999999999999998e-237 or 5.3999999999999997e-229 < x < 7.80000000000000049e-7

    1. Initial program 43.0%

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

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

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

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

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

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

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

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

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

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

    if 4.6999999999999998e-237 < x < 5.3999999999999997e-229

    1. Initial program 76.1%

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

      \[\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. Taylor expanded in x around inf 58.7%

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

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

        \[\leadsto \frac{\frac{1}{n} + \color{blue}{\left(-\frac{\log \left(\frac{1}{x}\right)}{{n}^{2}}\right)}}{x} \]
      3. distribute-frac-neg58.7%

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

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

        \[\leadsto \frac{\frac{1}{n} + \frac{\color{blue}{\log x}}{{n}^{2}}}{x} \]
    6. Simplified58.7%

      \[\leadsto \color{blue}{\frac{\frac{1}{n} + \frac{\log x}{{n}^{2}}}{x}} \]
    7. Taylor expanded in n around inf 72.9%

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

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

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

    if 7.80000000000000049e-7 < x

    1. Initial program 69.4%

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

      \[\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. Taylor expanded in x around inf 67.8%

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{n} + \frac{\color{blue}{\log x}}{{n}^{2}}}{x} \]
    6. Simplified67.8%

      \[\leadsto \color{blue}{\frac{\frac{1}{n} + \frac{\log x}{{n}^{2}}}{x}} \]
    7. Taylor expanded in n around inf 65.9%

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

        \[\leadsto \color{blue}{\frac{\frac{1}{n}}{x}} \]
    9. Simplified66.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 4.7 \cdot 10^{-237}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 5.4 \cdot 10^{-229}:\\ \;\;\;\;\frac{1}{x \cdot n}\\ \mathbf{elif}\;x \leq 7.8 \cdot 10^{-7}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 40.1% accurate, 42.2× speedup?

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

\\
\frac{1}{x \cdot n}
\end{array}
Derivation
  1. Initial program 53.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 51.7%

    \[\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. Taylor expanded in x around inf 41.0%

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

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

      \[\leadsto \frac{\frac{1}{n} + \color{blue}{\left(-\frac{\log \left(\frac{1}{x}\right)}{{n}^{2}}\right)}}{x} \]
    3. distribute-frac-neg41.0%

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

      \[\leadsto \frac{\frac{1}{n} + \frac{-\color{blue}{\left(-\log x\right)}}{{n}^{2}}}{x} \]
    5. remove-double-neg41.0%

      \[\leadsto \frac{\frac{1}{n} + \frac{\color{blue}{\log x}}{{n}^{2}}}{x} \]
  6. Simplified41.0%

    \[\leadsto \color{blue}{\frac{\frac{1}{n} + \frac{\log x}{{n}^{2}}}{x}} \]
  7. Taylor expanded in n around inf 39.6%

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

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

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

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

Alternative 11: 40.5% 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 53.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 51.7%

    \[\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. Taylor expanded in x around inf 41.0%

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

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

      \[\leadsto \frac{\frac{1}{n} + \color{blue}{\left(-\frac{\log \left(\frac{1}{x}\right)}{{n}^{2}}\right)}}{x} \]
    3. distribute-frac-neg41.0%

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

      \[\leadsto \frac{\frac{1}{n} + \frac{-\color{blue}{\left(-\log x\right)}}{{n}^{2}}}{x} \]
    5. remove-double-neg41.0%

      \[\leadsto \frac{\frac{1}{n} + \frac{\color{blue}{\log x}}{{n}^{2}}}{x} \]
  6. Simplified41.0%

    \[\leadsto \color{blue}{\frac{\frac{1}{n} + \frac{\log x}{{n}^{2}}}{x}} \]
  7. Taylor expanded in n around inf 39.6%

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

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

    \[\leadsto \color{blue}{\frac{\frac{1}{n}}{x}} \]
  10. Final simplification39.8%

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

Alternative 12: 4.5% accurate, 70.3× speedup?

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

\\
\frac{x}{n}
\end{array}
Derivation
  1. Initial program 53.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 51.7%

    \[\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. Taylor expanded in x around inf 41.0%

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

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

      \[\leadsto \frac{\frac{1}{n} + \color{blue}{\left(-\frac{\log \left(\frac{1}{x}\right)}{{n}^{2}}\right)}}{x} \]
    3. distribute-frac-neg41.0%

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

      \[\leadsto \frac{\frac{1}{n} + \frac{-\color{blue}{\left(-\log x\right)}}{{n}^{2}}}{x} \]
    5. remove-double-neg41.0%

      \[\leadsto \frac{\frac{1}{n} + \frac{\color{blue}{\log x}}{{n}^{2}}}{x} \]
  6. Simplified41.0%

    \[\leadsto \color{blue}{\frac{\frac{1}{n} + \frac{\log x}{{n}^{2}}}{x}} \]
  7. Taylor expanded in n around inf 39.6%

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

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

    \[\leadsto \color{blue}{\frac{1}{x \cdot n}} \]
  10. Step-by-step derivation
    1. inv-pow39.6%

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

      \[\leadsto \color{blue}{{x}^{-1} \cdot {n}^{-1}} \]
    3. pow-to-exp39.1%

      \[\leadsto \color{blue}{e^{\log x \cdot -1}} \cdot {n}^{-1} \]
    4. *-commutative39.1%

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

      \[\leadsto e^{\color{blue}{-\log x}} \cdot {n}^{-1} \]
    6. add-sqr-sqrt15.0%

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

      \[\leadsto e^{\color{blue}{\sqrt{\left(-\log x\right) \cdot \left(-\log x\right)}}} \cdot {n}^{-1} \]
    8. sqr-neg16.3%

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

      \[\leadsto e^{\color{blue}{\sqrt{\log x} \cdot \sqrt{\log x}}} \cdot {n}^{-1} \]
    10. add-sqr-sqrt4.6%

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

      \[\leadsto \color{blue}{x} \cdot {n}^{-1} \]
    12. inv-pow4.6%

      \[\leadsto x \cdot \color{blue}{\frac{1}{n}} \]
  11. Applied egg-rr4.6%

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

      \[\leadsto \color{blue}{\frac{x \cdot 1}{n}} \]
    2. *-rgt-identity4.6%

      \[\leadsto \frac{\color{blue}{x}}{n} \]
  13. Simplified4.6%

    \[\leadsto \color{blue}{\frac{x}{n}} \]
  14. Final simplification4.6%

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

Reproduce

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