2nthrt (problem 3.4.6)

Percentage Accurate: 53.0% → 85.9%
Time: 23.3s
Alternatives: 14
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 14 alternatives:

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

Initial Program: 53.0% accurate, 1.0× speedup?

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

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

Alternative 1: 85.9% accurate, 0.1× speedup?

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

\\
\begin{array}{l}
t_0 := \sqrt[3]{\sqrt[3]{x}}\\
\mathbf{if}\;\frac{1}{n} \leq -1:\\
\;\;\;\;{\left(1 + x\right)}^{\left(\frac{1}{n}\right)} - {\left(t_0 \cdot \left(t_0 \cdot t_0\right)\right)}^{\left(\frac{1}{n}\right)} \cdot {\left(\sqrt[3]{x \cdot x}\right)}^{\left(\frac{1}{n}\right)}\\

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

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


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

    1. Initial program 99.9%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Step-by-step derivation
      1. add-cube-cbrt99.9%

        \[\leadsto {\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)} \]
      2. unpow-prod-down99.9%

        \[\leadsto {\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)}} \]
      3. cbrt-unprod99.9%

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

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

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

      \[\leadsto {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - \color{blue}{{\left(\sqrt[3]{x \cdot x}\right)}^{\left({n}^{-1}\right)} \cdot {\left(\sqrt[3]{x}\right)}^{\left({n}^{-1}\right)}} \]
    4. Step-by-step derivation
      1. *-commutative99.9%

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

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

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

      \[\leadsto {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - \color{blue}{{\left(\sqrt[3]{x}\right)}^{\left(\frac{1}{n}\right)} \cdot {\left(\sqrt[3]{x \cdot x}\right)}^{\left(\frac{1}{n}\right)}} \]
    6. Step-by-step derivation
      1. add-cube-cbrt99.9%

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

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

    if -1 < (/.f64 1 n) < 500

    1. Initial program 36.4%

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

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

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

    if 500 < (/.f64 1 n)

    1. Initial program 44.8%

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

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

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

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

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

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

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

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

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{{n}^{-1}}{\color{blue}{\frac{2}{2}}}\right)} \]
      8. associate-/l*97.6%

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

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

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

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

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

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

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

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

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

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

Alternative 2: 86.0% accurate, 0.3× speedup?

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

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

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

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


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

    1. Initial program 91.8%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{{x}^{\left({n}^{-1}\right)}}}{n \cdot x} \]
      11. unpow-194.9%

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

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

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

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

    1. Initial program 35.8%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Step-by-step derivation
      1. add-cube-cbrt35.8%

        \[\leadsto {\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)} \]
      2. unpow-prod-down35.8%

        \[\leadsto {\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)}} \]
      3. cbrt-unprod11.1%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\log \left(\frac{x + 1}{{x}^{0.3333333333333333} \cdot \color{blue}{{x}^{\left(2 \cdot 0.3333333333333333\right)}}}\right)}{n} \]
      5. pow-prod-up77.0%

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

        \[\leadsto \frac{\log \left(\frac{x + 1}{{x}^{\left(0.3333333333333333 + \color{blue}{0.6666666666666666}\right)}}\right)}{n} \]
      7. metadata-eval77.0%

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

        \[\leadsto \frac{\log \left(\frac{x + 1}{\color{blue}{x}}\right)}{n} \]
    8. Applied egg-rr77.0%

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

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

    1. Initial program 45.6%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Step-by-step derivation
      1. add-exp-log45.6%

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

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

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

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

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

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

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

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

Alternative 3: 86.0% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-43}:\\ \;\;\;\;\frac{t_0}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-18}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\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) -5e-43)
     (/ t_0 (* n x))
     (if (<= (/ 1.0 n) 2e-18)
       (/ (log (/ (+ 1.0 x) 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-43) {
		tmp = t_0 / (n * x);
	} else if ((1.0 / n) <= 2e-18) {
		tmp = log(((1.0 + x) / 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-43) {
		tmp = t_0 / (n * x);
	} else if ((1.0 / n) <= 2e-18) {
		tmp = Math.log(((1.0 + x) / 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-43:
		tmp = t_0 / (n * x)
	elif (1.0 / n) <= 2e-18:
		tmp = math.log(((1.0 + x) / 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-43)
		tmp = Float64(t_0 / Float64(n * x));
	elseif (Float64(1.0 / n) <= 2e-18)
		tmp = Float64(log(Float64(Float64(1.0 + x) / 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-43], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-18], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / 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^{-43}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\

\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-18}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\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 1 n) < -5.00000000000000019e-43

    1. Initial program 91.8%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{{x}^{\left({n}^{-1}\right)}}}{n \cdot x} \]
      11. unpow-194.9%

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

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

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

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

    1. Initial program 35.8%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Step-by-step derivation
      1. add-cube-cbrt35.8%

        \[\leadsto {\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)} \]
      2. unpow-prod-down35.8%

        \[\leadsto {\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)}} \]
      3. cbrt-unprod11.1%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\log \left(\frac{x + 1}{{x}^{0.3333333333333333} \cdot \color{blue}{{x}^{\left(2 \cdot 0.3333333333333333\right)}}}\right)}{n} \]
      5. pow-prod-up77.0%

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

        \[\leadsto \frac{\log \left(\frac{x + 1}{{x}^{\left(0.3333333333333333 + \color{blue}{0.6666666666666666}\right)}}\right)}{n} \]
      7. metadata-eval77.0%

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

        \[\leadsto \frac{\log \left(\frac{x + 1}{\color{blue}{x}}\right)}{n} \]
    8. Applied egg-rr77.0%

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

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

    1. Initial program 45.6%

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

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

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

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

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

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

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

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

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{{n}^{-1}}{\color{blue}{\frac{2}{2}}}\right)} \]
      8. associate-/l*92.7%

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

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

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

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

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

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

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

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

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

Alternative 4: 86.1% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 91.8%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{{x}^{\left({n}^{-1}\right)}}}{n \cdot x} \]
      11. unpow-194.9%

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

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

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

    if -5.00000000000000019e-43 < (/.f64 1 n) < 5.0000000000000001e-9

    1. Initial program 35.6%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Step-by-step derivation
      1. add-cube-cbrt35.6%

        \[\leadsto {\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)} \]
      2. unpow-prod-down35.6%

        \[\leadsto {\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)}} \]
      3. cbrt-unprod11.0%

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

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

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

      \[\leadsto {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - \color{blue}{{\left(\sqrt[3]{x \cdot x}\right)}^{\left({n}^{-1}\right)} \cdot {\left(\sqrt[3]{x}\right)}^{\left({n}^{-1}\right)}} \]
    4. Step-by-step derivation
      1. *-commutative11.0%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\log \left(\frac{x + 1}{{x}^{0.3333333333333333} \cdot \color{blue}{{x}^{\left(2 \cdot 0.3333333333333333\right)}}}\right)}{n} \]
      5. pow-prod-up76.4%

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

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

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

        \[\leadsto \frac{\log \left(\frac{x + 1}{\color{blue}{x}}\right)}{n} \]
    8. Applied egg-rr76.4%

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

    if 5.0000000000000001e-9 < (/.f64 1 n)

    1. Initial program 46.5%

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

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

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

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

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

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

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

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

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{{n}^{-1}}{\color{blue}{\frac{2}{2}}}\right)} \]
      8. associate-/l*94.6%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-43}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-9}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{else}:\\ \;\;\;\;e^{\frac{x}{n}} - {x}^{\left(\frac{1}{n}\right)}\\ \end{array} \]

Alternative 5: 53.9% accurate, 1.7× speedup?

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

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+161}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (/.f64 1 n) < -5.0000000000000001e-9 or 2.0000000000000001e-18 < (/.f64 1 n) < 4.9999999999999997e161

    1. Initial program 93.4%

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

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

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

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

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

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

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

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

    if -5.0000000000000001e-9 < (/.f64 1 n) < 5.0000000000000002e-220

    1. Initial program 44.1%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{{x}^{\left({n}^{-1}\right)}}}{n \cdot x} \]
      11. unpow-163.7%

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{1}{n}}{x}} \]
    7. Simplified66.5%

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

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

    1. Initial program 16.4%

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

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

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

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

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

        \[\leadsto \left(1 + \mathsf{fma}\left(x \cdot x, \frac{\color{blue}{0.5}}{{n}^{2}} - 0.5 \cdot \frac{1}{n}, \frac{x}{n}\right)\right) - {x}^{\left(\frac{1}{n}\right)} \]
      5. unpow24.0%

        \[\leadsto \left(1 + \mathsf{fma}\left(x \cdot x, \frac{0.5}{\color{blue}{n \cdot n}} - 0.5 \cdot \frac{1}{n}, \frac{x}{n}\right)\right) - {x}^{\left(\frac{1}{n}\right)} \]
      6. associate-*r/4.0%

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

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

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

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

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

        \[\leadsto \frac{\left(x + \color{blue}{\left(x \cdot x\right)} \cdot -0.5\right) - \log x}{n} \]
    7. Simplified56.5%

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

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

    if 4.9999999999999997e161 < (/.f64 1 n)

    1. Initial program 12.0%

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

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

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

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

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

        \[\leadsto \left(1 + \mathsf{fma}\left(x \cdot x, \frac{\color{blue}{0.5}}{{n}^{2}} - 0.5 \cdot \frac{1}{n}, \frac{x}{n}\right)\right) - {x}^{\left(\frac{1}{n}\right)} \]
      5. unpow266.7%

        \[\leadsto \left(1 + \mathsf{fma}\left(x \cdot x, \frac{0.5}{\color{blue}{n \cdot n}} - 0.5 \cdot \frac{1}{n}, \frac{x}{n}\right)\right) - {x}^{\left(\frac{1}{n}\right)} \]
      6. associate-*r/66.7%

        \[\leadsto \left(1 + \mathsf{fma}\left(x \cdot x, \frac{0.5}{n \cdot n} - \color{blue}{\frac{0.5 \cdot 1}{n}}, \frac{x}{n}\right)\right) - {x}^{\left(\frac{1}{n}\right)} \]
      7. metadata-eval66.7%

        \[\leadsto \left(1 + \mathsf{fma}\left(x \cdot x, \frac{0.5}{n \cdot n} - \frac{\color{blue}{0.5}}{n}, \frac{x}{n}\right)\right) - {x}^{\left(\frac{1}{n}\right)} \]
    4. Simplified66.7%

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

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

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

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

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

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

        \[\leadsto {x}^{2} \cdot \left(\frac{0.5}{n \cdot n} - \frac{\color{blue}{0.5}}{n}\right) \]
      6. unpow266.7%

        \[\leadsto \color{blue}{\left(x \cdot x\right)} \cdot \left(\frac{0.5}{n \cdot n} - \frac{0.5}{n}\right) \]
      7. associate-*l*90.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-9}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-220}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-18}:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+161}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(x \cdot \left(\frac{0.5}{n \cdot n} - \frac{0.5}{n}\right)\right)\\ \end{array} \]

Alternative 6: 82.5% accurate, 1.7× speedup?

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

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

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

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

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


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

    1. Initial program 91.8%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{{x}^{\left({n}^{-1}\right)}}}{n \cdot x} \]
      11. unpow-194.9%

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

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

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

    if -5.00000000000000019e-43 < (/.f64 1 n) < 5.0000000000000001e-9

    1. Initial program 35.6%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Step-by-step derivation
      1. add-cube-cbrt35.6%

        \[\leadsto {\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)} \]
      2. unpow-prod-down35.6%

        \[\leadsto {\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)}} \]
      3. cbrt-unprod11.0%

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

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

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

      \[\leadsto {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - \color{blue}{{\left(\sqrt[3]{x \cdot x}\right)}^{\left({n}^{-1}\right)} \cdot {\left(\sqrt[3]{x}\right)}^{\left({n}^{-1}\right)}} \]
    4. Step-by-step derivation
      1. *-commutative11.0%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\log \left(\frac{x + 1}{{x}^{0.3333333333333333} \cdot \color{blue}{{x}^{\left(2 \cdot 0.3333333333333333\right)}}}\right)}{n} \]
      5. pow-prod-up76.4%

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

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

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

        \[\leadsto \frac{\log \left(\frac{x + 1}{\color{blue}{x}}\right)}{n} \]
    8. Applied egg-rr76.4%

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

    if 5.0000000000000001e-9 < (/.f64 1 n) < 4.9999999999999997e161

    1. Initial program 76.7%

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

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

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

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

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

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

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

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

    if 4.9999999999999997e161 < (/.f64 1 n)

    1. Initial program 12.0%

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

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

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

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

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

        \[\leadsto \left(1 + \mathsf{fma}\left(x \cdot x, \frac{\color{blue}{0.5}}{{n}^{2}} - 0.5 \cdot \frac{1}{n}, \frac{x}{n}\right)\right) - {x}^{\left(\frac{1}{n}\right)} \]
      5. unpow266.7%

        \[\leadsto \left(1 + \mathsf{fma}\left(x \cdot x, \frac{0.5}{\color{blue}{n \cdot n}} - 0.5 \cdot \frac{1}{n}, \frac{x}{n}\right)\right) - {x}^{\left(\frac{1}{n}\right)} \]
      6. associate-*r/66.7%

        \[\leadsto \left(1 + \mathsf{fma}\left(x \cdot x, \frac{0.5}{n \cdot n} - \color{blue}{\frac{0.5 \cdot 1}{n}}, \frac{x}{n}\right)\right) - {x}^{\left(\frac{1}{n}\right)} \]
      7. metadata-eval66.7%

        \[\leadsto \left(1 + \mathsf{fma}\left(x \cdot x, \frac{0.5}{n \cdot n} - \frac{\color{blue}{0.5}}{n}, \frac{x}{n}\right)\right) - {x}^{\left(\frac{1}{n}\right)} \]
    4. Simplified66.7%

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

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

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

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

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

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

        \[\leadsto {x}^{2} \cdot \left(\frac{0.5}{n \cdot n} - \frac{\color{blue}{0.5}}{n}\right) \]
      6. unpow266.7%

        \[\leadsto \color{blue}{\left(x \cdot x\right)} \cdot \left(\frac{0.5}{n \cdot n} - \frac{0.5}{n}\right) \]
      7. associate-*l*90.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-43}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-9}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+161}:\\ \;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(x \cdot \left(\frac{0.5}{n \cdot n} - \frac{0.5}{n}\right)\right)\\ \end{array} \]

Alternative 7: 82.4% accurate, 1.8× speedup?

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+161}:\\
\;\;\;\;1 - t_0\\

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


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

    1. Initial program 91.8%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{{x}^{\left({n}^{-1}\right)}}}{n \cdot x} \]
      11. unpow-194.9%

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

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

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

    if -5.00000000000000019e-43 < (/.f64 1 n) < 5.0000000000000001e-9

    1. Initial program 35.6%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Step-by-step derivation
      1. add-cube-cbrt35.6%

        \[\leadsto {\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)} \]
      2. unpow-prod-down35.6%

        \[\leadsto {\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)}} \]
      3. cbrt-unprod11.0%

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

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

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

      \[\leadsto {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - \color{blue}{{\left(\sqrt[3]{x \cdot x}\right)}^{\left({n}^{-1}\right)} \cdot {\left(\sqrt[3]{x}\right)}^{\left({n}^{-1}\right)}} \]
    4. Step-by-step derivation
      1. *-commutative11.0%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\log \left(\frac{x + 1}{{x}^{0.3333333333333333} \cdot \color{blue}{{x}^{\left(2 \cdot 0.3333333333333333\right)}}}\right)}{n} \]
      5. pow-prod-up76.4%

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

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

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

        \[\leadsto \frac{\log \left(\frac{x + 1}{\color{blue}{x}}\right)}{n} \]
    8. Applied egg-rr76.4%

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

    if 5.0000000000000001e-9 < (/.f64 1 n) < 4.9999999999999997e161

    1. Initial program 76.7%

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

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

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

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

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

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

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

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

    if 4.9999999999999997e161 < (/.f64 1 n)

    1. Initial program 12.0%

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

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

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

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

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

        \[\leadsto \left(1 + \mathsf{fma}\left(x \cdot x, \frac{\color{blue}{0.5}}{{n}^{2}} - 0.5 \cdot \frac{1}{n}, \frac{x}{n}\right)\right) - {x}^{\left(\frac{1}{n}\right)} \]
      5. unpow266.7%

        \[\leadsto \left(1 + \mathsf{fma}\left(x \cdot x, \frac{0.5}{\color{blue}{n \cdot n}} - 0.5 \cdot \frac{1}{n}, \frac{x}{n}\right)\right) - {x}^{\left(\frac{1}{n}\right)} \]
      6. associate-*r/66.7%

        \[\leadsto \left(1 + \mathsf{fma}\left(x \cdot x, \frac{0.5}{n \cdot n} - \color{blue}{\frac{0.5 \cdot 1}{n}}, \frac{x}{n}\right)\right) - {x}^{\left(\frac{1}{n}\right)} \]
      7. metadata-eval66.7%

        \[\leadsto \left(1 + \mathsf{fma}\left(x \cdot x, \frac{0.5}{n \cdot n} - \frac{\color{blue}{0.5}}{n}, \frac{x}{n}\right)\right) - {x}^{\left(\frac{1}{n}\right)} \]
    4. Simplified66.7%

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

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

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

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

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

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

        \[\leadsto {x}^{2} \cdot \left(\frac{0.5}{n \cdot n} - \frac{\color{blue}{0.5}}{n}\right) \]
      6. unpow266.7%

        \[\leadsto \color{blue}{\left(x \cdot x\right)} \cdot \left(\frac{0.5}{n \cdot n} - \frac{0.5}{n}\right) \]
      7. associate-*l*90.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-43}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-9}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+161}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(x \cdot \left(\frac{0.5}{n \cdot n} - \frac{0.5}{n}\right)\right)\\ \end{array} \]

Alternative 8: 68.0% accurate, 1.8× speedup?

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

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

\mathbf{elif}\;n \leq 3 \cdot 10^{-309}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;n \leq 10^{-167}:\\
\;\;\;\;x \cdot \left(x \cdot \left(\frac{0.5}{n \cdot n} - \frac{0.5}{n}\right)\right)\\

\mathbf{elif}\;n \leq 215000000:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if n < -2.20000000000000006e-192 or 2.15e8 < n

    1. Initial program 50.0%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Step-by-step derivation
      1. add-cube-cbrt50.0%

        \[\leadsto {\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)} \]
      2. unpow-prod-down50.0%

        \[\leadsto {\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)}} \]
      3. cbrt-unprod30.9%

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

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

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

      \[\leadsto {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - \color{blue}{{\left(\sqrt[3]{x \cdot x}\right)}^{\left({n}^{-1}\right)} \cdot {\left(\sqrt[3]{x}\right)}^{\left({n}^{-1}\right)}} \]
    4. Step-by-step derivation
      1. *-commutative30.9%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\log \left(\frac{x + 1}{{x}^{0.3333333333333333} \cdot \color{blue}{{x}^{\left(2 \cdot 0.3333333333333333\right)}}}\right)}{n} \]
      5. pow-prod-up69.9%

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

        \[\leadsto \frac{\log \left(\frac{x + 1}{{x}^{\left(0.3333333333333333 + \color{blue}{0.6666666666666666}\right)}}\right)}{n} \]
      7. metadata-eval69.9%

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

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

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

    if -2.20000000000000006e-192 < n < 3.000000000000001e-309 or 1e-167 < n < 2.15e8

    1. Initial program 91.0%

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

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

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

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

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

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

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

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

    if 3.000000000000001e-309 < n < 1e-167

    1. Initial program 12.0%

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

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

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

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

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

        \[\leadsto \left(1 + \mathsf{fma}\left(x \cdot x, \frac{\color{blue}{0.5}}{{n}^{2}} - 0.5 \cdot \frac{1}{n}, \frac{x}{n}\right)\right) - {x}^{\left(\frac{1}{n}\right)} \]
      5. unpow266.7%

        \[\leadsto \left(1 + \mathsf{fma}\left(x \cdot x, \frac{0.5}{\color{blue}{n \cdot n}} - 0.5 \cdot \frac{1}{n}, \frac{x}{n}\right)\right) - {x}^{\left(\frac{1}{n}\right)} \]
      6. associate-*r/66.7%

        \[\leadsto \left(1 + \mathsf{fma}\left(x \cdot x, \frac{0.5}{n \cdot n} - \color{blue}{\frac{0.5 \cdot 1}{n}}, \frac{x}{n}\right)\right) - {x}^{\left(\frac{1}{n}\right)} \]
      7. metadata-eval66.7%

        \[\leadsto \left(1 + \mathsf{fma}\left(x \cdot x, \frac{0.5}{n \cdot n} - \frac{\color{blue}{0.5}}{n}, \frac{x}{n}\right)\right) - {x}^{\left(\frac{1}{n}\right)} \]
    4. Simplified66.7%

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

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

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

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

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

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

        \[\leadsto {x}^{2} \cdot \left(\frac{0.5}{n \cdot n} - \frac{\color{blue}{0.5}}{n}\right) \]
      6. unpow266.7%

        \[\leadsto \color{blue}{\left(x \cdot x\right)} \cdot \left(\frac{0.5}{n \cdot n} - \frac{0.5}{n}\right) \]
      7. associate-*l*90.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -2.2 \cdot 10^{-192}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{elif}\;n \leq 3 \cdot 10^{-309}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;n \leq 10^{-167}:\\ \;\;\;\;x \cdot \left(x \cdot \left(\frac{0.5}{n \cdot n} - \frac{0.5}{n}\right)\right)\\ \mathbf{elif}\;n \leq 215000000:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \end{array} \]

Alternative 9: 56.4% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.8 \cdot 10^{-264}:\\
\;\;\;\;\frac{-\log x}{n}\\

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

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

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


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

    1. Initial program 48.5%

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.7999999999999997e-264 < x < 7.5e-247

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{{x}^{\left({n}^{-1}\right)}}}{n \cdot x} \]
      11. unpow-187.5%

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

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

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

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

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

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

    if 7.5e-247 < x < 1

    1. Initial program 43.6%

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

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

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

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

        \[\leadsto \left(1 + \mathsf{fma}\left(x \cdot x, \color{blue}{\frac{0.5 \cdot 1}{{n}^{2}}} - 0.5 \cdot \frac{1}{n}, \frac{x}{n}\right)\right) - {x}^{\left(\frac{1}{n}\right)} \]
      4. metadata-eval35.9%

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

        \[\leadsto \left(1 + \mathsf{fma}\left(x \cdot x, \frac{0.5}{\color{blue}{n \cdot n}} - 0.5 \cdot \frac{1}{n}, \frac{x}{n}\right)\right) - {x}^{\left(\frac{1}{n}\right)} \]
      6. associate-*r/35.9%

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

        \[\leadsto \left(1 + \mathsf{fma}\left(x \cdot x, \frac{0.5}{n \cdot n} - \frac{\color{blue}{0.5}}{n}, \frac{x}{n}\right)\right) - {x}^{\left(\frac{1}{n}\right)} \]
    4. Simplified35.9%

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

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

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

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

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

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

    if 1 < x

    1. Initial program 68.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{{x}^{\left({n}^{-1}\right)}}}{n \cdot x} \]
      11. unpow-196.8%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 4.8 \cdot 10^{-264}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 7.5 \cdot 10^{-247}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \end{array} \]

Alternative 10: 56.1% accurate, 1.9× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 5.0000000000000001e-264 or 8.1999999999999997e-247 < x < 0.52000000000000002

    1. Initial program 44.4%

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.0000000000000001e-264 < x < 8.1999999999999997e-247

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{{x}^{\left({n}^{-1}\right)}}}{n \cdot x} \]
      11. unpow-187.5%

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

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

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

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

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

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

    if 0.52000000000000002 < x

    1. Initial program 68.0%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{{x}^{\left({n}^{-1}\right)}}}{n \cdot x} \]
      11. unpow-196.8%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 5 \cdot 10^{-264}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 8.2 \cdot 10^{-247}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \mathbf{elif}\;x \leq 0.52:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \end{array} \]

Alternative 11: 43.0% accurate, 12.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq 5 \cdot 10^{-7}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\

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


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

    1. Initial program 59.4%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\color{blue}{{x}^{\left({n}^{-1}\right)}}}{n \cdot x} \]
      11. unpow-172.1%

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

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

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

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

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

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

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

    1. Initial program 43.7%

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

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

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

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

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

        \[\leadsto \left(1 + \mathsf{fma}\left(x \cdot x, \frac{\color{blue}{0.5}}{{n}^{2}} - 0.5 \cdot \frac{1}{n}, \frac{x}{n}\right)\right) - {x}^{\left(\frac{1}{n}\right)} \]
      5. unpow266.1%

        \[\leadsto \left(1 + \mathsf{fma}\left(x \cdot x, \frac{0.5}{\color{blue}{n \cdot n}} - 0.5 \cdot \frac{1}{n}, \frac{x}{n}\right)\right) - {x}^{\left(\frac{1}{n}\right)} \]
      6. associate-*r/66.1%

        \[\leadsto \left(1 + \mathsf{fma}\left(x \cdot x, \frac{0.5}{n \cdot n} - \color{blue}{\frac{0.5 \cdot 1}{n}}, \frac{x}{n}\right)\right) - {x}^{\left(\frac{1}{n}\right)} \]
      7. metadata-eval66.1%

        \[\leadsto \left(1 + \mathsf{fma}\left(x \cdot x, \frac{0.5}{n \cdot n} - \frac{\color{blue}{0.5}}{n}, \frac{x}{n}\right)\right) - {x}^{\left(\frac{1}{n}\right)} \]
    4. Simplified66.1%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(x \cdot x\right)} \cdot \left(\frac{0.5}{n \cdot n} - \frac{0.5}{n}\right) \]
      7. associate-*l*52.3%

        \[\leadsto \color{blue}{x \cdot \left(x \cdot \left(\frac{0.5}{n \cdot n} - \frac{0.5}{n}\right)\right)} \]
    7. Simplified52.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq 5 \cdot 10^{-7}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(x \cdot \left(\frac{0.5}{n \cdot n} - \frac{0.5}{n}\right)\right)\\ \end{array} \]

Alternative 12: 40.6% accurate, 42.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{{x}^{\left({n}^{-1}\right)}}}{n \cdot x} \]
    11. unpow-161.3%

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

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

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

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

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

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

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

Alternative 13: 41.2% accurate, 42.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{{x}^{\left({n}^{-1}\right)}}}{n \cdot x} \]
    11. unpow-161.3%

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{1}{n}}{x}} \]
  7. Simplified47.6%

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

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

Alternative 14: 4.6% accurate, 70.3× speedup?

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

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

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

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

      \[\leadsto \left(1 + \color{blue}{\mathsf{fma}\left({x}^{2}, 0.5 \cdot \frac{1}{{n}^{2}} - 0.5 \cdot \frac{1}{n}, \frac{x}{n}\right)}\right) - {x}^{\left(\frac{1}{n}\right)} \]
    2. unpow222.5%

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

      \[\leadsto \left(1 + \mathsf{fma}\left(x \cdot x, \color{blue}{\frac{0.5 \cdot 1}{{n}^{2}}} - 0.5 \cdot \frac{1}{n}, \frac{x}{n}\right)\right) - {x}^{\left(\frac{1}{n}\right)} \]
    4. metadata-eval22.5%

      \[\leadsto \left(1 + \mathsf{fma}\left(x \cdot x, \frac{\color{blue}{0.5}}{{n}^{2}} - 0.5 \cdot \frac{1}{n}, \frac{x}{n}\right)\right) - {x}^{\left(\frac{1}{n}\right)} \]
    5. unpow222.5%

      \[\leadsto \left(1 + \mathsf{fma}\left(x \cdot x, \frac{0.5}{\color{blue}{n \cdot n}} - 0.5 \cdot \frac{1}{n}, \frac{x}{n}\right)\right) - {x}^{\left(\frac{1}{n}\right)} \]
    6. associate-*r/22.5%

      \[\leadsto \left(1 + \mathsf{fma}\left(x \cdot x, \frac{0.5}{n \cdot n} - \color{blue}{\frac{0.5 \cdot 1}{n}}, \frac{x}{n}\right)\right) - {x}^{\left(\frac{1}{n}\right)} \]
    7. metadata-eval22.5%

      \[\leadsto \left(1 + \mathsf{fma}\left(x \cdot x, \frac{0.5}{n \cdot n} - \frac{\color{blue}{0.5}}{n}, \frac{x}{n}\right)\right) - {x}^{\left(\frac{1}{n}\right)} \]
  4. Simplified22.5%

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

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

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

      \[\leadsto \frac{\left(x + \color{blue}{\left(x \cdot x\right)} \cdot -0.5\right) - \log x}{n} \]
  7. Simplified25.3%

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

    \[\leadsto \frac{\color{blue}{x} - \log x}{n} \]
  9. Taylor expanded in x around inf 4.4%

    \[\leadsto \color{blue}{\frac{x}{n}} \]
  10. Final simplification4.4%

    \[\leadsto \frac{x}{n} \]

Reproduce

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