2nthrt (problem 3.4.6)

Percentage Accurate: 54.1% → 98.2%
Time: 44.5s
Alternatives: 18
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 18 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: 98.2% accurate, 0.7× speedup?

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

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

\mathbf{elif}\;\frac{1}{n} \leq 10^{-9}:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\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) < 1.00000000000000006e-9

    1. Initial program 25.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\log \color{blue}{\left(\frac{1}{x} \cdot x + \frac{1}{x} \cdot 1\right)}}{n} \]
      11. lft-mult-inverse75.1%

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

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

        \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(\frac{1}{x}\right)}}{n} \]
    10. Simplified98.2%

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

    if 1.00000000000000006e-9 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 54.5%

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

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

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

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

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

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

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

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

Alternative 2: 94.5% 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}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 0.0001:\\ \;\;\;\;\frac{\mathsf{log1p}\left(\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 (* n x))
     (if (<= (/ 1.0 n) 0.0001)
       (/ (log1p (/ 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 / (n * x);
	} else if ((1.0 / n) <= 0.0001) {
		tmp = log1p((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;
}
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 / (n * x);
	} else if ((1.0 / n) <= 0.0001) {
		tmp = Math.log1p((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 / (n * x)
	elif (1.0 / n) <= 0.0001:
		tmp = math.log1p((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(n * x));
	elseif (Float64(1.0 / n) <= 0.0001)
		tmp = Float64(log1p(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
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[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 0.0001], N[(N[Log[1 + N[(1.0 / x), $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}{n \cdot x}\\

\mathbf{elif}\;\frac{1}{n} \leq 0.0001:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\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. add-exp-log73.9%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\log \color{blue}{\left(\frac{1}{x} \cdot x + \frac{1}{x} \cdot 1\right)}}{n} \]
      11. lft-mult-inverse74.8%

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

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

        \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(\frac{1}{x}\right)}}{n} \]
    10. Simplified97.7%

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(\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 simplification93.9%

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

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

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

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


\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.00000000000000006e-9

    1. Initial program 25.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\log \color{blue}{\left(\frac{1}{x} \cdot x + \frac{1}{x} \cdot 1\right)}}{n} \]
      11. lft-mult-inverse75.1%

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

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

        \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(\frac{1}{x}\right)}}{n} \]
    10. Simplified98.2%

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

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

    1. Initial program 73.5%

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

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

        \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\frac{1}{x}}{n}\right)\right)} \]
      2. associate-/l/74.5%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\frac{1}{n \cdot x}}\right)\right) \]
      3. associate-/r*74.5%

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

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

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

Alternative 4: 94.5% 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}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 0.0001:\\ \;\;\;\;\frac{\mathsf{log1p}\left(\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}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\frac{1}{n}}{x}\right)\right)\\ \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 (* n x))
     (if (<= (/ 1.0 n) 0.0001)
       (/ (log1p (/ 1.0 x)) n)
       (if (<= (/ 1.0 n) 5e+158)
         (- (+ 1.0 (/ x n)) t_0)
         (log1p (expm1 (/ (/ 1.0 n) x))))))))
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 / (n * x);
	} else if ((1.0 / n) <= 0.0001) {
		tmp = log1p((1.0 / x)) / n;
	} else if ((1.0 / n) <= 5e+158) {
		tmp = (1.0 + (x / n)) - t_0;
	} else {
		tmp = log1p(expm1(((1.0 / n) / x)));
	}
	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 / (n * x);
	} else if ((1.0 / n) <= 0.0001) {
		tmp = Math.log1p((1.0 / x)) / n;
	} else if ((1.0 / n) <= 5e+158) {
		tmp = (1.0 + (x / n)) - t_0;
	} else {
		tmp = Math.log1p(Math.expm1(((1.0 / n) / x)));
	}
	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 / (n * x)
	elif (1.0 / n) <= 0.0001:
		tmp = math.log1p((1.0 / x)) / n
	elif (1.0 / n) <= 5e+158:
		tmp = (1.0 + (x / n)) - t_0
	else:
		tmp = math.log1p(math.expm1(((1.0 / n) / x)))
	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(n * x));
	elseif (Float64(1.0 / n) <= 0.0001)
		tmp = Float64(log1p(Float64(1.0 / x)) / n);
	elseif (Float64(1.0 / n) <= 5e+158)
		tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0);
	else
		tmp = log1p(expm1(Float64(Float64(1.0 / n) / x)));
	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[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 0.0001], N[(N[Log[1 + N[(1.0 / x), $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[Log[1 + N[(Exp[N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]] - 1), $MachinePrecision]], $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}{n \cdot x}\\

\mathbf{elif}\;\frac{1}{n} \leq 0.0001:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\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}:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\frac{1}{n}}{x}\right)\right)\\


\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. add-exp-log73.9%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\log \color{blue}{\left(\frac{1}{x} \cdot x + \frac{1}{x} \cdot 1\right)}}{n} \]
      11. lft-mult-inverse74.8%

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

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

        \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(\frac{1}{x}\right)}}{n} \]
    10. Simplified97.7%

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(\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 inf 70.7%

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

        \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\frac{1}{x}}{n}\right)\right)} \]
      2. associate-/l/85.1%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\frac{1}{n \cdot x}}\right)\right) \]
      3. associate-/r*85.1%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -1.05 \cdot 10^{-11}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 0.0001:\\ \;\;\;\;\frac{\mathsf{log1p}\left(\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}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\frac{1}{n}}{x}\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 93.9% 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}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 0.0001:\\ \;\;\;\;\frac{\mathsf{log1p}\left(\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{\frac{1}{\frac{x}{\frac{\frac{0.3333333333333333}{x} + -0.5}{x} + -1}}}{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 (* n x))
     (if (<= (/ 1.0 n) 0.0001)
       (/ (log1p (/ 1.0 x)) n)
       (if (<= (/ 1.0 n) 5e+158)
         (- (+ 1.0 (/ x n)) t_0)
         (/
          (/ 1.0 (/ x (+ (/ (+ (/ 0.3333333333333333 x) -0.5) 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 / (n * x);
	} else if ((1.0 / n) <= 0.0001) {
		tmp = log1p((1.0 / x)) / n;
	} else if ((1.0 / n) <= 5e+158) {
		tmp = (1.0 + (x / n)) - t_0;
	} else {
		tmp = (1.0 / (x / ((((0.3333333333333333 / x) + -0.5) / 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 / (n * x);
	} else if ((1.0 / n) <= 0.0001) {
		tmp = Math.log1p((1.0 / x)) / n;
	} else if ((1.0 / n) <= 5e+158) {
		tmp = (1.0 + (x / n)) - t_0;
	} else {
		tmp = (1.0 / (x / ((((0.3333333333333333 / x) + -0.5) / 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 / (n * x)
	elif (1.0 / n) <= 0.0001:
		tmp = math.log1p((1.0 / x)) / n
	elif (1.0 / n) <= 5e+158:
		tmp = (1.0 + (x / n)) - t_0
	else:
		tmp = (1.0 / (x / ((((0.3333333333333333 / x) + -0.5) / 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(n * x));
	elseif (Float64(1.0 / n) <= 0.0001)
		tmp = Float64(log1p(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(Float64(1.0 / Float64(x / Float64(Float64(Float64(Float64(0.3333333333333333 / x) + -0.5) / x) + -1.0))) / 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[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 0.0001], N[(N[Log[1 + N[(1.0 / x), $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[(1.0 / N[(x / N[(N[(N[(N[(0.3333333333333333 / x), $MachinePrecision] + -0.5), $MachinePrecision] / x), $MachinePrecision] + -1.0), $MachinePrecision]), $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}{n \cdot x}\\

\mathbf{elif}\;\frac{1}{n} \leq 0.0001:\\
\;\;\;\;\frac{\mathsf{log1p}\left(\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{\frac{1}{\frac{x}{\frac{\frac{0.3333333333333333}{x} + -0.5}{x} + -1}}}{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. add-exp-log73.9%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\log \color{blue}{\left(\frac{1}{x} \cdot x + \frac{1}{x} \cdot 1\right)}}{n} \]
      11. lft-mult-inverse74.8%

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

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

        \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(\frac{1}{x}\right)}}{n} \]
    10. Simplified97.7%

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(\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 -inf 77.9%

      \[\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-sqrt77.9%

        \[\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-unprod77.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-neg77.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-neg77.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-neg77.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-sqrt0.1%

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

        \[\leadsto \frac{\color{blue}{\frac{1}{\frac{x}{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}}}}{n} \]
      9. sub-neg0.1%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -1.05 \cdot 10^{-11}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 0.0001:\\ \;\;\;\;\frac{\mathsf{log1p}\left(\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{\frac{1}{\frac{x}{\frac{\frac{0.3333333333333333}{x} + -0.5}{x} + -1}}}{n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 93.7% 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}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 0.0001:\\ \;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{+156}:\\ \;\;\;\;1 - t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{\frac{x}{\frac{\frac{0.3333333333333333}{x} + -0.5}{x} + -1}}}{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 (* n x))
     (if (<= (/ 1.0 n) 0.0001)
       (/ (log1p (/ 1.0 x)) n)
       (if (<= (/ 1.0 n) 1e+156)
         (- 1.0 t_0)
         (/
          (/ 1.0 (/ x (+ (/ (+ (/ 0.3333333333333333 x) -0.5) 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 / (n * x);
	} else if ((1.0 / n) <= 0.0001) {
		tmp = log1p((1.0 / x)) / n;
	} else if ((1.0 / n) <= 1e+156) {
		tmp = 1.0 - t_0;
	} else {
		tmp = (1.0 / (x / ((((0.3333333333333333 / x) + -0.5) / 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 / (n * x);
	} else if ((1.0 / n) <= 0.0001) {
		tmp = Math.log1p((1.0 / x)) / n;
	} else if ((1.0 / n) <= 1e+156) {
		tmp = 1.0 - t_0;
	} else {
		tmp = (1.0 / (x / ((((0.3333333333333333 / x) + -0.5) / 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 / (n * x)
	elif (1.0 / n) <= 0.0001:
		tmp = math.log1p((1.0 / x)) / n
	elif (1.0 / n) <= 1e+156:
		tmp = 1.0 - t_0
	else:
		tmp = (1.0 / (x / ((((0.3333333333333333 / x) + -0.5) / 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(n * x));
	elseif (Float64(1.0 / n) <= 0.0001)
		tmp = Float64(log1p(Float64(1.0 / x)) / n);
	elseif (Float64(1.0 / n) <= 1e+156)
		tmp = Float64(1.0 - t_0);
	else
		tmp = Float64(Float64(1.0 / Float64(x / Float64(Float64(Float64(Float64(0.3333333333333333 / x) + -0.5) / x) + -1.0))) / 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[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 0.0001], N[(N[Log[1 + N[(1.0 / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+156], N[(1.0 - t$95$0), $MachinePrecision], N[(N[(1.0 / N[(x / N[(N[(N[(N[(0.3333333333333333 / x), $MachinePrecision] + -0.5), $MachinePrecision] / x), $MachinePrecision] + -1.0), $MachinePrecision]), $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}{n \cdot x}\\

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

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{\frac{x}{\frac{\frac{0.3333333333333333}{x} + -0.5}{x} + -1}}}{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. add-exp-log73.9%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\log \color{blue}{\left(\frac{1}{x} \cdot x + \frac{1}{x} \cdot 1\right)}}{n} \]
      11. lft-mult-inverse74.8%

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

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

        \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(\frac{1}{x}\right)}}{n} \]
    10. Simplified97.7%

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

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

    1. Initial program 71.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 71.7%

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

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

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

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

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

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

    1. Initial program 19.9%

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

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

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

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

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

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

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

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

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

        \[\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-sqrt0.1%

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

        \[\leadsto \frac{\color{blue}{\frac{1}{\frac{x}{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}}}}{n} \]
      9. sub-neg0.1%

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

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

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

Alternative 7: 83.1% accurate, 1.7× speedup?

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

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

\mathbf{elif}\;n \leq -3.7 \cdot 10^{-116}:\\
\;\;\;\;\frac{0}{n}\\

\mathbf{elif}\;n \leq 9.6 \cdot 10^{-167}:\\
\;\;\;\;\frac{\frac{x \cdot \frac{\frac{0.3333333333333333}{x} + -0.5}{x} - x}{x \cdot x}}{n}\\

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

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if n < -0.0037000000000000002 or 19000 < n

    1. Initial program 25.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\log \color{blue}{\left(\frac{1}{x} \cdot x + \frac{1}{x} \cdot 1\right)}}{n} \]
      11. lft-mult-inverse72.8%

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

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

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

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

    if -0.0037000000000000002 < n < -3.7000000000000002e-116

    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. Taylor expanded in x around inf 78.6%

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

    if -3.7000000000000002e-116 < n < 9.59999999999999972e-167

    1. Initial program 81.9%

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

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

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

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

      \[\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-sqrt50.9%

        \[\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-unprod66.8%

        \[\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-neg66.8%

        \[\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-neg66.8%

        \[\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-neg66.8%

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

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

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

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

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

        \[\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-rr66.8%

      \[\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 9.59999999999999972e-167 < n < 19000

    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.5%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -0.0037:\\ \;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\ \mathbf{elif}\;n \leq -3.7 \cdot 10^{-116}:\\ \;\;\;\;\frac{0}{n}\\ \mathbf{elif}\;n \leq 9.6 \cdot 10^{-167}:\\ \;\;\;\;\frac{\frac{x \cdot \frac{\frac{0.3333333333333333}{x} + -0.5}{x} - x}{x \cdot x}}{n}\\ \mathbf{elif}\;n \leq 19000:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 78.2% accurate, 1.8× speedup?

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

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

\mathbf{elif}\;n \leq -3.7 \cdot 10^{-116}:\\
\;\;\;\;\frac{0}{n}\\

\mathbf{elif}\;n \leq 9 \cdot 10^{-109}:\\
\;\;\;\;\frac{\frac{x \cdot \frac{\frac{0.3333333333333333}{x} + -0.5}{x} - x}{x \cdot x}}{n}\\

\mathbf{else}:\\
\;\;\;\;t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if n < -0.0037000000000000002 or 9.0000000000000002e-109 < n

    1. Initial program 32.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 64.2%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\log \left(\frac{x + 1}{\color{blue}{x}}\right)}{n} \]
      8. *-lft-identity64.5%

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

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

        \[\leadsto \frac{\log \color{blue}{\left(\frac{1}{x} \cdot x + \frac{1}{x} \cdot 1\right)}}{n} \]
      11. lft-mult-inverse64.5%

        \[\leadsto \frac{\log \left(\color{blue}{1} + \frac{1}{x} \cdot 1\right)}{n} \]
      12. *-rgt-identity64.5%

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

        \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(\frac{1}{x}\right)}}{n} \]
    10. Simplified84.8%

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

    if -0.0037000000000000002 < n < -3.7000000000000002e-116

    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. Taylor expanded in x around inf 78.6%

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

    if -3.7000000000000002e-116 < n < 9.0000000000000002e-109

    1. Initial program 78.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 37.6%

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

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

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

      \[\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-sqrt47.8%

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

        \[\leadsto \frac{\color{blue}{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}}}{n} \]
      8. div-sub1.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-2neg1.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-eval1.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-sub14.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -0.0037:\\ \;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\ \mathbf{elif}\;n \leq -3.7 \cdot 10^{-116}:\\ \;\;\;\;\frac{0}{n}\\ \mathbf{elif}\;n \leq 9 \cdot 10^{-109}:\\ \;\;\;\;\frac{\frac{x \cdot \frac{\frac{0.3333333333333333}{x} + -0.5}{x} - x}{x \cdot x}}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{log1p}\left(\frac{1}{x}\right)}{n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 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 1.7 \cdot 10^{+165}:\\ \;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{n \cdot x} + \frac{-0.5}{n}}{x}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x \cdot \frac{\frac{0.3333333333333333}{x} + -0.5}{x} - x}{x \cdot x}}{n}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= x 0.58)
   (/ (- (log x)) n)
   (if (<= x 1.7e+165)
     (/ (+ (/ 1.0 n) (/ (+ (/ 0.3333333333333333 (* n x)) (/ -0.5 n)) x)) x)
     (/ (/ (- (* x (/ (+ (/ 0.3333333333333333 x) -0.5) x)) x) (* x x)) n))))
double code(double x, double n) {
	double tmp;
	if (x <= 0.58) {
		tmp = -log(x) / n;
	} else if (x <= 1.7e+165) {
		tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x;
	} else {
		tmp = (((x * (((0.3333333333333333 / x) + -0.5) / 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 <= 1.7d+165) then
        tmp = ((1.0d0 / n) + (((0.3333333333333333d0 / (n * x)) + ((-0.5d0) / n)) / x)) / x
    else
        tmp = (((x * (((0.3333333333333333d0 / x) + (-0.5d0)) / 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 <= 1.7e+165) {
		tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x;
	} else {
		tmp = (((x * (((0.3333333333333333 / x) + -0.5) / x)) - x) / (x * x)) / n;
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if x <= 0.58:
		tmp = -math.log(x) / n
	elif x <= 1.7e+165:
		tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x
	else:
		tmp = (((x * (((0.3333333333333333 / x) + -0.5) / x)) - x) / (x * x)) / n
	return tmp
function code(x, n)
	tmp = 0.0
	if (x <= 0.58)
		tmp = Float64(Float64(-log(x)) / n);
	elseif (x <= 1.7e+165)
		tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(n * x)) + Float64(-0.5 / n)) / x)) / x);
	else
		tmp = Float64(Float64(Float64(Float64(x * Float64(Float64(Float64(0.3333333333333333 / x) + -0.5) / 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 <= 1.7e+165)
		tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x;
	else
		tmp = (((x * (((0.3333333333333333 / x) + -0.5) / 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, 1.7e+165], N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(0.3333333333333333 / N[(n * x), $MachinePrecision]), $MachinePrecision] + N[(-0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], N[(N[(N[(N[(x * N[(N[(N[(0.3333333333333333 / x), $MachinePrecision] + -0.5), $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 1.7 \cdot 10^{+165}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{n \cdot x} + \frac{-0.5}{n}}{x}}{x}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{x \cdot \frac{\frac{0.3333333333333333}{x} + -0.5}{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 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 51.3%

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

        \[\leadsto \color{blue}{\frac{-1 \cdot \log x}{n}} \]
      2. neg-mul-151.3%

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

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

    if 0.57999999999999996 < x < 1.70000000000000005e165

    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. Step-by-step derivation
      1. add-exp-log46.4%

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

      \[\leadsto \frac{\color{blue}{e^{\log \left(\mathsf{log1p}\left(x\right) - \log x\right)}}}{n} \]
    8. 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}} \]
    9. Step-by-step derivation
      1. associate-*r/59.2%

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

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

    if 1.70000000000000005e165 < 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 1.7 \cdot 10^{+165}:\\ \;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{n \cdot x} + \frac{-0.5}{n}}{x}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{x \cdot \frac{\frac{0.3333333333333333}{x} + -0.5}{x} - x}{x \cdot x}}{n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 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{\frac{0.3333333333333333}{x} + -0.5}{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}{n \cdot x} + \frac{-0.5}{n}}{x}}{x}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= (/ 1.0 n) -2e+118)
   (/ (/ (- (* x (/ (+ (/ 0.3333333333333333 x) -0.5) x)) x) (* x x)) n)
   (if (<= (/ 1.0 n) -1000000.0)
     (/ 0.0 n)
     (/ (+ (/ 1.0 n) (/ (+ (/ 0.3333333333333333 (* n x)) (/ -0.5 n)) x)) x))))
double code(double x, double n) {
	double tmp;
	if ((1.0 / n) <= -2e+118) {
		tmp = (((x * (((0.3333333333333333 / x) + -0.5) / x)) - x) / (x * x)) / n;
	} else if ((1.0 / n) <= -1000000.0) {
		tmp = 0.0 / n;
	} else {
		tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x;
	}
	return tmp;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    real(8) :: tmp
    if ((1.0d0 / n) <= (-2d+118)) then
        tmp = (((x * (((0.3333333333333333d0 / x) + (-0.5d0)) / x)) - x) / (x * x)) / n
    else if ((1.0d0 / n) <= (-1000000.0d0)) then
        tmp = 0.0d0 / n
    else
        tmp = ((1.0d0 / n) + (((0.3333333333333333d0 / (n * x)) + ((-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.3333333333333333 / x) + -0.5) / x)) - x) / (x * x)) / n;
	} else if ((1.0 / n) <= -1000000.0) {
		tmp = 0.0 / n;
	} else {
		tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x;
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if (1.0 / n) <= -2e+118:
		tmp = (((x * (((0.3333333333333333 / x) + -0.5) / x)) - x) / (x * x)) / n
	elif (1.0 / n) <= -1000000.0:
		tmp = 0.0 / n
	else:
		tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-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(Float64(0.3333333333333333 / x) + -0.5) / 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(n * x)) + 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.3333333333333333 / x) + -0.5) / x)) - x) / (x * x)) / n;
	elseif ((1.0 / n) <= -1000000.0)
		tmp = 0.0 / n;
	else
		tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-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[(N[(0.3333333333333333 / x), $MachinePrecision] + -0.5), $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[(n * x), $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{\frac{0.3333333333333333}{x} + -0.5}{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}{n \cdot x} + \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. 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. Step-by-step derivation
      1. add-exp-log56.1%

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

      \[\leadsto \frac{\color{blue}{e^{\log \left(\mathsf{log1p}\left(x\right) - \log x\right)}}}{n} \]
    8. 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}} \]
    9. Step-by-step derivation
      1. associate-*r/43.7%

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

      \[\leadsto \color{blue}{\frac{\frac{\frac{0.3333333333333333}{x \cdot n} + \frac{-0.5}{n}}{x} + \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{\frac{0.3333333333333333}{x} + -0.5}{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}{n \cdot x} + \frac{-0.5}{n}}{x}}{x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 53.5% accurate, 8.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -1000000:\\ \;\;\;\;\frac{\frac{x \cdot \frac{\frac{0.3333333333333333}{x} + -0.5}{x} - x}{x \cdot x}}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{n \cdot x} + \frac{-0.5}{n}}{x}}{x}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= (/ 1.0 n) -1000000.0)
   (/ (/ (- (* x (/ (+ (/ 0.3333333333333333 x) -0.5) x)) x) (* x x)) n)
   (/ (+ (/ 1.0 n) (/ (+ (/ 0.3333333333333333 (* n x)) (/ -0.5 n)) x)) x)))
double code(double x, double n) {
	double tmp;
	if ((1.0 / n) <= -1000000.0) {
		tmp = (((x * (((0.3333333333333333 / x) + -0.5) / x)) - x) / (x * x)) / n;
	} else {
		tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x;
	}
	return tmp;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    real(8) :: tmp
    if ((1.0d0 / n) <= (-1000000.0d0)) then
        tmp = (((x * (((0.3333333333333333d0 / x) + (-0.5d0)) / x)) - x) / (x * x)) / n
    else
        tmp = ((1.0d0 / n) + (((0.3333333333333333d0 / (n * x)) + ((-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.3333333333333333 / x) + -0.5) / x)) - x) / (x * x)) / n;
	} else {
		tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-0.5 / n)) / x)) / x;
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if (1.0 / n) <= -1000000.0:
		tmp = (((x * (((0.3333333333333333 / x) + -0.5) / x)) - x) / (x * x)) / n
	else:
		tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-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(Float64(0.3333333333333333 / x) + -0.5) / x)) - x) / Float64(x * x)) / n);
	else
		tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(n * x)) + 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.3333333333333333 / x) + -0.5) / x)) - x) / (x * x)) / n;
	else
		tmp = ((1.0 / n) + (((0.3333333333333333 / (n * x)) + (-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[(N[(0.3333333333333333 / x), $MachinePrecision] + -0.5), $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[(n * x), $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{\frac{0.3333333333333333}{x} + -0.5}{x} - x}{x \cdot x}}{n}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{n \cdot x} + \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. Step-by-step derivation
      1. add-exp-log56.1%

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

      \[\leadsto \frac{\color{blue}{e^{\log \left(\mathsf{log1p}\left(x\right) - \log x\right)}}}{n} \]
    8. 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}} \]
    9. Step-by-step derivation
      1. associate-*r/43.7%

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

      \[\leadsto \color{blue}{\frac{\frac{\frac{0.3333333333333333}{x \cdot n} + \frac{-0.5}{n}}{x} + \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{\frac{0.3333333333333333}{x} + -0.5}{x} - x}{x \cdot x}}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{n \cdot x} + \frac{-0.5}{n}}{x}}{x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 47.1% accurate, 12.4× speedup?

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

\\
\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{n \cdot x} + \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. Step-by-step derivation
    1. add-exp-log56.8%

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

    \[\leadsto \frac{\color{blue}{e^{\log \left(\mathsf{log1p}\left(x\right) - \log x\right)}}}{n} \]
  8. 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}} \]
  9. Step-by-step derivation
    1. associate-*r/41.6%

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

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

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

Alternative 13: 47.1% accurate, 16.2× speedup?

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

\\
\frac{\frac{1 + \frac{\frac{0.3333333333333333}{x} + -0.5}{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-expm1-u48.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\color{blue}{\frac{1 + \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{x}}}{n} \]
  11. Final simplification41.6%

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

Alternative 14: 46.5% accurate, 16.2× speedup?

\[\begin{array}{l} \\ \frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{n \cdot x} \end{array} \]
(FPCore (x n)
 :precision binary64
 (/ (- 1.0 (/ (+ 0.5 (/ -0.3333333333333333 x)) x)) (* n x)))
double code(double x, double n) {
	return (1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / (n * x);
}
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)) / (n * x)
end function
public static double code(double x, double n) {
	return (1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / (n * x);
}
def code(x, n):
	return (1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / (n * x)
function code(x, n)
	return Float64(Float64(1.0 - Float64(Float64(0.5 + Float64(-0.3333333333333333 / x)) / x)) / Float64(n * x))
end
function tmp = code(x, n)
	tmp = (1.0 - ((0.5 + (-0.3333333333333333 / x)) / x)) / (n * x);
end
code[x_, n_] := N[(N[(1.0 - N[(N[(0.5 + N[(-0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1 - \frac{0.5 + \frac{-0.3333333333333333}{x}}{x}}{n \cdot 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 \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. Final simplification40.7%

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

Alternative 15: 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 35.8%

    \[\leadsto \frac{\color{blue}{\frac{1}{x}}}{n} \]
  7. Step-by-step derivation
    1. *-un-lft-identity35.8%

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

      \[\leadsto \color{blue}{\frac{\frac{1}{x}}{n} \cdot 1} \]
    3. associate-/l/34.9%

      \[\leadsto \color{blue}{\frac{1}{n \cdot x}} \cdot 1 \]
    4. associate-/r*35.8%

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

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

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

Alternative 16: 41.5% accurate, 42.2× speedup?

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

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

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

Alternative 17: 40.9% accurate, 42.2× speedup?

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

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

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

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

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

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

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

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

Alternative 18: 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 0 30.6%

    \[\leadsto \frac{\color{blue}{x - \log x}}{n} \]
  7. Taylor expanded in x around inf 4.6%

    \[\leadsto \color{blue}{\frac{x}{n}} \]
  8. 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))))