2nthrt (problem 3.4.6)

Percentage Accurate: 53.6% → 85.3%
Time: 20.8s
Alternatives: 12
Speedup: 1.9×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 12 alternatives:

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

Initial Program: 53.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: 85.3% accurate, 0.7× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 1 n) < -2.0000000000000001e-59

    1. Initial program 89.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.0000000000000001e-59 < (/.f64 1 n) < 1.99999999999999982e-21

    1. Initial program 30.0%

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

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

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

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

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

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

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

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

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

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

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

    if 1.99999999999999982e-21 < (/.f64 1 n)

    1. Initial program 49.7%

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

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

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

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

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 1 n) < -2.0000000000000001e-59

    1. Initial program 89.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.0000000000000001e-59 < (/.f64 1 n) < 5.00000000000000024e-5

    1. Initial program 29.6%

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

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

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

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

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

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

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

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

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

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

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

    if 5.00000000000000024e-5 < (/.f64 1 n)

    1. Initial program 51.9%

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

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

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

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

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

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

Alternative 3: 66.8% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\ t_1 := \frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{+67}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{1}{n} \leq -0.1:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-5}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{+237}:\\ \;\;\;\;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 (/ (log (/ (+ 1.0 x) x)) n)))
   (if (<= (/ 1.0 n) -2e+67)
     t_1
     (if (<= (/ 1.0 n) -0.1)
       t_0
       (if (<= (/ 1.0 n) 5e-5)
         t_1
         (if (<= (/ 1.0 n) 1e+237) 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 = log(((1.0 + x) / x)) / n;
	double tmp;
	if ((1.0 / n) <= -2e+67) {
		tmp = t_1;
	} else if ((1.0 / n) <= -0.1) {
		tmp = t_0;
	} else if ((1.0 / n) <= 5e-5) {
		tmp = t_1;
	} else if ((1.0 / n) <= 1e+237) {
		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 = log(((1.0d0 + x) / x)) / n
    if ((1.0d0 / n) <= (-2d+67)) then
        tmp = t_1
    else if ((1.0d0 / n) <= (-0.1d0)) then
        tmp = t_0
    else if ((1.0d0 / n) <= 5d-5) then
        tmp = t_1
    else if ((1.0d0 / n) <= 1d+237) 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 = Math.log(((1.0 + x) / x)) / n;
	double tmp;
	if ((1.0 / n) <= -2e+67) {
		tmp = t_1;
	} else if ((1.0 / n) <= -0.1) {
		tmp = t_0;
	} else if ((1.0 / n) <= 5e-5) {
		tmp = t_1;
	} else if ((1.0 / n) <= 1e+237) {
		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 = math.log(((1.0 + x) / x)) / n
	tmp = 0
	if (1.0 / n) <= -2e+67:
		tmp = t_1
	elif (1.0 / n) <= -0.1:
		tmp = t_0
	elif (1.0 / n) <= 5e-5:
		tmp = t_1
	elif (1.0 / n) <= 1e+237:
		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(log(Float64(Float64(1.0 + x) / x)) / n)
	tmp = 0.0
	if (Float64(1.0 / n) <= -2e+67)
		tmp = t_1;
	elseif (Float64(1.0 / n) <= -0.1)
		tmp = t_0;
	elseif (Float64(1.0 / n) <= 5e-5)
		tmp = t_1;
	elseif (Float64(1.0 / n) <= 1e+237)
		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 = log(((1.0 + x) / x)) / n;
	tmp = 0.0;
	if ((1.0 / n) <= -2e+67)
		tmp = t_1;
	elseif ((1.0 / n) <= -0.1)
		tmp = t_0;
	elseif ((1.0 / n) <= 5e-5)
		tmp = t_1;
	elseif ((1.0 / n) <= 1e+237)
		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[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e+67], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], -0.1], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-5], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+237], 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{\log \left(\frac{1 + x}{x}\right)}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{+67}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;\frac{1}{n} \leq -0.1:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;\frac{1}{n} \leq 10^{+237}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 1 n) < -1.99999999999999997e67 or -0.10000000000000001 < (/.f64 1 n) < 5.00000000000000024e-5

    1. Initial program 50.3%

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

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

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

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

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

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

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

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

    if -1.99999999999999997e67 < (/.f64 1 n) < -0.10000000000000001 or 5.00000000000000024e-5 < (/.f64 1 n) < 9.9999999999999994e236

    1. Initial program 80.4%

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

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

    if 9.9999999999999994e236 < (/.f64 1 n)

    1. Initial program 3.1%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Taylor expanded in n around inf 100.0%

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

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

Alternative 4: 66.8% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{+67}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq -0.1:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-5}:\\ \;\;\;\;\frac{-\log \left(\frac{x}{1 + x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{+237}:\\ \;\;\;\;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)))))
   (if (<= (/ 1.0 n) -2e+67)
     (/ (log (/ (+ 1.0 x) x)) n)
     (if (<= (/ 1.0 n) -0.1)
       t_0
       (if (<= (/ 1.0 n) 5e-5)
         (/ (- (log (/ x (+ 1.0 x)))) n)
         (if (<= (/ 1.0 n) 1e+237) t_0 (/ 1.0 (* n x))))))))
double code(double x, double n) {
	double t_0 = 1.0 - pow(x, (1.0 / n));
	double tmp;
	if ((1.0 / n) <= -2e+67) {
		tmp = log(((1.0 + x) / x)) / n;
	} else if ((1.0 / n) <= -0.1) {
		tmp = t_0;
	} else if ((1.0 / n) <= 5e-5) {
		tmp = -log((x / (1.0 + x))) / n;
	} else if ((1.0 / n) <= 1e+237) {
		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) :: tmp
    t_0 = 1.0d0 - (x ** (1.0d0 / n))
    if ((1.0d0 / n) <= (-2d+67)) then
        tmp = log(((1.0d0 + x) / x)) / n
    else if ((1.0d0 / n) <= (-0.1d0)) then
        tmp = t_0
    else if ((1.0d0 / n) <= 5d-5) then
        tmp = -log((x / (1.0d0 + x))) / n
    else if ((1.0d0 / n) <= 1d+237) 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 tmp;
	if ((1.0 / n) <= -2e+67) {
		tmp = Math.log(((1.0 + x) / x)) / n;
	} else if ((1.0 / n) <= -0.1) {
		tmp = t_0;
	} else if ((1.0 / n) <= 5e-5) {
		tmp = -Math.log((x / (1.0 + x))) / n;
	} else if ((1.0 / n) <= 1e+237) {
		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))
	tmp = 0
	if (1.0 / n) <= -2e+67:
		tmp = math.log(((1.0 + x) / x)) / n
	elif (1.0 / n) <= -0.1:
		tmp = t_0
	elif (1.0 / n) <= 5e-5:
		tmp = -math.log((x / (1.0 + x))) / n
	elif (1.0 / n) <= 1e+237:
		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)))
	tmp = 0.0
	if (Float64(1.0 / n) <= -2e+67)
		tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n);
	elseif (Float64(1.0 / n) <= -0.1)
		tmp = t_0;
	elseif (Float64(1.0 / n) <= 5e-5)
		tmp = Float64(Float64(-log(Float64(x / Float64(1.0 + x)))) / n);
	elseif (Float64(1.0 / n) <= 1e+237)
		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));
	tmp = 0.0;
	if ((1.0 / n) <= -2e+67)
		tmp = log(((1.0 + x) / x)) / n;
	elseif ((1.0 / n) <= -0.1)
		tmp = t_0;
	elseif ((1.0 / n) <= 5e-5)
		tmp = -log((x / (1.0 + x))) / n;
	elseif ((1.0 / n) <= 1e+237)
		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]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e+67], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -0.1], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-5], N[((-N[Log[N[(x / N[(1.0 + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+237], 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)}\\
\mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{+67}:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\

\mathbf{elif}\;\frac{1}{n} \leq -0.1:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;\frac{1}{n} \leq 10^{+237}:\\
\;\;\;\;t_0\\

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

    if -1.99999999999999997e67 < (/.f64 1 n) < -0.10000000000000001 or 5.00000000000000024e-5 < (/.f64 1 n) < 9.9999999999999994e236

    1. Initial program 80.4%

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

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

    if -0.10000000000000001 < (/.f64 1 n) < 5.00000000000000024e-5

    1. Initial program 29.6%

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

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

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

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

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

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

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

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

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

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

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

    if 9.9999999999999994e236 < (/.f64 1 n)

    1. Initial program 3.1%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Taylor expanded in n around inf 100.0%

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

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

Alternative 5: 81.2% accurate, 1.6× speedup?

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

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

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

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


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

    1. Initial program 89.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.0000000000000001e-59 < (/.f64 1 n) < 4.99999999999999977e-7

    1. Initial program 29.8%

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

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

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

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

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

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

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

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

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

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

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

    if 4.99999999999999977e-7 < (/.f64 1 n) < 9.9999999999999994e236

    1. Initial program 65.7%

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

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

    if 9.9999999999999994e236 < (/.f64 1 n)

    1. Initial program 3.1%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Taylor expanded in n around inf 100.0%

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

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

Alternative 6: 81.0% accurate, 1.7× speedup?

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

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

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

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


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

    1. Initial program 89.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.0000000000000001e-59 < (/.f64 1 n) < 5.00000000000000024e-5

    1. Initial program 29.6%

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

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

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

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

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

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

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

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

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

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

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

    if 5.00000000000000024e-5 < (/.f64 1 n) < 9.9999999999999994e236

    1. Initial program 67.6%

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

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

    if 9.9999999999999994e236 < (/.f64 1 n)

    1. Initial program 3.1%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Taylor expanded in n around inf 100.0%

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

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

Alternative 7: 59.2% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{if}\;x \leq 7 \cdot 10^{-255}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 5.2 \cdot 10^{-119}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 1.2 \cdot 10^{-81}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{elif}\;x \leq 2.85 \cdot 10^{+43}:\\ \;\;\;\;\frac{1}{n} \cdot \frac{1}{x}\\ \mathbf{elif}\;x \leq 1.35 \cdot 10^{+74}:\\ \;\;\;\;0\\ \mathbf{elif}\;x \leq 2.1 \cdot 10^{+95}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))))
   (if (<= x 7e-255)
     t_0
     (if (<= x 5.2e-119)
       (/ (- (log x)) n)
       (if (<= x 1.2e-81)
         t_0
         (if (<= x 1.0)
           (/ (- x (log x)) n)
           (if (<= x 2.85e+43)
             (* (/ 1.0 n) (/ 1.0 x))
             (if (<= x 1.35e+74)
               0.0
               (if (<= x 2.1e+95) (/ (/ 1.0 n) x) 0.0)))))))))
double code(double x, double n) {
	double t_0 = 1.0 - pow(x, (1.0 / n));
	double tmp;
	if (x <= 7e-255) {
		tmp = t_0;
	} else if (x <= 5.2e-119) {
		tmp = -log(x) / n;
	} else if (x <= 1.2e-81) {
		tmp = t_0;
	} else if (x <= 1.0) {
		tmp = (x - log(x)) / n;
	} else if (x <= 2.85e+43) {
		tmp = (1.0 / n) * (1.0 / x);
	} else if (x <= 1.35e+74) {
		tmp = 0.0;
	} else if (x <= 2.1e+95) {
		tmp = (1.0 / n) / x;
	} else {
		tmp = 0.0;
	}
	return tmp;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 1.0d0 - (x ** (1.0d0 / n))
    if (x <= 7d-255) then
        tmp = t_0
    else if (x <= 5.2d-119) then
        tmp = -log(x) / n
    else if (x <= 1.2d-81) then
        tmp = t_0
    else if (x <= 1.0d0) then
        tmp = (x - log(x)) / n
    else if (x <= 2.85d+43) then
        tmp = (1.0d0 / n) * (1.0d0 / x)
    else if (x <= 1.35d+74) then
        tmp = 0.0d0
    else if (x <= 2.1d+95) then
        tmp = (1.0d0 / n) / x
    else
        tmp = 0.0d0
    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 tmp;
	if (x <= 7e-255) {
		tmp = t_0;
	} else if (x <= 5.2e-119) {
		tmp = -Math.log(x) / n;
	} else if (x <= 1.2e-81) {
		tmp = t_0;
	} else if (x <= 1.0) {
		tmp = (x - Math.log(x)) / n;
	} else if (x <= 2.85e+43) {
		tmp = (1.0 / n) * (1.0 / x);
	} else if (x <= 1.35e+74) {
		tmp = 0.0;
	} else if (x <= 2.1e+95) {
		tmp = (1.0 / n) / x;
	} else {
		tmp = 0.0;
	}
	return tmp;
}
def code(x, n):
	t_0 = 1.0 - math.pow(x, (1.0 / n))
	tmp = 0
	if x <= 7e-255:
		tmp = t_0
	elif x <= 5.2e-119:
		tmp = -math.log(x) / n
	elif x <= 1.2e-81:
		tmp = t_0
	elif x <= 1.0:
		tmp = (x - math.log(x)) / n
	elif x <= 2.85e+43:
		tmp = (1.0 / n) * (1.0 / x)
	elif x <= 1.35e+74:
		tmp = 0.0
	elif x <= 2.1e+95:
		tmp = (1.0 / n) / x
	else:
		tmp = 0.0
	return tmp
function code(x, n)
	t_0 = Float64(1.0 - (x ^ Float64(1.0 / n)))
	tmp = 0.0
	if (x <= 7e-255)
		tmp = t_0;
	elseif (x <= 5.2e-119)
		tmp = Float64(Float64(-log(x)) / n);
	elseif (x <= 1.2e-81)
		tmp = t_0;
	elseif (x <= 1.0)
		tmp = Float64(Float64(x - log(x)) / n);
	elseif (x <= 2.85e+43)
		tmp = Float64(Float64(1.0 / n) * Float64(1.0 / x));
	elseif (x <= 1.35e+74)
		tmp = 0.0;
	elseif (x <= 2.1e+95)
		tmp = Float64(Float64(1.0 / n) / x);
	else
		tmp = 0.0;
	end
	return tmp
end
function tmp_2 = code(x, n)
	t_0 = 1.0 - (x ^ (1.0 / n));
	tmp = 0.0;
	if (x <= 7e-255)
		tmp = t_0;
	elseif (x <= 5.2e-119)
		tmp = -log(x) / n;
	elseif (x <= 1.2e-81)
		tmp = t_0;
	elseif (x <= 1.0)
		tmp = (x - log(x)) / n;
	elseif (x <= 2.85e+43)
		tmp = (1.0 / n) * (1.0 / x);
	elseif (x <= 1.35e+74)
		tmp = 0.0;
	elseif (x <= 2.1e+95)
		tmp = (1.0 / n) / x;
	else
		tmp = 0.0;
	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]}, If[LessEqual[x, 7e-255], t$95$0, If[LessEqual[x, 5.2e-119], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 1.2e-81], t$95$0, If[LessEqual[x, 1.0], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 2.85e+43], N[(N[(1.0 / n), $MachinePrecision] * N[(1.0 / x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.35e+74], 0.0, If[LessEqual[x, 2.1e+95], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], 0.0]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq 5.2 \cdot 10^{-119}:\\
\;\;\;\;\frac{-\log x}{n}\\

\mathbf{elif}\;x \leq 1.2 \cdot 10^{-81}:\\
\;\;\;\;t_0\\

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

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

\mathbf{elif}\;x \leq 1.35 \cdot 10^{+74}:\\
\;\;\;\;0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 6 regimes
  2. if x < 6.99999999999999958e-255 or 5.20000000000000023e-119 < x < 1.2e-81

    1. Initial program 61.6%

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

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

    if 6.99999999999999958e-255 < x < 5.20000000000000023e-119

    1. Initial program 38.0%

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

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

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

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

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

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

    if 1.2e-81 < x < 1

    1. Initial program 26.7%

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

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

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

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

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

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

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

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

    if 1 < x < 2.8499999999999999e43

    1. Initial program 29.6%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Taylor expanded in n around inf 67.5%

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

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

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

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

    if 2.8499999999999999e43 < x < 1.3499999999999999e74 or 2.1e95 < x

    1. Initial program 81.2%

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

      \[\leadsto \color{blue}{1 - e^{\frac{\log x}{n}}} \]
    4. Taylor expanded in n around inf 81.3%

      \[\leadsto 1 - \color{blue}{1} \]

    if 1.3499999999999999e74 < x < 2.1e95

    1. Initial program 21.8%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Taylor expanded in n around inf 66.6%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 7 \cdot 10^{-255}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 5.2 \cdot 10^{-119}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 1.2 \cdot 10^{-81}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{elif}\;x \leq 2.85 \cdot 10^{+43}:\\ \;\;\;\;\frac{1}{n} \cdot \frac{1}{x}\\ \mathbf{elif}\;x \leq 1.35 \cdot 10^{+74}:\\ \;\;\;\;0\\ \mathbf{elif}\;x \leq 2.1 \cdot 10^{+95}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 59.4% accurate, 1.9× speedup?

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

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

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

\mathbf{elif}\;x \leq 1.5 \cdot 10^{+74}:\\
\;\;\;\;0\\

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

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


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

    1. Initial program 41.9%

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

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

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

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

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

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

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

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

    if 1 < x < 3.2499999999999999e43

    1. Initial program 29.6%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Taylor expanded in n around inf 67.5%

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

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

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

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

    if 3.2499999999999999e43 < x < 1.5e74 or 1.82000000000000009e93 < x

    1. Initial program 81.2%

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

      \[\leadsto \color{blue}{1 - e^{\frac{\log x}{n}}} \]
    4. Taylor expanded in n around inf 81.3%

      \[\leadsto 1 - \color{blue}{1} \]

    if 1.5e74 < x < 1.82000000000000009e93

    1. Initial program 21.8%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Taylor expanded in n around inf 66.6%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{elif}\;x \leq 3.25 \cdot 10^{+43}:\\ \;\;\;\;\frac{1}{n} \cdot \frac{1}{x}\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{+74}:\\ \;\;\;\;0\\ \mathbf{elif}\;x \leq 1.82 \cdot 10^{+93}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 59.3% accurate, 1.9× speedup?

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

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

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

\mathbf{elif}\;x \leq 1.35 \cdot 10^{+74}:\\
\;\;\;\;0\\

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

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


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

    1. Initial program 41.9%

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

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

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

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

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

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

    if 0.55000000000000004 < x < 2.34999999999999999e43

    1. Initial program 29.6%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Taylor expanded in n around inf 67.5%

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

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

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

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

    if 2.34999999999999999e43 < x < 1.3499999999999999e74 or 5.19999999999999981e95 < x

    1. Initial program 81.2%

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

      \[\leadsto \color{blue}{1 - e^{\frac{\log x}{n}}} \]
    4. Taylor expanded in n around inf 81.3%

      \[\leadsto 1 - \color{blue}{1} \]

    if 1.3499999999999999e74 < x < 5.19999999999999981e95

    1. Initial program 21.8%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Taylor expanded in n around inf 66.6%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 0.55:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 2.35 \cdot 10^{+43}:\\ \;\;\;\;\frac{1}{n} \cdot \frac{1}{x}\\ \mathbf{elif}\;x \leq 1.35 \cdot 10^{+74}:\\ \;\;\;\;0\\ \mathbf{elif}\;x \leq 5.2 \cdot 10^{+95}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 46.5% accurate, 14.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq -2.5 \cdot 10^{-8} \lor \neg \left(n \leq -7.5 \cdot 10^{-256}\right):\\ \;\;\;\;\frac{1}{n \cdot x}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (or (<= n -2.5e-8) (not (<= n -7.5e-256))) (/ 1.0 (* n x)) 0.0))
double code(double x, double n) {
	double tmp;
	if ((n <= -2.5e-8) || !(n <= -7.5e-256)) {
		tmp = 1.0 / (n * x);
	} else {
		tmp = 0.0;
	}
	return tmp;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    real(8) :: tmp
    if ((n <= (-2.5d-8)) .or. (.not. (n <= (-7.5d-256)))) then
        tmp = 1.0d0 / (n * x)
    else
        tmp = 0.0d0
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double tmp;
	if ((n <= -2.5e-8) || !(n <= -7.5e-256)) {
		tmp = 1.0 / (n * x);
	} else {
		tmp = 0.0;
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if (n <= -2.5e-8) or not (n <= -7.5e-256):
		tmp = 1.0 / (n * x)
	else:
		tmp = 0.0
	return tmp
function code(x, n)
	tmp = 0.0
	if ((n <= -2.5e-8) || !(n <= -7.5e-256))
		tmp = Float64(1.0 / Float64(n * x));
	else
		tmp = 0.0;
	end
	return tmp
end
function tmp_2 = code(x, n)
	tmp = 0.0;
	if ((n <= -2.5e-8) || ~((n <= -7.5e-256)))
		tmp = 1.0 / (n * x);
	else
		tmp = 0.0;
	end
	tmp_2 = tmp;
end
code[x_, n_] := If[Or[LessEqual[n, -2.5e-8], N[Not[LessEqual[n, -7.5e-256]], $MachinePrecision]], N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision], 0.0]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;n \leq -2.5 \cdot 10^{-8} \lor \neg \left(n \leq -7.5 \cdot 10^{-256}\right):\\
\;\;\;\;\frac{1}{n \cdot x}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if n < -2.4999999999999999e-8 or -7.50000000000000005e-256 < n

    1. Initial program 40.0%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Taylor expanded in n around inf 45.0%

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

    if -2.4999999999999999e-8 < n < -7.50000000000000005e-256

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{1 - e^{\frac{\log x}{n}}} \]
    4. Taylor expanded in n around inf 66.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -2.5 \cdot 10^{-8} \lor \neg \left(n \leq -7.5 \cdot 10^{-256}\right):\\ \;\;\;\;\frac{1}{n \cdot x}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 47.1% accurate, 17.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -200000000000:\\
\;\;\;\;0\\

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


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

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{1 - e^{\frac{\log x}{n}}} \]
    4. Taylor expanded in n around inf 64.5%

      \[\leadsto 1 - \color{blue}{1} \]

    if -2e11 < (/.f64 1 n)

    1. Initial program 36.7%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Taylor expanded in n around inf 44.6%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -200000000000:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 31.0% accurate, 211.0× speedup?

\[\begin{array}{l} \\ 0 \end{array} \]
(FPCore (x n) :precision binary64 0.0)
double code(double x, double n) {
	return 0.0;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    code = 0.0d0
end function
public static double code(double x, double n) {
	return 0.0;
}
def code(x, n):
	return 0.0
function code(x, n)
	return 0.0
end
function tmp = code(x, n)
	tmp = 0.0;
end
code[x_, n_] := 0.0
\begin{array}{l}

\\
0
\end{array}
Derivation
  1. Initial program 54.5%

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

    \[\leadsto \color{blue}{1 - e^{\frac{\log x}{n}}} \]
  4. Taylor expanded in n around inf 34.2%

    \[\leadsto 1 - \color{blue}{1} \]
  5. Final simplification34.2%

    \[\leadsto 0 \]
  6. Add Preprocessing

Reproduce

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