2nthrt (problem 3.4.6)

Percentage Accurate: 57.7% → 88.9%
Time: 1.0min
Alternatives: 18
Speedup: 1.9×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 18 alternatives:

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

Initial Program: 57.7% 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: 88.9% accurate, 0.1× speedup?

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

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

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

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


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

    1. Initial program 98.7%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Add Preprocessing

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

    1. Initial program 25.0%

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

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

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

    if 9.99999999999999999e-15 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 47.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. *-un-lft-identity47.3%

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(1, {\left(x + 1\right)}^{\left(\frac{1}{n}\right)}, -{\left(\sqrt[3]{x}\right)}^{\left(\frac{1}{n}\right)} \cdot {\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right)}^{\left(\frac{1}{n}\right)}\right) + \mathsf{fma}\left(-{\left(\sqrt[3]{x}\right)}^{\left(\frac{1}{n}\right)}, {\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right)}^{\left(\frac{1}{n}\right)}, {\left(\sqrt[3]{x}\right)}^{\left(\frac{1}{n}\right)} \cdot {\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right)}^{\left(\frac{1}{n}\right)}\right)} \]
    4. Applied egg-rr96.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(1, e^{\frac{\mathsf{log1p}\left(x\right)}{n}}, -{\left(\sqrt[3]{x}\right)}^{\left(\frac{1}{n}\right)} \cdot {\left({\left(\sqrt[3]{x}\right)}^{2}\right)}^{\left(\frac{1}{n}\right)}\right) + \mathsf{fma}\left(-{\left(\sqrt[3]{x}\right)}^{\left(\frac{1}{n}\right)}, {\left({\left(\sqrt[3]{x}\right)}^{2}\right)}^{\left(\frac{1}{n}\right)}, {\left(\sqrt[3]{x}\right)}^{\left(\frac{1}{n}\right)} \cdot {\left({\left(\sqrt[3]{x}\right)}^{2}\right)}^{\left(\frac{1}{n}\right)}\right)} \]
    5. Step-by-step derivation
      1. +-commutative96.7%

        \[\leadsto \color{blue}{\mathsf{fma}\left(-{\left(\sqrt[3]{x}\right)}^{\left(\frac{1}{n}\right)}, {\left({\left(\sqrt[3]{x}\right)}^{2}\right)}^{\left(\frac{1}{n}\right)}, {\left(\sqrt[3]{x}\right)}^{\left(\frac{1}{n}\right)} \cdot {\left({\left(\sqrt[3]{x}\right)}^{2}\right)}^{\left(\frac{1}{n}\right)}\right) + \mathsf{fma}\left(1, e^{\frac{\mathsf{log1p}\left(x\right)}{n}}, -{\left(\sqrt[3]{x}\right)}^{\left(\frac{1}{n}\right)} \cdot {\left({\left(\sqrt[3]{x}\right)}^{2}\right)}^{\left(\frac{1}{n}\right)}\right)} \]
      2. fma-undefine96.7%

        \[\leadsto \mathsf{fma}\left(-{\left(\sqrt[3]{x}\right)}^{\left(\frac{1}{n}\right)}, {\left({\left(\sqrt[3]{x}\right)}^{2}\right)}^{\left(\frac{1}{n}\right)}, {\left(\sqrt[3]{x}\right)}^{\left(\frac{1}{n}\right)} \cdot {\left({\left(\sqrt[3]{x}\right)}^{2}\right)}^{\left(\frac{1}{n}\right)}\right) + \color{blue}{\left(1 \cdot e^{\frac{\mathsf{log1p}\left(x\right)}{n}} + \left(-{\left(\sqrt[3]{x}\right)}^{\left(\frac{1}{n}\right)} \cdot {\left({\left(\sqrt[3]{x}\right)}^{2}\right)}^{\left(\frac{1}{n}\right)}\right)\right)} \]
      3. *-lft-identity96.7%

        \[\leadsto \mathsf{fma}\left(-{\left(\sqrt[3]{x}\right)}^{\left(\frac{1}{n}\right)}, {\left({\left(\sqrt[3]{x}\right)}^{2}\right)}^{\left(\frac{1}{n}\right)}, {\left(\sqrt[3]{x}\right)}^{\left(\frac{1}{n}\right)} \cdot {\left({\left(\sqrt[3]{x}\right)}^{2}\right)}^{\left(\frac{1}{n}\right)}\right) + \left(\color{blue}{e^{\frac{\mathsf{log1p}\left(x\right)}{n}}} + \left(-{\left(\sqrt[3]{x}\right)}^{\left(\frac{1}{n}\right)} \cdot {\left({\left(\sqrt[3]{x}\right)}^{2}\right)}^{\left(\frac{1}{n}\right)}\right)\right) \]
      4. distribute-rgt-neg-in96.7%

        \[\leadsto \mathsf{fma}\left(-{\left(\sqrt[3]{x}\right)}^{\left(\frac{1}{n}\right)}, {\left({\left(\sqrt[3]{x}\right)}^{2}\right)}^{\left(\frac{1}{n}\right)}, {\left(\sqrt[3]{x}\right)}^{\left(\frac{1}{n}\right)} \cdot {\left({\left(\sqrt[3]{x}\right)}^{2}\right)}^{\left(\frac{1}{n}\right)}\right) + \left(e^{\frac{\mathsf{log1p}\left(x\right)}{n}} + \color{blue}{{\left(\sqrt[3]{x}\right)}^{\left(\frac{1}{n}\right)} \cdot \left(-{\left({\left(\sqrt[3]{x}\right)}^{2}\right)}^{\left(\frac{1}{n}\right)}\right)}\right) \]
    6. Simplified96.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-{\left(\sqrt[3]{x}\right)}^{\left(\frac{1}{n}\right)}, {\left({\left(\sqrt[3]{x}\right)}^{2}\right)}^{\left(\frac{1}{n}\right)}, {\left(\sqrt[3]{x}\right)}^{\left(\frac{1}{n}\right)} \cdot {\left({\left(\sqrt[3]{x}\right)}^{2}\right)}^{\left(\frac{1}{n}\right)}\right) + \left(e^{\frac{\mathsf{log1p}\left(x\right)}{n}} + {\left(\sqrt[3]{x}\right)}^{\left(\frac{1}{n}\right)} \cdot \left(-{\left({\left(\sqrt[3]{x}\right)}^{2}\right)}^{\left(\frac{1}{n}\right)}\right)\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification90.2%

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

Alternative 2: 89.0% accurate, 0.1× speedup?

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

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

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


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

    1. Initial program 98.7%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Add Preprocessing

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

    1. Initial program 24.8%

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

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

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

    if 4.00000000000000025e-9 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 48.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 28.6%

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

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

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

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

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

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

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

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

Alternative 3: 88.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^{-6}:\\ \;\;\;\;{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - t\_0\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-16}:\\ \;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \left(\log x - 0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}\right)}{n}\\ \mathbf{else}:\\ \;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t\_0\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (pow x (/ 1.0 n))))
   (if (<= (/ 1.0 n) -2e-6)
     (- (pow (+ x 1.0) (/ 1.0 n)) t_0)
     (if (<= (/ 1.0 n) 5e-16)
       (/
        (-
         (log1p x)
         (- (log x) (* 0.5 (/ (- (pow (log1p x) 2.0) (pow (log x) 2.0)) n))))
        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-6) {
		tmp = pow((x + 1.0), (1.0 / n)) - t_0;
	} else if ((1.0 / n) <= 5e-16) {
		tmp = (log1p(x) - (log(x) - (0.5 * ((pow(log1p(x), 2.0) - pow(log(x), 2.0)) / n)))) / 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-6) {
		tmp = Math.pow((x + 1.0), (1.0 / n)) - t_0;
	} else if ((1.0 / n) <= 5e-16) {
		tmp = (Math.log1p(x) - (Math.log(x) - (0.5 * ((Math.pow(Math.log1p(x), 2.0) - Math.pow(Math.log(x), 2.0)) / n)))) / 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-6:
		tmp = math.pow((x + 1.0), (1.0 / n)) - t_0
	elif (1.0 / n) <= 5e-16:
		tmp = (math.log1p(x) - (math.log(x) - (0.5 * ((math.pow(math.log1p(x), 2.0) - math.pow(math.log(x), 2.0)) / n)))) / 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-6)
		tmp = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - t_0);
	elseif (Float64(1.0 / n) <= 5e-16)
		tmp = Float64(Float64(log1p(x) - Float64(log(x) - Float64(0.5 * Float64(Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0)) / n)))) / 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-6], N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-16], N[(N[(N[Log[1 + x], $MachinePrecision] - N[(N[Log[x], $MachinePrecision] - N[(0.5 * N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]), $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^{-6}:\\
\;\;\;\;{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - t\_0\\

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

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


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

    1. Initial program 98.5%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Add Preprocessing

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

    1. Initial program 24.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.2%

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

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

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

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

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

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

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

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

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

    if 5.0000000000000004e-16 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 46.5%

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

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

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

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

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

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

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

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

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

Alternative 4: 88.7% 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^{-6}:\\ \;\;\;\;{\left(1 + x\right)}^{\left(\frac{1}{n}\right)} - t\_0\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-16}:\\ \;\;\;\;\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-6)
     (- (pow (+ 1.0 x) (/ 1.0 n)) t_0)
     (if (<= (/ 1.0 n) 5e-16)
       (/ (- (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-6) {
		tmp = pow((1.0 + x), (1.0 / n)) - t_0;
	} else if ((1.0 / n) <= 5e-16) {
		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-6) {
		tmp = Math.pow((1.0 + x), (1.0 / n)) - t_0;
	} else if ((1.0 / n) <= 5e-16) {
		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-6:
		tmp = math.pow((1.0 + x), (1.0 / n)) - t_0
	elif (1.0 / n) <= 5e-16:
		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-6)
		tmp = Float64((Float64(1.0 + x) ^ Float64(1.0 / n)) - t_0);
	elseif (Float64(1.0 / n) <= 5e-16)
		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-6], N[(N[Power[N[(1.0 + x), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-16], 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^{-6}:\\
\;\;\;\;{\left(1 + x\right)}^{\left(\frac{1}{n}\right)} - t\_0\\

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

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


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

    1. Initial program 98.5%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Add Preprocessing

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

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

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

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

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

    if 5.0000000000000004e-16 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 46.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


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

    1. Initial program 71.2%

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

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

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

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

        \[\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-log71.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. pow-to-exp12.1%

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

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

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

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

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

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

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

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

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

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

    if -8.6000000000000001e-239 < x < 9.1999999999999998e-280

    1. Initial program 64.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 64.9%

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

    if 9.1999999999999998e-280 < x < 3.7999999999999999e-81

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

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

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

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

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

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

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

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

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

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

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

    if 3.7999999999999999e-81 < x < 1.84999999999999991e-5

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.84999999999999991e-5 < x

    1. Initial program 65.8%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 93.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. associate-/r*94.4%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -8.6 \cdot 10^{-239}:\\ \;\;\;\;0\\ \mathbf{elif}\;x \leq 9.2 \cdot 10^{-280}:\\ \;\;\;\;\left(\frac{x}{n} + 1\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 3.8 \cdot 10^{-81}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 1.85 \cdot 10^{-5}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{n \cdot x}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 80.3% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 98.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 69.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if -2e4 < (/.f64 #s(literal 1 binary64) n) < 4.00000000000000025e-9

    1. Initial program 25.4%

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

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

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

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

    if 4.00000000000000025e-9 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 48.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 58.0%

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

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

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

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

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

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

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


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

    1. Initial program 98.5%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Add Preprocessing

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

    1. Initial program 24.3%

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

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

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

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

    if 4.00000000000000025e-9 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 48.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 58.0%

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

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

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

Alternative 8: 74.3% accurate, 1.5× speedup?

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

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

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 6 regimes
  2. if x < -9.4999999999999992e-239

    1. Initial program 71.2%

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

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

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

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

        \[\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-log71.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. pow-to-exp12.1%

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

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

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

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

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

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

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

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

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

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

    if -9.4999999999999992e-239 < x < 7.00000000000000019e-279

    1. Initial program 64.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 64.9%

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

    if 7.00000000000000019e-279 < x < 8e-79

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

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

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

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

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

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

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

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

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

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

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

    if 8e-79 < x < 2.70000000000000019e-62

    1. Initial program 56.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 84.0%

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

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

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

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

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

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

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

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

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

    if 2.70000000000000019e-62 < x < 0.0135999999999999992

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

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

      \[\leadsto \color{blue}{\frac{x \cdot \left(1 + -0.5 \cdot x\right) - \log x}{n}} \]
    5. Taylor expanded in x around 0 48.4%

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

    if 0.0135999999999999992 < x

    1. Initial program 68.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 96.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. associate-/r*97.4%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -9.5 \cdot 10^{-239}:\\ \;\;\;\;0\\ \mathbf{elif}\;x \leq 7 \cdot 10^{-279}:\\ \;\;\;\;\left(\frac{x}{n} + 1\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 8 \cdot 10^{-79}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 2.7 \cdot 10^{-62}:\\ \;\;\;\;\left(1 - x \cdot \left(\frac{-1}{n} - x \cdot \frac{-0.5 + \frac{0.5}{n}}{n}\right)\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 0.0136:\\ \;\;\;\;x \cdot \left(\frac{1}{n} + -0.5 \cdot \frac{x}{n}\right) - \frac{\log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 72.5% accurate, 1.5× speedup?

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

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

\mathbf{elif}\;x \leq 9.5 \cdot 10^{-280}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;x \leq 2.05 \cdot 10^{-19}:\\
\;\;\;\;t\_1\\

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

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


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

    1. Initial program 71.2%

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

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

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

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

        \[\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-log71.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. pow-to-exp12.1%

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

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

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

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

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

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

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

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

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

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

    if -9.4999999999999992e-239 < x < 9.50000000000000082e-280 or 1.05e-79 < x < 2.04999999999999993e-19

    1. Initial program 58.3%

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

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

    if 9.50000000000000082e-280 < x < 1.05e-79

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

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

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

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

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

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

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

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

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

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

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

    if 2.04999999999999993e-19 < x < 0.0135999999999999992

    1. Initial program 23.3%

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

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

      \[\leadsto \color{blue}{\frac{x \cdot \left(1 + -0.5 \cdot x\right) - \log x}{n}} \]
    5. Taylor expanded in x around 0 67.9%

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

    if 0.0135999999999999992 < x

    1. Initial program 68.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 96.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. associate-/r*97.4%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -9.5 \cdot 10^{-239}:\\ \;\;\;\;0\\ \mathbf{elif}\;x \leq 9.5 \cdot 10^{-280}:\\ \;\;\;\;\left(\frac{x}{n} + 1\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 1.05 \cdot 10^{-79}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 2.05 \cdot 10^{-19}:\\ \;\;\;\;\left(\frac{x}{n} + 1\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 0.0136:\\ \;\;\;\;x \cdot \left(\frac{1}{n} + -0.5 \cdot \frac{x}{n}\right) - \frac{\log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 72.4% accurate, 1.6× speedup?

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

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

\mathbf{elif}\;x \leq 1.05 \cdot 10^{-278}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;x \leq 8.2 \cdot 10^{-17}:\\
\;\;\;\;t\_1\\

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

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


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

    1. Initial program 71.2%

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

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

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

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

        \[\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-log71.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. pow-to-exp12.1%

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

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

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

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

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

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

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

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

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

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

    if -9.4999999999999992e-239 < x < 1.05000000000000007e-278 or 3.19999999999999988e-79 < x < 8.2000000000000001e-17

    1. Initial program 58.3%

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

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

    if 1.05000000000000007e-278 < x < 3.19999999999999988e-79

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

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

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

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

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

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

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

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

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

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

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

    if 8.2000000000000001e-17 < x < 0.0179999999999999986

    1. Initial program 23.3%

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

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

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

    if 0.0179999999999999986 < x

    1. Initial program 68.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 96.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. associate-/r*97.4%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -9.5 \cdot 10^{-239}:\\ \;\;\;\;0\\ \mathbf{elif}\;x \leq 1.05 \cdot 10^{-278}:\\ \;\;\;\;\left(\frac{x}{n} + 1\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 3.2 \cdot 10^{-79}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 8.2 \cdot 10^{-17}:\\ \;\;\;\;\left(\frac{x}{n} + 1\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 0.018:\\ \;\;\;\;\frac{x \cdot \left(x \cdot -0.5 + 1\right) - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 72.2% accurate, 1.6× speedup?

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

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

\mathbf{elif}\;x \leq 8 \cdot 10^{-280}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;x \leq 1.56 \cdot 10^{-15}:\\
\;\;\;\;t\_1\\

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

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


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

    1. Initial program 71.2%

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

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

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

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

        \[\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-log71.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. pow-to-exp12.1%

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

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

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

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

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

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

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

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

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

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

    if -9.4999999999999992e-239 < x < 7.9999999999999997e-280 or 4.7999999999999998e-80 < x < 1.55999999999999991e-15

    1. Initial program 58.3%

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

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

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

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

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

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

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

    if 7.9999999999999997e-280 < x < 4.7999999999999998e-80

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

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

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

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

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

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

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

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

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

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

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

    if 1.55999999999999991e-15 < x < 0.0135999999999999992

    1. Initial program 23.3%

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

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

      \[\leadsto \color{blue}{\frac{x \cdot \left(1 + -0.5 \cdot x\right) - \log x}{n}} \]
    5. Taylor expanded in x around 0 57.0%

      \[\leadsto \color{blue}{-1 \cdot \frac{\log x}{n} + \frac{x}{n}} \]
    6. Step-by-step derivation
      1. +-commutative57.0%

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

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

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

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

    if 0.0135999999999999992 < x

    1. Initial program 68.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 96.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. associate-/r*97.4%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -9.5 \cdot 10^{-239}:\\ \;\;\;\;0\\ \mathbf{elif}\;x \leq 8 \cdot 10^{-280}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 4.8 \cdot 10^{-80}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 1.56 \cdot 10^{-15}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 0.0136:\\ \;\;\;\;\frac{x}{n} - \frac{\log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 72.5% accurate, 1.6× speedup?

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

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

\mathbf{elif}\;x \leq 2.55 \cdot 10^{-279}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;x \leq 3.2 \cdot 10^{-19}:\\
\;\;\;\;t\_1\\

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

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


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

    1. Initial program 71.2%

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

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

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

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

        \[\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-log71.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. pow-to-exp12.1%

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

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

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

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

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

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

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

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

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

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

    if -7.00000000000000011e-239 < x < 2.54999999999999982e-279 or 1.5999999999999999e-80 < x < 3.19999999999999982e-19

    1. Initial program 58.3%

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

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

    if 2.54999999999999982e-279 < x < 1.5999999999999999e-80

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

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

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

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

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

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

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

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

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

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

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

    if 3.19999999999999982e-19 < x < 0.0184999999999999991

    1. Initial program 23.3%

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

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

      \[\leadsto \color{blue}{\frac{x \cdot \left(1 + -0.5 \cdot x\right) - \log x}{n}} \]
    5. Taylor expanded in x around 0 57.0%

      \[\leadsto \color{blue}{-1 \cdot \frac{\log x}{n} + \frac{x}{n}} \]
    6. Step-by-step derivation
      1. +-commutative57.0%

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

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

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

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

    if 0.0184999999999999991 < x

    1. Initial program 68.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 96.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. associate-/r*97.4%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -7 \cdot 10^{-239}:\\ \;\;\;\;0\\ \mathbf{elif}\;x \leq 2.55 \cdot 10^{-279}:\\ \;\;\;\;\left(\frac{x}{n} + 1\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 1.6 \cdot 10^{-80}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 3.2 \cdot 10^{-19}:\\ \;\;\;\;\left(\frac{x}{n} + 1\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 0.0185:\\ \;\;\;\;\frac{x}{n} - \frac{\log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 62.6% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{if}\;x \leq -9.5 \cdot 10^{-239}:\\ \;\;\;\;0\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{-279}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 5 \cdot 10^{-80}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 2.1 \cdot 10^{+54} \lor \neg \left(x \leq 9.5 \cdot 10^{+98}\right) \land x \leq 2.5 \cdot 10^{+161}:\\ \;\;\;\;\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)))))
   (if (<= x -9.5e-239)
     0.0
     (if (<= x 1.4e-279)
       t_0
       (if (<= x 5e-80)
         (/ (log x) (- n))
         (if (<= x 1.0)
           t_0
           (if (or (<= x 2.1e+54) (and (not (<= x 9.5e+98)) (<= x 2.5e+161)))
             (/ (/ 1.0 n) x)
             0.0)))))))
double code(double x, double n) {
	double t_0 = 1.0 - pow(x, (1.0 / n));
	double tmp;
	if (x <= -9.5e-239) {
		tmp = 0.0;
	} else if (x <= 1.4e-279) {
		tmp = t_0;
	} else if (x <= 5e-80) {
		tmp = log(x) / -n;
	} else if (x <= 1.0) {
		tmp = t_0;
	} else if ((x <= 2.1e+54) || (!(x <= 9.5e+98) && (x <= 2.5e+161))) {
		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 = 1.0d0 - (x ** (1.0d0 / n))
    if (x <= (-9.5d-239)) then
        tmp = 0.0d0
    else if (x <= 1.4d-279) then
        tmp = t_0
    else if (x <= 5d-80) then
        tmp = log(x) / -n
    else if (x <= 1.0d0) then
        tmp = t_0
    else if ((x <= 2.1d+54) .or. (.not. (x <= 9.5d+98)) .and. (x <= 2.5d+161)) 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 tmp;
	if (x <= -9.5e-239) {
		tmp = 0.0;
	} else if (x <= 1.4e-279) {
		tmp = t_0;
	} else if (x <= 5e-80) {
		tmp = Math.log(x) / -n;
	} else if (x <= 1.0) {
		tmp = t_0;
	} else if ((x <= 2.1e+54) || (!(x <= 9.5e+98) && (x <= 2.5e+161))) {
		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))
	tmp = 0
	if x <= -9.5e-239:
		tmp = 0.0
	elif x <= 1.4e-279:
		tmp = t_0
	elif x <= 5e-80:
		tmp = math.log(x) / -n
	elif x <= 1.0:
		tmp = t_0
	elif (x <= 2.1e+54) or (not (x <= 9.5e+98) and (x <= 2.5e+161)):
		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)))
	tmp = 0.0
	if (x <= -9.5e-239)
		tmp = 0.0;
	elseif (x <= 1.4e-279)
		tmp = t_0;
	elseif (x <= 5e-80)
		tmp = Float64(log(x) / Float64(-n));
	elseif (x <= 1.0)
		tmp = t_0;
	elseif ((x <= 2.1e+54) || (!(x <= 9.5e+98) && (x <= 2.5e+161)))
		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));
	tmp = 0.0;
	if (x <= -9.5e-239)
		tmp = 0.0;
	elseif (x <= 1.4e-279)
		tmp = t_0;
	elseif (x <= 5e-80)
		tmp = log(x) / -n;
	elseif (x <= 1.0)
		tmp = t_0;
	elseif ((x <= 2.1e+54) || (~((x <= 9.5e+98)) && (x <= 2.5e+161)))
		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]}, If[LessEqual[x, -9.5e-239], 0.0, If[LessEqual[x, 1.4e-279], t$95$0, If[LessEqual[x, 5e-80], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 1.0], t$95$0, If[Or[LessEqual[x, 2.1e+54], And[N[Not[LessEqual[x, 9.5e+98]], $MachinePrecision], LessEqual[x, 2.5e+161]]], 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)}\\
\mathbf{if}\;x \leq -9.5 \cdot 10^{-239}:\\
\;\;\;\;0\\

\mathbf{elif}\;x \leq 1.4 \cdot 10^{-279}:\\
\;\;\;\;t\_0\\

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

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

\mathbf{elif}\;x \leq 2.1 \cdot 10^{+54} \lor \neg \left(x \leq 9.5 \cdot 10^{+98}\right) \land x \leq 2.5 \cdot 10^{+161}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -9.4999999999999992e-239 or 2.09999999999999986e54 < x < 9.5000000000000001e98 or 2.4999999999999998e161 < x

    1. Initial program 79.9%

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

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

        \[\leadsto \color{blue}{\left(-{x}^{\left(\frac{1}{n}\right)}\right) + {\left(x + 1\right)}^{\left(\frac{1}{n}\right)}} \]
      3. add-log-exp79.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-exp79.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-log79.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. pow-to-exp50.0%

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

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

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

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

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

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

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

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

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

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

    if -9.4999999999999992e-239 < x < 1.4e-279 or 5e-80 < x < 1

    1. Initial program 56.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 45.2%

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

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

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

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

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

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

    if 1.4e-279 < x < 5e-80

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

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

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

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

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

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

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

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

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

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

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

    if 1 < x < 2.09999999999999986e54 or 9.5000000000000001e98 < x < 2.4999999999999998e161

    1. Initial program 40.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 91.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. associate-/r*94.1%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -9.5 \cdot 10^{-239}:\\ \;\;\;\;0\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{-279}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 5 \cdot 10^{-80}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 2.1 \cdot 10^{+54} \lor \neg \left(x \leq 9.5 \cdot 10^{+98}\right) \land x \leq 2.5 \cdot 10^{+161}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 63.7% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -5 \cdot 10^{-310}:\\ \;\;\;\;0\\ \mathbf{elif}\;x \leq 0.023:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{+54} \lor \neg \left(x \leq 1.8 \cdot 10^{+94}\right) \land x \leq 2 \cdot 10^{+161}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= x -5e-310)
   0.0
   (if (<= x 0.023)
     (/ (- x (log x)) n)
     (if (or (<= x 1.4e+54) (and (not (<= x 1.8e+94)) (<= x 2e+161)))
       (/ (/ 1.0 n) x)
       0.0))))
double code(double x, double n) {
	double tmp;
	if (x <= -5e-310) {
		tmp = 0.0;
	} else if (x <= 0.023) {
		tmp = (x - log(x)) / n;
	} else if ((x <= 1.4e+54) || (!(x <= 1.8e+94) && (x <= 2e+161))) {
		tmp = (1.0 / n) / x;
	} else {
		tmp = 0.0;
	}
	return tmp;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    real(8) :: tmp
    if (x <= (-5d-310)) then
        tmp = 0.0d0
    else if (x <= 0.023d0) then
        tmp = (x - log(x)) / n
    else if ((x <= 1.4d+54) .or. (.not. (x <= 1.8d+94)) .and. (x <= 2d+161)) then
        tmp = (1.0d0 / n) / x
    else
        tmp = 0.0d0
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double tmp;
	if (x <= -5e-310) {
		tmp = 0.0;
	} else if (x <= 0.023) {
		tmp = (x - Math.log(x)) / n;
	} else if ((x <= 1.4e+54) || (!(x <= 1.8e+94) && (x <= 2e+161))) {
		tmp = (1.0 / n) / x;
	} else {
		tmp = 0.0;
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if x <= -5e-310:
		tmp = 0.0
	elif x <= 0.023:
		tmp = (x - math.log(x)) / n
	elif (x <= 1.4e+54) or (not (x <= 1.8e+94) and (x <= 2e+161)):
		tmp = (1.0 / n) / x
	else:
		tmp = 0.0
	return tmp
function code(x, n)
	tmp = 0.0
	if (x <= -5e-310)
		tmp = 0.0;
	elseif (x <= 0.023)
		tmp = Float64(Float64(x - log(x)) / n);
	elseif ((x <= 1.4e+54) || (!(x <= 1.8e+94) && (x <= 2e+161)))
		tmp = Float64(Float64(1.0 / n) / x);
	else
		tmp = 0.0;
	end
	return tmp
end
function tmp_2 = code(x, n)
	tmp = 0.0;
	if (x <= -5e-310)
		tmp = 0.0;
	elseif (x <= 0.023)
		tmp = (x - log(x)) / n;
	elseif ((x <= 1.4e+54) || (~((x <= 1.8e+94)) && (x <= 2e+161)))
		tmp = (1.0 / n) / x;
	else
		tmp = 0.0;
	end
	tmp_2 = tmp;
end
code[x_, n_] := If[LessEqual[x, -5e-310], 0.0, If[LessEqual[x, 0.023], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[Or[LessEqual[x, 1.4e+54], And[N[Not[LessEqual[x, 1.8e+94]], $MachinePrecision], LessEqual[x, 2e+161]]], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], 0.0]]]
\begin{array}{l}

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

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

\mathbf{elif}\;x \leq 1.4 \cdot 10^{+54} \lor \neg \left(x \leq 1.8 \cdot 10^{+94}\right) \land x \leq 2 \cdot 10^{+161}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -4.999999999999985e-310 or 1.40000000000000008e54 < x < 1.79999999999999996e94 or 2.0000000000000001e161 < x

    1. Initial program 80.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-neg80.3%

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

        \[\leadsto \color{blue}{\left(-{x}^{\left(\frac{1}{n}\right)}\right) + {\left(x + 1\right)}^{\left(\frac{1}{n}\right)}} \]
      3. add-log-exp80.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-exp80.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-log80.3%

        \[\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. pow-to-exp52.6%

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

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

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

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

      \[\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 40.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-neg40.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-inverse83.5%

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

        \[\leadsto \color{blue}{0} \]
    7. Simplified83.5%

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

    if -4.999999999999985e-310 < x < 0.023

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

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

      \[\leadsto \color{blue}{\frac{x \cdot \left(1 + -0.5 \cdot x\right) - \log x}{n}} \]
    5. Taylor expanded in x around 0 50.9%

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

    if 0.023 < x < 1.40000000000000008e54 or 1.79999999999999996e94 < x < 2.0000000000000001e161

    1. Initial program 43.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 92.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. associate-/r*94.5%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5 \cdot 10^{-310}:\\ \;\;\;\;0\\ \mathbf{elif}\;x \leq 0.023:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{+54} \lor \neg \left(x \leq 1.8 \cdot 10^{+94}\right) \land x \leq 2 \cdot 10^{+161}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 63.4% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -5 \cdot 10^{-310}:\\ \;\;\;\;0\\ \mathbf{elif}\;x \leq 0.023:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 9.6 \cdot 10^{+50} \lor \neg \left(x \leq 2.35 \cdot 10^{+98}\right) \land x \leq 3.3 \cdot 10^{+161}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= x -5e-310)
   0.0
   (if (<= x 0.023)
     (/ (log x) (- n))
     (if (or (<= x 9.6e+50) (and (not (<= x 2.35e+98)) (<= x 3.3e+161)))
       (/ (/ 1.0 n) x)
       0.0))))
double code(double x, double n) {
	double tmp;
	if (x <= -5e-310) {
		tmp = 0.0;
	} else if (x <= 0.023) {
		tmp = log(x) / -n;
	} else if ((x <= 9.6e+50) || (!(x <= 2.35e+98) && (x <= 3.3e+161))) {
		tmp = (1.0 / n) / x;
	} else {
		tmp = 0.0;
	}
	return tmp;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    real(8) :: tmp
    if (x <= (-5d-310)) then
        tmp = 0.0d0
    else if (x <= 0.023d0) then
        tmp = log(x) / -n
    else if ((x <= 9.6d+50) .or. (.not. (x <= 2.35d+98)) .and. (x <= 3.3d+161)) then
        tmp = (1.0d0 / n) / x
    else
        tmp = 0.0d0
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double tmp;
	if (x <= -5e-310) {
		tmp = 0.0;
	} else if (x <= 0.023) {
		tmp = Math.log(x) / -n;
	} else if ((x <= 9.6e+50) || (!(x <= 2.35e+98) && (x <= 3.3e+161))) {
		tmp = (1.0 / n) / x;
	} else {
		tmp = 0.0;
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if x <= -5e-310:
		tmp = 0.0
	elif x <= 0.023:
		tmp = math.log(x) / -n
	elif (x <= 9.6e+50) or (not (x <= 2.35e+98) and (x <= 3.3e+161)):
		tmp = (1.0 / n) / x
	else:
		tmp = 0.0
	return tmp
function code(x, n)
	tmp = 0.0
	if (x <= -5e-310)
		tmp = 0.0;
	elseif (x <= 0.023)
		tmp = Float64(log(x) / Float64(-n));
	elseif ((x <= 9.6e+50) || (!(x <= 2.35e+98) && (x <= 3.3e+161)))
		tmp = Float64(Float64(1.0 / n) / x);
	else
		tmp = 0.0;
	end
	return tmp
end
function tmp_2 = code(x, n)
	tmp = 0.0;
	if (x <= -5e-310)
		tmp = 0.0;
	elseif (x <= 0.023)
		tmp = log(x) / -n;
	elseif ((x <= 9.6e+50) || (~((x <= 2.35e+98)) && (x <= 3.3e+161)))
		tmp = (1.0 / n) / x;
	else
		tmp = 0.0;
	end
	tmp_2 = tmp;
end
code[x_, n_] := If[LessEqual[x, -5e-310], 0.0, If[LessEqual[x, 0.023], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[Or[LessEqual[x, 9.6e+50], And[N[Not[LessEqual[x, 2.35e+98]], $MachinePrecision], LessEqual[x, 3.3e+161]]], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], 0.0]]]
\begin{array}{l}

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

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

\mathbf{elif}\;x \leq 9.6 \cdot 10^{+50} \lor \neg \left(x \leq 2.35 \cdot 10^{+98}\right) \land x \leq 3.3 \cdot 10^{+161}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -4.999999999999985e-310 or 9.6000000000000007e50 < x < 2.34999999999999985e98 or 3.29999999999999997e161 < x

    1. Initial program 80.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-neg80.3%

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

        \[\leadsto \color{blue}{\left(-{x}^{\left(\frac{1}{n}\right)}\right) + {\left(x + 1\right)}^{\left(\frac{1}{n}\right)}} \]
      3. add-log-exp80.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-exp80.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-log80.3%

        \[\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. pow-to-exp52.6%

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

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

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

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

      \[\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 40.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-neg40.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-inverse83.5%

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

        \[\leadsto \color{blue}{0} \]
    7. Simplified83.5%

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

    if -4.999999999999985e-310 < x < 0.023

    1. Initial program 40.4%

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

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

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

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

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

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

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

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

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

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

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

    if 0.023 < x < 9.6000000000000007e50 or 2.34999999999999985e98 < x < 3.29999999999999997e161

    1. Initial program 43.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 92.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. associate-/r*94.5%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5 \cdot 10^{-310}:\\ \;\;\;\;0\\ \mathbf{elif}\;x \leq 0.023:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 9.6 \cdot 10^{+50} \lor \neg \left(x \leq 2.35 \cdot 10^{+98}\right) \land x \leq 3.3 \cdot 10^{+161}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 16: 49.8% accurate, 8.4× speedup?

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

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

\mathbf{elif}\;x \leq 8.5 \cdot 10^{+50} \lor \neg \left(x \leq 2.2 \cdot 10^{+99}\right) \land x \leq 2.7 \cdot 10^{+116}:\\
\;\;\;\;\frac{1}{n \cdot x}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 4.49999999999999974e-291 or 8.49999999999999961e50 < x < 2.19999999999999978e99 or 2.7e116 < x

    1. Initial program 75.9%

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

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

        \[\leadsto \color{blue}{\left(-{x}^{\left(\frac{1}{n}\right)}\right) + {\left(x + 1\right)}^{\left(\frac{1}{n}\right)}} \]
      3. add-log-exp75.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-exp75.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-log75.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. pow-to-exp52.5%

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

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

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

        \[\leadsto \log \left(e^{-{x}^{\left(\frac{1}{n}\right)}} \cdot e^{e^{\frac{\color{blue}{\mathsf{log1p}\left(x\right)}}{n}}}\right) \]
    4. Applied egg-rr63.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 39.7%

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

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

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

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

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

    if 4.49999999999999974e-291 < x < 8.49999999999999961e50 or 2.19999999999999978e99 < x < 2.7e116

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 4.5 \cdot 10^{-291}:\\ \;\;\;\;0\\ \mathbf{elif}\;x \leq 8.5 \cdot 10^{+50} \lor \neg \left(x \leq 2.2 \cdot 10^{+99}\right) \land x \leq 2.7 \cdot 10^{+116}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 17: 50.0% accurate, 8.4× speedup?

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

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

\mathbf{elif}\;x \leq 1.2 \cdot 10^{+55} \lor \neg \left(x \leq 4.5 \cdot 10^{+100}\right) \land x \leq 1.3 \cdot 10^{+162}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 4.49999999999999974e-291 or 1.2e55 < x < 4.50000000000000036e100 or 1.3e162 < x

    1. Initial program 77.2%

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

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

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

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

        \[\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-log77.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. pow-to-exp51.7%

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

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

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

        \[\leadsto \log \left(e^{-{x}^{\left(\frac{1}{n}\right)}} \cdot e^{e^{\frac{\color{blue}{\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 37.8%

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

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

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

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

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

    if 4.49999999999999974e-291 < x < 1.2e55 or 4.50000000000000036e100 < x < 1.3e162

    1. Initial program 41.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 42.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 4.5 \cdot 10^{-291}:\\ \;\;\;\;0\\ \mathbf{elif}\;x \leq 1.2 \cdot 10^{+55} \lor \neg \left(x \leq 4.5 \cdot 10^{+100}\right) \land x \leq 1.3 \cdot 10^{+162}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 18: 41.0% 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 55.5%

    \[{\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-neg55.5%

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

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

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

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

      \[\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. pow-to-exp45.3%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0} \]
  7. Simplified37.8%

    \[\leadsto \color{blue}{0} \]
  8. Final simplification37.8%

    \[\leadsto 0 \]
  9. Add Preprocessing

Reproduce

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