2nthrt (problem 3.4.6)

Percentage Accurate: 53.6% → 86.2%
Time: 27.6s
Alternatives: 16
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 16 alternatives:

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

Initial Program: 53.6% 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.1× speedup?

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

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

\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-7}:\\
\;\;\;\;\left(\frac{t_0 - \log x}{n} + \left(\frac{-0.16666666666666666 \cdot {\log x}^{3} - -0.16666666666666666 \cdot {t_0}^{3}}{{n}^{3}} + \left(0.041666666666666664 \cdot \frac{{t_0}^{4}}{{n}^{4}} + 0.5 \cdot \frac{{t_0}^{2}}{{n}^{2}}\right)\right)\right) - \left(0.041666666666666664 \cdot \frac{{\log x}^{4}}{{n}^{4}} + 0.5 \cdot \frac{{\log x}^{2}}{{n}^{2}}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 1 n) < -1.9999999999999998e-71

    1. Initial program 89.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.9999999999999998e-71 < (/.f64 1 n) < 3.9999999999999998e-7

    1. Initial program 33.7%

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

      \[\leadsto \color{blue}{\left(-1 \cdot \frac{-1 \cdot \log \left(1 + x\right) - -1 \cdot \log x}{n} + \left(-1 \cdot \frac{-0.16666666666666666 \cdot {\log \left(1 + x\right)}^{3} - -0.16666666666666666 \cdot {\log x}^{3}}{{n}^{3}} + \left(0.041666666666666664 \cdot \frac{{\log \left(1 + x\right)}^{4}}{{n}^{4}} + 0.5 \cdot \frac{{\log \left(1 + x\right)}^{2}}{{n}^{2}}\right)\right)\right) - \left(0.041666666666666664 \cdot \frac{{\log x}^{4}}{{n}^{4}} + 0.5 \cdot \frac{{\log x}^{2}}{{n}^{2}}\right)} \]

    if 3.9999999999999998e-7 < (/.f64 1 n)

    1. Initial program 45.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 0 45.0%

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

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

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

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

Alternative 2: 86.2% accurate, 0.2× speedup?

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

\mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-7}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n} + \left(\frac{0.16666666666666666}{\frac{{n}^{3}}{{\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}}} + 0.5 \cdot \left(\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{{n}^{2}} - \frac{{\log x}^{2}}{{n}^{2}}\right)\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 1 n) < -1.9999999999999998e-71

    1. Initial program 89.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.9999999999999998e-71 < (/.f64 1 n) < 3.9999999999999998e-7

    1. Initial program 33.7%

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{\left(-1 \cdot -1\right) \cdot \left(\log \left(1 + x\right) - \log x\right)}}{n} + \left(\left(-1 \cdot \frac{-0.16666666666666666 \cdot {\log \left(1 + x\right)}^{3} - -0.16666666666666666 \cdot {\log x}^{3}}{{n}^{3}} + 0.5 \cdot \frac{{\log \left(1 + x\right)}^{2}}{{n}^{2}}\right) - 0.5 \cdot \frac{{\log x}^{2}}{{n}^{2}}\right) \]
      5. metadata-eval80.8%

        \[\leadsto \frac{\color{blue}{1} \cdot \left(\log \left(1 + x\right) - \log x\right)}{n} + \left(\left(-1 \cdot \frac{-0.16666666666666666 \cdot {\log \left(1 + x\right)}^{3} - -0.16666666666666666 \cdot {\log x}^{3}}{{n}^{3}} + 0.5 \cdot \frac{{\log \left(1 + x\right)}^{2}}{{n}^{2}}\right) - 0.5 \cdot \frac{{\log x}^{2}}{{n}^{2}}\right) \]
      6. *-lft-identity80.8%

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

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

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

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

    if 3.9999999999999998e-7 < (/.f64 1 n)

    1. Initial program 45.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 0 45.0%

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

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

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

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

Alternative 3: 85.9% accurate, 0.3× speedup?

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

\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-18}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n} + 0.5 \cdot \left(\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{{n}^{2}} - \frac{{\log x}^{2}}{{n}^{2}}\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 1 n) < -1.9999999999999998e-71

    1. Initial program 89.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.9999999999999998e-71 < (/.f64 1 n) < 2.0000000000000001e-18

    1. Initial program 33.5%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in n around inf 81.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. Step-by-step derivation
      1. associate--l+76.0%

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

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

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

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

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

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

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

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

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

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

    if 2.0000000000000001e-18 < (/.f64 1 n)

    1. Initial program 45.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 0 45.0%

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

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

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

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

Alternative 4: 85.9% accurate, 0.7× speedup?

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

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

\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-18}:\\
\;\;\;\;\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 1 n) < -1.9999999999999998e-71

    1. Initial program 89.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.9999999999999998e-71 < (/.f64 1 n) < 2.0000000000000001e-18

    1. Initial program 33.5%

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

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

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

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

    if 2.0000000000000001e-18 < (/.f64 1 n)

    1. Initial program 45.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 0 45.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-71}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-18}:\\ \;\;\;\;\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 5: 71.2% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {x}^{\left(\frac{1}{n}\right)}\\ t_1 := \frac{-\log x}{n}\\ \mathbf{if}\;x \leq 4.1 \cdot 10^{-305}:\\ \;\;\;\;1 - t_0\\ \mathbf{elif}\;x \leq 5.5 \cdot 10^{-235}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 3.5 \cdot 10^{-173}:\\ \;\;\;\;\left(1 + \frac{x}{n}\right) - t_0\\ \mathbf{elif}\;x \leq 6.3 \cdot 10^{-71}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 0.0105:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\frac{1}{x}}{n}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{t_0}{x}}{n}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ (- (log x)) n)))
   (if (<= x 4.1e-305)
     (- 1.0 t_0)
     (if (<= x 5.5e-235)
       t_1
       (if (<= x 3.5e-173)
         (- (+ 1.0 (/ x n)) t_0)
         (if (<= x 6.3e-71)
           t_1
           (if (<= x 0.0105)
             (log1p (expm1 (/ (/ 1.0 x) n)))
             (/ (/ t_0 x) n))))))))
double code(double x, double n) {
	double t_0 = pow(x, (1.0 / n));
	double t_1 = -log(x) / n;
	double tmp;
	if (x <= 4.1e-305) {
		tmp = 1.0 - t_0;
	} else if (x <= 5.5e-235) {
		tmp = t_1;
	} else if (x <= 3.5e-173) {
		tmp = (1.0 + (x / n)) - t_0;
	} else if (x <= 6.3e-71) {
		tmp = t_1;
	} else if (x <= 0.0105) {
		tmp = log1p(expm1(((1.0 / x) / n)));
	} else {
		tmp = (t_0 / x) / n;
	}
	return tmp;
}
public static double code(double x, double n) {
	double t_0 = Math.pow(x, (1.0 / n));
	double t_1 = -Math.log(x) / n;
	double tmp;
	if (x <= 4.1e-305) {
		tmp = 1.0 - t_0;
	} else if (x <= 5.5e-235) {
		tmp = t_1;
	} else if (x <= 3.5e-173) {
		tmp = (1.0 + (x / n)) - t_0;
	} else if (x <= 6.3e-71) {
		tmp = t_1;
	} else if (x <= 0.0105) {
		tmp = Math.log1p(Math.expm1(((1.0 / x) / n)));
	} else {
		tmp = (t_0 / x) / n;
	}
	return tmp;
}
def code(x, n):
	t_0 = math.pow(x, (1.0 / n))
	t_1 = -math.log(x) / n
	tmp = 0
	if x <= 4.1e-305:
		tmp = 1.0 - t_0
	elif x <= 5.5e-235:
		tmp = t_1
	elif x <= 3.5e-173:
		tmp = (1.0 + (x / n)) - t_0
	elif x <= 6.3e-71:
		tmp = t_1
	elif x <= 0.0105:
		tmp = math.log1p(math.expm1(((1.0 / x) / n)))
	else:
		tmp = (t_0 / x) / n
	return tmp
function code(x, n)
	t_0 = x ^ Float64(1.0 / n)
	t_1 = Float64(Float64(-log(x)) / n)
	tmp = 0.0
	if (x <= 4.1e-305)
		tmp = Float64(1.0 - t_0);
	elseif (x <= 5.5e-235)
		tmp = t_1;
	elseif (x <= 3.5e-173)
		tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0);
	elseif (x <= 6.3e-71)
		tmp = t_1;
	elseif (x <= 0.0105)
		tmp = log1p(expm1(Float64(Float64(1.0 / x) / n)));
	else
		tmp = Float64(Float64(t_0 / x) / 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[Log[x], $MachinePrecision]) / n), $MachinePrecision]}, If[LessEqual[x, 4.1e-305], N[(1.0 - t$95$0), $MachinePrecision], If[LessEqual[x, 5.5e-235], t$95$1, If[LessEqual[x, 3.5e-173], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[x, 6.3e-71], t$95$1, If[LessEqual[x, 0.0105], N[Log[1 + N[(Exp[N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision], N[(N[(t$95$0 / x), $MachinePrecision] / n), $MachinePrecision]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq 5.5 \cdot 10^{-235}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;x \leq 6.3 \cdot 10^{-71}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 0.0105:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\frac{1}{x}}{n}\right)\right)\\

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


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

    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} - {x}^{\left(\frac{1}{n}\right)} \]

    if 4.1000000000000002e-305 < x < 5.4999999999999998e-235 or 3.50000000000000014e-173 < x < 6.3000000000000003e-71

    1. Initial program 35.4%

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

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

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

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

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

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

    if 5.4999999999999998e-235 < x < 3.50000000000000014e-173

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

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

    if 6.3000000000000003e-71 < x < 0.0105000000000000007

    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 x around inf 36.7%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Taylor expanded in n around inf 19.5%

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

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

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

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

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

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

    if 0.0105000000000000007 < 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 x around inf 96.1%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Step-by-step derivation
      1. expm1-log1p-u96.1%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{{x}^{\left(\frac{1}{n} + -1\right)}}{n}} \]
    10. Step-by-step derivation
      1. pow-prod-up97.7%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 4.1 \cdot 10^{-305}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 5.5 \cdot 10^{-235}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 3.5 \cdot 10^{-173}:\\ \;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 6.3 \cdot 10^{-71}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 0.0105:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\frac{1}{x}}{n}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{x}}{n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 82.3% accurate, 0.9× speedup?

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

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

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

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

\mathbf{else}:\\
\;\;\;\;\sqrt{{\left(n \cdot x\right)}^{-2}}\\


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

    1. Initial program 89.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.9999999999999998e-71 < (/.f64 1 n) < 2e-16

    1. Initial program 33.2%

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

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

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

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

    if 2e-16 < (/.f64 1 n) < 1.00000000000000004e154

    1. Initial program 71.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 67.3%

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

    if 1.00000000000000004e154 < (/.f64 1 n)

    1. Initial program 17.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 0.4%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Taylor expanded in n around inf 55.3%

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

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

      \[\leadsto \color{blue}{\frac{1}{x \cdot n}} \]
    9. Step-by-step derivation
      1. add-sqr-sqrt55.3%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{x \cdot n}} \cdot \sqrt{\frac{1}{x \cdot n}}} \]
      2. sqrt-unprod79.8%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{x \cdot n} \cdot \frac{1}{x \cdot n}}} \]
      3. inv-pow79.8%

        \[\leadsto \sqrt{\color{blue}{{\left(x \cdot n\right)}^{-1}} \cdot \frac{1}{x \cdot n}} \]
      4. inv-pow79.8%

        \[\leadsto \sqrt{{\left(x \cdot n\right)}^{-1} \cdot \color{blue}{{\left(x \cdot n\right)}^{-1}}} \]
      5. pow-prod-up79.8%

        \[\leadsto \sqrt{\color{blue}{{\left(x \cdot n\right)}^{\left(-1 + -1\right)}}} \]
      6. metadata-eval79.8%

        \[\leadsto \sqrt{{\left(x \cdot n\right)}^{\color{blue}{-2}}} \]
    10. Applied egg-rr79.8%

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

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

Alternative 7: 67.6% accurate, 0.9× speedup?

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

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

\mathbf{elif}\;n \leq -1.65 \cdot 10^{+71}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;n \leq 1.35 \cdot 10^{-160}:\\
\;\;\;\;\sqrt{{\left(n \cdot x\right)}^{-2}}\\

\mathbf{elif}\;n \leq 42000:\\
\;\;\;\;\left(1 + \frac{x}{n}\right) - t_0\\

\mathbf{elif}\;n \leq 1.02 \cdot 10^{+180}:\\
\;\;\;\;\frac{\frac{t_0}{x}}{n}\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 6 regimes
  2. if n < -2.99999999999999991e95

    1. Initial program 46.1%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Step-by-step derivation
      1. expm1-log1p-u62.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{1}{n}}{x}} \]
    12. Simplified63.7%

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

    if -2.99999999999999991e95 < n < -1.6499999999999999e71 or 1.02e180 < n

    1. Initial program 25.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 25.8%

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

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

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

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

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

    if -1.6499999999999999e71 < n < -2.0000000000019e-312

    1. Initial program 89.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.0000000000019e-312 < n < 1.35000000000000005e-160

    1. Initial program 17.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 0.4%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Taylor expanded in n around inf 55.3%

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

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

      \[\leadsto \color{blue}{\frac{1}{x \cdot n}} \]
    9. Step-by-step derivation
      1. add-sqr-sqrt55.3%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{x \cdot n}} \cdot \sqrt{\frac{1}{x \cdot n}}} \]
      2. sqrt-unprod79.8%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{x \cdot n} \cdot \frac{1}{x \cdot n}}} \]
      3. inv-pow79.8%

        \[\leadsto \sqrt{\color{blue}{{\left(x \cdot n\right)}^{-1}} \cdot \frac{1}{x \cdot n}} \]
      4. inv-pow79.8%

        \[\leadsto \sqrt{{\left(x \cdot n\right)}^{-1} \cdot \color{blue}{{\left(x \cdot n\right)}^{-1}}} \]
      5. pow-prod-up79.8%

        \[\leadsto \sqrt{\color{blue}{{\left(x \cdot n\right)}^{\left(-1 + -1\right)}}} \]
      6. metadata-eval79.8%

        \[\leadsto \sqrt{{\left(x \cdot n\right)}^{\color{blue}{-2}}} \]
    10. Applied egg-rr79.8%

      \[\leadsto \color{blue}{\sqrt{{\left(x \cdot n\right)}^{-2}}} \]

    if 1.35000000000000005e-160 < n < 42000

    1. Initial program 78.5%

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

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

    if 42000 < n < 1.02e180

    1. Initial program 22.0%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Step-by-step derivation
      1. expm1-log1p-u55.6%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{{x}^{\left(\frac{1}{n} + -1\right)}}{n}} \]
    10. Step-by-step derivation
      1. pow-prod-up57.5%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -3 \cdot 10^{+95}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \mathbf{elif}\;n \leq -1.65 \cdot 10^{+71}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;n \leq -2 \cdot 10^{-312}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\ \mathbf{elif}\;n \leq 1.35 \cdot 10^{-160}:\\ \;\;\;\;\sqrt{{\left(n \cdot x\right)}^{-2}}\\ \mathbf{elif}\;n \leq 42000:\\ \;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;n \leq 1.02 \cdot 10^{+180}:\\ \;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{x}}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\log x}{n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 85.9% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-16}:\\
\;\;\;\;\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 1 n) < -1.9999999999999998e-71

    1. Initial program 89.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.9999999999999998e-71 < (/.f64 1 n) < 2e-16

    1. Initial program 33.2%

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

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

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

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

    if 2e-16 < (/.f64 1 n)

    1. Initial program 46.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 0 46.0%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-71}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-16}:\\ \;\;\;\;\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 9: 69.8% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {x}^{\left(\frac{1}{n}\right)}\\ t_1 := 1 - t_0\\ t_2 := \frac{-\log x}{n}\\ \mathbf{if}\;x \leq 4.2 \cdot 10^{-305}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2 \cdot 10^{-235}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{-172}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2.4 \cdot 10^{-45}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 8.2 \cdot 10^{-24}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 0.0106:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{t_0}{x}}{n}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (pow x (/ 1.0 n))) (t_1 (- 1.0 t_0)) (t_2 (/ (- (log x)) n)))
   (if (<= x 4.2e-305)
     t_1
     (if (<= x 2e-235)
       t_2
       (if (<= x 1.4e-172)
         t_1
         (if (<= x 2.4e-45)
           t_2
           (if (<= x 8.2e-24) t_1 (if (<= x 0.0106) t_2 (/ (/ t_0 x) n)))))))))
double code(double x, double n) {
	double t_0 = pow(x, (1.0 / n));
	double t_1 = 1.0 - t_0;
	double t_2 = -log(x) / n;
	double tmp;
	if (x <= 4.2e-305) {
		tmp = t_1;
	} else if (x <= 2e-235) {
		tmp = t_2;
	} else if (x <= 1.4e-172) {
		tmp = t_1;
	} else if (x <= 2.4e-45) {
		tmp = t_2;
	} else if (x <= 8.2e-24) {
		tmp = t_1;
	} else if (x <= 0.0106) {
		tmp = t_2;
	} 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) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_0 = x ** (1.0d0 / n)
    t_1 = 1.0d0 - t_0
    t_2 = -log(x) / n
    if (x <= 4.2d-305) then
        tmp = t_1
    else if (x <= 2d-235) then
        tmp = t_2
    else if (x <= 1.4d-172) then
        tmp = t_1
    else if (x <= 2.4d-45) then
        tmp = t_2
    else if (x <= 8.2d-24) then
        tmp = t_1
    else if (x <= 0.0106d0) then
        tmp = t_2
    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 t_1 = 1.0 - t_0;
	double t_2 = -Math.log(x) / n;
	double tmp;
	if (x <= 4.2e-305) {
		tmp = t_1;
	} else if (x <= 2e-235) {
		tmp = t_2;
	} else if (x <= 1.4e-172) {
		tmp = t_1;
	} else if (x <= 2.4e-45) {
		tmp = t_2;
	} else if (x <= 8.2e-24) {
		tmp = t_1;
	} else if (x <= 0.0106) {
		tmp = t_2;
	} else {
		tmp = (t_0 / x) / n;
	}
	return tmp;
}
def code(x, n):
	t_0 = math.pow(x, (1.0 / n))
	t_1 = 1.0 - t_0
	t_2 = -math.log(x) / n
	tmp = 0
	if x <= 4.2e-305:
		tmp = t_1
	elif x <= 2e-235:
		tmp = t_2
	elif x <= 1.4e-172:
		tmp = t_1
	elif x <= 2.4e-45:
		tmp = t_2
	elif x <= 8.2e-24:
		tmp = t_1
	elif x <= 0.0106:
		tmp = t_2
	else:
		tmp = (t_0 / x) / n
	return tmp
function code(x, n)
	t_0 = x ^ Float64(1.0 / n)
	t_1 = Float64(1.0 - t_0)
	t_2 = Float64(Float64(-log(x)) / n)
	tmp = 0.0
	if (x <= 4.2e-305)
		tmp = t_1;
	elseif (x <= 2e-235)
		tmp = t_2;
	elseif (x <= 1.4e-172)
		tmp = t_1;
	elseif (x <= 2.4e-45)
		tmp = t_2;
	elseif (x <= 8.2e-24)
		tmp = t_1;
	elseif (x <= 0.0106)
		tmp = t_2;
	else
		tmp = Float64(Float64(t_0 / x) / n);
	end
	return tmp
end
function tmp_2 = code(x, n)
	t_0 = x ^ (1.0 / n);
	t_1 = 1.0 - t_0;
	t_2 = -log(x) / n;
	tmp = 0.0;
	if (x <= 4.2e-305)
		tmp = t_1;
	elseif (x <= 2e-235)
		tmp = t_2;
	elseif (x <= 1.4e-172)
		tmp = t_1;
	elseif (x <= 2.4e-45)
		tmp = t_2;
	elseif (x <= 8.2e-24)
		tmp = t_1;
	elseif (x <= 0.0106)
		tmp = t_2;
	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]}, Block[{t$95$1 = N[(1.0 - t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision]}, If[LessEqual[x, 4.2e-305], t$95$1, If[LessEqual[x, 2e-235], t$95$2, If[LessEqual[x, 1.4e-172], t$95$1, If[LessEqual[x, 2.4e-45], t$95$2, If[LessEqual[x, 8.2e-24], t$95$1, If[LessEqual[x, 0.0106], t$95$2, N[(N[(t$95$0 / x), $MachinePrecision] / n), $MachinePrecision]]]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq 2 \cdot 10^{-235}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;x \leq 1.4 \cdot 10^{-172}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 2.4 \cdot 10^{-45}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;x \leq 8.2 \cdot 10^{-24}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 0.0106:\\
\;\;\;\;t_2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 4.2e-305 or 1.9999999999999999e-235 < x < 1.40000000000000006e-172 or 2.3999999999999999e-45 < x < 8.20000000000000029e-24

    1. Initial program 70.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 70.1%

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

    if 4.2e-305 < x < 1.9999999999999999e-235 or 1.40000000000000006e-172 < x < 2.3999999999999999e-45 or 8.20000000000000029e-24 < x < 0.0106

    1. Initial program 33.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 32.8%

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

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

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

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

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

    if 0.0106 < x

    1. Initial program 70.0%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Step-by-step derivation
      1. expm1-log1p-u96.8%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{{x}^{\left(\frac{1}{n} + -1\right)}}{n}} \]
    10. Step-by-step derivation
      1. pow-prod-up98.5%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 4.2 \cdot 10^{-305}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 2 \cdot 10^{-235}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{-172}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 2.4 \cdot 10^{-45}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 8.2 \cdot 10^{-24}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 0.0106:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{x}}{n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 69.8% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {x}^{\left(\frac{1}{n}\right)}\\ t_1 := \left(1 + \frac{x}{n}\right) - t_0\\ t_2 := \frac{-\log x}{n}\\ \mathbf{if}\;x \leq 4.1 \cdot 10^{-305}:\\ \;\;\;\;1 - t_0\\ \mathbf{elif}\;x \leq 6.8 \cdot 10^{-236}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 3.1 \cdot 10^{-173}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.95 \cdot 10^{-45}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 1.6 \cdot 10^{-24}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 0.0112:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{t_0}{x}}{n}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (pow x (/ 1.0 n)))
        (t_1 (- (+ 1.0 (/ x n)) t_0))
        (t_2 (/ (- (log x)) n)))
   (if (<= x 4.1e-305)
     (- 1.0 t_0)
     (if (<= x 6.8e-236)
       t_2
       (if (<= x 3.1e-173)
         t_1
         (if (<= x 1.95e-45)
           t_2
           (if (<= x 1.6e-24) t_1 (if (<= x 0.0112) t_2 (/ (/ t_0 x) n)))))))))
double code(double x, double n) {
	double t_0 = pow(x, (1.0 / n));
	double t_1 = (1.0 + (x / n)) - t_0;
	double t_2 = -log(x) / n;
	double tmp;
	if (x <= 4.1e-305) {
		tmp = 1.0 - t_0;
	} else if (x <= 6.8e-236) {
		tmp = t_2;
	} else if (x <= 3.1e-173) {
		tmp = t_1;
	} else if (x <= 1.95e-45) {
		tmp = t_2;
	} else if (x <= 1.6e-24) {
		tmp = t_1;
	} else if (x <= 0.0112) {
		tmp = t_2;
	} 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) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_0 = x ** (1.0d0 / n)
    t_1 = (1.0d0 + (x / n)) - t_0
    t_2 = -log(x) / n
    if (x <= 4.1d-305) then
        tmp = 1.0d0 - t_0
    else if (x <= 6.8d-236) then
        tmp = t_2
    else if (x <= 3.1d-173) then
        tmp = t_1
    else if (x <= 1.95d-45) then
        tmp = t_2
    else if (x <= 1.6d-24) then
        tmp = t_1
    else if (x <= 0.0112d0) then
        tmp = t_2
    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 t_1 = (1.0 + (x / n)) - t_0;
	double t_2 = -Math.log(x) / n;
	double tmp;
	if (x <= 4.1e-305) {
		tmp = 1.0 - t_0;
	} else if (x <= 6.8e-236) {
		tmp = t_2;
	} else if (x <= 3.1e-173) {
		tmp = t_1;
	} else if (x <= 1.95e-45) {
		tmp = t_2;
	} else if (x <= 1.6e-24) {
		tmp = t_1;
	} else if (x <= 0.0112) {
		tmp = t_2;
	} else {
		tmp = (t_0 / x) / n;
	}
	return tmp;
}
def code(x, n):
	t_0 = math.pow(x, (1.0 / n))
	t_1 = (1.0 + (x / n)) - t_0
	t_2 = -math.log(x) / n
	tmp = 0
	if x <= 4.1e-305:
		tmp = 1.0 - t_0
	elif x <= 6.8e-236:
		tmp = t_2
	elif x <= 3.1e-173:
		tmp = t_1
	elif x <= 1.95e-45:
		tmp = t_2
	elif x <= 1.6e-24:
		tmp = t_1
	elif x <= 0.0112:
		tmp = t_2
	else:
		tmp = (t_0 / x) / n
	return tmp
function code(x, n)
	t_0 = x ^ Float64(1.0 / n)
	t_1 = Float64(Float64(1.0 + Float64(x / n)) - t_0)
	t_2 = Float64(Float64(-log(x)) / n)
	tmp = 0.0
	if (x <= 4.1e-305)
		tmp = Float64(1.0 - t_0);
	elseif (x <= 6.8e-236)
		tmp = t_2;
	elseif (x <= 3.1e-173)
		tmp = t_1;
	elseif (x <= 1.95e-45)
		tmp = t_2;
	elseif (x <= 1.6e-24)
		tmp = t_1;
	elseif (x <= 0.0112)
		tmp = t_2;
	else
		tmp = Float64(Float64(t_0 / x) / n);
	end
	return tmp
end
function tmp_2 = code(x, n)
	t_0 = x ^ (1.0 / n);
	t_1 = (1.0 + (x / n)) - t_0;
	t_2 = -log(x) / n;
	tmp = 0.0;
	if (x <= 4.1e-305)
		tmp = 1.0 - t_0;
	elseif (x <= 6.8e-236)
		tmp = t_2;
	elseif (x <= 3.1e-173)
		tmp = t_1;
	elseif (x <= 1.95e-45)
		tmp = t_2;
	elseif (x <= 1.6e-24)
		tmp = t_1;
	elseif (x <= 0.0112)
		tmp = t_2;
	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]}, Block[{t$95$1 = N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision]}, If[LessEqual[x, 4.1e-305], N[(1.0 - t$95$0), $MachinePrecision], If[LessEqual[x, 6.8e-236], t$95$2, If[LessEqual[x, 3.1e-173], t$95$1, If[LessEqual[x, 1.95e-45], t$95$2, If[LessEqual[x, 1.6e-24], t$95$1, If[LessEqual[x, 0.0112], t$95$2, N[(N[(t$95$0 / x), $MachinePrecision] / n), $MachinePrecision]]]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq 6.8 \cdot 10^{-236}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;x \leq 3.1 \cdot 10^{-173}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 1.95 \cdot 10^{-45}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;x \leq 1.6 \cdot 10^{-24}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 0.0112:\\
\;\;\;\;t_2\\

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


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

    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} - {x}^{\left(\frac{1}{n}\right)} \]

    if 4.1000000000000002e-305 < x < 6.79999999999999961e-236 or 3.10000000000000005e-173 < x < 1.95e-45 or 1.60000000000000006e-24 < x < 0.0111999999999999999

    1. Initial program 33.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 32.8%

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

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

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

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

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

    if 6.79999999999999961e-236 < x < 3.10000000000000005e-173 or 1.95e-45 < x < 1.60000000000000006e-24

    1. Initial program 66.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 66.7%

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

    if 0.0111999999999999999 < x

    1. Initial program 70.0%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Step-by-step derivation
      1. expm1-log1p-u96.8%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{{x}^{\left(\frac{1}{n} + -1\right)}}{n}} \]
    10. Step-by-step derivation
      1. pow-prod-up98.5%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 4.1 \cdot 10^{-305}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 6.8 \cdot 10^{-236}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 3.1 \cdot 10^{-173}:\\ \;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 1.95 \cdot 10^{-45}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 1.6 \cdot 10^{-24}:\\ \;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 0.0112:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{x}}{n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 58.1% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\ t_1 := \frac{-\log x}{n}\\ \mathbf{if}\;x \leq 4.1 \cdot 10^{-305}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 6.5 \cdot 10^{-236}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 6.2 \cdot 10^{-173}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.4 \cdot 10^{-45}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 3 \cdot 10^{-24}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 0.55:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 3 \cdot 10^{+73}:\\ \;\;\;\;\frac{\frac{1}{x}}{n}\\ \mathbf{elif}\;x \leq 8 \cdot 10^{+137}:\\ \;\;\;\;0\\ \mathbf{elif}\;x \leq 5.2 \cdot 10^{+170}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))) (t_1 (/ (- (log x)) n)))
   (if (<= x 4.1e-305)
     t_0
     (if (<= x 6.5e-236)
       t_1
       (if (<= x 6.2e-173)
         t_0
         (if (<= x 2.4e-45)
           t_1
           (if (<= x 3e-24)
             t_0
             (if (<= x 0.55)
               t_1
               (if (<= x 3e+73)
                 (/ (/ 1.0 x) n)
                 (if (<= x 8e+137)
                   0.0
                   (if (<= x 5.2e+170) (/ (/ 1.0 n) x) 0.0)))))))))))
double code(double x, double n) {
	double t_0 = 1.0 - pow(x, (1.0 / n));
	double t_1 = -log(x) / n;
	double tmp;
	if (x <= 4.1e-305) {
		tmp = t_0;
	} else if (x <= 6.5e-236) {
		tmp = t_1;
	} else if (x <= 6.2e-173) {
		tmp = t_0;
	} else if (x <= 2.4e-45) {
		tmp = t_1;
	} else if (x <= 3e-24) {
		tmp = t_0;
	} else if (x <= 0.55) {
		tmp = t_1;
	} else if (x <= 3e+73) {
		tmp = (1.0 / x) / n;
	} else if (x <= 8e+137) {
		tmp = 0.0;
	} else if (x <= 5.2e+170) {
		tmp = (1.0 / n) / x;
	} else {
		tmp = 0.0;
	}
	return tmp;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = 1.0d0 - (x ** (1.0d0 / n))
    t_1 = -log(x) / n
    if (x <= 4.1d-305) then
        tmp = t_0
    else if (x <= 6.5d-236) then
        tmp = t_1
    else if (x <= 6.2d-173) then
        tmp = t_0
    else if (x <= 2.4d-45) then
        tmp = t_1
    else if (x <= 3d-24) then
        tmp = t_0
    else if (x <= 0.55d0) then
        tmp = t_1
    else if (x <= 3d+73) then
        tmp = (1.0d0 / x) / n
    else if (x <= 8d+137) then
        tmp = 0.0d0
    else if (x <= 5.2d+170) then
        tmp = (1.0d0 / n) / x
    else
        tmp = 0.0d0
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double t_0 = 1.0 - Math.pow(x, (1.0 / n));
	double t_1 = -Math.log(x) / n;
	double tmp;
	if (x <= 4.1e-305) {
		tmp = t_0;
	} else if (x <= 6.5e-236) {
		tmp = t_1;
	} else if (x <= 6.2e-173) {
		tmp = t_0;
	} else if (x <= 2.4e-45) {
		tmp = t_1;
	} else if (x <= 3e-24) {
		tmp = t_0;
	} else if (x <= 0.55) {
		tmp = t_1;
	} else if (x <= 3e+73) {
		tmp = (1.0 / x) / n;
	} else if (x <= 8e+137) {
		tmp = 0.0;
	} else if (x <= 5.2e+170) {
		tmp = (1.0 / n) / x;
	} else {
		tmp = 0.0;
	}
	return tmp;
}
def code(x, n):
	t_0 = 1.0 - math.pow(x, (1.0 / n))
	t_1 = -math.log(x) / n
	tmp = 0
	if x <= 4.1e-305:
		tmp = t_0
	elif x <= 6.5e-236:
		tmp = t_1
	elif x <= 6.2e-173:
		tmp = t_0
	elif x <= 2.4e-45:
		tmp = t_1
	elif x <= 3e-24:
		tmp = t_0
	elif x <= 0.55:
		tmp = t_1
	elif x <= 3e+73:
		tmp = (1.0 / x) / n
	elif x <= 8e+137:
		tmp = 0.0
	elif x <= 5.2e+170:
		tmp = (1.0 / n) / x
	else:
		tmp = 0.0
	return tmp
function code(x, n)
	t_0 = Float64(1.0 - (x ^ Float64(1.0 / n)))
	t_1 = Float64(Float64(-log(x)) / n)
	tmp = 0.0
	if (x <= 4.1e-305)
		tmp = t_0;
	elseif (x <= 6.5e-236)
		tmp = t_1;
	elseif (x <= 6.2e-173)
		tmp = t_0;
	elseif (x <= 2.4e-45)
		tmp = t_1;
	elseif (x <= 3e-24)
		tmp = t_0;
	elseif (x <= 0.55)
		tmp = t_1;
	elseif (x <= 3e+73)
		tmp = Float64(Float64(1.0 / x) / n);
	elseif (x <= 8e+137)
		tmp = 0.0;
	elseif (x <= 5.2e+170)
		tmp = Float64(Float64(1.0 / n) / x);
	else
		tmp = 0.0;
	end
	return tmp
end
function tmp_2 = code(x, n)
	t_0 = 1.0 - (x ^ (1.0 / n));
	t_1 = -log(x) / n;
	tmp = 0.0;
	if (x <= 4.1e-305)
		tmp = t_0;
	elseif (x <= 6.5e-236)
		tmp = t_1;
	elseif (x <= 6.2e-173)
		tmp = t_0;
	elseif (x <= 2.4e-45)
		tmp = t_1;
	elseif (x <= 3e-24)
		tmp = t_0;
	elseif (x <= 0.55)
		tmp = t_1;
	elseif (x <= 3e+73)
		tmp = (1.0 / x) / n;
	elseif (x <= 8e+137)
		tmp = 0.0;
	elseif (x <= 5.2e+170)
		tmp = (1.0 / n) / x;
	else
		tmp = 0.0;
	end
	tmp_2 = tmp;
end
code[x_, n_] := Block[{t$95$0 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision]}, If[LessEqual[x, 4.1e-305], t$95$0, If[LessEqual[x, 6.5e-236], t$95$1, If[LessEqual[x, 6.2e-173], t$95$0, If[LessEqual[x, 2.4e-45], t$95$1, If[LessEqual[x, 3e-24], t$95$0, If[LessEqual[x, 0.55], t$95$1, If[LessEqual[x, 3e+73], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 8e+137], 0.0, If[LessEqual[x, 5.2e+170], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], 0.0]]]]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq 6.5 \cdot 10^{-236}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 6.2 \cdot 10^{-173}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 2.4 \cdot 10^{-45}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 3 \cdot 10^{-24}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 0.55:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;x \leq 8 \cdot 10^{+137}:\\
\;\;\;\;0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if x < 4.1000000000000002e-305 or 6.5000000000000001e-236 < x < 6.20000000000000011e-173 or 2.3999999999999999e-45 < x < 2.99999999999999995e-24

    1. Initial program 70.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 70.1%

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

    if 4.1000000000000002e-305 < x < 6.5000000000000001e-236 or 6.20000000000000011e-173 < x < 2.3999999999999999e-45 or 2.99999999999999995e-24 < x < 0.55000000000000004

    1. Initial program 33.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 32.8%

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

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

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

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

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

    if 0.55000000000000004 < x < 3.00000000000000011e73

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Step-by-step derivation
      1. expm1-log1p-u91.1%

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

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{\color{blue}{{x}^{1}}}}{n}\right)} - 1 \]
      7. pow-div42.9%

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

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

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

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

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

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

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

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

    if 3.00000000000000011e73 < x < 8.0000000000000003e137 or 5.1999999999999996e170 < x

    1. Initial program 88.3%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \log \left(e^{-{x}^{\left(\frac{1}{n}\right)}} \cdot e^{e^{\color{blue}{\mathsf{log1p}\left(x\right) \cdot \frac{1}{n}}}}\right) \]
      11. un-div-inv88.2%

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

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

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

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

        \[\leadsto \log \color{blue}{1} \]
      3. metadata-eval88.3%

        \[\leadsto \color{blue}{0} \]
    7. Simplified88.3%

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

    if 8.0000000000000003e137 < x < 5.1999999999999996e170

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Step-by-step derivation
      1. expm1-log1p-u97.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{1}{n}}{x}} \]
    12. Simplified92.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 4.1 \cdot 10^{-305}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 6.5 \cdot 10^{-236}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 6.2 \cdot 10^{-173}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 2.4 \cdot 10^{-45}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 3 \cdot 10^{-24}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 0.55:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 3 \cdot 10^{+73}:\\ \;\;\;\;\frac{\frac{1}{x}}{n}\\ \mathbf{elif}\;x \leq 8 \cdot 10^{+137}:\\ \;\;\;\;0\\ \mathbf{elif}\;x \leq 5.2 \cdot 10^{+170}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 56.9% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{-\log x}{n}\\
\mathbf{if}\;x \leq 6.2 \cdot 10^{-221}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;x \leq 0.55:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;x \leq 1.02 \cdot 10^{+138}:\\
\;\;\;\;0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if x < 6.1999999999999998e-221 or 3.10000000000000005e-173 < x < 0.55000000000000004

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

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

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

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

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

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

    if 6.1999999999999998e-221 < x < 3.10000000000000005e-173

    1. Initial program 67.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 43.7%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Taylor expanded in n around inf 55.8%

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

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

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

    if 0.55000000000000004 < x < 2.2999999999999999e74

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Step-by-step derivation
      1. expm1-log1p-u91.1%

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

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

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

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

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

        \[\leadsto e^{\mathsf{log1p}\left(\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{\color{blue}{{x}^{1}}}}{n}\right)} - 1 \]
      7. pow-div42.9%

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

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

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

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

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

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

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

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

    if 2.2999999999999999e74 < x < 1.02e138 or 1.0500000000000001e171 < x

    1. Initial program 88.3%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \log \left(e^{-{x}^{\left(\frac{1}{n}\right)}} \cdot e^{e^{\color{blue}{\mathsf{log1p}\left(x\right) \cdot \frac{1}{n}}}}\right) \]
      11. un-div-inv88.2%

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

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

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

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

        \[\leadsto \log \color{blue}{1} \]
      3. metadata-eval88.3%

        \[\leadsto \color{blue}{0} \]
    7. Simplified88.3%

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

    if 1.02e138 < x < 1.0500000000000001e171

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Step-by-step derivation
      1. expm1-log1p-u97.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{1}{n}}{x}} \]
    12. Simplified92.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 6.2 \cdot 10^{-221}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 3.1 \cdot 10^{-173}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \mathbf{elif}\;x \leq 0.55:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 2.3 \cdot 10^{+74}:\\ \;\;\;\;\frac{\frac{1}{x}}{n}\\ \mathbf{elif}\;x \leq 1.02 \cdot 10^{+138}:\\ \;\;\;\;0\\ \mathbf{elif}\;x \leq 1.05 \cdot 10^{+171}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 45.0% accurate, 14.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;n \leq -3.4 \lor \neg \left(n \leq -2.4 \cdot 10^{-201}\right):\\
\;\;\;\;\frac{1}{n \cdot x}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if n < -3.39999999999999991 or -2.40000000000000009e-201 < n

    1. Initial program 44.2%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 49.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. mul-1-neg49.3%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Taylor expanded in n around inf 49.7%

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

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

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

    if -3.39999999999999991 < n < -2.40000000000000009e-201

    1. Initial program 100.0%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. sub-neg100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \log \left(e^{-{x}^{\left(\frac{1}{n}\right)}} \cdot e^{e^{\color{blue}{\mathsf{log1p}\left(x\right) \cdot \frac{1}{n}}}}\right) \]
      11. un-div-inv100.0%

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

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

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

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

        \[\leadsto \log \color{blue}{1} \]
      3. metadata-eval56.3%

        \[\leadsto \color{blue}{0} \]
    7. Simplified56.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -3.4 \lor \neg \left(n \leq -2.4 \cdot 10^{-201}\right):\\ \;\;\;\;\frac{1}{n \cdot x}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 45.6% accurate, 14.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;n \leq -13 \lor \neg \left(n \leq -1.05 \cdot 10^{-201}\right):\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if n < -13 or -1.05000000000000006e-201 < n

    1. Initial program 44.2%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 49.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. mul-1-neg49.3%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Step-by-step derivation
      1. expm1-log1p-u39.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -13 < n < -1.05000000000000006e-201

    1. Initial program 100.0%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. sub-neg100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \log \left(e^{-{x}^{\left(\frac{1}{n}\right)}} \cdot e^{e^{\color{blue}{\mathsf{log1p}\left(x\right) \cdot \frac{1}{n}}}}\right) \]
      11. un-div-inv100.0%

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

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

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

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

        \[\leadsto \log \color{blue}{1} \]
      3. metadata-eval56.3%

        \[\leadsto \color{blue}{0} \]
    7. Simplified56.3%

      \[\leadsto \color{blue}{0} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification51.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -13 \lor \neg \left(n \leq -1.05 \cdot 10^{-201}\right):\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 45.6% accurate, 14.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;n \leq -11:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\

\mathbf{elif}\;n \leq -7.8 \cdot 10^{-202}:\\
\;\;\;\;0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if n < -11

    1. Initial program 38.1%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Step-by-step derivation
      1. expm1-log1p-u56.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{1}{n}}{x}} \]
    12. Simplified58.2%

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

    if -11 < n < -7.7999999999999998e-202

    1. Initial program 100.0%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. sub-neg100.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \log \left(e^{-{x}^{\left(\frac{1}{n}\right)}} \cdot e^{e^{\color{blue}{\mathsf{log1p}\left(x\right) \cdot \frac{1}{n}}}}\right) \]
      11. un-div-inv100.0%

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

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

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

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

        \[\leadsto \log \color{blue}{1} \]
      3. metadata-eval56.3%

        \[\leadsto \color{blue}{0} \]
    7. Simplified56.3%

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

    if -7.7999999999999998e-202 < n

    1. Initial program 47.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 44.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. mul-1-neg44.9%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Step-by-step derivation
      1. expm1-log1p-u29.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 16: 30.8% accurate, 211.0× speedup?

\[\begin{array}{l} \\ 0 \end{array} \]
(FPCore (x n) :precision binary64 0.0)
double code(double x, double n) {
	return 0.0;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    code = 0.0d0
end function
public static double code(double x, double n) {
	return 0.0;
}
def code(x, n):
	return 0.0
function code(x, n)
	return 0.0
end
function tmp = code(x, n)
	tmp = 0.0;
end
code[x_, n_] := 0.0
\begin{array}{l}

\\
0
\end{array}
Derivation
  1. Initial program 56.0%

    \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. sub-neg56.0%

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

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

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

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

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

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

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

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

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

      \[\leadsto \log \left(e^{-{x}^{\left(\frac{1}{n}\right)}} \cdot e^{e^{\color{blue}{\mathsf{log1p}\left(x\right) \cdot \frac{1}{n}}}}\right) \]
    11. un-div-inv63.2%

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

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

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

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

      \[\leadsto \log \color{blue}{1} \]
    3. metadata-eval31.9%

      \[\leadsto \color{blue}{0} \]
  7. Simplified31.9%

    \[\leadsto \color{blue}{0} \]
  8. Final simplification31.9%

    \[\leadsto 0 \]
  9. Add Preprocessing

Reproduce

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