2nthrt (problem 3.4.6)

Percentage Accurate: 54.2% → 85.0%
Time: 33.7s
Alternatives: 17
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 17 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: 54.2% accurate, 1.0× speedup?

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

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

Alternative 1: 85.0% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{{x}^{\left({n}^{-1}\right)}}\\ t_1 := \frac{\mathsf{log1p}\left(x\right)}{n}\\ \mathbf{if}\;n \leq -6900000:\\ \;\;\;\;\mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, t_1\right) - \mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{n \cdot n}, \frac{\log x}{n}\right)\\ \mathbf{elif}\;n \leq 1.2 \cdot 10^{-7}:\\ \;\;\;\;\mathsf{fma}\left(t_0, -t_0, e^{t_1}\right)\\ \mathbf{elif}\;n \leq 3.3 \cdot 10^{+78}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (sqrt (pow x (pow n -1.0)))) (t_1 (/ (log1p x) n)))
   (if (<= n -6900000.0)
     (-
      (fma 0.5 (/ (pow (log1p x) 2.0) (* n n)) t_1)
      (fma 0.5 (/ (pow (log x) 2.0) (* n n)) (/ (log x) n)))
     (if (<= n 1.2e-7)
       (fma t_0 (- t_0) (exp t_1))
       (if (<= n 3.3e+78)
         (/ (pow x (/ 1.0 n)) (* n x))
         (/ (- (log1p x) (log x)) n))))))
double code(double x, double n) {
	double t_0 = sqrt(pow(x, pow(n, -1.0)));
	double t_1 = log1p(x) / n;
	double tmp;
	if (n <= -6900000.0) {
		tmp = fma(0.5, (pow(log1p(x), 2.0) / (n * n)), t_1) - fma(0.5, (pow(log(x), 2.0) / (n * n)), (log(x) / n));
	} else if (n <= 1.2e-7) {
		tmp = fma(t_0, -t_0, exp(t_1));
	} else if (n <= 3.3e+78) {
		tmp = pow(x, (1.0 / n)) / (n * x);
	} else {
		tmp = (log1p(x) - log(x)) / n;
	}
	return tmp;
}
function code(x, n)
	t_0 = sqrt((x ^ (n ^ -1.0)))
	t_1 = Float64(log1p(x) / n)
	tmp = 0.0
	if (n <= -6900000.0)
		tmp = Float64(fma(0.5, Float64((log1p(x) ^ 2.0) / Float64(n * n)), t_1) - fma(0.5, Float64((log(x) ^ 2.0) / Float64(n * n)), Float64(log(x) / n)));
	elseif (n <= 1.2e-7)
		tmp = fma(t_0, Float64(-t_0), exp(t_1));
	elseif (n <= 3.3e+78)
		tmp = Float64((x ^ Float64(1.0 / n)) / Float64(n * x));
	else
		tmp = Float64(Float64(log1p(x) - log(x)) / n);
	end
	return tmp
end
code[x_, n_] := Block[{t$95$0 = N[Sqrt[N[Power[x, N[Power[n, -1.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[n, -6900000.0], N[(N[(0.5 * N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision] - N[(0.5 * N[(N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision] + N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.2e-7], N[(t$95$0 * (-t$95$0) + N[Exp[t$95$1], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 3.3e+78], N[(N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sqrt{{x}^{\left({n}^{-1}\right)}}\\
t_1 := \frac{\mathsf{log1p}\left(x\right)}{n}\\
\mathbf{if}\;n \leq -6900000:\\
\;\;\;\;\mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, t_1\right) - \mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{n \cdot n}, \frac{\log x}{n}\right)\\

\mathbf{elif}\;n \leq 1.2 \cdot 10^{-7}:\\
\;\;\;\;\mathsf{fma}\left(t_0, -t_0, e^{t_1}\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if n < -6.9e6

    1. Initial program 31.6%

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, \frac{\mathsf{log1p}\left(x\right)}{n}\right) - \color{blue}{\mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{{n}^{2}}, \frac{\log x}{n}\right)} \]
      6. unpow279.4%

        \[\leadsto \mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, \frac{\mathsf{log1p}\left(x\right)}{n}\right) - \mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{\color{blue}{n \cdot n}}, \frac{\log x}{n}\right) \]
    4. Simplified79.4%

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

    if -6.9e6 < n < 1.19999999999999989e-7

    1. Initial program 85.1%

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

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

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

        \[\leadsto \left(-\color{blue}{{x}^{\left(\frac{\frac{1}{n}}{2}\right)} \cdot {x}^{\left(\frac{\frac{1}{n}}{2}\right)}}\right) + {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} \]
      4. distribute-rgt-neg-in85.1%

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(\sqrt{{x}^{\left({n}^{-1}\right)}}, -\color{blue}{\sqrt{{x}^{\left(\frac{1}{n}\right)}}}, {\left(x + 1\right)}^{\left(\frac{1}{n}\right)}\right) \]
      11. pow185.1%

        \[\leadsto \mathsf{fma}\left(\sqrt{{x}^{\left({n}^{-1}\right)}}, -\sqrt{\color{blue}{{\left({x}^{\left(\frac{1}{n}\right)}\right)}^{1}}}, {\left(x + 1\right)}^{\left(\frac{1}{n}\right)}\right) \]
      12. pow185.1%

        \[\leadsto \mathsf{fma}\left(\sqrt{{x}^{\left({n}^{-1}\right)}}, -\sqrt{\color{blue}{{x}^{\left(\frac{1}{n}\right)}}}, {\left(x + 1\right)}^{\left(\frac{1}{n}\right)}\right) \]
      13. inv-pow85.1%

        \[\leadsto \mathsf{fma}\left(\sqrt{{x}^{\left({n}^{-1}\right)}}, -\sqrt{{x}^{\color{blue}{\left({n}^{-1}\right)}}}, {\left(x + 1\right)}^{\left(\frac{1}{n}\right)}\right) \]
      14. pow-to-exp85.1%

        \[\leadsto \mathsf{fma}\left(\sqrt{{x}^{\left({n}^{-1}\right)}}, -\sqrt{{x}^{\left({n}^{-1}\right)}}, \color{blue}{e^{\log \left(x + 1\right) \cdot \frac{1}{n}}}\right) \]
      15. un-div-inv85.1%

        \[\leadsto \mathsf{fma}\left(\sqrt{{x}^{\left({n}^{-1}\right)}}, -\sqrt{{x}^{\left({n}^{-1}\right)}}, e^{\color{blue}{\frac{\log \left(x + 1\right)}{n}}}\right) \]
      16. +-commutative85.1%

        \[\leadsto \mathsf{fma}\left(\sqrt{{x}^{\left({n}^{-1}\right)}}, -\sqrt{{x}^{\left({n}^{-1}\right)}}, e^{\frac{\log \color{blue}{\left(1 + x\right)}}{n}}\right) \]
      17. log1p-udef99.8%

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

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

    if 1.19999999999999989e-7 < n < 3.3e78

    1. Initial program 16.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.3e78 < n

    1. Initial program 23.5%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -6900000:\\ \;\;\;\;\mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, \frac{\mathsf{log1p}\left(x\right)}{n}\right) - \mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{n \cdot n}, \frac{\log x}{n}\right)\\ \mathbf{elif}\;n \leq 1.2 \cdot 10^{-7}:\\ \;\;\;\;\mathsf{fma}\left(\sqrt{{x}^{\left({n}^{-1}\right)}}, -\sqrt{{x}^{\left({n}^{-1}\right)}}, e^{\frac{\mathsf{log1p}\left(x\right)}{n}}\right)\\ \mathbf{elif}\;n \leq 3.3 \cdot 10^{+78}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\ \end{array} \]

Alternative 2: 85.1% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {x}^{\left(\frac{1}{n}\right)}\\ t_1 := \frac{\mathsf{log1p}\left(x\right)}{n}\\ \mathbf{if}\;n \leq -28000000:\\ \;\;\;\;\mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, t_1\right) - \mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{n \cdot n}, \frac{\log x}{n}\right)\\ \mathbf{elif}\;n \leq 1.2 \cdot 10^{-7}:\\ \;\;\;\;e^{t_1} - t_0\\ \mathbf{elif}\;n \leq 6.6 \cdot 10^{+77}:\\ \;\;\;\;\frac{t_0}{n \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ (log1p x) n)))
   (if (<= n -28000000.0)
     (-
      (fma 0.5 (/ (pow (log1p x) 2.0) (* n n)) t_1)
      (fma 0.5 (/ (pow (log x) 2.0) (* n n)) (/ (log x) n)))
     (if (<= n 1.2e-7)
       (- (exp t_1) t_0)
       (if (<= n 6.6e+77) (/ t_0 (* n x)) (/ (- (log1p x) (log x)) n))))))
double code(double x, double n) {
	double t_0 = pow(x, (1.0 / n));
	double t_1 = log1p(x) / n;
	double tmp;
	if (n <= -28000000.0) {
		tmp = fma(0.5, (pow(log1p(x), 2.0) / (n * n)), t_1) - fma(0.5, (pow(log(x), 2.0) / (n * n)), (log(x) / n));
	} else if (n <= 1.2e-7) {
		tmp = exp(t_1) - t_0;
	} else if (n <= 6.6e+77) {
		tmp = t_0 / (n * x);
	} else {
		tmp = (log1p(x) - log(x)) / n;
	}
	return tmp;
}
function code(x, n)
	t_0 = x ^ Float64(1.0 / n)
	t_1 = Float64(log1p(x) / n)
	tmp = 0.0
	if (n <= -28000000.0)
		tmp = Float64(fma(0.5, Float64((log1p(x) ^ 2.0) / Float64(n * n)), t_1) - fma(0.5, Float64((log(x) ^ 2.0) / Float64(n * n)), Float64(log(x) / n)));
	elseif (n <= 1.2e-7)
		tmp = Float64(exp(t_1) - t_0);
	elseif (n <= 6.6e+77)
		tmp = Float64(t_0 / Float64(n * x));
	else
		tmp = Float64(Float64(log1p(x) - log(x)) / n);
	end
	return tmp
end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[n, -28000000.0], N[(N[(0.5 * N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision] - N[(0.5 * N[(N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision] + N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.2e-7], N[(N[Exp[t$95$1], $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[n, 6.6e+77], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{\mathsf{log1p}\left(x\right)}{n}\\
\mathbf{if}\;n \leq -28000000:\\
\;\;\;\;\mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, t_1\right) - \mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{n \cdot n}, \frac{\log x}{n}\right)\\

\mathbf{elif}\;n \leq 1.2 \cdot 10^{-7}:\\
\;\;\;\;e^{t_1} - t_0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if n < -2.8e7

    1. Initial program 31.6%

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, \frac{\mathsf{log1p}\left(x\right)}{n}\right) - \color{blue}{\mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{{n}^{2}}, \frac{\log x}{n}\right)} \]
      6. unpow279.4%

        \[\leadsto \mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, \frac{\mathsf{log1p}\left(x\right)}{n}\right) - \mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{\color{blue}{n \cdot n}}, \frac{\log x}{n}\right) \]
    4. Simplified79.4%

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

    if -2.8e7 < n < 1.19999999999999989e-7

    1. Initial program 85.1%

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

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

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

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

    if 1.19999999999999989e-7 < n < 6.5999999999999996e77

    1. Initial program 16.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 6.5999999999999996e77 < n

    1. Initial program 23.5%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -28000000:\\ \;\;\;\;\mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, \frac{\mathsf{log1p}\left(x\right)}{n}\right) - \mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{n \cdot n}, \frac{\log x}{n}\right)\\ \mathbf{elif}\;n \leq 1.2 \cdot 10^{-7}:\\ \;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;n \leq 6.6 \cdot 10^{+77}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\ \end{array} \]

Alternative 3: 84.7% accurate, 0.4× speedup?

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq 10000000:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\

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


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

    1. Initial program 99.7%

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

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

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

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

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

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

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

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

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

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

    if -0.0040000000000000001 < (/.f64 1 n) < 5.0000000000000002e-84

    1. Initial program 27.9%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Step-by-step derivation
      1. flip--80.8%

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

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

        \[\leadsto \frac{\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - \color{blue}{{\log x}^{2}}}{\mathsf{log1p}\left(x\right) + \log x}}{n} \]
    6. Applied egg-rr80.8%

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

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

        \[\leadsto \frac{\frac{\mathsf{log1p}\left(x\right) \cdot \mathsf{log1p}\left(x\right) - \color{blue}{\log x \cdot \log x}}{\mathsf{log1p}\left(x\right) + \log x}}{n} \]
      3. flip--80.9%

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

        \[\leadsto \frac{\color{blue}{\log \left(1 + x\right)} - \log x}{n} \]
      5. diff-log81.0%

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

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

    if 5.0000000000000002e-84 < (/.f64 1 n) < 1e7

    1. Initial program 16.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1e7 < (/.f64 1 n)

    1. Initial program 52.1%

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

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

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

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

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

Alternative 4: 85.0% accurate, 0.7× speedup?

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

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

\mathbf{elif}\;n \leq 1.2 \cdot 10^{-7}:\\
\;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - t_0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if n < -2.2e10

    1. Initial program 31.6%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Step-by-step derivation
      1. flip--79.1%

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

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

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

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

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

        \[\leadsto \frac{\frac{\mathsf{log1p}\left(x\right) \cdot \mathsf{log1p}\left(x\right) - \color{blue}{\log x \cdot \log x}}{\mathsf{log1p}\left(x\right) + \log x}}{n} \]
      3. flip--79.2%

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

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

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

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

    if -2.2e10 < n < 1.19999999999999989e-7

    1. Initial program 85.1%

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

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

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

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

    if 1.19999999999999989e-7 < n < 3.19999999999999994e78

    1. Initial program 16.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 3.19999999999999994e78 < n

    1. Initial program 23.5%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -22000000000:\\ \;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\ \mathbf{elif}\;n \leq 1.2 \cdot 10^{-7}:\\ \;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;n \leq 3.2 \cdot 10^{+78}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\ \end{array} \]

Alternative 5: 79.3% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{if}\;\frac{1}{n} \leq -0.004:\\ \;\;\;\;{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - t_0\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-84}:\\ \;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 10000000:\\ \;\;\;\;\frac{t_0}{n \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\left(1 + \mathsf{fma}\left(x \cdot x, \frac{0.5}{n \cdot n} - \frac{0.5}{n}, \frac{x}{n}\right)\right) - t_0\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (pow x (/ 1.0 n))))
   (if (<= (/ 1.0 n) -0.004)
     (- (pow (+ x 1.0) (/ 1.0 n)) t_0)
     (if (<= (/ 1.0 n) 5e-84)
       (/ (log (/ (+ x 1.0) x)) n)
       (if (<= (/ 1.0 n) 10000000.0)
         (/ t_0 (* n x))
         (-
          (+ 1.0 (fma (* x x) (- (/ 0.5 (* n n)) (/ 0.5 n)) (/ x n)))
          t_0))))))
double code(double x, double n) {
	double t_0 = pow(x, (1.0 / n));
	double tmp;
	if ((1.0 / n) <= -0.004) {
		tmp = pow((x + 1.0), (1.0 / n)) - t_0;
	} else if ((1.0 / n) <= 5e-84) {
		tmp = log(((x + 1.0) / x)) / n;
	} else if ((1.0 / n) <= 10000000.0) {
		tmp = t_0 / (n * x);
	} else {
		tmp = (1.0 + fma((x * x), ((0.5 / (n * n)) - (0.5 / n)), (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) <= -0.004)
		tmp = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - t_0);
	elseif (Float64(1.0 / n) <= 5e-84)
		tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n);
	elseif (Float64(1.0 / n) <= 10000000.0)
		tmp = Float64(t_0 / Float64(n * x));
	else
		tmp = Float64(Float64(1.0 + fma(Float64(x * x), Float64(Float64(0.5 / Float64(n * n)) - Float64(0.5 / n)), Float64(x / n))) - t_0);
	end
	return tmp
end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -0.004], N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-84], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 10000000.0], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(N[(x * x), $MachinePrecision] * N[(N[(0.5 / N[(n * n), $MachinePrecision]), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision] + N[(x / n), $MachinePrecision]), $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 -0.004:\\
\;\;\;\;{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - t_0\\

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

\mathbf{elif}\;\frac{1}{n} \leq 10000000:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\

\mathbf{else}:\\
\;\;\;\;\left(1 + \mathsf{fma}\left(x \cdot x, \frac{0.5}{n \cdot n} - \frac{0.5}{n}, \frac{x}{n}\right)\right) - t_0\\


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

    1. Initial program 99.7%

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

    if -0.0040000000000000001 < (/.f64 1 n) < 5.0000000000000002e-84

    1. Initial program 27.9%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Step-by-step derivation
      1. flip--80.8%

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

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

        \[\leadsto \frac{\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - \color{blue}{{\log x}^{2}}}{\mathsf{log1p}\left(x\right) + \log x}}{n} \]
    6. Applied egg-rr80.8%

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

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

        \[\leadsto \frac{\frac{\mathsf{log1p}\left(x\right) \cdot \mathsf{log1p}\left(x\right) - \color{blue}{\log x \cdot \log x}}{\mathsf{log1p}\left(x\right) + \log x}}{n} \]
      3. flip--80.9%

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

        \[\leadsto \frac{\color{blue}{\log \left(1 + x\right)} - \log x}{n} \]
      5. diff-log81.0%

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

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

    if 5.0000000000000002e-84 < (/.f64 1 n) < 1e7

    1. Initial program 16.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1e7 < (/.f64 1 n)

    1. Initial program 52.1%

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

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

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

        \[\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/70.4%

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

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

        \[\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/70.4%

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

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

      \[\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)} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification84.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -0.004:\\ \;\;\;\;{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-84}:\\ \;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 10000000:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\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)}\\ \end{array} \]

Alternative 6: 80.8% accurate, 0.9× speedup?

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq 10000000:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\

\mathbf{elif}\;\frac{1}{n} \leq 10^{+143}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (/.f64 1 n) < -0.0040000000000000001 or 1e7 < (/.f64 1 n) < 1e143

    1. Initial program 94.5%

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

    if -0.0040000000000000001 < (/.f64 1 n) < 5.0000000000000002e-84

    1. Initial program 27.9%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Step-by-step derivation
      1. flip--80.8%

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

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

        \[\leadsto \frac{\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - \color{blue}{{\log x}^{2}}}{\mathsf{log1p}\left(x\right) + \log x}}{n} \]
    6. Applied egg-rr80.8%

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

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

        \[\leadsto \frac{\frac{\mathsf{log1p}\left(x\right) \cdot \mathsf{log1p}\left(x\right) - \color{blue}{\log x \cdot \log x}}{\mathsf{log1p}\left(x\right) + \log x}}{n} \]
      3. flip--80.9%

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

        \[\leadsto \frac{\color{blue}{\log \left(1 + x\right)} - \log x}{n} \]
      5. diff-log81.0%

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

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

    if 5.0000000000000002e-84 < (/.f64 1 n) < 1e7

    1. Initial program 16.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1e143 < (/.f64 1 n)

    1. Initial program 31.5%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Step-by-step derivation
      1. div-sub6.1%

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

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

        \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) \cdot n - n \cdot \log x}{n \cdot n}} \]
    8. Applied egg-rr81.8%

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) \cdot n - n \cdot \log x}{n \cdot n}} \]
    9. Step-by-step derivation
      1. log1p-def81.8%

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

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

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

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

      \[\leadsto \color{blue}{\frac{n \cdot \left(\mathsf{log1p}\left(x\right) - \log x\right)}{n \cdot n}} \]
    11. Taylor expanded in x around inf 81.8%

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

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

Alternative 7: 71.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^{+81}:\\ \;\;\;\;\frac{\frac{0.3333333333333333}{{x}^{3}}}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{+19}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-84}:\\ \;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-21}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{+143}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{n}{x}}{n \cdot n}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))))
   (if (<= (/ 1.0 n) -5e+81)
     (/ (/ 0.3333333333333333 (pow x 3.0)) n)
     (if (<= (/ 1.0 n) -5e+19)
       t_0
       (if (<= (/ 1.0 n) 5e-84)
         (/ (log (/ (+ x 1.0) x)) n)
         (if (<= (/ 1.0 n) 2e-21)
           (/ (/ 1.0 n) x)
           (if (<= (/ 1.0 n) 1e+143) t_0 (/ (/ n x) (* n n)))))))))
double code(double x, double n) {
	double t_0 = 1.0 - pow(x, (1.0 / n));
	double tmp;
	if ((1.0 / n) <= -5e+81) {
		tmp = (0.3333333333333333 / pow(x, 3.0)) / n;
	} else if ((1.0 / n) <= -5e+19) {
		tmp = t_0;
	} else if ((1.0 / n) <= 5e-84) {
		tmp = log(((x + 1.0) / x)) / n;
	} else if ((1.0 / n) <= 2e-21) {
		tmp = (1.0 / n) / x;
	} else if ((1.0 / n) <= 1e+143) {
		tmp = t_0;
	} else {
		tmp = (n / x) / (n * 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+81)) then
        tmp = (0.3333333333333333d0 / (x ** 3.0d0)) / n
    else if ((1.0d0 / n) <= (-5d+19)) then
        tmp = t_0
    else if ((1.0d0 / n) <= 5d-84) then
        tmp = log(((x + 1.0d0) / x)) / n
    else if ((1.0d0 / n) <= 2d-21) then
        tmp = (1.0d0 / n) / x
    else if ((1.0d0 / n) <= 1d+143) then
        tmp = t_0
    else
        tmp = (n / x) / (n * 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+81) {
		tmp = (0.3333333333333333 / Math.pow(x, 3.0)) / n;
	} else if ((1.0 / n) <= -5e+19) {
		tmp = t_0;
	} else if ((1.0 / n) <= 5e-84) {
		tmp = Math.log(((x + 1.0) / x)) / n;
	} else if ((1.0 / n) <= 2e-21) {
		tmp = (1.0 / n) / x;
	} else if ((1.0 / n) <= 1e+143) {
		tmp = t_0;
	} else {
		tmp = (n / x) / (n * n);
	}
	return tmp;
}
def code(x, n):
	t_0 = 1.0 - math.pow(x, (1.0 / n))
	tmp = 0
	if (1.0 / n) <= -5e+81:
		tmp = (0.3333333333333333 / math.pow(x, 3.0)) / n
	elif (1.0 / n) <= -5e+19:
		tmp = t_0
	elif (1.0 / n) <= 5e-84:
		tmp = math.log(((x + 1.0) / x)) / n
	elif (1.0 / n) <= 2e-21:
		tmp = (1.0 / n) / x
	elif (1.0 / n) <= 1e+143:
		tmp = t_0
	else:
		tmp = (n / x) / (n * 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+81)
		tmp = Float64(Float64(0.3333333333333333 / (x ^ 3.0)) / n);
	elseif (Float64(1.0 / n) <= -5e+19)
		tmp = t_0;
	elseif (Float64(1.0 / n) <= 5e-84)
		tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n);
	elseif (Float64(1.0 / n) <= 2e-21)
		tmp = Float64(Float64(1.0 / n) / x);
	elseif (Float64(1.0 / n) <= 1e+143)
		tmp = t_0;
	else
		tmp = Float64(Float64(n / x) / Float64(n * 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+81)
		tmp = (0.3333333333333333 / (x ^ 3.0)) / n;
	elseif ((1.0 / n) <= -5e+19)
		tmp = t_0;
	elseif ((1.0 / n) <= 5e-84)
		tmp = log(((x + 1.0) / x)) / n;
	elseif ((1.0 / n) <= 2e-21)
		tmp = (1.0 / n) / x;
	elseif ((1.0 / n) <= 1e+143)
		tmp = t_0;
	else
		tmp = (n / x) / (n * 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+81], N[(N[(0.3333333333333333 / N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e+19], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-84], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-21], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+143], t$95$0, N[(N[(n / x), $MachinePrecision] / N[(n * n), $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^{+81}:\\
\;\;\;\;\frac{\frac{0.3333333333333333}{{x}^{3}}}{n}\\

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq 10^{+143}:\\
\;\;\;\;t_0\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{0.3333333333333333}{{x}^{3}}}}{n} \]

    if -4.9999999999999998e81 < (/.f64 1 n) < -5e19 or 1.99999999999999982e-21 < (/.f64 1 n) < 1e143

    1. Initial program 79.0%

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

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

    if -5e19 < (/.f64 1 n) < 5.0000000000000002e-84

    1. Initial program 31.8%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Step-by-step derivation
      1. flip--81.4%

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

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

        \[\leadsto \frac{\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - \color{blue}{{\log x}^{2}}}{\mathsf{log1p}\left(x\right) + \log x}}{n} \]
    6. Applied egg-rr81.4%

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

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

        \[\leadsto \frac{\frac{\mathsf{log1p}\left(x\right) \cdot \mathsf{log1p}\left(x\right) - \color{blue}{\log x \cdot \log x}}{\mathsf{log1p}\left(x\right) + \log x}}{n} \]
      3. flip--81.5%

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

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

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

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

    if 5.0000000000000002e-84 < (/.f64 1 n) < 1.99999999999999982e-21

    1. Initial program 12.3%

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, \frac{\mathsf{log1p}\left(x\right)}{n}\right) - \color{blue}{\mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{{n}^{2}}, \frac{\log x}{n}\right)} \]
      6. unpow231.6%

        \[\leadsto \mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, \frac{\mathsf{log1p}\left(x\right)}{n}\right) - \mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{\color{blue}{n \cdot n}}, \frac{\log x}{n}\right) \]
    4. Simplified31.6%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{1}{n} + \frac{\log x}{n \cdot n}}{x}} \]
    8. Taylor expanded in n around inf 80.7%

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

    if 1e143 < (/.f64 1 n)

    1. Initial program 31.5%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Step-by-step derivation
      1. div-sub6.1%

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

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

        \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) \cdot n - n \cdot \log x}{n \cdot n}} \]
    8. Applied egg-rr81.8%

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) \cdot n - n \cdot \log x}{n \cdot n}} \]
    9. Step-by-step derivation
      1. log1p-def81.8%

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

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

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

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

      \[\leadsto \color{blue}{\frac{n \cdot \left(\mathsf{log1p}\left(x\right) - \log x\right)}{n \cdot n}} \]
    11. Taylor expanded in x around inf 81.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{+81}:\\ \;\;\;\;\frac{\frac{0.3333333333333333}{{x}^{3}}}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{+19}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-84}:\\ \;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-21}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{+143}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{n}{x}}{n \cdot n}\\ \end{array} \]

Alternative 8: 80.5% accurate, 1.7× speedup?

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq 10000000:\\
\;\;\;\;t_1\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (/.f64 1 n) < -0.0040000000000000001 or 5.0000000000000002e-84 < (/.f64 1 n) < 1e7

    1. Initial program 86.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.0040000000000000001 < (/.f64 1 n) < 5.0000000000000002e-84

    1. Initial program 27.9%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Step-by-step derivation
      1. flip--80.8%

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

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

        \[\leadsto \frac{\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - \color{blue}{{\log x}^{2}}}{\mathsf{log1p}\left(x\right) + \log x}}{n} \]
    6. Applied egg-rr80.8%

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

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

        \[\leadsto \frac{\frac{\mathsf{log1p}\left(x\right) \cdot \mathsf{log1p}\left(x\right) - \color{blue}{\log x \cdot \log x}}{\mathsf{log1p}\left(x\right) + \log x}}{n} \]
      3. flip--80.9%

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

        \[\leadsto \frac{\color{blue}{\log \left(1 + x\right)} - \log x}{n} \]
      5. diff-log81.0%

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

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

    if 1e7 < (/.f64 1 n) < 1e143

    1. Initial program 71.6%

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

    if 1e143 < (/.f64 1 n)

    1. Initial program 31.5%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Step-by-step derivation
      1. div-sub6.1%

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

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

        \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) \cdot n - n \cdot \log x}{n \cdot n}} \]
    8. Applied egg-rr81.8%

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) \cdot n - n \cdot \log x}{n \cdot n}} \]
    9. Step-by-step derivation
      1. log1p-def81.8%

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

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

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

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

      \[\leadsto \color{blue}{\frac{n \cdot \left(\mathsf{log1p}\left(x\right) - \log x\right)}{n \cdot n}} \]
    11. Taylor expanded in x around inf 81.8%

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

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

Alternative 9: 80.5% accurate, 1.7× speedup?

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq 10000000:\\
\;\;\;\;t_1\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (/.f64 1 n) < -0.0040000000000000001 or 5.0000000000000002e-84 < (/.f64 1 n) < 1e7

    1. Initial program 86.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.0040000000000000001 < (/.f64 1 n) < 5.0000000000000002e-84

    1. Initial program 27.9%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Step-by-step derivation
      1. flip--80.8%

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

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

        \[\leadsto \frac{\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - \color{blue}{{\log x}^{2}}}{\mathsf{log1p}\left(x\right) + \log x}}{n} \]
    6. Applied egg-rr80.8%

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

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

        \[\leadsto \frac{\frac{\mathsf{log1p}\left(x\right) \cdot \mathsf{log1p}\left(x\right) - \color{blue}{\log x \cdot \log x}}{\mathsf{log1p}\left(x\right) + \log x}}{n} \]
      3. flip--80.9%

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

        \[\leadsto \frac{\color{blue}{\log \left(1 + x\right)} - \log x}{n} \]
      5. diff-log81.0%

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

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

    if 1e7 < (/.f64 1 n) < 1e143

    1. Initial program 71.6%

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

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

    if 1e143 < (/.f64 1 n)

    1. Initial program 31.5%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Step-by-step derivation
      1. div-sub6.1%

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

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

        \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) \cdot n - n \cdot \log x}{n \cdot n}} \]
    8. Applied egg-rr81.8%

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) \cdot n - n \cdot \log x}{n \cdot n}} \]
    9. Step-by-step derivation
      1. log1p-def81.8%

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

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

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

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

      \[\leadsto \color{blue}{\frac{n \cdot \left(\mathsf{log1p}\left(x\right) - \log x\right)}{n \cdot n}} \]
    11. Taylor expanded in x around inf 81.8%

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

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

Alternative 10: 59.8% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{-\log x}{n}\\
t_1 := \frac{\frac{0.3333333333333333}{{x}^{3}}}{n}\\
\mathbf{if}\;x \leq 1.4 \cdot 10^{-259}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;x \leq 3.3 \cdot 10^{-97}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 7.5 \cdot 10^{-74}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;x \leq 1.15 \cdot 10^{+113}:\\
\;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if x < 1.4e-259 or 7.50000000000000006e-230 < x < 3.3000000000000001e-97

    1. Initial program 33.3%

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \log x}}{n} \]
    6. Step-by-step derivation
      1. neg-mul-167.9%

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

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

    if 1.4e-259 < x < 7.50000000000000006e-230

    1. Initial program 76.4%

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

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

    if 3.3000000000000001e-97 < x < 7.5e-74 or 1.14999999999999998e113 < x

    1. Initial program 75.8%

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{0.3333333333333333}{{x}^{3}}}}{n} \]

    if 7.5e-74 < x < 0.97999999999999998

    1. Initial program 41.8%

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

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

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

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

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

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

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

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

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

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

    if 0.97999999999999998 < x < 1.14999999999999998e113

    1. Initial program 37.1%

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{x} - \color{blue}{\frac{0.5 \cdot 1}{{x}^{2}}}}{n} \]
      2. metadata-eval63.8%

        \[\leadsto \frac{\frac{1}{x} - \frac{\color{blue}{0.5}}{{x}^{2}}}{n} \]
      3. unpow263.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.4 \cdot 10^{-259}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 7.5 \cdot 10^{-230}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 3.3 \cdot 10^{-97}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 7.5 \cdot 10^{-74}:\\ \;\;\;\;\frac{\frac{0.3333333333333333}{{x}^{3}}}{n}\\ \mathbf{elif}\;x \leq 0.98:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{elif}\;x \leq 1.15 \cdot 10^{+113}:\\ \;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{0.3333333333333333}{{x}^{3}}}{n}\\ \end{array} \]

Alternative 11: 56.4% accurate, 1.8× speedup?

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

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

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

\mathbf{elif}\;x \leq 7.6 \cdot 10^{-90}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 1.1 \cdot 10^{-73}:\\
\;\;\;\;\frac{\frac{n}{x}}{n \cdot n}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if x < 1.8999999999999999e-258 or 6e-230 < x < 7.6e-90

    1. Initial program 33.1%

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \log x}}{n} \]
    6. Step-by-step derivation
      1. neg-mul-166.1%

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

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

    if 1.8999999999999999e-258 < x < 6e-230

    1. Initial program 76.4%

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

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

    if 7.6e-90 < x < 1.1e-73

    1. Initial program 51.7%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Step-by-step derivation
      1. div-sub12.9%

        \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right)}{n} - \frac{\log x}{n}} \]
    6. Applied egg-rr12.9%

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

        \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) \cdot n - n \cdot \log x}{n \cdot n}} \]
    8. Applied egg-rr72.8%

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) \cdot n - n \cdot \log x}{n \cdot n}} \]
    9. Step-by-step derivation
      1. log1p-def72.8%

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

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

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

        \[\leadsto \frac{n \cdot \left(\color{blue}{\mathsf{log1p}\left(x\right)} - \log x\right)}{n \cdot n} \]
    10. Simplified72.8%

      \[\leadsto \color{blue}{\frac{n \cdot \left(\mathsf{log1p}\left(x\right) - \log x\right)}{n \cdot n}} \]
    11. Taylor expanded in x around inf 66.2%

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

    if 1.1e-73 < x < 1

    1. Initial program 41.8%

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

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

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

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

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

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

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

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

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

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

    if 1 < x

    1. Initial program 65.4%

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{x} - \color{blue}{\frac{0.5 \cdot 1}{{x}^{2}}}}{n} \]
      2. metadata-eval63.7%

        \[\leadsto \frac{\frac{1}{x} - \frac{\color{blue}{0.5}}{{x}^{2}}}{n} \]
      3. unpow263.7%

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

      \[\leadsto \frac{\color{blue}{\frac{1}{x} - \frac{0.5}{x \cdot x}}}{n} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification63.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.9 \cdot 10^{-258}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 6 \cdot 10^{-230}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 7.6 \cdot 10^{-90}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 1.1 \cdot 10^{-73}:\\ \;\;\;\;\frac{\frac{n}{x}}{n \cdot n}\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\ \end{array} \]

Alternative 12: 56.6% accurate, 1.9× speedup?

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

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

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

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\


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

    1. Initial program 38.5%

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \log x}}{n} \]
    6. Step-by-step derivation
      1. neg-mul-161.5%

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

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

    if 7.6e-90 < x < 7.5e-74

    1. Initial program 51.7%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Step-by-step derivation
      1. div-sub12.9%

        \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right)}{n} - \frac{\log x}{n}} \]
    6. Applied egg-rr12.9%

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

        \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) \cdot n - n \cdot \log x}{n \cdot n}} \]
    8. Applied egg-rr72.8%

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) \cdot n - n \cdot \log x}{n \cdot n}} \]
    9. Step-by-step derivation
      1. log1p-def72.8%

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

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

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

        \[\leadsto \frac{n \cdot \left(\color{blue}{\mathsf{log1p}\left(x\right)} - \log x\right)}{n \cdot n} \]
    10. Simplified72.8%

      \[\leadsto \color{blue}{\frac{n \cdot \left(\mathsf{log1p}\left(x\right) - \log x\right)}{n \cdot n}} \]
    11. Taylor expanded in x around inf 66.2%

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

    if 7.5e-74 < x < 0.94999999999999996

    1. Initial program 41.8%

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

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

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

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

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

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

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

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

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

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

    if 0.94999999999999996 < x

    1. Initial program 65.4%

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{x} - \color{blue}{\frac{0.5 \cdot 1}{{x}^{2}}}}{n} \]
      2. metadata-eval63.7%

        \[\leadsto \frac{\frac{1}{x} - \frac{\color{blue}{0.5}}{{x}^{2}}}{n} \]
      3. unpow263.7%

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

      \[\leadsto \frac{\color{blue}{\frac{1}{x} - \frac{0.5}{x \cdot x}}}{n} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification61.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 7.6 \cdot 10^{-90}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 7.5 \cdot 10^{-74}:\\ \;\;\;\;\frac{\frac{n}{x}}{n \cdot n}\\ \mathbf{elif}\;x \leq 0.95:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\ \end{array} \]

Alternative 13: 56.4% accurate, 1.9× speedup?

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

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

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

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 6.4999999999999996e-90 or 7.5e-74 < x < 0.69999999999999996

    1. Initial program 39.4%

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \log x}}{n} \]
    6. Step-by-step derivation
      1. neg-mul-158.6%

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

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

    if 6.4999999999999996e-90 < x < 7.5e-74

    1. Initial program 51.7%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Step-by-step derivation
      1. div-sub12.9%

        \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right)}{n} - \frac{\log x}{n}} \]
    6. Applied egg-rr12.9%

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

        \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) \cdot n - n \cdot \log x}{n \cdot n}} \]
    8. Applied egg-rr72.8%

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) \cdot n - n \cdot \log x}{n \cdot n}} \]
    9. Step-by-step derivation
      1. log1p-def72.8%

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

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

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

        \[\leadsto \frac{n \cdot \left(\color{blue}{\mathsf{log1p}\left(x\right)} - \log x\right)}{n \cdot n} \]
    10. Simplified72.8%

      \[\leadsto \color{blue}{\frac{n \cdot \left(\mathsf{log1p}\left(x\right) - \log x\right)}{n \cdot n}} \]
    11. Taylor expanded in x around inf 66.2%

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

    if 0.69999999999999996 < x

    1. Initial program 65.4%

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{x} - \color{blue}{\frac{0.5 \cdot 1}{{x}^{2}}}}{n} \]
      2. metadata-eval63.7%

        \[\leadsto \frac{\frac{1}{x} - \frac{\color{blue}{0.5}}{{x}^{2}}}{n} \]
      3. unpow263.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 6.5 \cdot 10^{-90}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 7.5 \cdot 10^{-74}:\\ \;\;\;\;\frac{\frac{n}{x}}{n \cdot n}\\ \mathbf{elif}\;x \leq 0.7:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\ \end{array} \]

Alternative 14: 44.3% accurate, 16.2× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 1

    1. Initial program 40.6%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Step-by-step derivation
      1. div-sub55.0%

        \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right)}{n} - \frac{\log x}{n}} \]
    6. Applied egg-rr55.0%

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

        \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) \cdot n - n \cdot \log x}{n \cdot n}} \]
    8. Applied egg-rr49.2%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{n \cdot \left(\mathsf{log1p}\left(x\right) - \log x\right)}{n \cdot n}} \]
    11. Taylor expanded in x around inf 28.3%

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

    if 1 < x

    1. Initial program 65.4%

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{x} - \color{blue}{\frac{0.5 \cdot 1}{{x}^{2}}}}{n} \]
      2. metadata-eval63.7%

        \[\leadsto \frac{\frac{1}{x} - \frac{\color{blue}{0.5}}{{x}^{2}}}{n} \]
      3. unpow263.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1:\\ \;\;\;\;\frac{\frac{n}{x}}{n \cdot n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\ \end{array} \]

Alternative 15: 43.9% accurate, 23.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 0.0065:\\ \;\;\;\;\frac{\frac{n}{x}}{n \cdot n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= x 0.0065) (/ (/ n x) (* n n)) (/ (/ 1.0 n) x)))
double code(double x, double n) {
	double tmp;
	if (x <= 0.0065) {
		tmp = (n / x) / (n * 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 <= 0.0065d0) then
        tmp = (n / x) / (n * 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 <= 0.0065) {
		tmp = (n / x) / (n * n);
	} else {
		tmp = (1.0 / n) / x;
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if x <= 0.0065:
		tmp = (n / x) / (n * n)
	else:
		tmp = (1.0 / n) / x
	return tmp
function code(x, n)
	tmp = 0.0
	if (x <= 0.0065)
		tmp = Float64(Float64(n / x) / Float64(n * n));
	else
		tmp = Float64(Float64(1.0 / n) / x);
	end
	return tmp
end
function tmp_2 = code(x, n)
	tmp = 0.0;
	if (x <= 0.0065)
		tmp = (n / x) / (n * n);
	else
		tmp = (1.0 / n) / x;
	end
	tmp_2 = tmp;
end
code[x_, n_] := If[LessEqual[x, 0.0065], N[(N[(n / x), $MachinePrecision] / N[(n * n), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.0065:\\
\;\;\;\;\frac{\frac{n}{x}}{n \cdot n}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 0.0064999999999999997

    1. Initial program 40.4%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    5. Step-by-step derivation
      1. div-sub55.1%

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

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

        \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) \cdot n - n \cdot \log x}{n \cdot n}} \]
    8. Applied egg-rr49.2%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{n \cdot \left(\mathsf{log1p}\left(x\right) - \log x\right)}{n \cdot n}} \]
    11. Taylor expanded in x around inf 28.6%

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

    if 0.0064999999999999997 < x

    1. Initial program 65.2%

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, \frac{\mathsf{log1p}\left(x\right)}{n}\right) - \color{blue}{\mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{{n}^{2}}, \frac{\log x}{n}\right)} \]
      6. unpow250.7%

        \[\leadsto \mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, \frac{\mathsf{log1p}\left(x\right)}{n}\right) - \mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{\color{blue}{n \cdot n}}, \frac{\log x}{n}\right) \]
    4. Simplified50.7%

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{n} + \frac{\log x}{\color{blue}{n \cdot n}}}{x} \]
    7. Simplified62.0%

      \[\leadsto \color{blue}{\frac{\frac{1}{n} + \frac{\log x}{n \cdot n}}{x}} \]
    8. Taylor expanded in n around inf 62.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 0.0065:\\ \;\;\;\;\frac{\frac{n}{x}}{n \cdot n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \end{array} \]

Alternative 16: 41.1% 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 51.2%

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

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

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

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

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

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

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

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

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

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

Alternative 17: 41.6% 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 51.2%

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, \frac{\mathsf{log1p}\left(x\right)}{n}\right) - \color{blue}{\mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{{n}^{2}}, \frac{\log x}{n}\right)} \]
    6. unpow252.6%

      \[\leadsto \mathsf{fma}\left(0.5, \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{n \cdot n}, \frac{\mathsf{log1p}\left(x\right)}{n}\right) - \mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{\color{blue}{n \cdot n}}, \frac{\log x}{n}\right) \]
  4. Simplified52.6%

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\frac{1}{n} + \frac{\log x}{n \cdot n}}{x}} \]
  8. Taylor expanded in n around inf 39.3%

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

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

Reproduce

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