2nthrt (problem 3.4.6)

Percentage Accurate: 53.8% → 86.3%
Time: 29.2s
Alternatives: 20
Speedup: 2.0×

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 20 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.3% accurate, 0.3× speedup?

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

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

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

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


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

    1. Initial program 96.3%

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

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

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

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

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

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

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

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

    if -9.99999999999999971e-29 < (/.f64 1 n) < 1.00000000000000006e-9

    1. Initial program 26.9%

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

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

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

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

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

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

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

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

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

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

    1. Initial program 61.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 85.9% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-28}:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x}\\

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

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


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

    1. Initial program 96.3%

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

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

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

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

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

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

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

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

    if -9.99999999999999971e-29 < (/.f64 1 n) < 4.99999999999999954e-22

    1. Initial program 27.0%

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

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

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

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

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

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

    if 4.99999999999999954e-22 < (/.f64 1 n)

    1. Initial program 58.1%

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

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

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

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

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

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

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

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

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

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

Alternative 3: 86.2% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-28}:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x}\\

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

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


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

    1. Initial program 96.3%

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

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

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

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

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

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

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

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

    if -9.99999999999999971e-29 < (/.f64 1 n) < 9.50000000000000028e-10

    1. Initial program 26.6%

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

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

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

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

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

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

    if 9.50000000000000028e-10 < (/.f64 1 n)

    1. Initial program 61.4%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-28}:\\ \;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 9.5 \cdot 10^{-10}:\\ \;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{e^{\frac{x}{n} \cdot 3}} - {x}^{\left(\frac{1}{n}\right)}\\ \end{array} \]

Alternative 4: 86.0% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-28}:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x}\\

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

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


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

    1. Initial program 96.3%

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

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

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

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

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

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

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

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

    if -9.99999999999999971e-29 < (/.f64 1 n) < 4.99999999999999954e-22

    1. Initial program 27.0%

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

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

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

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

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

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

    if 4.99999999999999954e-22 < (/.f64 1 n)

    1. Initial program 58.1%

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

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

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

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

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

Alternative 5: 86.2% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-28}:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x}\\

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

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


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

    1. Initial program 96.3%

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

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

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

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

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

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

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

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

    if -9.99999999999999971e-29 < (/.f64 1 n) < 9.50000000000000028e-10

    1. Initial program 26.6%

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

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

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

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

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

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

    if 9.50000000000000028e-10 < (/.f64 1 n)

    1. Initial program 61.4%

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

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

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

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

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

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

Alternative 6: 81.9% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{-28}:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x}\\

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

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

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


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

    1. Initial program 96.3%

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

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

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

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

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

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

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

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

    if -9.99999999999999971e-29 < (/.f64 1 n) < 9.50000000000000028e-10

    1. Initial program 26.6%

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

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

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

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

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

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

    if 9.50000000000000028e-10 < (/.f64 1 n) < 4.99999999999999972e118

    1. Initial program 90.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.99999999999999972e118 < (/.f64 1 n)

    1. Initial program 36.2%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{{x}^{2}}{{n}^{2}}} \]
    6. Step-by-step derivation
      1. unpow253.0%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x \cdot x}}{{n}^{2}} \]
      2. unpow253.0%

        \[\leadsto 0.5 \cdot \frac{x \cdot x}{\color{blue}{n \cdot n}} \]
    7. Simplified53.0%

      \[\leadsto \color{blue}{0.5 \cdot \frac{x \cdot x}{n \cdot n}} \]
    8. Taylor expanded in x around 0 53.0%

      \[\leadsto \color{blue}{0.5 \cdot \frac{{x}^{2}}{{n}^{2}}} \]
    9. Step-by-step derivation
      1. *-commutative53.0%

        \[\leadsto \color{blue}{\frac{{x}^{2}}{{n}^{2}} \cdot 0.5} \]
      2. associate-*l/53.0%

        \[\leadsto \color{blue}{\frac{{x}^{2} \cdot 0.5}{{n}^{2}}} \]
      3. associate-*r/56.8%

        \[\leadsto \color{blue}{{x}^{2} \cdot \frac{0.5}{{n}^{2}}} \]
      4. unpow256.8%

        \[\leadsto {x}^{2} \cdot \frac{0.5}{\color{blue}{n \cdot n}} \]
      5. unpow256.8%

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

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

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

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

Alternative 7: 68.0% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq 9.5 \cdot 10^{-10}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\

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

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


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

    1. Initial program 50.2%

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

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

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

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

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

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

    if 9.50000000000000028e-10 < (/.f64 1 n) < 4.99999999999999972e118

    1. Initial program 90.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.99999999999999972e118 < (/.f64 1 n)

    1. Initial program 36.2%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{{x}^{2}}{{n}^{2}}} \]
    6. Step-by-step derivation
      1. unpow253.0%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x \cdot x}}{{n}^{2}} \]
      2. unpow253.0%

        \[\leadsto 0.5 \cdot \frac{x \cdot x}{\color{blue}{n \cdot n}} \]
    7. Simplified53.0%

      \[\leadsto \color{blue}{0.5 \cdot \frac{x \cdot x}{n \cdot n}} \]
    8. Taylor expanded in x around 0 53.0%

      \[\leadsto \color{blue}{0.5 \cdot \frac{{x}^{2}}{{n}^{2}}} \]
    9. Step-by-step derivation
      1. *-commutative53.0%

        \[\leadsto \color{blue}{\frac{{x}^{2}}{{n}^{2}} \cdot 0.5} \]
      2. associate-*l/53.0%

        \[\leadsto \color{blue}{\frac{{x}^{2} \cdot 0.5}{{n}^{2}}} \]
      3. associate-*r/56.8%

        \[\leadsto \color{blue}{{x}^{2} \cdot \frac{0.5}{{n}^{2}}} \]
      4. unpow256.8%

        \[\leadsto {x}^{2} \cdot \frac{0.5}{\color{blue}{n \cdot n}} \]
      5. unpow256.8%

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

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

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

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

Alternative 8: 56.7% accurate, 1.7× speedup?

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

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

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

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

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


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

    1. Initial program 43.6%

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{\log x}{n}} \]
    4. Step-by-step derivation
      1. mul-1-neg56.5%

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

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

    if 3.3e-177 < x < 1.56e-155

    1. Initial program 71.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.56e-155 < x < 3.59999999999999984e-6

    1. Initial program 34.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(-\left(x + \left(\left(x \cdot x\right) \cdot -0.5 - \log x\right)\right)\right) \cdot \frac{1}{-n}} \]
      3. associate-*l*54.7%

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

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

    if 3.59999999999999984e-6 < x

    1. Initial program 68.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 3.3 \cdot 10^{-177}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 1.56 \cdot 10^{-155}:\\ \;\;\;\;\left(\left(1 + \frac{x}{n}\right) + \left(x \cdot \frac{x}{n}\right) \cdot \left(-0.5 + \frac{0.5}{n}\right)\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 3.6 \cdot 10^{-6}:\\ \;\;\;\;\left(x + \left(x \cdot \left(x \cdot -0.5\right) - \log x\right)\right) \cdot \frac{-1}{-n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{0.3333333333333333}{{x}^{3}} + \left(\frac{1}{x} - \frac{0.5}{x \cdot x}\right)}{n}\\ \end{array} \]

Alternative 9: 56.7% accurate, 1.7× speedup?

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

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

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

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

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


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

    1. Initial program 43.6%

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{\log x}{n}} \]
    4. Step-by-step derivation
      1. mul-1-neg56.5%

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

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

    if 5.59999999999999973e-177 < x < 1.25e-155

    1. Initial program 71.1%

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

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

    if 1.25e-155 < x < 3.59999999999999984e-6

    1. Initial program 34.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(-\left(x + \left(\left(x \cdot x\right) \cdot -0.5 - \log x\right)\right)\right) \cdot \frac{1}{-n}} \]
      3. associate-*l*54.7%

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

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

    if 3.59999999999999984e-6 < x

    1. Initial program 68.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 5.6 \cdot 10^{-177}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 1.25 \cdot 10^{-155}:\\ \;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 3.6 \cdot 10^{-6}:\\ \;\;\;\;\left(x + \left(x \cdot \left(x \cdot -0.5\right) - \log x\right)\right) \cdot \frac{-1}{-n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{0.3333333333333333}{{x}^{3}} + \left(\frac{1}{x} - \frac{0.5}{x \cdot x}\right)}{n}\\ \end{array} \]

Alternative 10: 56.9% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 5.6 \cdot 10^{-177}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 2.65 \cdot 10^{-155}:\\ \;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;\left(x + \left(x \cdot \left(x \cdot -0.5\right) - \log x\right)\right) \cdot \frac{-1}{-n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{n}}{x} - \frac{0.5}{n \cdot \left(x \cdot x\right)}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= x 5.6e-177)
   (/ (- (log x)) n)
   (if (<= x 2.65e-155)
     (- (+ 1.0 (/ x n)) (pow x (/ 1.0 n)))
     (if (<= x 1.0)
       (* (+ x (- (* x (* x -0.5)) (log x))) (/ -1.0 (- n)))
       (- (/ (/ 1.0 n) x) (/ 0.5 (* n (* x x))))))))
double code(double x, double n) {
	double tmp;
	if (x <= 5.6e-177) {
		tmp = -log(x) / n;
	} else if (x <= 2.65e-155) {
		tmp = (1.0 + (x / n)) - pow(x, (1.0 / n));
	} else if (x <= 1.0) {
		tmp = (x + ((x * (x * -0.5)) - log(x))) * (-1.0 / -n);
	} else {
		tmp = ((1.0 / n) / x) - (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) :: tmp
    if (x <= 5.6d-177) then
        tmp = -log(x) / n
    else if (x <= 2.65d-155) then
        tmp = (1.0d0 + (x / n)) - (x ** (1.0d0 / n))
    else if (x <= 1.0d0) then
        tmp = (x + ((x * (x * (-0.5d0))) - log(x))) * ((-1.0d0) / -n)
    else
        tmp = ((1.0d0 / n) / x) - (0.5d0 / (n * (x * x)))
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double tmp;
	if (x <= 5.6e-177) {
		tmp = -Math.log(x) / n;
	} else if (x <= 2.65e-155) {
		tmp = (1.0 + (x / n)) - Math.pow(x, (1.0 / n));
	} else if (x <= 1.0) {
		tmp = (x + ((x * (x * -0.5)) - Math.log(x))) * (-1.0 / -n);
	} else {
		tmp = ((1.0 / n) / x) - (0.5 / (n * (x * x)));
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if x <= 5.6e-177:
		tmp = -math.log(x) / n
	elif x <= 2.65e-155:
		tmp = (1.0 + (x / n)) - math.pow(x, (1.0 / n))
	elif x <= 1.0:
		tmp = (x + ((x * (x * -0.5)) - math.log(x))) * (-1.0 / -n)
	else:
		tmp = ((1.0 / n) / x) - (0.5 / (n * (x * x)))
	return tmp
function code(x, n)
	tmp = 0.0
	if (x <= 5.6e-177)
		tmp = Float64(Float64(-log(x)) / n);
	elseif (x <= 2.65e-155)
		tmp = Float64(Float64(1.0 + Float64(x / n)) - (x ^ Float64(1.0 / n)));
	elseif (x <= 1.0)
		tmp = Float64(Float64(x + Float64(Float64(x * Float64(x * -0.5)) - log(x))) * Float64(-1.0 / Float64(-n)));
	else
		tmp = Float64(Float64(Float64(1.0 / n) / x) - Float64(0.5 / Float64(n * Float64(x * x))));
	end
	return tmp
end
function tmp_2 = code(x, n)
	tmp = 0.0;
	if (x <= 5.6e-177)
		tmp = -log(x) / n;
	elseif (x <= 2.65e-155)
		tmp = (1.0 + (x / n)) - (x ^ (1.0 / n));
	elseif (x <= 1.0)
		tmp = (x + ((x * (x * -0.5)) - log(x))) * (-1.0 / -n);
	else
		tmp = ((1.0 / n) / x) - (0.5 / (n * (x * x)));
	end
	tmp_2 = tmp;
end
code[x_, n_] := If[LessEqual[x, 5.6e-177], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 2.65e-155], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.0], N[(N[(x + N[(N[(x * N[(x * -0.5), $MachinePrecision]), $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(-1.0 / (-n)), $MachinePrecision]), $MachinePrecision], N[(N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision] - N[(0.5 / N[(n * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

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

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

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


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

    1. Initial program 43.6%

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{\log x}{n}} \]
    4. Step-by-step derivation
      1. mul-1-neg56.5%

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

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

    if 5.59999999999999973e-177 < x < 2.6499999999999999e-155

    1. Initial program 71.1%

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

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

    if 2.6499999999999999e-155 < x < 1

    1. Initial program 37.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1 < x

    1. Initial program 67.3%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{n}}{x} - \frac{\color{blue}{0.5}}{n \cdot {x}^{2}} \]
      4. unpow264.2%

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

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

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

Alternative 11: 56.8% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 8.5 \cdot 10^{-178}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 1.32 \cdot 10^{-155}:\\ \;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;\frac{x + \left(-0.5 \cdot \left(x \cdot x\right) - \log x\right)}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{n}}{x} - \frac{0.5}{n \cdot \left(x \cdot x\right)}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= x 8.5e-178)
   (/ (- (log x)) n)
   (if (<= x 1.32e-155)
     (- (+ 1.0 (/ x n)) (pow x (/ 1.0 n)))
     (if (<= x 1.0)
       (/ (+ x (- (* -0.5 (* x x)) (log x))) n)
       (- (/ (/ 1.0 n) x) (/ 0.5 (* n (* x x))))))))
double code(double x, double n) {
	double tmp;
	if (x <= 8.5e-178) {
		tmp = -log(x) / n;
	} else if (x <= 1.32e-155) {
		tmp = (1.0 + (x / n)) - pow(x, (1.0 / n));
	} else if (x <= 1.0) {
		tmp = (x + ((-0.5 * (x * x)) - log(x))) / n;
	} else {
		tmp = ((1.0 / n) / x) - (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) :: tmp
    if (x <= 8.5d-178) then
        tmp = -log(x) / n
    else if (x <= 1.32d-155) then
        tmp = (1.0d0 + (x / n)) - (x ** (1.0d0 / n))
    else if (x <= 1.0d0) then
        tmp = (x + (((-0.5d0) * (x * x)) - log(x))) / n
    else
        tmp = ((1.0d0 / n) / x) - (0.5d0 / (n * (x * x)))
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double tmp;
	if (x <= 8.5e-178) {
		tmp = -Math.log(x) / n;
	} else if (x <= 1.32e-155) {
		tmp = (1.0 + (x / n)) - Math.pow(x, (1.0 / n));
	} else if (x <= 1.0) {
		tmp = (x + ((-0.5 * (x * x)) - Math.log(x))) / n;
	} else {
		tmp = ((1.0 / n) / x) - (0.5 / (n * (x * x)));
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if x <= 8.5e-178:
		tmp = -math.log(x) / n
	elif x <= 1.32e-155:
		tmp = (1.0 + (x / n)) - math.pow(x, (1.0 / n))
	elif x <= 1.0:
		tmp = (x + ((-0.5 * (x * x)) - math.log(x))) / n
	else:
		tmp = ((1.0 / n) / x) - (0.5 / (n * (x * x)))
	return tmp
function code(x, n)
	tmp = 0.0
	if (x <= 8.5e-178)
		tmp = Float64(Float64(-log(x)) / n);
	elseif (x <= 1.32e-155)
		tmp = Float64(Float64(1.0 + Float64(x / n)) - (x ^ Float64(1.0 / n)));
	elseif (x <= 1.0)
		tmp = Float64(Float64(x + Float64(Float64(-0.5 * Float64(x * x)) - log(x))) / n);
	else
		tmp = Float64(Float64(Float64(1.0 / n) / x) - Float64(0.5 / Float64(n * Float64(x * x))));
	end
	return tmp
end
function tmp_2 = code(x, n)
	tmp = 0.0;
	if (x <= 8.5e-178)
		tmp = -log(x) / n;
	elseif (x <= 1.32e-155)
		tmp = (1.0 + (x / n)) - (x ^ (1.0 / n));
	elseif (x <= 1.0)
		tmp = (x + ((-0.5 * (x * x)) - log(x))) / n;
	else
		tmp = ((1.0 / n) / x) - (0.5 / (n * (x * x)));
	end
	tmp_2 = tmp;
end
code[x_, n_] := If[LessEqual[x, 8.5e-178], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 1.32e-155], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.0], N[(N[(x + N[(N[(-0.5 * N[(x * x), $MachinePrecision]), $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision] - N[(0.5 / N[(n * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

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

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

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


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

    1. Initial program 43.6%

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{\log x}{n}} \]
    4. Step-by-step derivation
      1. mul-1-neg56.5%

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

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

    if 8.5000000000000001e-178 < x < 1.3199999999999999e-155

    1. Initial program 71.1%

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

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

    if 1.3199999999999999e-155 < x < 1

    1. Initial program 37.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1 < x

    1. Initial program 67.3%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{n}}{x} - \frac{\color{blue}{0.5}}{n \cdot {x}^{2}} \]
      4. unpow264.2%

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

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

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

Alternative 12: 56.8% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 5.2 \cdot 10^{-177}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 1.55 \cdot 10^{-155}:\\ \;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 0.95:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{n}}{x} - \frac{0.5}{n \cdot \left(x \cdot x\right)}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= x 5.2e-177)
   (/ (- (log x)) n)
   (if (<= x 1.55e-155)
     (- (+ 1.0 (/ x n)) (pow x (/ 1.0 n)))
     (if (<= x 0.95)
       (/ (- x (log x)) n)
       (- (/ (/ 1.0 n) x) (/ 0.5 (* n (* x x))))))))
double code(double x, double n) {
	double tmp;
	if (x <= 5.2e-177) {
		tmp = -log(x) / n;
	} else if (x <= 1.55e-155) {
		tmp = (1.0 + (x / n)) - pow(x, (1.0 / n));
	} else if (x <= 0.95) {
		tmp = (x - log(x)) / n;
	} else {
		tmp = ((1.0 / n) / x) - (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) :: tmp
    if (x <= 5.2d-177) then
        tmp = -log(x) / n
    else if (x <= 1.55d-155) then
        tmp = (1.0d0 + (x / n)) - (x ** (1.0d0 / n))
    else if (x <= 0.95d0) then
        tmp = (x - log(x)) / n
    else
        tmp = ((1.0d0 / n) / x) - (0.5d0 / (n * (x * x)))
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double tmp;
	if (x <= 5.2e-177) {
		tmp = -Math.log(x) / n;
	} else if (x <= 1.55e-155) {
		tmp = (1.0 + (x / n)) - Math.pow(x, (1.0 / n));
	} else if (x <= 0.95) {
		tmp = (x - Math.log(x)) / n;
	} else {
		tmp = ((1.0 / n) / x) - (0.5 / (n * (x * x)));
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if x <= 5.2e-177:
		tmp = -math.log(x) / n
	elif x <= 1.55e-155:
		tmp = (1.0 + (x / n)) - math.pow(x, (1.0 / n))
	elif x <= 0.95:
		tmp = (x - math.log(x)) / n
	else:
		tmp = ((1.0 / n) / x) - (0.5 / (n * (x * x)))
	return tmp
function code(x, n)
	tmp = 0.0
	if (x <= 5.2e-177)
		tmp = Float64(Float64(-log(x)) / n);
	elseif (x <= 1.55e-155)
		tmp = Float64(Float64(1.0 + Float64(x / n)) - (x ^ Float64(1.0 / n)));
	elseif (x <= 0.95)
		tmp = Float64(Float64(x - log(x)) / n);
	else
		tmp = Float64(Float64(Float64(1.0 / n) / x) - Float64(0.5 / Float64(n * Float64(x * x))));
	end
	return tmp
end
function tmp_2 = code(x, n)
	tmp = 0.0;
	if (x <= 5.2e-177)
		tmp = -log(x) / n;
	elseif (x <= 1.55e-155)
		tmp = (1.0 + (x / n)) - (x ^ (1.0 / n));
	elseif (x <= 0.95)
		tmp = (x - log(x)) / n;
	else
		tmp = ((1.0 / n) / x) - (0.5 / (n * (x * x)));
	end
	tmp_2 = tmp;
end
code[x_, n_] := If[LessEqual[x, 5.2e-177], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 1.55e-155], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.95], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision] - N[(0.5 / N[(n * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

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

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

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


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

    1. Initial program 43.6%

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{\log x}{n}} \]
    4. Step-by-step derivation
      1. mul-1-neg56.5%

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

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

    if 5.2000000000000002e-177 < x < 1.55e-155

    1. Initial program 71.1%

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

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

    if 1.55e-155 < x < 0.94999999999999996

    1. Initial program 37.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{x + -1 \cdot \log x}}{n} \]
    9. Step-by-step derivation
      1. mul-1-neg52.2%

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

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

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

    if 0.94999999999999996 < x

    1. Initial program 67.3%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{n}}{x} - \frac{\color{blue}{0.5}}{n \cdot {x}^{2}} \]
      4. unpow264.2%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 5.2 \cdot 10^{-177}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 1.55 \cdot 10^{-155}:\\ \;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 0.95:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{n}}{x} - \frac{0.5}{n \cdot \left(x \cdot x\right)}\\ \end{array} \]

Alternative 13: 56.8% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 3.3 \cdot 10^{-177}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 1.25 \cdot 10^{-155}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 0.95:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{n}}{x} - \frac{0.5}{n \cdot \left(x \cdot x\right)}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= x 3.3e-177)
   (/ (- (log x)) n)
   (if (<= x 1.25e-155)
     (- 1.0 (pow x (/ 1.0 n)))
     (if (<= x 0.95)
       (/ (- x (log x)) n)
       (- (/ (/ 1.0 n) x) (/ 0.5 (* n (* x x))))))))
double code(double x, double n) {
	double tmp;
	if (x <= 3.3e-177) {
		tmp = -log(x) / n;
	} else if (x <= 1.25e-155) {
		tmp = 1.0 - pow(x, (1.0 / n));
	} else if (x <= 0.95) {
		tmp = (x - log(x)) / n;
	} else {
		tmp = ((1.0 / n) / x) - (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) :: tmp
    if (x <= 3.3d-177) then
        tmp = -log(x) / n
    else if (x <= 1.25d-155) then
        tmp = 1.0d0 - (x ** (1.0d0 / n))
    else if (x <= 0.95d0) then
        tmp = (x - log(x)) / n
    else
        tmp = ((1.0d0 / n) / x) - (0.5d0 / (n * (x * x)))
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double tmp;
	if (x <= 3.3e-177) {
		tmp = -Math.log(x) / n;
	} else if (x <= 1.25e-155) {
		tmp = 1.0 - Math.pow(x, (1.0 / n));
	} else if (x <= 0.95) {
		tmp = (x - Math.log(x)) / n;
	} else {
		tmp = ((1.0 / n) / x) - (0.5 / (n * (x * x)));
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if x <= 3.3e-177:
		tmp = -math.log(x) / n
	elif x <= 1.25e-155:
		tmp = 1.0 - math.pow(x, (1.0 / n))
	elif x <= 0.95:
		tmp = (x - math.log(x)) / n
	else:
		tmp = ((1.0 / n) / x) - (0.5 / (n * (x * x)))
	return tmp
function code(x, n)
	tmp = 0.0
	if (x <= 3.3e-177)
		tmp = Float64(Float64(-log(x)) / n);
	elseif (x <= 1.25e-155)
		tmp = Float64(1.0 - (x ^ Float64(1.0 / n)));
	elseif (x <= 0.95)
		tmp = Float64(Float64(x - log(x)) / n);
	else
		tmp = Float64(Float64(Float64(1.0 / n) / x) - Float64(0.5 / Float64(n * Float64(x * x))));
	end
	return tmp
end
function tmp_2 = code(x, n)
	tmp = 0.0;
	if (x <= 3.3e-177)
		tmp = -log(x) / n;
	elseif (x <= 1.25e-155)
		tmp = 1.0 - (x ^ (1.0 / n));
	elseif (x <= 0.95)
		tmp = (x - log(x)) / n;
	else
		tmp = ((1.0 / n) / x) - (0.5 / (n * (x * x)));
	end
	tmp_2 = tmp;
end
code[x_, n_] := If[LessEqual[x, 3.3e-177], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 1.25e-155], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 0.95], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision] - N[(0.5 / N[(n * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

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

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

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

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


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

    1. Initial program 43.6%

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{\log x}{n}} \]
    4. Step-by-step derivation
      1. mul-1-neg56.5%

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

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

    if 3.3e-177 < x < 1.25e-155

    1. Initial program 71.1%

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

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

    if 1.25e-155 < x < 0.94999999999999996

    1. Initial program 37.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{x + -1 \cdot \log x}}{n} \]
    9. Step-by-step derivation
      1. mul-1-neg52.2%

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

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

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

    if 0.94999999999999996 < x

    1. Initial program 67.3%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{n}}{x} - \frac{\color{blue}{0.5}}{n \cdot {x}^{2}} \]
      4. unpow264.2%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 3.3 \cdot 10^{-177}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 1.25 \cdot 10^{-155}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 0.95:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{n}}{x} - \frac{0.5}{n \cdot \left(x \cdot x\right)}\\ \end{array} \]

Alternative 14: 57.3% accurate, 2.0× speedup?

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

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

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


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

    1. Initial program 42.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.97999999999999998 < x

    1. Initial program 67.3%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{n}}{x} - \frac{\color{blue}{0.5}}{n \cdot {x}^{2}} \]
      4. unpow264.2%

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

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

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

Alternative 15: 57.1% accurate, 2.0× speedup?

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

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

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


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

    1. Initial program 41.7%

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

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

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

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

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

    if 0.660000000000000031 < x

    1. Initial program 67.6%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{n}}{x} - \frac{\color{blue}{0.5}}{n \cdot {x}^{2}} \]
      4. unpow263.6%

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

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

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

Alternative 16: 41.8% accurate, 12.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq 2 \cdot 10^{+74}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\

\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+214}:\\
\;\;\;\;0.5 \cdot \frac{x \cdot x}{n \cdot n}\\

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


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

    1. Initial program 52.6%

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

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

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

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

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

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

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

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

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

    if 1.9999999999999999e74 < (/.f64 1 n) < 1.9999999999999999e214

    1. Initial program 61.5%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{0.5 \cdot \frac{{x}^{2}}{{n}^{2}}} \]
    6. Step-by-step derivation
      1. unpow234.7%

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x \cdot x}}{{n}^{2}} \]
      2. unpow234.7%

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

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

    if 1.9999999999999999e214 < (/.f64 1 n)

    1. Initial program 19.7%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq 2 \cdot 10^{+74}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+214}:\\ \;\;\;\;0.5 \cdot \frac{x \cdot x}{n \cdot n}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \end{array} \]

Alternative 17: 42.8% accurate, 16.2× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq 2 \cdot 10^{+48}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\

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


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

    1. Initial program 51.9%

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

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

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

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

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

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

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

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

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

    if 2.00000000000000009e48 < (/.f64 1 n)

    1. Initial program 54.5%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto 0.5 \cdot \frac{\color{blue}{x \cdot x}}{{n}^{2}} \]
      2. unpow237.2%

        \[\leadsto 0.5 \cdot \frac{x \cdot x}{\color{blue}{n \cdot n}} \]
    7. Simplified37.2%

      \[\leadsto \color{blue}{0.5 \cdot \frac{x \cdot x}{n \cdot n}} \]
    8. Taylor expanded in x around 0 37.2%

      \[\leadsto \color{blue}{0.5 \cdot \frac{{x}^{2}}{{n}^{2}}} \]
    9. Step-by-step derivation
      1. *-commutative37.2%

        \[\leadsto \color{blue}{\frac{{x}^{2}}{{n}^{2}} \cdot 0.5} \]
      2. associate-*l/37.2%

        \[\leadsto \color{blue}{\frac{{x}^{2} \cdot 0.5}{{n}^{2}}} \]
      3. associate-*r/39.8%

        \[\leadsto \color{blue}{{x}^{2} \cdot \frac{0.5}{{n}^{2}}} \]
      4. unpow239.8%

        \[\leadsto {x}^{2} \cdot \frac{0.5}{\color{blue}{n \cdot n}} \]
      5. unpow239.8%

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

        \[\leadsto \color{blue}{x \cdot \left(x \cdot \frac{0.5}{n \cdot n}\right)} \]
    10. Simplified51.0%

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

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

Alternative 18: 40.6% accurate, 42.2× speedup?

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{1}{n \cdot x}} \]
  6. Final simplification38.3%

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

Alternative 19: 41.2% accurate, 42.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 20: 4.5% 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 52.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(x \cdot x, \frac{0.5}{\color{blue}{n \cdot n}} + \left(-\frac{0.5}{n}\right), \frac{x}{n}\right) \]
    9. distribute-neg-frac8.6%

      \[\leadsto \mathsf{fma}\left(x \cdot x, \frac{0.5}{n \cdot n} + \color{blue}{\frac{-0.5}{n}}, \frac{x}{n}\right) \]
    10. metadata-eval8.6%

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

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

    \[\leadsto \color{blue}{\frac{x}{n}} \]
  9. Final simplification4.6%

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

Reproduce

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