2nthrt (problem 3.4.6)

Percentage Accurate: 54.1% → 86.1%
Time: 48.1s
Alternatives: 19
Speedup: 1.9×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 19 alternatives:

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

Initial Program: 54.1% 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.1% accurate, 0.2× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{x \cdot n}\\


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

    1. Initial program 41.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 78.3%

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

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

    if 3 < x

    1. Initial program 65.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 96.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-neg96.8%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification86.3%

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

Alternative 2: 85.6% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 0.68:\\ \;\;\;\;\frac{\frac{-0.16666666666666666 \cdot \frac{{\log x}^{3}}{n} + {\log x}^{2} \cdot -0.5}{n} - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{e^{\frac{\log x}{n}}}{x \cdot n}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= x 0.68)
   (/
    (-
     (/
      (+
       (* -0.16666666666666666 (/ (pow (log x) 3.0) n))
       (* (pow (log x) 2.0) -0.5))
      n)
     (log x))
    n)
   (/ (exp (/ (log x) n)) (* x n))))
double code(double x, double n) {
	double tmp;
	if (x <= 0.68) {
		tmp = ((((-0.16666666666666666 * (pow(log(x), 3.0) / n)) + (pow(log(x), 2.0) * -0.5)) / n) - log(x)) / n;
	} else {
		tmp = exp((log(x) / n)) / (x * n);
	}
	return tmp;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    real(8) :: tmp
    if (x <= 0.68d0) then
        tmp = (((((-0.16666666666666666d0) * ((log(x) ** 3.0d0) / n)) + ((log(x) ** 2.0d0) * (-0.5d0))) / n) - log(x)) / n
    else
        tmp = exp((log(x) / n)) / (x * n)
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double tmp;
	if (x <= 0.68) {
		tmp = ((((-0.16666666666666666 * (Math.pow(Math.log(x), 3.0) / n)) + (Math.pow(Math.log(x), 2.0) * -0.5)) / n) - Math.log(x)) / n;
	} else {
		tmp = Math.exp((Math.log(x) / n)) / (x * n);
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if x <= 0.68:
		tmp = ((((-0.16666666666666666 * (math.pow(math.log(x), 3.0) / n)) + (math.pow(math.log(x), 2.0) * -0.5)) / n) - math.log(x)) / n
	else:
		tmp = math.exp((math.log(x) / n)) / (x * n)
	return tmp
function code(x, n)
	tmp = 0.0
	if (x <= 0.68)
		tmp = Float64(Float64(Float64(Float64(Float64(-0.16666666666666666 * Float64((log(x) ^ 3.0) / n)) + Float64((log(x) ^ 2.0) * -0.5)) / n) - log(x)) / n);
	else
		tmp = Float64(exp(Float64(log(x) / n)) / Float64(x * n));
	end
	return tmp
end
function tmp_2 = code(x, n)
	tmp = 0.0;
	if (x <= 0.68)
		tmp = ((((-0.16666666666666666 * ((log(x) ^ 3.0) / n)) + ((log(x) ^ 2.0) * -0.5)) / n) - log(x)) / n;
	else
		tmp = exp((log(x) / n)) / (x * n);
	end
	tmp_2 = tmp;
end
code[x_, n_] := If[LessEqual[x, 0.68], N[(N[(N[(N[(N[(-0.16666666666666666 * N[(N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] + N[(N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.68:\\
\;\;\;\;\frac{\frac{-0.16666666666666666 \cdot \frac{{\log x}^{3}}{n} + {\log x}^{2} \cdot -0.5}{n} - \log x}{n}\\

\mathbf{else}:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{x \cdot n}\\


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

    1. Initial program 41.8%

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot \frac{-0.16666666666666666 \cdot \frac{{\log x}^{3}}{n} - 0.5 \cdot {\log x}^{2}}{n} - -1 \cdot \log x}{n}} \]
    7. Step-by-step derivation
      1. mul-1-neg77.1%

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

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

    if 0.680000000000000049 < x

    1. Initial program 64.4%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 0.68:\\ \;\;\;\;\frac{\frac{-0.16666666666666666 \cdot \frac{{\log x}^{3}}{n} + {\log x}^{2} \cdot -0.5}{n} - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{e^{\frac{\log x}{n}}}{x \cdot n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 85.7% accurate, 0.7× speedup?

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

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

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


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

    1. Initial program 96.2%

      \[{\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 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.0499999999999999e-11 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999997e-12

    1. Initial program 25.5%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\log \left(\frac{x + 1}{x}\right)}}{n} \]
    10. Taylor expanded in x around inf 75.8%

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

    if 4.9999999999999997e-12 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 53.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 0 53.7%

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

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

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

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

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

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

Alternative 4: 81.9% accurate, 0.9× speedup?

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

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

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


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

    1. Initial program 96.2%

      \[{\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 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.0499999999999999e-11 < (/.f64 #s(literal 1 binary64) n) < 1.00000000000000005e-4

    1. Initial program 25.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 74.5%

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\log \left(\frac{x + 1}{x}\right)}}{n} \]
    10. Taylor expanded in x around inf 74.8%

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

    if 1.00000000000000005e-4 < (/.f64 #s(literal 1 binary64) n)

    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 x around 0 72.6%

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

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

Alternative 5: 81.7% accurate, 0.9× speedup?

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

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

\mathbf{elif}\;\frac{1}{n} \leq 10^{+129}:\\
\;\;\;\;{\left(x + 1\right)}^{\left(\frac{1}{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) < -1.0499999999999999e-11

    1. Initial program 96.2%

      \[{\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 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.0499999999999999e-11 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999997e-12

    1. Initial program 25.5%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\log \left(\frac{x + 1}{x}\right)}}{n} \]
    10. Taylor expanded in x around inf 75.8%

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

    if 4.9999999999999997e-12 < (/.f64 #s(literal 1 binary64) n) < 1e129

    1. Initial program 70.9%

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

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

    1. Initial program 26.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 11.0%

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 81.5% accurate, 1.6× speedup?

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

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

\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+158}:\\
\;\;\;\;\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) < -1.0499999999999999e-11

    1. Initial program 96.2%

      \[{\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 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.0499999999999999e-11 < (/.f64 #s(literal 1 binary64) n) < 1.00000000000000005e-4

    1. Initial program 25.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 74.5%

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\log \left(\frac{x + 1}{x}\right)}}{n} \]
    10. Taylor expanded in x around inf 74.8%

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

    if 1.00000000000000005e-4 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999996e158

    1. Initial program 70.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 0 70.6%

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

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

    1. Initial program 15.1%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -1.05 \cdot 10^{-11}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{x \cdot n}\\ \mathbf{elif}\;\frac{1}{n} \leq 0.0001:\\ \;\;\;\;\frac{\log \left(1 + \frac{1}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+158}:\\ \;\;\;\;\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 7: 81.2% accurate, 1.7× speedup?

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

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

\mathbf{elif}\;\frac{1}{n} \leq 10^{+129}:\\
\;\;\;\;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) < -1.0499999999999999e-11

    1. Initial program 96.2%

      \[{\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 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.0499999999999999e-11 < (/.f64 #s(literal 1 binary64) n) < 1.00000000000000005e-4

    1. Initial program 25.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 74.5%

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\log \left(\frac{x + 1}{x}\right)}}{n} \]
    10. Taylor expanded in x around inf 74.8%

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

    if 1.00000000000000005e-4 < (/.f64 #s(literal 1 binary64) n) < 1e129

    1. Initial program 74.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 74.7%

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

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

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

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

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

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

    1. Initial program 26.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 11.0%

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 69.5% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{+174}:\\ \;\;\;\;\frac{\frac{x \cdot \frac{-0.5 + \frac{0.3333333333333333}{x}}{x} - x}{x \cdot x}}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 0.0001:\\ \;\;\;\;\frac{\log \left(1 + \frac{1}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{+129}:\\ \;\;\;\;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) -2e+174)
   (/ (/ (- (* x (/ (+ -0.5 (/ 0.3333333333333333 x)) x)) x) (* x x)) n)
   (if (<= (/ 1.0 n) 0.0001)
     (/ (log (+ 1.0 (/ 1.0 x))) n)
     (if (<= (/ 1.0 n) 1e+129)
       (- 1.0 (pow x (/ 1.0 n)))
       (/ (log1p (+ x -1.0)) (- n))))))
double code(double x, double n) {
	double tmp;
	if ((1.0 / n) <= -2e+174) {
		tmp = (((x * ((-0.5 + (0.3333333333333333 / x)) / x)) - x) / (x * x)) / n;
	} else if ((1.0 / n) <= 0.0001) {
		tmp = log((1.0 + (1.0 / x))) / n;
	} else if ((1.0 / n) <= 1e+129) {
		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) <= -2e+174) {
		tmp = (((x * ((-0.5 + (0.3333333333333333 / x)) / x)) - x) / (x * x)) / n;
	} else if ((1.0 / n) <= 0.0001) {
		tmp = Math.log((1.0 + (1.0 / x))) / n;
	} else if ((1.0 / n) <= 1e+129) {
		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) <= -2e+174:
		tmp = (((x * ((-0.5 + (0.3333333333333333 / x)) / x)) - x) / (x * x)) / n
	elif (1.0 / n) <= 0.0001:
		tmp = math.log((1.0 + (1.0 / x))) / n
	elif (1.0 / n) <= 1e+129:
		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) <= -2e+174)
		tmp = Float64(Float64(Float64(Float64(x * Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x)) - x) / Float64(x * x)) / n);
	elseif (Float64(1.0 / n) <= 0.0001)
		tmp = Float64(log(Float64(1.0 + Float64(1.0 / x))) / n);
	elseif (Float64(1.0 / n) <= 1e+129)
		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], -2e+174], N[(N[(N[(N[(x * N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 0.0001], N[(N[Log[N[(1.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+129], 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 -2 \cdot 10^{+174}:\\
\;\;\;\;\frac{\frac{x \cdot \frac{-0.5 + \frac{0.3333333333333333}{x}}{x} - x}{x \cdot x}}{n}\\

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

\mathbf{elif}\;\frac{1}{n} \leq 10^{+129}:\\
\;\;\;\;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) < -2.00000000000000014e174

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

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

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}}}{n} \]
    7. Step-by-step derivation
      1. add-sqr-sqrt44.7%

        \[\leadsto \frac{\color{blue}{\sqrt{-1 \cdot \frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}} \cdot \sqrt{-1 \cdot \frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}}}}{n} \]
      2. sqrt-unprod69.6%

        \[\leadsto \frac{\color{blue}{\sqrt{\left(-1 \cdot \frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}\right) \cdot \left(-1 \cdot \frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}\right)}}}{n} \]
      3. mul-1-neg69.6%

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

        \[\leadsto \frac{\sqrt{\left(-\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}\right) \cdot \color{blue}{\left(-\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}\right)}}}{n} \]
      5. sqr-neg69.6%

        \[\leadsto \frac{\sqrt{\color{blue}{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x} \cdot \frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}}}}{n} \]
      6. sqrt-unprod0.0%

        \[\leadsto \frac{\color{blue}{\sqrt{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}} \cdot \sqrt{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}}}}{n} \]
      7. add-sqr-sqrt1.3%

        \[\leadsto \frac{\color{blue}{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}}}{n} \]
      8. div-sub1.3%

        \[\leadsto \frac{\color{blue}{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}}{x} - \frac{1}{x}}}{n} \]
      9. frac-2neg1.3%

        \[\leadsto \frac{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}}{x} - \color{blue}{\frac{-1}{-x}}}{n} \]
      10. metadata-eval1.3%

        \[\leadsto \frac{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}}{x} - \frac{\color{blue}{-1}}{-x}}{n} \]
      11. frac-sub26.3%

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

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

    if -2.00000000000000014e174 < (/.f64 #s(literal 1 binary64) n) < 1.00000000000000005e-4

    1. Initial program 41.1%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\log \left(\frac{x + 1}{x}\right)}}{n} \]
    10. Taylor expanded in x around inf 70.7%

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

    if 1.00000000000000005e-4 < (/.f64 #s(literal 1 binary64) n) < 1e129

    1. Initial program 74.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 74.7%

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

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

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

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

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

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

    1. Initial program 26.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 11.0%

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 59.9% accurate, 1.8× speedup?

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

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

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

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

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


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

    1. Initial program 41.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 57.7%

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

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

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

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

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

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

    if 3.10000000000000007e-110 < x < 0.57999999999999996

    1. Initial program 42.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 42.6%

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

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

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

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

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

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

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

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

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

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

    if 0.57999999999999996 < x < 5.69999999999999997e162

    1. Initial program 48.4%

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    6. Taylor expanded in x around -inf 59.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. mul-1-neg59.2%

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

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

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

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

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

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

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

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

    if 5.69999999999999997e162 < x

    1. Initial program 83.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 83.3%

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

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

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{-1 \cdot \frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}} \cdot \sqrt{-1 \cdot \frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}}}}{n} \]
      2. sqrt-unprod83.3%

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

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

        \[\leadsto \frac{\sqrt{\left(-\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}\right) \cdot \color{blue}{\left(-\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}\right)}}}{n} \]
      5. sqr-neg83.3%

        \[\leadsto \frac{\sqrt{\color{blue}{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x} \cdot \frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}}}}{n} \]
      6. sqrt-unprod0.0%

        \[\leadsto \frac{\color{blue}{\sqrt{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}} \cdot \sqrt{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}}}}{n} \]
      7. add-sqr-sqrt47.3%

        \[\leadsto \frac{\color{blue}{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}}}{n} \]
      8. div-sub47.3%

        \[\leadsto \frac{\color{blue}{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}}{x} - \frac{1}{x}}}{n} \]
      9. frac-2neg47.3%

        \[\leadsto \frac{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}}{x} - \color{blue}{\frac{-1}{-x}}}{n} \]
      10. metadata-eval47.3%

        \[\leadsto \frac{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}}{x} - \frac{\color{blue}{-1}}{-x}}{n} \]
      11. frac-sub83.3%

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

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

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

Alternative 10: 60.7% accurate, 1.9× speedup?

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

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

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

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


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

    1. Initial program 41.8%

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

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

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

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

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

    if 0.859999999999999987 < x < 2.8999999999999999e160

    1. Initial program 48.4%

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    6. Taylor expanded in x around -inf 59.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. mul-1-neg59.2%

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

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

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

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

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

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

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

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

    if 2.8999999999999999e160 < x

    1. Initial program 83.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 83.3%

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

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

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{-1 \cdot \frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}} \cdot \sqrt{-1 \cdot \frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}}}}{n} \]
      2. sqrt-unprod83.3%

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

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

        \[\leadsto \frac{\sqrt{\left(-\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}\right) \cdot \color{blue}{\left(-\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}\right)}}}{n} \]
      5. sqr-neg83.3%

        \[\leadsto \frac{\sqrt{\color{blue}{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x} \cdot \frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}}}}{n} \]
      6. sqrt-unprod0.0%

        \[\leadsto \frac{\color{blue}{\sqrt{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}} \cdot \sqrt{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}}}}{n} \]
      7. add-sqr-sqrt47.3%

        \[\leadsto \frac{\color{blue}{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}}}{n} \]
      8. div-sub47.3%

        \[\leadsto \frac{\color{blue}{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}}{x} - \frac{1}{x}}}{n} \]
      9. frac-2neg47.3%

        \[\leadsto \frac{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}}{x} - \color{blue}{\frac{-1}{-x}}}{n} \]
      10. metadata-eval47.3%

        \[\leadsto \frac{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}}{x} - \frac{\color{blue}{-1}}{-x}}{n} \]
      11. frac-sub83.3%

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

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

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

Alternative 11: 60.4% accurate, 1.9× speedup?

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

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

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

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


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

    1. Initial program 41.8%

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

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

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

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

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

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

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

    if 0.57999999999999996 < x < 2.4999999999999998e161

    1. Initial program 48.4%

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    6. Taylor expanded in x around -inf 59.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. mul-1-neg59.2%

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

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

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

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

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

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

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

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

    if 2.4999999999999998e161 < x

    1. Initial program 83.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 83.3%

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

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

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

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

        \[\leadsto \frac{\color{blue}{\sqrt{-1 \cdot \frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}} \cdot \sqrt{-1 \cdot \frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}}}}{n} \]
      2. sqrt-unprod83.3%

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

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

        \[\leadsto \frac{\sqrt{\left(-\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}\right) \cdot \color{blue}{\left(-\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}\right)}}}{n} \]
      5. sqr-neg83.3%

        \[\leadsto \frac{\sqrt{\color{blue}{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x} \cdot \frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}}}}{n} \]
      6. sqrt-unprod0.0%

        \[\leadsto \frac{\color{blue}{\sqrt{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}} \cdot \sqrt{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}}}}{n} \]
      7. add-sqr-sqrt47.3%

        \[\leadsto \frac{\color{blue}{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}}}{n} \]
      8. div-sub47.3%

        \[\leadsto \frac{\color{blue}{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}}{x} - \frac{1}{x}}}{n} \]
      9. frac-2neg47.3%

        \[\leadsto \frac{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}}{x} - \color{blue}{\frac{-1}{-x}}}{n} \]
      10. metadata-eval47.3%

        \[\leadsto \frac{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}}{x} - \frac{\color{blue}{-1}}{-x}}{n} \]
      11. frac-sub83.3%

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

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

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

Alternative 12: 52.4% accurate, 6.8× speedup?

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

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

\mathbf{elif}\;\frac{1}{n} \leq -1000000:\\
\;\;\;\;\frac{0}{n}\\

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


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

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

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

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}}}{n} \]
    7. Step-by-step derivation
      1. add-sqr-sqrt43.6%

        \[\leadsto \frac{\color{blue}{\sqrt{-1 \cdot \frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}} \cdot \sqrt{-1 \cdot \frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}}}}{n} \]
      2. sqrt-unprod63.9%

        \[\leadsto \frac{\color{blue}{\sqrt{\left(-1 \cdot \frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}\right) \cdot \left(-1 \cdot \frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}\right)}}}{n} \]
      3. mul-1-neg63.9%

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

        \[\leadsto \frac{\sqrt{\left(-\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}\right) \cdot \color{blue}{\left(-\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}\right)}}}{n} \]
      5. sqr-neg63.9%

        \[\leadsto \frac{\sqrt{\color{blue}{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x} \cdot \frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}}}}{n} \]
      6. sqrt-unprod0.0%

        \[\leadsto \frac{\color{blue}{\sqrt{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}} \cdot \sqrt{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}}}}{n} \]
      7. add-sqr-sqrt1.3%

        \[\leadsto \frac{\color{blue}{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}}}{n} \]
      8. div-sub1.3%

        \[\leadsto \frac{\color{blue}{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}}{x} - \frac{1}{x}}}{n} \]
      9. frac-2neg1.3%

        \[\leadsto \frac{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}}{x} - \color{blue}{\frac{-1}{-x}}}{n} \]
      10. metadata-eval1.3%

        \[\leadsto \frac{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}}{x} - \frac{\color{blue}{-1}}{-x}}{n} \]
      11. frac-sub21.5%

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

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

    if -1.99999999999999993e118 < (/.f64 #s(literal 1 binary64) n) < -1e6

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\log \left(\frac{x + 1}{x}\right)}}{n} \]
    10. Taylor expanded in x around inf 78.6%

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

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

    1. Initial program 33.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 56.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 13: 53.5% accurate, 8.8× speedup?

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

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

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


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

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

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

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}}}{n} \]
    7. Step-by-step derivation
      1. add-sqr-sqrt36.3%

        \[\leadsto \frac{\color{blue}{\sqrt{-1 \cdot \frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}} \cdot \sqrt{-1 \cdot \frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}}}}{n} \]
      2. sqrt-unprod61.9%

        \[\leadsto \frac{\color{blue}{\sqrt{\left(-1 \cdot \frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}\right) \cdot \left(-1 \cdot \frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}\right)}}}{n} \]
      3. mul-1-neg61.9%

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

        \[\leadsto \frac{\sqrt{\left(-\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}\right) \cdot \color{blue}{\left(-\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}\right)}}}{n} \]
      5. sqr-neg61.9%

        \[\leadsto \frac{\sqrt{\color{blue}{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x} \cdot \frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}}}}{n} \]
      6. sqrt-unprod0.0%

        \[\leadsto \frac{\color{blue}{\sqrt{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}} \cdot \sqrt{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}}}}{n} \]
      7. add-sqr-sqrt2.0%

        \[\leadsto \frac{\color{blue}{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}}}{n} \]
      8. div-sub2.0%

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

        \[\leadsto \frac{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}}{x} - \color{blue}{\frac{-1}{-x}}}{n} \]
      10. metadata-eval2.0%

        \[\leadsto \frac{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x}}{x} - \frac{\color{blue}{-1}}{-x}}{n} \]
      11. frac-sub27.6%

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

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

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

    1. Initial program 33.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 56.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 14: 47.1% accurate, 12.4× speedup?

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

\\
\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} - \frac{0.5}{n}}{x}}{x}
\end{array}
Derivation
  1. Initial program 51.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 57.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 15: 47.1% accurate, 16.2× 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)) / 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 51.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 57.1%

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\color{blue}{-1 \cdot \frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}}}{n} \]
  11. Simplified41.6%

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

Alternative 16: 46.5% accurate, 16.2× speedup?

\[\begin{array}{l} \\ \frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{x \cdot 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(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[(1.0 - N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{x \cdot n}
\end{array}
Derivation
  1. Initial program 51.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 57.1%

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

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

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

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

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

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

Alternative 17: 41.5% accurate, 42.2× speedup?

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

\\
\frac{\frac{1}{n}}{x}
\end{array}
Derivation
  1. Initial program 51.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 57.1%

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

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

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

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

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

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

Alternative 18: 40.9% accurate, 42.2× speedup?

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

\\
\frac{1}{x \cdot n}
\end{array}
Derivation
  1. Initial program 51.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 57.1%

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

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

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

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

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

Alternative 19: 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 51.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 57.1%

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

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

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

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

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

      \[\leadsto {\color{blue}{\left(x \cdot n\right)}}^{-1} \]
    3. unpow-prod-down35.8%

      \[\leadsto \color{blue}{{x}^{-1} \cdot {n}^{-1}} \]
    4. inv-pow35.8%

      \[\leadsto \color{blue}{\frac{1}{x}} \cdot {n}^{-1} \]
    5. rem-exp-log35.1%

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

      \[\leadsto e^{\color{blue}{-\log x}} \cdot {n}^{-1} \]
    7. add-sqr-sqrt10.9%

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

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

      \[\leadsto e^{\sqrt{\color{blue}{\log x \cdot \log x}}} \cdot {n}^{-1} \]
    10. sqrt-unprod1.4%

      \[\leadsto e^{\color{blue}{\sqrt{\log x} \cdot \sqrt{\log x}}} \cdot {n}^{-1} \]
    11. add-sqr-sqrt4.6%

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

      \[\leadsto \color{blue}{x} \cdot {n}^{-1} \]
    13. inv-pow4.6%

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

    \[\leadsto \color{blue}{x \cdot \frac{1}{n}} \]
  9. 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} \]
  10. Simplified4.6%

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

Reproduce

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