2nthrt (problem 3.4.6)

Percentage Accurate: 53.8% → 86.4%
Time: 40.0s
Alternatives: 19
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 19 alternatives:

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

Initial Program: 53.8% accurate, 1.0× speedup?

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

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

Alternative 1: 86.4% accurate, 0.2× speedup?

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

\\
\begin{array}{l}
t_0 := \sqrt{e^{\frac{\mathsf{log1p}\left(x\right)}{n}}}\\
t_1 := {x}^{\left(\frac{1}{n}\right)}\\
t_2 := \sqrt{t\_1}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-61}:\\
\;\;\;\;\frac{t\_1}{x \cdot n}\\

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

\mathbf{else}:\\
\;\;\;\;\left(t\_0 + t\_2\right) \cdot \left(t\_0 - t\_2\right)\\


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

    1. Initial program 87.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.0000000000000001e-61 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999989e-20

    1. Initial program 25.9%

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

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

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

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

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

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

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

    if 1.99999999999999989e-20 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 62.8%

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

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

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

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

        \[\leadsto \left(\color{blue}{\sqrt{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)}}} + {x}^{\left(\frac{\frac{1}{n}}{2}\right)}\right) \cdot \left({\left(x + 1\right)}^{\left(\frac{\frac{1}{n}}{2}\right)} - {x}^{\left(\frac{\frac{1}{n}}{2}\right)}\right) \]
      5. pow-to-exp62.9%

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

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

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

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

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

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

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

Alternative 2: 81.2% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 1550:\\ \;\;\;\;\frac{\left(\mathsf{log1p}\left(x\right) + \frac{0.5 \cdot \left({\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}\right) + \frac{-0.16666666666666666 \cdot \left({\log x}^{3} - {\left(\mathsf{log1p}\left(x\right)\right)}^{3}\right) + -0.041666666666666664 \cdot \frac{{\log x}^{4} - {\left(\mathsf{log1p}\left(x\right)\right)}^{4}}{n}}{n}}{n}\right) - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt[3]{{x}^{\left(\frac{2}{n}\right)}}}{x} \cdot \frac{\sqrt[3]{{x}^{\left(\frac{1}{n}\right)}}}{n}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= x 1550.0)
   (/
    (-
     (+
      (log1p x)
      (/
       (+
        (* 0.5 (- (pow (log1p x) 2.0) (pow (log x) 2.0)))
        (/
         (+
          (* -0.16666666666666666 (- (pow (log x) 3.0) (pow (log1p x) 3.0)))
          (*
           -0.041666666666666664
           (/ (- (pow (log x) 4.0) (pow (log1p x) 4.0)) n)))
         n))
       n))
     (log x))
    n)
   (* (/ (cbrt (pow x (/ 2.0 n))) x) (/ (cbrt (pow x (/ 1.0 n))) n))))
double code(double x, double n) {
	double tmp;
	if (x <= 1550.0) {
		tmp = ((log1p(x) + (((0.5 * (pow(log1p(x), 2.0) - pow(log(x), 2.0))) + (((-0.16666666666666666 * (pow(log(x), 3.0) - pow(log1p(x), 3.0))) + (-0.041666666666666664 * ((pow(log(x), 4.0) - pow(log1p(x), 4.0)) / n))) / n)) / n)) - log(x)) / n;
	} else {
		tmp = (cbrt(pow(x, (2.0 / n))) / x) * (cbrt(pow(x, (1.0 / n))) / n);
	}
	return tmp;
}
public static double code(double x, double n) {
	double tmp;
	if (x <= 1550.0) {
		tmp = ((Math.log1p(x) + (((0.5 * (Math.pow(Math.log1p(x), 2.0) - Math.pow(Math.log(x), 2.0))) + (((-0.16666666666666666 * (Math.pow(Math.log(x), 3.0) - Math.pow(Math.log1p(x), 3.0))) + (-0.041666666666666664 * ((Math.pow(Math.log(x), 4.0) - Math.pow(Math.log1p(x), 4.0)) / n))) / n)) / n)) - Math.log(x)) / n;
	} else {
		tmp = (Math.cbrt(Math.pow(x, (2.0 / n))) / x) * (Math.cbrt(Math.pow(x, (1.0 / n))) / n);
	}
	return tmp;
}
function code(x, n)
	tmp = 0.0
	if (x <= 1550.0)
		tmp = Float64(Float64(Float64(log1p(x) + Float64(Float64(Float64(0.5 * Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0))) + Float64(Float64(Float64(-0.16666666666666666 * Float64((log(x) ^ 3.0) - (log1p(x) ^ 3.0))) + Float64(-0.041666666666666664 * Float64(Float64((log(x) ^ 4.0) - (log1p(x) ^ 4.0)) / n))) / n)) / n)) - log(x)) / n);
	else
		tmp = Float64(Float64(cbrt((x ^ Float64(2.0 / n))) / x) * Float64(cbrt((x ^ Float64(1.0 / n))) / n));
	end
	return tmp
end
code[x_, n_] := If[LessEqual[x, 1550.0], N[(N[(N[(N[Log[1 + x], $MachinePrecision] + N[(N[(N[(0.5 * N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(-0.16666666666666666 * N[(N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision] - N[Power[N[Log[1 + x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-0.041666666666666664 * N[(N[(N[Power[N[Log[x], $MachinePrecision], 4.0], $MachinePrecision] - N[Power[N[Log[1 + x], $MachinePrecision], 4.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[Power[N[Power[x, N[(2.0 / n), $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision] / x), $MachinePrecision] * N[(N[Power[N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 1550:\\
\;\;\;\;\frac{\left(\mathsf{log1p}\left(x\right) + \frac{0.5 \cdot \left({\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}\right) + \frac{-0.16666666666666666 \cdot \left({\log x}^{3} - {\left(\mathsf{log1p}\left(x\right)\right)}^{3}\right) + -0.041666666666666664 \cdot \frac{{\log x}^{4} - {\left(\mathsf{log1p}\left(x\right)\right)}^{4}}{n}}{n}}{n}\right) - \log x}{n}\\

\mathbf{else}:\\
\;\;\;\;\frac{\sqrt[3]{{x}^{\left(\frac{2}{n}\right)}}}{x} \cdot \frac{\sqrt[3]{{x}^{\left(\frac{1}{n}\right)}}}{n}\\


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

    1. Initial program 49.5%

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

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

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

    if 1550 < x

    1. Initial program 59.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 86.5% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {x}^{\left(\frac{1}{n}\right)}\\ t_1 := \sqrt{t\_0}\\ \mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-61}:\\ \;\;\;\;\frac{t\_0}{x \cdot n}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-15}:\\ \;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(t\_1, -t\_1, e^{\frac{\mathsf{log1p}\left(x\right)}{n}}\right)\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (pow x (/ 1.0 n))) (t_1 (sqrt t_0)))
   (if (<= (/ 1.0 n) -2e-61)
     (/ t_0 (* x n))
     (if (<= (/ 1.0 n) 2e-15)
       (/ (log (/ (+ x 1.0) x)) n)
       (fma t_1 (- t_1) (exp (/ (log1p x) n)))))))
double code(double x, double n) {
	double t_0 = pow(x, (1.0 / n));
	double t_1 = sqrt(t_0);
	double tmp;
	if ((1.0 / n) <= -2e-61) {
		tmp = t_0 / (x * n);
	} else if ((1.0 / n) <= 2e-15) {
		tmp = log(((x + 1.0) / x)) / n;
	} else {
		tmp = fma(t_1, -t_1, exp((log1p(x) / n)));
	}
	return tmp;
}
function code(x, n)
	t_0 = x ^ Float64(1.0 / n)
	t_1 = sqrt(t_0)
	tmp = 0.0
	if (Float64(1.0 / n) <= -2e-61)
		tmp = Float64(t_0 / Float64(x * n));
	elseif (Float64(1.0 / n) <= 2e-15)
		tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n);
	else
		tmp = fma(t_1, Float64(-t_1), exp(Float64(log1p(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[Sqrt[t$95$0], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-61], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-15], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(t$95$1 * (-t$95$1) + N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

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

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


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

    1. Initial program 87.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 25.8%

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

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

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

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

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

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

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

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

    1. Initial program 64.2%

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

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

        \[\leadsto \color{blue}{\left(-{x}^{\left(\frac{1}{n}\right)}\right) + {\left(x + 1\right)}^{\left(\frac{1}{n}\right)}} \]
      3. sqr-pow64.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-in64.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-define64.3%

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

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

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

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

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

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

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

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

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

Alternative 4: 86.3% accurate, 0.4× speedup?

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

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

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

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


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

    1. Initial program 87.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.0000000000000001e-61 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999989e-20

    1. Initial program 25.9%

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

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

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

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

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

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

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

    if 1.99999999999999989e-20 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 62.8%

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

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

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

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

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

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

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

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

Alternative 5: 86.4% accurate, 0.7× speedup?

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

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

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

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


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

    1. Initial program 87.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.0000000000000001e-61 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999989e-20

    1. Initial program 25.9%

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

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

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

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

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

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

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

    if 1.99999999999999989e-20 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 62.8%

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

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

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

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

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

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

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

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

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

Alternative 6: 83.1% accurate, 0.9× speedup?

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

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

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

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


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

    1. Initial program 87.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.0000000000000001e-61 < (/.f64 #s(literal 1 binary64) n) < 3.9999999999999998e-7

    1. Initial program 25.6%

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

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

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

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

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

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

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

    if 3.9999999999999998e-7 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 65.9%

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

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

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

Alternative 7: 83.2% accurate, 0.9× speedup?

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

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

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

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

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


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

    1. Initial program 87.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.0000000000000001e-61 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999989e-20

    1. Initial program 25.9%

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

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

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

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

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

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

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

    if 1.99999999999999989e-20 < (/.f64 #s(literal 1 binary64) n) < 1e189

    1. Initial program 80.6%

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

    if 1e189 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 12.8%

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

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

      \[\leadsto \color{blue}{\frac{x}{n}} \]
    5. Step-by-step derivation
      1. log1p-expm1-u100.0%

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

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

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

Alternative 8: 83.0% accurate, 0.9× speedup?

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

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

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

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

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


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

    1. Initial program 87.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.0000000000000001e-61 < (/.f64 #s(literal 1 binary64) n) < 3.9999999999999998e-7

    1. Initial program 25.6%

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

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

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

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

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

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

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

    if 3.9999999999999998e-7 < (/.f64 #s(literal 1 binary64) n) < 1e189

    1. Initial program 86.3%

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

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

    if 1e189 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 12.8%

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

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

      \[\leadsto \color{blue}{\frac{x}{n}} \]
    5. Step-by-step derivation
      1. log1p-expm1-u100.0%

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

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

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

Alternative 9: 68.6% accurate, 1.6× 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^{-5}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-61}:\\ \;\;\;\;\frac{1}{x \cdot n}\\ \mathbf{elif}\;\frac{1}{n} \leq 4 \cdot 10^{-7}:\\ \;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{+189}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} - \frac{0.5}{n}}{x}}{x}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))))
   (if (<= (/ 1.0 n) -5e-5)
     t_0
     (if (<= (/ 1.0 n) -2e-61)
       (/ 1.0 (* x n))
       (if (<= (/ 1.0 n) 4e-7)
         (/ (log (/ (+ x 1.0) x)) n)
         (if (<= (/ 1.0 n) 1e+189)
           t_0
           (/
            (+ (/ 1.0 n) (/ (- (/ 0.3333333333333333 (* x n)) (/ 0.5 n)) x))
            x)))))))
double code(double x, double n) {
	double t_0 = 1.0 - pow(x, (1.0 / n));
	double tmp;
	if ((1.0 / n) <= -5e-5) {
		tmp = t_0;
	} else if ((1.0 / n) <= -2e-61) {
		tmp = 1.0 / (x * n);
	} else if ((1.0 / n) <= 4e-7) {
		tmp = log(((x + 1.0) / x)) / n;
	} else if ((1.0 / n) <= 1e+189) {
		tmp = t_0;
	} else {
		tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
	}
	return tmp;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 1.0d0 - (x ** (1.0d0 / n))
    if ((1.0d0 / n) <= (-5d-5)) then
        tmp = t_0
    else if ((1.0d0 / n) <= (-2d-61)) then
        tmp = 1.0d0 / (x * n)
    else if ((1.0d0 / n) <= 4d-7) then
        tmp = log(((x + 1.0d0) / x)) / n
    else if ((1.0d0 / n) <= 1d+189) then
        tmp = t_0
    else
        tmp = ((1.0d0 / n) + (((0.3333333333333333d0 / (x * n)) - (0.5d0 / n)) / x)) / x
    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-5) {
		tmp = t_0;
	} else if ((1.0 / n) <= -2e-61) {
		tmp = 1.0 / (x * n);
	} else if ((1.0 / n) <= 4e-7) {
		tmp = Math.log(((x + 1.0) / x)) / n;
	} else if ((1.0 / n) <= 1e+189) {
		tmp = t_0;
	} else {
		tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
	}
	return tmp;
}
def code(x, n):
	t_0 = 1.0 - math.pow(x, (1.0 / n))
	tmp = 0
	if (1.0 / n) <= -5e-5:
		tmp = t_0
	elif (1.0 / n) <= -2e-61:
		tmp = 1.0 / (x * n)
	elif (1.0 / n) <= 4e-7:
		tmp = math.log(((x + 1.0) / x)) / n
	elif (1.0 / n) <= 1e+189:
		tmp = t_0
	else:
		tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x
	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-5)
		tmp = t_0;
	elseif (Float64(1.0 / n) <= -2e-61)
		tmp = Float64(1.0 / Float64(x * n));
	elseif (Float64(1.0 / n) <= 4e-7)
		tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n);
	elseif (Float64(1.0 / n) <= 1e+189)
		tmp = t_0;
	else
		tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(x * n)) - Float64(0.5 / n)) / x)) / x);
	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-5)
		tmp = t_0;
	elseif ((1.0 / n) <= -2e-61)
		tmp = 1.0 / (x * n);
	elseif ((1.0 / n) <= 4e-7)
		tmp = log(((x + 1.0) / x)) / n;
	elseif ((1.0 / n) <= 1e+189)
		tmp = t_0;
	else
		tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
	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-5], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-61], N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 4e-7], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+189], t$95$0, N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(0.3333333333333333 / N[(x * n), $MachinePrecision]), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $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^{-5}:\\
\;\;\;\;t\_0\\

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

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

\mathbf{elif}\;\frac{1}{n} \leq 10^{+189}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (/.f64 #s(literal 1 binary64) n) < -5.00000000000000024e-5 or 3.9999999999999998e-7 < (/.f64 #s(literal 1 binary64) n) < 1e189

    1. Initial program 96.5%

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

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

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

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

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

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

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

    if -5.00000000000000024e-5 < (/.f64 #s(literal 1 binary64) n) < -2.0000000000000001e-61

    1. Initial program 8.0%

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

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

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

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

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

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

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

    if -2.0000000000000001e-61 < (/.f64 #s(literal 1 binary64) n) < 3.9999999999999998e-7

    1. Initial program 25.6%

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

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

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

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

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

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

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

    if 1e189 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 12.8%

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{n \cdot x} - 0.5 \cdot \frac{1}{n}}{x} - \frac{1}{n}}{x}} \]
    7. Step-by-step derivation
      1. mul-1-neg81.5%

        \[\leadsto \color{blue}{-\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{n \cdot x} - 0.5 \cdot \frac{1}{n}}{x} - \frac{1}{n}}{x}} \]
      2. mul-1-neg81.5%

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

        \[\leadsto -\frac{\left(-\frac{\color{blue}{\frac{0.3333333333333333 \cdot 1}{n \cdot x}} - 0.5 \cdot \frac{1}{n}}{x}\right) - \frac{1}{n}}{x} \]
      4. metadata-eval81.5%

        \[\leadsto -\frac{\left(-\frac{\frac{\color{blue}{0.3333333333333333}}{n \cdot x} - 0.5 \cdot \frac{1}{n}}{x}\right) - \frac{1}{n}}{x} \]
      5. *-commutative81.5%

        \[\leadsto -\frac{\left(-\frac{\frac{0.3333333333333333}{\color{blue}{x \cdot n}} - 0.5 \cdot \frac{1}{n}}{x}\right) - \frac{1}{n}}{x} \]
      6. associate-*r/81.5%

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

        \[\leadsto -\frac{\left(-\frac{\frac{0.3333333333333333}{x \cdot n} - \frac{\color{blue}{0.5}}{n}}{x}\right) - \frac{1}{n}}{x} \]
    8. Simplified81.5%

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

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

Alternative 10: 82.6% accurate, 1.6× speedup?

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

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

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

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

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


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

    1. Initial program 87.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.0000000000000001e-61 < (/.f64 #s(literal 1 binary64) n) < 3.9999999999999998e-7

    1. Initial program 25.6%

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

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

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

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

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

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

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

    if 3.9999999999999998e-7 < (/.f64 #s(literal 1 binary64) n) < 1.00000000000000004e201

    1. Initial program 86.8%

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

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

    if 1.00000000000000004e201 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 3.1%

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{n \cdot x} - 0.5 \cdot \frac{1}{n}}{x} - \frac{1}{n}}{x}} \]
    7. Step-by-step derivation
      1. mul-1-neg90.0%

        \[\leadsto \color{blue}{-\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{n \cdot x} - 0.5 \cdot \frac{1}{n}}{x} - \frac{1}{n}}{x}} \]
      2. mul-1-neg90.0%

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

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

        \[\leadsto -\frac{\left(-\frac{\frac{\color{blue}{0.3333333333333333}}{n \cdot x} - 0.5 \cdot \frac{1}{n}}{x}\right) - \frac{1}{n}}{x} \]
      5. *-commutative90.0%

        \[\leadsto -\frac{\left(-\frac{\frac{0.3333333333333333}{\color{blue}{x \cdot n}} - 0.5 \cdot \frac{1}{n}}{x}\right) - \frac{1}{n}}{x} \]
      6. associate-*r/90.0%

        \[\leadsto -\frac{\left(-\frac{\frac{0.3333333333333333}{x \cdot n} - \color{blue}{\frac{0.5 \cdot 1}{n}}}{x}\right) - \frac{1}{n}}{x} \]
      7. metadata-eval90.0%

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

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

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

Alternative 11: 82.6% accurate, 1.7× speedup?

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq 10^{+189}:\\
\;\;\;\;1 - t\_0\\

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


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

    1. Initial program 87.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.0000000000000001e-61 < (/.f64 #s(literal 1 binary64) n) < 3.9999999999999998e-7

    1. Initial program 25.6%

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

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

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

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

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

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

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

    if 3.9999999999999998e-7 < (/.f64 #s(literal 1 binary64) n) < 1e189

    1. Initial program 86.3%

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

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

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

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

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

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

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

    if 1e189 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 12.8%

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{n \cdot x} - 0.5 \cdot \frac{1}{n}}{x} - \frac{1}{n}}{x}} \]
    7. Step-by-step derivation
      1. mul-1-neg81.5%

        \[\leadsto \color{blue}{-\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{n \cdot x} - 0.5 \cdot \frac{1}{n}}{x} - \frac{1}{n}}{x}} \]
      2. mul-1-neg81.5%

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

        \[\leadsto -\frac{\left(-\frac{\color{blue}{\frac{0.3333333333333333 \cdot 1}{n \cdot x}} - 0.5 \cdot \frac{1}{n}}{x}\right) - \frac{1}{n}}{x} \]
      4. metadata-eval81.5%

        \[\leadsto -\frac{\left(-\frac{\frac{\color{blue}{0.3333333333333333}}{n \cdot x} - 0.5 \cdot \frac{1}{n}}{x}\right) - \frac{1}{n}}{x} \]
      5. *-commutative81.5%

        \[\leadsto -\frac{\left(-\frac{\frac{0.3333333333333333}{\color{blue}{x \cdot n}} - 0.5 \cdot \frac{1}{n}}{x}\right) - \frac{1}{n}}{x} \]
      6. associate-*r/81.5%

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

        \[\leadsto -\frac{\left(-\frac{\frac{0.3333333333333333}{x \cdot n} - \frac{\color{blue}{0.5}}{n}}{x}\right) - \frac{1}{n}}{x} \]
    8. Simplified81.5%

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

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

Alternative 12: 59.7% accurate, 1.8× speedup?

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

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

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

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

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


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

    1. Initial program 57.9%

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

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

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

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

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

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

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

    if 1.19999999999999992e-164 < x < 0.92000000000000004

    1. Initial program 41.8%

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

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

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

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

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

    if 0.92000000000000004 < x < 1.84999999999999998e123

    1. Initial program 37.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(\sqrt[3]{{x}^{\left(\frac{1}{n}\right)}} \cdot \sqrt[3]{{x}^{\left(\frac{1}{n}\right)}}\right) \cdot \frac{\sqrt[3]{{x}^{\left(\frac{1}{n}\right)}}}{x \cdot n}} \]
      3. cbrt-unprod93.6%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sqrt[3]{{x}^{\left(\frac{2}{n}\right)}}}{x} \cdot \frac{\sqrt[3]{{x}^{\left(\frac{1}{n}\right)}}}{n}} \]
    10. Taylor expanded in n around inf 73.2%

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

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

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

    if 1.84999999999999998e123 < x

    1. Initial program 78.3%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.2 \cdot 10^{-164}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 0.92:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{elif}\;x \leq 1.85 \cdot 10^{+123}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 60.1% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.92:\\
\;\;\;\;\frac{x - \log x}{n}\\

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

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


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

    1. Initial program 49.1%

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

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

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

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

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

    if 0.92000000000000004 < x < 1.79999999999999999e123

    1. Initial program 37.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(\sqrt[3]{{x}^{\left(\frac{1}{n}\right)}} \cdot \sqrt[3]{{x}^{\left(\frac{1}{n}\right)}}\right) \cdot \frac{\sqrt[3]{{x}^{\left(\frac{1}{n}\right)}}}{x \cdot n}} \]
      3. cbrt-unprod93.6%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sqrt[3]{{x}^{\left(\frac{2}{n}\right)}}}{x} \cdot \frac{\sqrt[3]{{x}^{\left(\frac{1}{n}\right)}}}{n}} \]
    10. Taylor expanded in n around inf 73.2%

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

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

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

    if 1.79999999999999999e123 < x

    1. Initial program 78.3%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 0.92:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{elif}\;x \leq 1.8 \cdot 10^{+123}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 59.8% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.56:\\
\;\;\;\;\frac{\log x}{-n}\\

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

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


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

    1. Initial program 49.1%

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{-\frac{\log x}{n}} \]
      2. distribute-neg-frac48.8%

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

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

    if 0.56000000000000005 < x < 1.79999999999999999e123

    1. Initial program 37.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(\sqrt[3]{{x}^{\left(\frac{1}{n}\right)}} \cdot \sqrt[3]{{x}^{\left(\frac{1}{n}\right)}}\right) \cdot \frac{\sqrt[3]{{x}^{\left(\frac{1}{n}\right)}}}{x \cdot n}} \]
      3. cbrt-unprod93.6%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sqrt[3]{{x}^{\left(\frac{2}{n}\right)}}}{x} \cdot \frac{\sqrt[3]{{x}^{\left(\frac{1}{n}\right)}}}{n}} \]
    10. Taylor expanded in n around inf 73.2%

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

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

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

    if 1.79999999999999999e123 < x

    1. Initial program 78.3%

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

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

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

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

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

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

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

      \[\leadsto \log \color{blue}{1} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification59.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 0.56:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 1.8 \cdot 10^{+123}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 49.6% accurate, 9.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.8 \cdot 10^{+123}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} - \frac{0.5}{n}}{x}}{x}\\

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


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

    1. Initial program 46.6%

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{n \cdot x} - 0.5 \cdot \frac{1}{n}}{x} - \frac{1}{n}}{x}} \]
    7. Step-by-step derivation
      1. mul-1-neg44.8%

        \[\leadsto \color{blue}{-\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{n \cdot x} - 0.5 \cdot \frac{1}{n}}{x} - \frac{1}{n}}{x}} \]
      2. mul-1-neg44.8%

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

        \[\leadsto -\frac{\left(-\frac{\color{blue}{\frac{0.3333333333333333 \cdot 1}{n \cdot x}} - 0.5 \cdot \frac{1}{n}}{x}\right) - \frac{1}{n}}{x} \]
      4. metadata-eval44.8%

        \[\leadsto -\frac{\left(-\frac{\frac{\color{blue}{0.3333333333333333}}{n \cdot x} - 0.5 \cdot \frac{1}{n}}{x}\right) - \frac{1}{n}}{x} \]
      5. *-commutative44.8%

        \[\leadsto -\frac{\left(-\frac{\frac{0.3333333333333333}{\color{blue}{x \cdot n}} - 0.5 \cdot \frac{1}{n}}{x}\right) - \frac{1}{n}}{x} \]
      6. associate-*r/44.8%

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

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

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

    if 1.79999999999999999e123 < x

    1. Initial program 78.3%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.8 \cdot 10^{+123}:\\ \;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} - \frac{0.5}{n}}{x}}{x}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 16: 46.0% accurate, 12.4× speedup?

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

\\
\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} - \frac{0.5}{n}}{x}}{x}
\end{array}
Derivation
  1. Initial program 53.4%

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

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

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

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

    \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{n \cdot x} - 0.5 \cdot \frac{1}{n}}{x} - \frac{1}{n}}{x}} \]
  7. Step-by-step derivation
    1. mul-1-neg48.8%

      \[\leadsto \color{blue}{-\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{n \cdot x} - 0.5 \cdot \frac{1}{n}}{x} - \frac{1}{n}}{x}} \]
    2. mul-1-neg48.8%

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

      \[\leadsto -\frac{\left(-\frac{\color{blue}{\frac{0.3333333333333333 \cdot 1}{n \cdot x}} - 0.5 \cdot \frac{1}{n}}{x}\right) - \frac{1}{n}}{x} \]
    4. metadata-eval48.8%

      \[\leadsto -\frac{\left(-\frac{\frac{\color{blue}{0.3333333333333333}}{n \cdot x} - 0.5 \cdot \frac{1}{n}}{x}\right) - \frac{1}{n}}{x} \]
    5. *-commutative48.8%

      \[\leadsto -\frac{\left(-\frac{\frac{0.3333333333333333}{\color{blue}{x \cdot n}} - 0.5 \cdot \frac{1}{n}}{x}\right) - \frac{1}{n}}{x} \]
    6. associate-*r/48.8%

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

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

    \[\leadsto \color{blue}{-\frac{\left(-\frac{\frac{0.3333333333333333}{x \cdot n} - \frac{0.5}{n}}{x}\right) - \frac{1}{n}}{x}} \]
  9. Final simplification48.8%

    \[\leadsto \frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} - \frac{0.5}{n}}{x}}{x} \]
  10. Add Preprocessing

Alternative 17: 40.1% accurate, 42.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\sqrt[3]{{x}^{\left(\frac{2}{n}\right)}}}{x} \cdot \frac{\sqrt[3]{{x}^{\left(\frac{1}{n}\right)}}}{n}} \]
  10. Taylor expanded in n around inf 41.9%

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

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

    \[\leadsto \color{blue}{\frac{\frac{1}{n}}{x}} \]
  13. Add Preprocessing

Alternative 18: 39.5% accurate, 42.2× speedup?

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{1}{x \cdot n}} \]
  9. Add Preprocessing

Alternative 19: 4.6% accurate, 70.3× speedup?

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

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

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

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

    \[\leadsto \color{blue}{\frac{x}{n}} \]
  5. Add Preprocessing

Reproduce

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