2nthrt (problem 3.4.6)

Percentage Accurate: 53.4% → 86.4%
Time: 1.5min
Alternatives: 23
Speedup: 1.8×

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 23 alternatives:

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

Initial Program: 53.4% accurate, 1.0× speedup?

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

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

Alternative 1: 86.4% accurate, 0.4× speedup?

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq 2:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x}\\

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


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

    1. Initial program 95.1%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity99.9%

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

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

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

      \[\leadsto \color{blue}{1 \cdot \frac{{x}^{\left(\frac{1}{n}\right)}}{x \cdot n}} \]
    8. Step-by-step derivation
      1. *-lft-identity100.0%

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

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

    if -2e-16 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000001e-41

    1. Initial program 25.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.00000000000000001e-41 < (/.f64 #s(literal 1 binary64) n) < 2

    1. Initial program 5.7%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 98.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-neg98.0%

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

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

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

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

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

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

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

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

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

    1. Initial program 52.6%

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

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(x + 1\right)}^{\left(\frac{1}{n}\right)}\right)\right)} - {x}^{\left(\frac{1}{n}\right)} \]
      2. expm1-undefine52.6%

        \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left({\left(x + 1\right)}^{\left(\frac{1}{n}\right)}\right)} - 1\right)} - {x}^{\left(\frac{1}{n}\right)} \]
      3. pow-to-exp52.6%

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

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

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

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

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

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

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

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

Alternative 2: 86.4% accurate, 0.6× speedup?

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq 2:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x}\\

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


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

    1. Initial program 95.1%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity99.9%

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

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

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

      \[\leadsto \color{blue}{1 \cdot \frac{{x}^{\left(\frac{1}{n}\right)}}{x \cdot n}} \]
    8. Step-by-step derivation
      1. *-lft-identity100.0%

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

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

    if -2e-16 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000001e-41

    1. Initial program 25.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.00000000000000001e-41 < (/.f64 #s(literal 1 binary64) n) < 2

    1. Initial program 5.7%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 98.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-neg98.0%

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

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

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

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

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

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

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

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

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

    1. Initial program 52.6%

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

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

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

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

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

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

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

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

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

Alternative 3: 82.7% accurate, 0.9× speedup?

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

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

\mathbf{elif}\;\frac{1}{n} \leq 2:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{n \cdot x}\\

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


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

    1. Initial program 95.1%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity99.9%

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

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

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

      \[\leadsto \color{blue}{1 \cdot \frac{{x}^{\left(\frac{1}{n}\right)}}{x \cdot n}} \]
    8. Step-by-step derivation
      1. *-lft-identity100.0%

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

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

    if -2e-16 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000001e-41

    1. Initial program 25.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.00000000000000001e-41 < (/.f64 #s(literal 1 binary64) n) < 2

    1. Initial program 5.7%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 98.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-neg98.0%

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

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

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

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

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

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

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

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

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

    1. Initial program 52.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 75.1%

      \[\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)} \]
    4. Step-by-step derivation
      1. inv-pow75.1%

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

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

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

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

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

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

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

Alternative 4: 82.7% accurate, 1.4× speedup?

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

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

\mathbf{elif}\;\frac{1}{n} \leq 2:\\
\;\;\;\;t\_1\\

\mathbf{else}:\\
\;\;\;\;\left(1 + x \cdot \left(\frac{1}{n} + x \cdot \left(0.5 \cdot \left(\frac{1}{n} \cdot \frac{1}{n}\right) + 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) < -2e-16 or 2.00000000000000001e-41 < (/.f64 #s(literal 1 binary64) n) < 2

    1. Initial program 87.7%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity99.7%

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

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

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

      \[\leadsto \color{blue}{1 \cdot \frac{{x}^{\left(\frac{1}{n}\right)}}{x \cdot n}} \]
    8. Step-by-step derivation
      1. *-lft-identity99.8%

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

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

    if -2e-16 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000001e-41

    1. Initial program 25.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 52.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 75.1%

      \[\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)} \]
    4. Step-by-step derivation
      1. inv-pow75.1%

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

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

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

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

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

      \[\leadsto \left(1 + x \cdot \left(x \cdot \left(0.5 \cdot \color{blue}{\left(\frac{1}{n} \cdot \frac{1}{n}\right)} - 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 simplification88.7%

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

Alternative 5: 82.7% accurate, 1.5× speedup?

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq 2:\\
\;\;\;\;t\_1\\

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


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

    1. Initial program 87.7%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity99.7%

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

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

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

      \[\leadsto \color{blue}{1 \cdot \frac{{x}^{\left(\frac{1}{n}\right)}}{x \cdot n}} \]
    8. Step-by-step derivation
      1. *-lft-identity99.8%

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

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

    if -2e-16 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000001e-41

    1. Initial program 25.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    1. Initial program 52.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 75.1%

      \[\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)} \]
    4. Taylor expanded in n around inf 73.0%

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

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

Alternative 6: 81.9% accurate, 1.5× speedup?

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq 2:\\
\;\;\;\;t\_1\\

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

\mathbf{else}:\\
\;\;\;\;\frac{1}{x \cdot \frac{n}{1 + \frac{0.25}{{x}^{3}}}}\\


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

    1. Initial program 87.7%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity99.7%

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

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

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

      \[\leadsto \color{blue}{1 \cdot \frac{{x}^{\left(\frac{1}{n}\right)}}{x \cdot n}} \]
    8. Step-by-step derivation
      1. *-lft-identity99.8%

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

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

    if -2e-16 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000001e-41

    1. Initial program 25.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2 < (/.f64 #s(literal 1 binary64) n) < 9.99999999999999965e218

    1. Initial program 65.1%

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

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

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

    1. Initial program 15.2%

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

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

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

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

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

      \[\leadsto \color{blue}{{\left(\frac{n}{\frac{\frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x} + -0.5}{x} + 1}{x}}\right)}^{-1}} \]
    8. Step-by-step derivation
      1. unpow-188.6%

        \[\leadsto \color{blue}{\frac{1}{\frac{n}{\frac{\frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x} + -0.5}{x} + 1}{x}}}} \]
      2. associate-/r/88.6%

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

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

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

      \[\leadsto \color{blue}{\frac{1}{\frac{n}{1 + \frac{-0.5 + \frac{\frac{0.25}{x} + -0.3333333333333333}{x}}{x}} \cdot x}} \]
    10. Taylor expanded in x around 0 88.6%

      \[\leadsto \frac{1}{\frac{n}{1 + \color{blue}{\frac{0.25}{{x}^{3}}}} \cdot x} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification88.1%

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

Alternative 7: 81.9% accurate, 1.5× speedup?

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq 2:\\
\;\;\;\;t\_1\\

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

\mathbf{else}:\\
\;\;\;\;\frac{0.25}{n \cdot {x}^{4}}\\


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

    1. Initial program 87.7%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity99.7%

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

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

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

      \[\leadsto \color{blue}{1 \cdot \frac{{x}^{\left(\frac{1}{n}\right)}}{x \cdot n}} \]
    8. Step-by-step derivation
      1. *-lft-identity99.8%

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

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

    if -2e-16 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000001e-41

    1. Initial program 25.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2 < (/.f64 #s(literal 1 binary64) n) < 9.99999999999999965e218

    1. Initial program 65.1%

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

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

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

    1. Initial program 15.2%

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

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

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

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

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

      \[\leadsto \color{blue}{{\left(\frac{n}{\frac{\frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x} + -0.5}{x} + 1}{x}}\right)}^{-1}} \]
    8. Step-by-step derivation
      1. unpow-188.6%

        \[\leadsto \color{blue}{\frac{1}{\frac{n}{\frac{\frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x} + -0.5}{x} + 1}{x}}}} \]
      2. associate-/r/88.6%

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

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

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

      \[\leadsto \color{blue}{\frac{1}{\frac{n}{1 + \frac{-0.5 + \frac{\frac{0.25}{x} + -0.3333333333333333}{x}}{x}} \cdot x}} \]
    10. Taylor expanded in x around 0 88.6%

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

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

Alternative 8: 81.8% accurate, 1.6× speedup?

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq 2:\\
\;\;\;\;t\_1\\

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

\mathbf{else}:\\
\;\;\;\;\frac{0.25}{n \cdot {x}^{4}}\\


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

    1. Initial program 87.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2e-16 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000001e-41

    1. Initial program 25.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2 < (/.f64 #s(literal 1 binary64) n) < 9.99999999999999965e218

    1. Initial program 65.1%

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

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

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

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

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

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

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

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

    1. Initial program 15.2%

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

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

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

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

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

      \[\leadsto \color{blue}{{\left(\frac{n}{\frac{\frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x} + -0.5}{x} + 1}{x}}\right)}^{-1}} \]
    8. Step-by-step derivation
      1. unpow-188.6%

        \[\leadsto \color{blue}{\frac{1}{\frac{n}{\frac{\frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x} + -0.5}{x} + 1}{x}}}} \]
      2. associate-/r/88.6%

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

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

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

      \[\leadsto \color{blue}{\frac{1}{\frac{n}{1 + \frac{-0.5 + \frac{\frac{0.25}{x} + -0.3333333333333333}{x}}{x}} \cdot x}} \]
    10. Taylor expanded in x around 0 88.6%

      \[\leadsto \color{blue}{\frac{0.25}{n \cdot {x}^{4}}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification87.8%

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

Alternative 9: 81.8% accurate, 1.6× speedup?

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq 2:\\
\;\;\;\;t\_1\\

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

\mathbf{else}:\\
\;\;\;\;\frac{0.25}{n \cdot {x}^{4}}\\


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

    1. Initial program 87.7%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Step-by-step derivation
      1. *-un-lft-identity99.7%

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

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

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

      \[\leadsto \color{blue}{1 \cdot \frac{{x}^{\left(\frac{1}{n}\right)}}{x \cdot n}} \]
    8. Step-by-step derivation
      1. *-lft-identity99.8%

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

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

    if -2e-16 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000001e-41

    1. Initial program 25.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2 < (/.f64 #s(literal 1 binary64) n) < 9.99999999999999965e218

    1. Initial program 65.1%

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

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

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

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

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

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

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

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

    1. Initial program 15.2%

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

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

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

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

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

      \[\leadsto \color{blue}{{\left(\frac{n}{\frac{\frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x} + -0.5}{x} + 1}{x}}\right)}^{-1}} \]
    8. Step-by-step derivation
      1. unpow-188.6%

        \[\leadsto \color{blue}{\frac{1}{\frac{n}{\frac{\frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x} + -0.5}{x} + 1}{x}}}} \]
      2. associate-/r/88.6%

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

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

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

      \[\leadsto \color{blue}{\frac{1}{\frac{n}{1 + \frac{-0.5 + \frac{\frac{0.25}{x} + -0.3333333333333333}{x}}{x}} \cdot x}} \]
    10. Taylor expanded in x around 0 88.6%

      \[\leadsto \color{blue}{\frac{0.25}{n \cdot {x}^{4}}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification87.8%

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

Alternative 10: 75.4% accurate, 1.7× speedup?

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

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

\mathbf{elif}\;n \leq 1.06 \cdot 10^{-219}:\\
\;\;\;\;\frac{0.25}{n \cdot {x}^{4}}\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if n < -4e15 or 4.20000000000000022e49 < n

    1. Initial program 26.2%

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

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

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

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

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

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

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

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

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

    if -4e15 < n < 1.06e-219

    1. Initial program 87.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 48.3%

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

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

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

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

      \[\leadsto \color{blue}{{\left(\frac{n}{\frac{\frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x} + -0.5}{x} + 1}{x}}\right)}^{-1}} \]
    8. Step-by-step derivation
      1. unpow-144.2%

        \[\leadsto \color{blue}{\frac{1}{\frac{n}{\frac{\frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x} + -0.5}{x} + 1}{x}}}} \]
      2. associate-/r/44.2%

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

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

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

      \[\leadsto \color{blue}{\frac{1}{\frac{n}{1 + \frac{-0.5 + \frac{\frac{0.25}{x} + -0.3333333333333333}{x}}{x}} \cdot x}} \]
    10. Taylor expanded in x around 0 69.0%

      \[\leadsto \color{blue}{\frac{0.25}{n \cdot {x}^{4}}} \]

    if 1.06e-219 < n < 0.75

    1. Initial program 65.1%

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

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

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

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

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

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

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

    if 0.75 < n < 4.20000000000000022e49

    1. Initial program 5.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 16.0%

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

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

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

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

      \[\leadsto \color{blue}{{\left(\frac{n}{\frac{\frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x} + -0.5}{x} + 1}{x}}\right)}^{-1}} \]
    8. Step-by-step derivation
      1. unpow-172.5%

        \[\leadsto \color{blue}{\frac{1}{\frac{n}{\frac{\frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x} + -0.5}{x} + 1}{x}}}} \]
      2. associate-/r/72.6%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -4 \cdot 10^{+15}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{elif}\;n \leq 1.06 \cdot 10^{-219}:\\ \;\;\;\;\frac{0.25}{n \cdot {x}^{4}}\\ \mathbf{elif}\;n \leq 0.75:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;n \leq 4.2 \cdot 10^{+49}:\\ \;\;\;\;\frac{1}{x \cdot \left(n + 0.5 \cdot \frac{n}{x}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 75.5% accurate, 1.7× speedup?

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

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

\mathbf{elif}\;n \leq 1.06 \cdot 10^{-219}:\\
\;\;\;\;\frac{0.25}{n \cdot {x}^{4}}\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if n < -3.9e9

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.9e9 < n < 1.06e-219

    1. Initial program 89.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 49.4%

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

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

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

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

      \[\leadsto \color{blue}{{\left(\frac{n}{\frac{\frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x} + -0.5}{x} + 1}{x}}\right)}^{-1}} \]
    8. Step-by-step derivation
      1. unpow-143.5%

        \[\leadsto \color{blue}{\frac{1}{\frac{n}{\frac{\frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x} + -0.5}{x} + 1}{x}}}} \]
      2. associate-/r/43.5%

        \[\leadsto \frac{1}{\color{blue}{\frac{n}{\frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x} + -0.5}{x} + 1} \cdot x}} \]
      3. +-commutative43.5%

        \[\leadsto \frac{1}{\frac{n}{\color{blue}{1 + \frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x} + -0.5}{x}}} \cdot x} \]
      4. +-commutative43.5%

        \[\leadsto \frac{1}{\frac{n}{1 + \frac{\color{blue}{-0.5 + \frac{\frac{0.25}{x} + -0.3333333333333333}{x}}}{x}} \cdot x} \]
    9. Simplified43.5%

      \[\leadsto \color{blue}{\frac{1}{\frac{n}{1 + \frac{-0.5 + \frac{\frac{0.25}{x} + -0.3333333333333333}{x}}{x}} \cdot x}} \]
    10. Taylor expanded in x around 0 70.5%

      \[\leadsto \color{blue}{\frac{0.25}{n \cdot {x}^{4}}} \]

    if 1.06e-219 < n < 0.75

    1. Initial program 65.1%

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

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

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

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

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

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

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

    if 0.75 < n < 2.59999999999999998e53

    1. Initial program 5.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 16.0%

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

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

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

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

      \[\leadsto \color{blue}{{\left(\frac{n}{\frac{\frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x} + -0.5}{x} + 1}{x}}\right)}^{-1}} \]
    8. Step-by-step derivation
      1. unpow-172.5%

        \[\leadsto \color{blue}{\frac{1}{\frac{n}{\frac{\frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x} + -0.5}{x} + 1}{x}}}} \]
      2. associate-/r/72.6%

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

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

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

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

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

    if 2.59999999999999998e53 < n

    1. Initial program 28.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 90.2%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -3900000000:\\ \;\;\;\;\frac{\log \left(\frac{x}{1 + x}\right)}{-n}\\ \mathbf{elif}\;n \leq 1.06 \cdot 10^{-219}:\\ \;\;\;\;\frac{0.25}{n \cdot {x}^{4}}\\ \mathbf{elif}\;n \leq 0.75:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;n \leq 2.6 \cdot 10^{+53}:\\ \;\;\;\;\frac{1}{x \cdot \left(n + 0.5 \cdot \frac{n}{x}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 59.5% accurate, 1.7× speedup?

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

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

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

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

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

\mathbf{else}:\\
\;\;\;\;\frac{-0.25}{n \cdot {x}^{4}}\\


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

    1. Initial program 38.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 62.9%

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

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

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

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

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

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

    if 6.0000000000000002e-164 < x < 6.9000000000000001e-133

    1. Initial program 61.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 61.6%

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

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

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

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

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

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

    if 6.9000000000000001e-133 < x < 0.880000000000000004

    1. Initial program 30.2%

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

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

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

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

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

    if 0.880000000000000004 < x < 4.0000000000000003e172

    1. Initial program 56.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 59.0%

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

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

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

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

    if 4.0000000000000003e172 < x

    1. Initial program 86.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 86.9%

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

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

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

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

      \[\leadsto \color{blue}{\frac{-0.25}{n \cdot {x}^{4}}} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification64.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 6 \cdot 10^{-164}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 6.9 \cdot 10^{-133}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 0.88:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{elif}\;x \leq 4 \cdot 10^{+172}:\\ \;\;\;\;\frac{\frac{1 + \frac{\frac{0.3333333333333333 - 0.25 \cdot \frac{1}{x}}{x} - 0.5}{x}}{x}}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{-0.25}{n \cdot {x}^{4}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 56.4% accurate, 1.8× speedup?

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

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

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

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

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


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

    1. Initial program 39.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 60.0%

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

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

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

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

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

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

    if 1e-142 < x < 4.2000000000000002e-132

    1. Initial program 67.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 7.1%

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

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

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

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

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

        \[\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*83.9%

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

        \[\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/83.9%

        \[\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/83.9%

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

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

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

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

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

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

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

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

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

    if 4.2000000000000002e-132 < x < 0.900000000000000022

    1. Initial program 30.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 60.9%

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

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

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

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

    if 0.900000000000000022 < x

    1. Initial program 68.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 69.8%

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

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

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

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

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

Alternative 14: 55.7% accurate, 1.8× speedup?

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

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

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

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

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


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

    1. Initial program 38.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 62.9%

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

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

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

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

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

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

    if 6.6e-164 < x < 9.4999999999999992e-133

    1. Initial program 61.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 61.6%

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

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

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

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

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

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

    if 9.4999999999999992e-133 < x < 0.880000000000000004

    1. Initial program 30.2%

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

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

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

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

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

    if 0.880000000000000004 < x

    1. Initial program 68.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 69.8%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 6.6 \cdot 10^{-164}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 9.5 \cdot 10^{-133}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 0.88:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1 + \frac{\frac{0.3333333333333333 - 0.25 \cdot \frac{1}{x}}{x} - 0.5}{x}}{x}}{n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 56.1% accurate, 1.8× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 9.5999999999999995e-143 or 2.30000000000000003e-132 < x < 0.69999999999999996

    1. Initial program 35.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 60.4%

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

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

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

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

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

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

    if 9.5999999999999995e-143 < x < 2.30000000000000003e-132

    1. Initial program 67.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 7.1%

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

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

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

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

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

        \[\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*83.9%

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

        \[\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/83.9%

        \[\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/83.9%

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

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

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

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

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

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

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

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

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

    if 0.69999999999999996 < x

    1. Initial program 68.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 69.8%

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

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

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

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

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

Alternative 16: 46.0% accurate, 11.1× speedup?

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x} + -0.5}{x} + 1}{x} \cdot \frac{1}{n}} \]
  8. Final simplification40.2%

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

Alternative 17: 46.0% accurate, 11.1× speedup?

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

\\
\frac{\frac{1}{x}}{n} \cdot \left(1 + \frac{-0.5 + \frac{\frac{0.25}{x} + -0.3333333333333333}{x}}{x}\right)
\end{array}
Derivation
  1. Initial program 49.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 63.1%

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

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

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

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

    \[\leadsto \color{blue}{{\left(\frac{n}{\frac{\frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x} + -0.5}{x} + 1}{x}}\right)}^{-1}} \]
  8. Step-by-step derivation
    1. unpow-139.8%

      \[\leadsto \color{blue}{\frac{1}{\frac{n}{\frac{\frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x} + -0.5}{x} + 1}{x}}}} \]
    2. associate-/r/39.8%

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

      \[\leadsto \frac{1}{\frac{n}{\color{blue}{1 + \frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x} + -0.5}{x}}} \cdot x} \]
    4. +-commutative39.8%

      \[\leadsto \frac{1}{\frac{n}{1 + \frac{\color{blue}{-0.5 + \frac{\frac{0.25}{x} + -0.3333333333333333}{x}}}{x}} \cdot x} \]
  9. Simplified39.8%

    \[\leadsto \color{blue}{\frac{1}{\frac{n}{1 + \frac{-0.5 + \frac{\frac{0.25}{x} + -0.3333333333333333}{x}}{x}} \cdot x}} \]
  10. Step-by-step derivation
    1. associate-*l/39.8%

      \[\leadsto \frac{1}{\color{blue}{\frac{n \cdot x}{1 + \frac{-0.5 + \frac{\frac{0.25}{x} + -0.3333333333333333}{x}}{x}}}} \]
    2. *-commutative39.8%

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

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

      \[\leadsto \color{blue}{\frac{\frac{1}{x}}{n}} \cdot \left(1 + \frac{-0.5 + \frac{\frac{0.25}{x} + -0.3333333333333333}{x}}{x}\right) \]
  11. Applied egg-rr40.2%

    \[\leadsto \color{blue}{\frac{\frac{1}{x}}{n} \cdot \left(1 + \frac{-0.5 + \frac{\frac{0.25}{x} + -0.3333333333333333}{x}}{x}\right)} \]
  12. Final simplification40.2%

    \[\leadsto \frac{\frac{1}{x}}{n} \cdot \left(1 + \frac{-0.5 + \frac{\frac{0.25}{x} + -0.3333333333333333}{x}}{x}\right) \]
  13. Add Preprocessing

Alternative 18: 45.5% accurate, 12.4× speedup?

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

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

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

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

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

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

    \[\leadsto \color{blue}{1 \cdot \frac{\frac{\frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x} + -0.5}{x} + 1}{x}}{n}} \]
  8. Step-by-step derivation
    1. *-lft-identity40.2%

      \[\leadsto \color{blue}{\frac{\frac{\frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x} + -0.5}{x} + 1}{x}}{n}} \]
    2. associate-/l/39.8%

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

      \[\leadsto \frac{\color{blue}{1 + \frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x} + -0.5}{x}}}{n \cdot x} \]
    4. +-commutative39.8%

      \[\leadsto \frac{1 + \frac{\color{blue}{-0.5 + \frac{\frac{0.25}{x} + -0.3333333333333333}{x}}}{x}}{n \cdot x} \]
    5. *-commutative39.8%

      \[\leadsto \frac{1 + \frac{-0.5 + \frac{\frac{0.25}{x} + -0.3333333333333333}{x}}{x}}{\color{blue}{x \cdot n}} \]
  9. Simplified39.8%

    \[\leadsto \color{blue}{\frac{1 + \frac{-0.5 + \frac{\frac{0.25}{x} + -0.3333333333333333}{x}}{x}}{x \cdot n}} \]
  10. Final simplification39.8%

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

Alternative 19: 45.2% accurate, 16.2× speedup?

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

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

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

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

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

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

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

      \[\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*38.9%

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

      \[\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/38.9%

      \[\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/38.9%

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

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

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

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

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

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

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

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

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

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

Alternative 20: 39.0% 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 49.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 63.1%

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

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

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

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

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

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

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

Alternative 21: 39.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 49.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 63.1%

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

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

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

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

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

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

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

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

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

Alternative 22: 39.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 49.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 63.1%

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

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

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

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

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

Alternative 23: 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 49.7%

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

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

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

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

Reproduce

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