2nthrt (problem 3.4.6)

Percentage Accurate: 52.6% → 83.3%
Time: 20.6s
Alternatives: 16
Speedup: 2.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 16 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: 52.6% 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: 83.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-105}:\\ \;\;\;\;\frac{1}{x} \cdot \frac{t_0}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{-135}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{-12}:\\ \;\;\;\;\frac{1}{n \cdot \left(x + 0.5\right)}\\ \mathbf{else}:\\ \;\;\;\;e^{\frac{x}{n}} - t_0\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (pow x (/ 1.0 n))))
   (if (<= (/ 1.0 n) -5e-105)
     (* (/ 1.0 x) (/ t_0 n))
     (if (<= (/ 1.0 n) 1e-135)
       (/ (log (/ (+ 1.0 x) x)) n)
       (if (<= (/ 1.0 n) 1e-12)
         (/ 1.0 (* n (+ x 0.5)))
         (- (exp (/ x n)) t_0))))))
double code(double x, double n) {
	double t_0 = pow(x, (1.0 / n));
	double tmp;
	if ((1.0 / n) <= -5e-105) {
		tmp = (1.0 / x) * (t_0 / n);
	} else if ((1.0 / n) <= 1e-135) {
		tmp = log(((1.0 + x) / x)) / n;
	} else if ((1.0 / n) <= 1e-12) {
		tmp = 1.0 / (n * (x + 0.5));
	} else {
		tmp = exp((x / 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) <= (-5d-105)) then
        tmp = (1.0d0 / x) * (t_0 / n)
    else if ((1.0d0 / n) <= 1d-135) then
        tmp = log(((1.0d0 + x) / x)) / n
    else if ((1.0d0 / n) <= 1d-12) then
        tmp = 1.0d0 / (n * (x + 0.5d0))
    else
        tmp = exp((x / 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) <= -5e-105) {
		tmp = (1.0 / x) * (t_0 / n);
	} else if ((1.0 / n) <= 1e-135) {
		tmp = Math.log(((1.0 + x) / x)) / n;
	} else if ((1.0 / n) <= 1e-12) {
		tmp = 1.0 / (n * (x + 0.5));
	} else {
		tmp = Math.exp((x / n)) - t_0;
	}
	return tmp;
}
def code(x, n):
	t_0 = math.pow(x, (1.0 / n))
	tmp = 0
	if (1.0 / n) <= -5e-105:
		tmp = (1.0 / x) * (t_0 / n)
	elif (1.0 / n) <= 1e-135:
		tmp = math.log(((1.0 + x) / x)) / n
	elif (1.0 / n) <= 1e-12:
		tmp = 1.0 / (n * (x + 0.5))
	else:
		tmp = math.exp((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) <= -5e-105)
		tmp = Float64(Float64(1.0 / x) * Float64(t_0 / n));
	elseif (Float64(1.0 / n) <= 1e-135)
		tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n);
	elseif (Float64(1.0 / n) <= 1e-12)
		tmp = Float64(1.0 / Float64(n * Float64(x + 0.5)));
	else
		tmp = Float64(exp(Float64(x / 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) <= -5e-105)
		tmp = (1.0 / x) * (t_0 / n);
	elseif ((1.0 / n) <= 1e-135)
		tmp = log(((1.0 + x) / x)) / n;
	elseif ((1.0 / n) <= 1e-12)
		tmp = 1.0 / (n * (x + 0.5));
	else
		tmp = exp((x / 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], -5e-105], N[(N[(1.0 / x), $MachinePrecision] * N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-135], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-12], N[(1.0 / N[(n * N[(x + 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]]]]]
\begin{array}{l}

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

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

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

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


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

    1. Initial program 76.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{e^{\frac{\color{blue}{\log x \cdot 1}}{n}}}{n \cdot x} \]
      6. associate-*r/88.8%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1}{x} \cdot \frac{{x}^{\left(\frac{1}{n}\right)}}{n}} \]
    9. Applied egg-rr89.2%

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

    if -4.99999999999999963e-105 < (/.f64 1 n) < 1e-135

    1. Initial program 43.8%

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

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

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

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

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

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

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

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

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

    if 1e-135 < (/.f64 1 n) < 9.9999999999999998e-13

    1. Initial program 18.5%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{0.5 \cdot n + n \cdot x}} \]
    10. Step-by-step derivation
      1. *-commutative77.5%

        \[\leadsto \frac{1}{\color{blue}{n \cdot 0.5} + n \cdot x} \]
      2. distribute-lft-out77.5%

        \[\leadsto \frac{1}{\color{blue}{n \cdot \left(0.5 + x\right)}} \]
    11. Simplified77.5%

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

    if 9.9999999999999998e-13 < (/.f64 1 n)

    1. Initial program 49.2%

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

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

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

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

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

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

Alternative 2: 78.5% accurate, 1.0× speedup?

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

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if (/.f64 1 n) < -4.99999999999999963e-105

    1. Initial program 76.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{e^{\frac{\color{blue}{\log x \cdot 1}}{n}}}{n \cdot x} \]
      6. associate-*r/88.8%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1}{x} \cdot \frac{{x}^{\left(\frac{1}{n}\right)}}{n}} \]
    9. Applied egg-rr89.2%

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

    if -4.99999999999999963e-105 < (/.f64 1 n) < 1e-135

    1. Initial program 43.8%

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

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

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

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

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

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

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

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

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

    if 1e-135 < (/.f64 1 n) < 9.9999999999999998e-13

    1. Initial program 18.5%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{0.5 \cdot n + n \cdot x}} \]
    10. Step-by-step derivation
      1. *-commutative77.5%

        \[\leadsto \frac{1}{\color{blue}{n \cdot 0.5} + n \cdot x} \]
      2. distribute-lft-out77.5%

        \[\leadsto \frac{1}{\color{blue}{n \cdot \left(0.5 + x\right)}} \]
    11. Simplified77.5%

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

    if 9.9999999999999998e-13 < (/.f64 1 n) < 2.0000000000000001e251

    1. Initial program 68.4%

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

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

    if 2.0000000000000001e251 < (/.f64 1 n)

    1. Initial program 4.0%

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{1}{x}}{n}} \]
      2. log1p-expm1-u91.2%

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

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

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

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

Alternative 3: 54.5% accurate, 1.6× speedup?

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

\\
\begin{array}{l}
t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{1}{n \cdot \left(x + 0.5\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-13}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-115}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-308}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;\frac{1}{n} \leq 10^{-202}:\\
\;\;\;\;\frac{-\log x}{n}\\

\mathbf{elif}\;\frac{1}{n} \leq 10^{-12}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+251}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if (/.f64 1 n) < -2.0000000000000001e-13 or 9.9999999999999998e-13 < (/.f64 1 n) < 2.0000000000000001e251

    1. Initial program 90.7%

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

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

    if -2.0000000000000001e-13 < (/.f64 1 n) < -1.0000000000000001e-115 or -2e-140 < (/.f64 1 n) < 4.99999999999999955e-308 or 1e-202 < (/.f64 1 n) < 9.9999999999999998e-13

    1. Initial program 36.4%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{0.5 \cdot n + n \cdot x}} \]
    10. Step-by-step derivation
      1. *-commutative69.4%

        \[\leadsto \frac{1}{\color{blue}{n \cdot 0.5} + n \cdot x} \]
      2. distribute-lft-out69.4%

        \[\leadsto \frac{1}{\color{blue}{n \cdot \left(0.5 + x\right)}} \]
    11. Simplified69.4%

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

    if -1.0000000000000001e-115 < (/.f64 1 n) < -2e-140

    1. Initial program 4.4%

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

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

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

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

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

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

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

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

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

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

    if 4.99999999999999955e-308 < (/.f64 1 n) < 1e-202

    1. Initial program 34.1%

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

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

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

        \[\leadsto \color{blue}{-\frac{\log x}{n}} \]
      2. distribute-neg-frac68.9%

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

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

    if 2.0000000000000001e251 < (/.f64 1 n)

    1. Initial program 4.0%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-13}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-115}:\\ \;\;\;\;\frac{1}{n \cdot \left(x + 0.5\right)}\\ \mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-140}:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-308}:\\ \;\;\;\;\frac{1}{n \cdot \left(x + 0.5\right)}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{-202}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{-12}:\\ \;\;\;\;\frac{1}{n \cdot \left(x + 0.5\right)}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+251}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \end{array} \]

Alternative 4: 64.5% accurate, 1.6× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{\log \left(\frac{1 + x}{x}\right)}{n}\\
t_1 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
t_2 := \frac{1}{n \cdot \left(x + 0.5\right)}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{+181}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{+65}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-13}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-115}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;\frac{1}{n} \leq 10^{-135}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;\frac{1}{n} \leq 10^{-12}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+251}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (/.f64 1 n) < -1.9999999999999998e181 or -2e65 < (/.f64 1 n) < -2.0000000000000001e-13 or 9.9999999999999998e-13 < (/.f64 1 n) < 2.0000000000000001e251

    1. Initial program 86.5%

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

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

    if -1.9999999999999998e181 < (/.f64 1 n) < -2e65 or -1.0000000000000001e-115 < (/.f64 1 n) < 1e-135

    1. Initial program 59.1%

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

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

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

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

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

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

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

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

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

    if -2.0000000000000001e-13 < (/.f64 1 n) < -1.0000000000000001e-115 or 1e-135 < (/.f64 1 n) < 9.9999999999999998e-13

    1. Initial program 15.8%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{0.5 \cdot n + n \cdot x}} \]
    10. Step-by-step derivation
      1. *-commutative72.2%

        \[\leadsto \frac{1}{\color{blue}{n \cdot 0.5} + n \cdot x} \]
      2. distribute-lft-out72.2%

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

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

    if 2.0000000000000001e251 < (/.f64 1 n)

    1. Initial program 4.0%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{+181}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{+65}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-13}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-115}:\\ \;\;\;\;\frac{1}{n \cdot \left(x + 0.5\right)}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{-135}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{-12}:\\ \;\;\;\;\frac{1}{n \cdot \left(x + 0.5\right)}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+251}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \end{array} \]

Alternative 5: 78.3% accurate, 1.7× speedup?

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

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if (/.f64 1 n) < -4.99999999999999963e-105

    1. Initial program 76.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{e^{\frac{\color{blue}{\log x \cdot 1}}{n}}}{n \cdot x} \]
      6. associate-*r/88.8%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1}{x} \cdot \frac{{x}^{\left(\frac{1}{n}\right)}}{n}} \]
    9. Applied egg-rr89.2%

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

    if -4.99999999999999963e-105 < (/.f64 1 n) < 1e-135

    1. Initial program 43.8%

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

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

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

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

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

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

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

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

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

    if 1e-135 < (/.f64 1 n) < 9.9999999999999998e-13

    1. Initial program 18.5%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{0.5 \cdot n + n \cdot x}} \]
    10. Step-by-step derivation
      1. *-commutative77.5%

        \[\leadsto \frac{1}{\color{blue}{n \cdot 0.5} + n \cdot x} \]
      2. distribute-lft-out77.5%

        \[\leadsto \frac{1}{\color{blue}{n \cdot \left(0.5 + x\right)}} \]
    11. Simplified77.5%

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

    if 9.9999999999999998e-13 < (/.f64 1 n) < 2.0000000000000001e251

    1. Initial program 68.4%

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

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

    if 2.0000000000000001e251 < (/.f64 1 n)

    1. Initial program 4.0%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-105}:\\ \;\;\;\;\frac{1}{x} \cdot \frac{{x}^{\left(\frac{1}{n}\right)}}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{-135}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{-12}:\\ \;\;\;\;\frac{1}{n \cdot \left(x + 0.5\right)}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+251}:\\ \;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \end{array} \]

Alternative 6: 78.4% accurate, 1.7× speedup?

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

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if (/.f64 1 n) < -4.99999999999999963e-105

    1. Initial program 76.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{e^{\frac{\color{blue}{\log x \cdot 1}}{n}}}{n \cdot x} \]
      6. associate-*r/88.8%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1}{x} \cdot \frac{{x}^{\left(\frac{1}{n}\right)}}{n}} \]
    9. Applied egg-rr89.2%

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

    if -4.99999999999999963e-105 < (/.f64 1 n) < 1e-135

    1. Initial program 43.8%

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

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

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

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

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

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

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

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

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

    if 1e-135 < (/.f64 1 n) < 9.9999999999999998e-13

    1. Initial program 18.5%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{0.5 \cdot n + n \cdot x}} \]
    10. Step-by-step derivation
      1. *-commutative77.5%

        \[\leadsto \frac{1}{\color{blue}{n \cdot 0.5} + n \cdot x} \]
      2. distribute-lft-out77.5%

        \[\leadsto \frac{1}{\color{blue}{n \cdot \left(0.5 + x\right)}} \]
    11. Simplified77.5%

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

    if 9.9999999999999998e-13 < (/.f64 1 n) < 2.0000000000000001e251

    1. Initial program 68.4%

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

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

    if 2.0000000000000001e251 < (/.f64 1 n)

    1. Initial program 4.0%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{x} - \frac{\color{blue}{0.5}}{{x}^{2}}}{n} \]
    7. Simplified0.1%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\left(-\left(\frac{1}{x} + \frac{-0.5}{{x}^{2}}\right)\right) \cdot \frac{1}{n}} \]
    10. Step-by-step derivation
      1. associate-*r/91.2%

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

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

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

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

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

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

        \[\leadsto \frac{\frac{0.5}{{x}^{2}} + \color{blue}{\frac{-1}{x}}}{n} \]
      8. metadata-eval91.2%

        \[\leadsto \frac{\frac{0.5}{{x}^{2}} + \frac{\color{blue}{-1}}{x}}{n} \]
    11. Simplified91.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-105}:\\ \;\;\;\;\frac{1}{x} \cdot \frac{{x}^{\left(\frac{1}{n}\right)}}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{-135}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{-12}:\\ \;\;\;\;\frac{1}{n \cdot \left(x + 0.5\right)}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+251}:\\ \;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{0.5}{{x}^{2}} + \frac{-1}{x}}{n}\\ \end{array} \]

Alternative 7: 78.1% accurate, 1.7× speedup?

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

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+251}:\\
\;\;\;\;1 - t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if (/.f64 1 n) < -4.99999999999999963e-105

    1. Initial program 76.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{e^{\frac{\color{blue}{\log x \cdot 1}}{n}}}{n \cdot x} \]
      6. associate-*r/88.8%

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

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

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

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

    if -4.99999999999999963e-105 < (/.f64 1 n) < 1e-135

    1. Initial program 43.8%

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

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

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

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

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

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

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

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

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

    if 1e-135 < (/.f64 1 n) < 9.9999999999999998e-13

    1. Initial program 18.5%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{0.5 \cdot n + n \cdot x}} \]
    10. Step-by-step derivation
      1. *-commutative77.5%

        \[\leadsto \frac{1}{\color{blue}{n \cdot 0.5} + n \cdot x} \]
      2. distribute-lft-out77.5%

        \[\leadsto \frac{1}{\color{blue}{n \cdot \left(0.5 + x\right)}} \]
    11. Simplified77.5%

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

    if 9.9999999999999998e-13 < (/.f64 1 n) < 2.0000000000000001e251

    1. Initial program 68.4%

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

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

    if 2.0000000000000001e251 < (/.f64 1 n)

    1. Initial program 4.0%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-105}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{-135}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{-12}:\\ \;\;\;\;\frac{1}{n \cdot \left(x + 0.5\right)}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+251}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \end{array} \]

Alternative 8: 78.2% accurate, 1.7× speedup?

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

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+251}:\\
\;\;\;\;1 - t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if (/.f64 1 n) < -4.99999999999999963e-105

    1. Initial program 76.0%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{e^{\frac{\color{blue}{\log x \cdot 1}}{n}}}{n \cdot x} \]
      6. associate-*r/88.8%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1}{x} \cdot \frac{{x}^{\left(\frac{1}{n}\right)}}{n}} \]
    9. Applied egg-rr89.2%

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

    if -4.99999999999999963e-105 < (/.f64 1 n) < 1e-135

    1. Initial program 43.8%

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

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

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

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

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

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

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

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

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

    if 1e-135 < (/.f64 1 n) < 9.9999999999999998e-13

    1. Initial program 18.5%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{0.5 \cdot n + n \cdot x}} \]
    10. Step-by-step derivation
      1. *-commutative77.5%

        \[\leadsto \frac{1}{\color{blue}{n \cdot 0.5} + n \cdot x} \]
      2. distribute-lft-out77.5%

        \[\leadsto \frac{1}{\color{blue}{n \cdot \left(0.5 + x\right)}} \]
    11. Simplified77.5%

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

    if 9.9999999999999998e-13 < (/.f64 1 n) < 2.0000000000000001e251

    1. Initial program 68.4%

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

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

    if 2.0000000000000001e251 < (/.f64 1 n)

    1. Initial program 4.0%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-105}:\\ \;\;\;\;\frac{1}{x} \cdot \frac{{x}^{\left(\frac{1}{n}\right)}}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{-135}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{-12}:\\ \;\;\;\;\frac{1}{n \cdot \left(x + 0.5\right)}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+251}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \end{array} \]

Alternative 9: 57.7% accurate, 1.8× speedup?

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

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

\mathbf{elif}\;x \leq 8.5 \cdot 10^{-168}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 8.5 \cdot 10^{-135}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 6 \cdot 10^{-119}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 1.02 \cdot 10^{-37}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 1:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 7.6 \cdot 10^{+232}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\

\mathbf{else}:\\
\;\;\;\;\frac{-0.5}{n \cdot {x}^{2}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < 5.7e-195 or 8.4999999999999994e-168 < x < 8.49999999999999942e-135 or 6.0000000000000004e-119 < x < 1.02000000000000006e-37

    1. Initial program 36.0%

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

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

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

        \[\leadsto \color{blue}{-\frac{\log x}{n}} \]
      2. distribute-neg-frac56.4%

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

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

    if 5.7e-195 < x < 8.4999999999999994e-168 or 8.49999999999999942e-135 < x < 6.0000000000000004e-119 or 1.02000000000000006e-37 < x < 1

    1. Initial program 70.1%

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

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

    if 1 < x < 7.6000000000000002e232

    1. Initial program 58.8%

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

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

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

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

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

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

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

    if 7.6000000000000002e232 < x

    1. Initial program 91.4%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{x} - \frac{\color{blue}{0.5}}{{x}^{2}}}{n} \]
    7. Simplified65.7%

      \[\leadsto \frac{\color{blue}{\frac{1}{x} - \frac{0.5}{{x}^{2}}}}{n} \]
    8. Taylor expanded in x around 0 91.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 5.7 \cdot 10^{-195}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 8.5 \cdot 10^{-168}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 8.5 \cdot 10^{-135}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 6 \cdot 10^{-119}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 1.02 \cdot 10^{-37}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 7.6 \cdot 10^{+232}:\\ \;\;\;\;\frac{\frac{1}{x}}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{-0.5}{n \cdot {x}^{2}}\\ \end{array} \]

Alternative 10: 57.5% accurate, 1.8× speedup?

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

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

\mathbf{elif}\;x \leq 1.35 \cdot 10^{-165}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 8 \cdot 10^{-138}:\\
\;\;\;\;\frac{1}{\frac{-n}{\log x}}\\

\mathbf{elif}\;x \leq 8 \cdot 10^{-119}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 1.02 \cdot 10^{-37}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;x \leq 0.95:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq 3.5 \cdot 10^{+232}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\

\mathbf{else}:\\
\;\;\;\;\frac{-0.5}{n \cdot {x}^{2}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if x < 6.3e-195 or 8.0000000000000001e-119 < x < 1.02000000000000006e-37

    1. Initial program 36.8%

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

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

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

        \[\leadsto \color{blue}{-\frac{\log x}{n}} \]
      2. distribute-neg-frac54.2%

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

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

    if 6.3e-195 < x < 1.3499999999999999e-165 or 8.00000000000000054e-138 < x < 8.0000000000000001e-119 or 1.02000000000000006e-37 < x < 0.94999999999999996

    1. Initial program 70.1%

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

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

    if 1.3499999999999999e-165 < x < 8.00000000000000054e-138

    1. Initial program 31.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.94999999999999996 < x < 3.50000000000000013e232

    1. Initial program 58.8%

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

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

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

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

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

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

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

    if 3.50000000000000013e232 < x

    1. Initial program 91.4%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{x} - \frac{\color{blue}{0.5}}{{x}^{2}}}{n} \]
    7. Simplified65.7%

      \[\leadsto \frac{\color{blue}{\frac{1}{x} - \frac{0.5}{{x}^{2}}}}{n} \]
    8. Taylor expanded in x around 0 91.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 6.3 \cdot 10^{-195}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 1.35 \cdot 10^{-165}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 8 \cdot 10^{-138}:\\ \;\;\;\;\frac{1}{\frac{-n}{\log x}}\\ \mathbf{elif}\;x \leq 8 \cdot 10^{-119}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 1.02 \cdot 10^{-37}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 0.95:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 3.5 \cdot 10^{+232}:\\ \;\;\;\;\frac{\frac{1}{x}}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{-0.5}{n \cdot {x}^{2}}\\ \end{array} \]

Alternative 11: 57.1% accurate, 2.0× speedup?

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

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

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


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

    1. Initial program 45.2%

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

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

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

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

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

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

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

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

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

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

    if 3.50000000000000024e-8 < x

    1. Initial program 68.0%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 3.5 \cdot 10^{-8}:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x}}{n}\\ \end{array} \]

Alternative 12: 57.0% accurate, 2.0× speedup?

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

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

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


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

    1. Initial program 45.2%

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

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

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

        \[\leadsto \color{blue}{-\frac{\log x}{n}} \]
      2. distribute-neg-frac47.2%

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

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

    if 3.50000000000000024e-8 < x

    1. Initial program 68.0%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 3.5 \cdot 10^{-8}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x}}{n}\\ \end{array} \]

Alternative 13: 39.6% accurate, 42.2× speedup?

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

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

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

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

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

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

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

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

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

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

Alternative 14: 40.2% accurate, 42.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 16: 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 55.8%

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

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

    \[\leadsto \color{blue}{\frac{x}{n}} \]
  4. Final simplification4.3%

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

Reproduce

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