2nthrt (problem 3.4.6)

Percentage Accurate: 53.9% → 86.0%
Time: 41.3s
Alternatives: 20
Speedup: 7.5×

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

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

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

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

\mathbf{else}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\


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

    1. Initial program 36.2%

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

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

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

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

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

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

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

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

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

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

    if -3.3e7 < n < 3.1e5

    1. Initial program 83.5%

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

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

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

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

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

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

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

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

    if 3.1e5 < n

    1. Initial program 30.3%

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

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

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

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

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

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

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

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

Alternative 2: 84.5% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq 5 \cdot 10^{-32}:\\ \;\;\;\;\frac{\log \left(\frac{\sqrt{e^{\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}} \cdot \left(1 + x\right)}{x}\right)}{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) 5e-32)
   (/
    (log
     (/
      (*
       (sqrt (exp (/ (- (pow (log1p x) 2.0) (pow (log x) 2.0)) n)))
       (+ 1.0 x))
      x))
    n)
   (- (exp (/ (log1p x) n)) (pow x (/ 1.0 n)))))
double code(double x, double n) {
	double tmp;
	if ((1.0 / n) <= 5e-32) {
		tmp = log(((sqrt(exp(((pow(log1p(x), 2.0) - pow(log(x), 2.0)) / n))) * (1.0 + x)) / 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) <= 5e-32) {
		tmp = Math.log(((Math.sqrt(Math.exp(((Math.pow(Math.log1p(x), 2.0) - Math.pow(Math.log(x), 2.0)) / n))) * (1.0 + x)) / 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) <= 5e-32:
		tmp = math.log(((math.sqrt(math.exp(((math.pow(math.log1p(x), 2.0) - math.pow(math.log(x), 2.0)) / n))) * (1.0 + x)) / 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) <= 5e-32)
		tmp = Float64(log(Float64(Float64(sqrt(exp(Float64(Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0)) / n))) * Float64(1.0 + x)) / 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], 5e-32], N[(N[Log[N[(N[(N[Sqrt[N[Exp[N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(1.0 + x), $MachinePrecision]), $MachinePrecision] / 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 5 \cdot 10^{-32}:\\
\;\;\;\;\frac{\log \left(\frac{\sqrt{e^{\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}} \cdot \left(1 + x\right)}{x}\right)}{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 2 regimes
  2. if (/.f64 #s(literal 1 binary64) n) < 5e-32

    1. Initial program 54.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\log \left(\frac{e^{\mathsf{log1p}\left(x\right) + 0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}}{\color{blue}{x}}\right)}{n} \]
    7. Applied egg-rr59.3%

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

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

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

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

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

        \[\leadsto \frac{\log \left(\frac{\color{blue}{\sqrt{e^{\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}}} \cdot e^{\mathsf{log1p}\left(x\right)}}{x}\right)}{n} \]
      6. log1p-define59.3%

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

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

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

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

    1. Initial program 57.0%

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

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

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

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

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

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

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

Alternative 3: 85.0% accurate, 0.3× speedup?

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

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

\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\

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


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

    1. Initial program 98.9%

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

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

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

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

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

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

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

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

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

    if -1.99999999999999991e-6 < (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) < 0.0

    1. Initial program 42.9%

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

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

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

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

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

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

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

    if 0.0 < (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n)))

    1. Initial program 59.6%

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

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

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

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

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

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

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

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

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

Alternative 4: 85.2% accurate, 0.7× speedup?

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

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

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

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


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

    1. Initial program 98.0%

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

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

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

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

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

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

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

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

    if -2e-8 < (/.f64 #s(literal 1 binary64) n) < 5e-32

    1. Initial program 32.9%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\log \color{blue}{\left(\frac{e^{\mathsf{log1p}\left(x\right) + 0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}}{e^{\log x}}\right)}}{n} \]
      4. add-exp-log58.6%

        \[\leadsto \frac{\log \left(\frac{e^{\mathsf{log1p}\left(x\right) + 0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}}{\color{blue}{x}}\right)}{n} \]
    7. Applied egg-rr58.6%

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

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

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

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

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

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

        \[\leadsto \frac{\log \left(\frac{\sqrt{e^{\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}} \cdot e^{\color{blue}{\log \left(1 + x\right)}}}{x}\right)}{n} \]
      7. rem-exp-log83.7%

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

      \[\leadsto \frac{\color{blue}{\log \left(\frac{\sqrt{e^{\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}} \cdot \left(1 + x\right)}{x}\right)}}{n} \]
    10. Taylor expanded in x around inf 83.4%

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

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

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

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

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

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

        \[\leadsto \frac{\log \left(1 + \left(\frac{1}{x} + \frac{\log x}{\color{blue}{x \cdot n}}\right)\right)}{n} \]
    12. Simplified83.4%

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

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

    1. Initial program 57.0%

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

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

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

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

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

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

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

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

Alternative 5: 82.1% accurate, 0.9× speedup?

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

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

\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-6}:\\
\;\;\;\;\frac{\log t\_0}{n}\\

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

\mathbf{else}:\\
\;\;\;\;\log \left({t\_0}^{\left(\frac{1}{n}\right)}\right)\\


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

    1. Initial program 98.6%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{e^{\frac{\log x}{n}}}{\color{blue}{x \cdot n}} \]
    5. Simplified99.9%

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

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

    1. Initial program 33.8%

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

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

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

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

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

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

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

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

    1. Initial program 90.8%

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

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

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

    1. Initial program 24.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 85.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq -8500000000 \lor \neg \left(n \leq 310000\right):\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{else}:\\ \;\;\;\;e^{\frac{x}{n}} - {x}^{\left(\frac{1}{n}\right)}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (or (<= n -8500000000.0) (not (<= n 310000.0)))
   (/ (log (/ (+ 1.0 x) x)) n)
   (- (exp (/ x n)) (pow x (/ 1.0 n)))))
double code(double x, double n) {
	double tmp;
	if ((n <= -8500000000.0) || !(n <= 310000.0)) {
		tmp = log(((1.0 + x) / x)) / n;
	} else {
		tmp = exp((x / n)) - pow(x, (1.0 / n));
	}
	return tmp;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    real(8) :: tmp
    if ((n <= (-8500000000.0d0)) .or. (.not. (n <= 310000.0d0))) then
        tmp = log(((1.0d0 + x) / x)) / n
    else
        tmp = exp((x / n)) - (x ** (1.0d0 / n))
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double tmp;
	if ((n <= -8500000000.0) || !(n <= 310000.0)) {
		tmp = Math.log(((1.0 + x) / x)) / n;
	} else {
		tmp = Math.exp((x / n)) - Math.pow(x, (1.0 / n));
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if (n <= -8500000000.0) or not (n <= 310000.0):
		tmp = math.log(((1.0 + x) / x)) / n
	else:
		tmp = math.exp((x / n)) - math.pow(x, (1.0 / n))
	return tmp
function code(x, n)
	tmp = 0.0
	if ((n <= -8500000000.0) || !(n <= 310000.0))
		tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n);
	else
		tmp = Float64(exp(Float64(x / n)) - (x ^ Float64(1.0 / n)));
	end
	return tmp
end
function tmp_2 = code(x, n)
	tmp = 0.0;
	if ((n <= -8500000000.0) || ~((n <= 310000.0)))
		tmp = log(((1.0 + x) / x)) / n;
	else
		tmp = exp((x / n)) - (x ^ (1.0 / n));
	end
	tmp_2 = tmp;
end
code[x_, n_] := If[Or[LessEqual[n, -8500000000.0], N[Not[LessEqual[n, 310000.0]], $MachinePrecision]], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / 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}\;n \leq -8500000000 \lor \neg \left(n \leq 310000\right):\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if n < -8.5e9 or 3.1e5 < n

    1. Initial program 32.8%

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

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

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

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

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

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

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

    if -8.5e9 < n < 3.1e5

    1. Initial program 83.4%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -8500000000 \lor \neg \left(n \leq 310000\right):\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{else}:\\ \;\;\;\;e^{\frac{x}{n}} - {x}^{\left(\frac{1}{n}\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 85.9% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;n \leq -10000000000:\\
\;\;\;\;\frac{\log \left(1 + \left(\frac{1}{x} + \frac{\log x}{n \cdot x}\right)\right)}{n}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\


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

    1. Initial program 35.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\log \left(\frac{e^{\mathsf{log1p}\left(x\right) + 0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}}{\color{blue}{x}}\right)}{n} \]
    7. Applied egg-rr61.3%

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

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

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

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

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

        \[\leadsto \frac{\log \left(\frac{\color{blue}{\sqrt{e^{\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}}} \cdot e^{\mathsf{log1p}\left(x\right)}}{x}\right)}{n} \]
      6. log1p-define61.3%

        \[\leadsto \frac{\log \left(\frac{\sqrt{e^{\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}} \cdot e^{\color{blue}{\log \left(1 + x\right)}}}{x}\right)}{n} \]
      7. rem-exp-log88.2%

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

      \[\leadsto \frac{\color{blue}{\log \left(\frac{\sqrt{e^{\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}} \cdot \left(1 + x\right)}{x}\right)}}{n} \]
    10. Taylor expanded in x around inf 87.7%

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

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

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

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

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

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

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

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

    if -1e10 < n < 3.1e5

    1. Initial program 83.4%

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

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

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

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

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

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

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

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

    if 3.1e5 < n

    1. Initial program 30.3%

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

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

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

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

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

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

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

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

Alternative 8: 82.1% accurate, 1.0× speedup?

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

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

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

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

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


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

    1. Initial program 98.6%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{e^{\frac{\log x}{n}}}{\color{blue}{x \cdot n}} \]
    5. Simplified99.9%

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

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

    1. Initial program 33.8%

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

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

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

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

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

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

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

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

    1. Initial program 90.8%

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

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

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

    1. Initial program 24.0%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Step-by-step derivation
      1. add-sqr-sqrt0.0%

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

        \[\leadsto \frac{e^{\color{blue}{\sqrt{\frac{\log x}{n} \cdot \frac{\log x}{n}}}}}{x \cdot n} \]
      3. sqr-neg80.6%

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

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

        \[\leadsto \frac{e^{\sqrt{\frac{-\log x}{n} \cdot \color{blue}{\frac{-\log x}{n}}}}}{x \cdot n} \]
      6. sqrt-unprod80.6%

        \[\leadsto \frac{e^{\color{blue}{\sqrt{\frac{-\log x}{n}} \cdot \sqrt{\frac{-\log x}{n}}}}}{x \cdot n} \]
      7. add-sqr-sqrt80.6%

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

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

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

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

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

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

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

Alternative 9: 82.1% accurate, 1.6× speedup?

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

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

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

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

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


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

    1. Initial program 98.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 33.8%

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

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

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

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

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

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

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

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

    1. Initial program 90.8%

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

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

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

    1. Initial program 24.0%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Step-by-step derivation
      1. add-sqr-sqrt0.0%

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

        \[\leadsto \frac{e^{\color{blue}{\sqrt{\frac{\log x}{n} \cdot \frac{\log x}{n}}}}}{x \cdot n} \]
      3. sqr-neg80.6%

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

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

        \[\leadsto \frac{e^{\sqrt{\frac{-\log x}{n} \cdot \color{blue}{\frac{-\log x}{n}}}}}{x \cdot n} \]
      6. sqrt-unprod80.6%

        \[\leadsto \frac{e^{\color{blue}{\sqrt{\frac{-\log x}{n}} \cdot \sqrt{\frac{-\log x}{n}}}}}{x \cdot n} \]
      7. add-sqr-sqrt80.6%

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

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

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

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

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

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

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

Alternative 10: 81.7% accurate, 1.6× speedup?

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

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

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

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

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


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

    1. Initial program 98.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 33.8%

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

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

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

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

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

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

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

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

    1. Initial program 90.8%

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

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

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

    1. Initial program 24.0%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-\mathsf{log1p}\left(\color{blue}{e^{\log x} - 1}\right)}{n} \]
      3. add-exp-log75.9%

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

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

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

Alternative 11: 81.6% accurate, 1.7× speedup?

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

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

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

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

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


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

    1. Initial program 98.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 33.8%

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

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

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

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

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

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

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

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

    1. Initial program 90.8%

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

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

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

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

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

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

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

    1. Initial program 24.0%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-\mathsf{log1p}\left(\color{blue}{e^{\log x} - 1}\right)}{n} \]
      3. add-exp-log75.9%

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

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

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

Alternative 12: 72.9% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -500:\\
\;\;\;\;\frac{\frac{x \cdot \frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x} + -0.5}{x} - x}{x \cdot x}}{n}\\

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}}}{n} \]
    7. Applied egg-rr71.3%

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

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

    1. Initial program 33.6%

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

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

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

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

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

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

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

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

    1. Initial program 90.8%

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

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

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

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

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

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

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

    1. Initial program 24.0%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-\mathsf{log1p}\left(\color{blue}{e^{\log x} - 1}\right)}{n} \]
      3. add-exp-log75.9%

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

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

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

Alternative 13: 59.4% accurate, 1.8× speedup?

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

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

\mathbf{elif}\;x \leq 9.8 \cdot 10^{-99}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{n \cdot x} - \frac{0.5}{n}}{x}}{x}\\

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

\mathbf{elif}\;x \leq 5.2 \cdot 10^{+73}:\\
\;\;\;\;\frac{\frac{1 + \frac{\frac{0.3333333333333333 - \frac{1}{x} \cdot 0.25}{x} - 0.5}{x}}{x}}{n}\\

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


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

    1. Initial program 45.3%

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

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

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

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

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

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

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

    if 1.84999999999999989e-140 < x < 9.8000000000000006e-99

    1. Initial program 59.6%

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

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

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

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

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

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

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

        \[\leadsto \frac{-\left(\color{blue}{\frac{-1 \cdot \left(0.3333333333333333 \cdot \frac{1}{n \cdot x} - 0.5 \cdot \frac{1}{n}\right)}{x}} - \frac{1}{n}\right)}{x} \]
      4. mul-1-neg73.2%

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

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

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

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

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

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

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

    if 9.8000000000000006e-99 < x < 0.900000000000000022

    1. Initial program 35.7%

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

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

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

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

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

    if 0.900000000000000022 < x < 5.2000000000000001e73

    1. Initial program 33.6%

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

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

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}}}{n} \]

    if 5.2000000000000001e73 < x

    1. Initial program 82.0%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.85 \cdot 10^{-140}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 9.8 \cdot 10^{-99}:\\ \;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{n \cdot x} - \frac{0.5}{n}}{x}}{x}\\ \mathbf{elif}\;x \leq 0.9:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{elif}\;x \leq 5.2 \cdot 10^{+73}:\\ \;\;\;\;\frac{\frac{1 + \frac{\frac{0.3333333333333333 - \frac{1}{x} \cdot 0.25}{x} - 0.5}{x}}{x}}{n}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 59.2% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{\log x}{-n}\\
\mathbf{if}\;x \leq 1.85 \cdot 10^{-140}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 1.45 \cdot 10^{-98}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{n \cdot x} - \frac{0.5}{n}}{x}}{x}\\

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

\mathbf{elif}\;x \leq 1.6 \cdot 10^{+75}:\\
\;\;\;\;\frac{\frac{1 + \frac{\frac{0.3333333333333333 - \frac{1}{x} \cdot 0.25}{x} - 0.5}{x}}{x}}{n}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < 1.84999999999999989e-140 or 1.45e-98 < x < 0.69999999999999996

    1. Initial program 41.5%

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

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

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

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

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

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

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

    if 1.84999999999999989e-140 < x < 1.45e-98

    1. Initial program 59.6%

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

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

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

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

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

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

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

        \[\leadsto \frac{-\left(\color{blue}{\frac{-1 \cdot \left(0.3333333333333333 \cdot \frac{1}{n \cdot x} - 0.5 \cdot \frac{1}{n}\right)}{x}} - \frac{1}{n}\right)}{x} \]
      4. mul-1-neg73.2%

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

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

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

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

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

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

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

    if 0.69999999999999996 < x < 1.59999999999999992e75

    1. Initial program 33.6%

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

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

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}}}{n} \]

    if 1.59999999999999992e75 < x

    1. Initial program 82.0%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.85 \cdot 10^{-140}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 1.45 \cdot 10^{-98}:\\ \;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{n \cdot x} - \frac{0.5}{n}}{x}}{x}\\ \mathbf{elif}\;x \leq 0.7:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 1.6 \cdot 10^{+75}:\\ \;\;\;\;\frac{\frac{1 + \frac{\frac{0.3333333333333333 - \frac{1}{x} \cdot 0.25}{x} - 0.5}{x}}{x}}{n}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 53.9% accurate, 7.5× speedup?

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}}}{n} \]
    7. Applied egg-rr70.5%

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

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

    1. Initial program 40.5%

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

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

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}}}{n} \]
    7. Taylor expanded in x around -inf 45.7%

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

        \[\leadsto \frac{\color{blue}{-\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}}}{n} \]
      2. distribute-neg-frac245.7%

        \[\leadsto \frac{\color{blue}{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{-x}}}{n} \]
      3. sub-neg45.7%

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{\frac{\left(-\frac{\color{blue}{0.3333333333333333}}{x}\right) + -1 \cdot -0.5}{x} + \left(-1\right)}{-x}}{n} \]
      11. distribute-neg-frac45.7%

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

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

        \[\leadsto \frac{\frac{\frac{\frac{-0.3333333333333333}{x} + \color{blue}{0.5}}{x} + \left(-1\right)}{-x}}{n} \]
      14. metadata-eval45.7%

        \[\leadsto \frac{\frac{\frac{\frac{-0.3333333333333333}{x} + 0.5}{x} + \color{blue}{-1}}{-x}}{n} \]
    9. Simplified45.7%

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

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

Alternative 16: 47.3% accurate, 11.7× speedup?

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

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

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

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

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

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

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

      \[\leadsto \frac{-1 \cdot \frac{\color{blue}{\mathsf{fma}\left(-1, \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x}, -1\right)}}{x}}{n} \]
  8. Applied egg-rr46.7%

    \[\leadsto \frac{-1 \cdot \frac{\color{blue}{\mathsf{fma}\left(-1, \frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x} + -0.5}{x}, -1\right)}}{x}}{n} \]
  9. Step-by-step derivation
    1. fma-undefine46.7%

      \[\leadsto \frac{-1 \cdot \frac{\color{blue}{-1 \cdot \frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x} + -0.5}{x} + -1}}{x}}{n} \]
    2. metadata-eval46.7%

      \[\leadsto \frac{-1 \cdot \frac{-1 \cdot \frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x} + -0.5}{x} + \color{blue}{-1 \cdot 1}}{x}}{n} \]
    3. distribute-lft-in46.7%

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

      \[\leadsto \frac{-1 \cdot \frac{-1 \cdot \color{blue}{\left(1 + \frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x} + -0.5}{x}\right)}}{x}}{n} \]
    5. distribute-lft-in46.7%

      \[\leadsto \frac{-1 \cdot \frac{\color{blue}{-1 \cdot 1 + -1 \cdot \frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x} + -0.5}{x}}}{x}}{n} \]
    6. metadata-eval46.7%

      \[\leadsto \frac{-1 \cdot \frac{\color{blue}{-1} + -1 \cdot \frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x} + -0.5}{x}}{x}}{n} \]
    7. associate-*r/46.7%

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

    \[\leadsto \frac{-1 \cdot \frac{\color{blue}{-1 + \frac{0.5 + \frac{0.3333333333333333 + \frac{-0.25}{x}}{x}}{x}}}{x}}{n} \]
  11. Final simplification46.7%

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

Alternative 17: 46.7% accurate, 15.1× speedup?

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

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

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

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

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

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

    \[\leadsto \frac{\color{blue}{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}}}{n} \]
  7. Taylor expanded in x around -inf 46.4%

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

      \[\leadsto \frac{\color{blue}{-\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}}}{n} \]
    2. distribute-neg-frac246.4%

      \[\leadsto \frac{\color{blue}{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{-x}}}{n} \]
    3. sub-neg46.4%

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

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

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

      \[\leadsto \frac{\frac{\frac{-1 \cdot \left(0.3333333333333333 \cdot \frac{1}{x} + \color{blue}{-0.5}\right)}{x} + \left(-1\right)}{-x}}{n} \]
    7. distribute-lft-in46.4%

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

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

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

      \[\leadsto \frac{\frac{\frac{\left(-\frac{\color{blue}{0.3333333333333333}}{x}\right) + -1 \cdot -0.5}{x} + \left(-1\right)}{-x}}{n} \]
    11. distribute-neg-frac46.4%

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

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

      \[\leadsto \frac{\frac{\frac{\frac{-0.3333333333333333}{x} + \color{blue}{0.5}}{x} + \left(-1\right)}{-x}}{n} \]
    14. metadata-eval46.4%

      \[\leadsto \frac{\frac{\frac{\frac{-0.3333333333333333}{x} + 0.5}{x} + \color{blue}{-1}}{-x}}{n} \]
  9. Simplified46.4%

    \[\leadsto \frac{\color{blue}{\frac{\frac{\frac{-0.3333333333333333}{x} + 0.5}{x} + -1}{-x}}}{n} \]
  10. Final simplification46.4%

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

Alternative 18: 41.1% accurate, 42.2× speedup?

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

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

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

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

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

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

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

Alternative 19: 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 54.9%

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

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

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

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

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

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

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

    \[\leadsto \frac{1}{n \cdot x} \]
  10. Add Preprocessing

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 54.9%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{1}{x}}{n}} \]
    2. div-inv38.6%

      \[\leadsto \color{blue}{\frac{1}{x} \cdot \frac{1}{n}} \]
    3. rem-exp-log38.0%

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

      \[\leadsto e^{\color{blue}{-\log x}} \cdot \frac{1}{n} \]
    5. add-sqr-sqrt12.3%

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

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

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

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

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

      \[\leadsto e^{{\log x}^{\color{blue}{1}}} \cdot \frac{1}{n} \]
    11. pow14.6%

      \[\leadsto e^{\color{blue}{\log x}} \cdot \frac{1}{n} \]
    12. add-exp-log4.6%

      \[\leadsto \color{blue}{x} \cdot \frac{1}{n} \]
  10. Applied egg-rr4.6%

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

      \[\leadsto \color{blue}{\frac{x \cdot 1}{n}} \]
    2. *-rgt-identity4.6%

      \[\leadsto \frac{\color{blue}{x}}{n} \]
  12. Simplified4.6%

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

Reproduce

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