2nthrt (problem 3.4.6)

Percentage Accurate: 54.7% → 86.1%
Time: 17.6s
Alternatives: 13
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 13 alternatives:

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

Initial Program: 54.7% accurate, 1.0× speedup?

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

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

Alternative 1: 86.1% accurate, 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^{-18}:\\ \;\;\;\;\frac{t_0}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 5000:\\ \;\;\;\;-\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-18)
     (/ t_0 (* n x))
     (if (<= (/ 1.0 n) 5000.0)
       (- (/ (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-18) {
		tmp = t_0 / (n * x);
	} else if ((1.0 / n) <= 5000.0) {
		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-18)) then
        tmp = t_0 / (n * x)
    else if ((1.0d0 / n) <= 5000.0d0) 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-18) {
		tmp = t_0 / (n * x);
	} else if ((1.0 / n) <= 5000.0) {
		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-18:
		tmp = t_0 / (n * x)
	elif (1.0 / n) <= 5000.0:
		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-18)
		tmp = Float64(t_0 / Float64(n * x));
	elseif (Float64(1.0 / n) <= 5000.0)
		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-18)
		tmp = t_0 / (n * x);
	elseif ((1.0 / n) <= 5000.0)
		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-18], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5000.0], (-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^{-18}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\

\mathbf{elif}\;\frac{1}{n} \leq 5000:\\
\;\;\;\;-\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-18

    1. Initial program 96.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 0 96.3%

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

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

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

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

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

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

        \[\leadsto \frac{e^{-1 \cdot \color{blue}{\left(-1 \cdot \frac{\log x}{n}\right)}}}{n \cdot x} \]
      4. associate-*r*100.0%

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

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

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

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

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

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

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

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

    if -2.0000000000000001e-18 < (/.f64 1 n) < 5e3

    1. Initial program 28.4%

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

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

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

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

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

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

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

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

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

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

    if 5e3 < (/.f64 1 n)

    1. Initial program 54.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 0 54.0%

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

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

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

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

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

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

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

\mathbf{else}:\\
\;\;\;\;\sqrt{{\left(n \cdot x\right)}^{-2}}\\


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

    1. Initial program 96.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 0 96.3%

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

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

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

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

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

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

        \[\leadsto \frac{e^{-1 \cdot \color{blue}{\left(-1 \cdot \frac{\log x}{n}\right)}}}{n \cdot x} \]
      4. associate-*r*100.0%

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

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

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

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

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

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

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

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

    if -2.0000000000000001e-18 < (/.f64 1 n) < 5e3

    1. Initial program 28.4%

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

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

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

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

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

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

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

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

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

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

    if 5e3 < (/.f64 1 n) < 4.9999999999999998e195

    1. Initial program 79.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 79.8%

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

    if 4.9999999999999998e195 < (/.f64 1 n)

    1. Initial program 10.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 20.9%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{x \cdot n}} \]
    9. Step-by-step derivation
      1. add-sqr-sqrt86.6%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{x \cdot n}} \cdot \sqrt{\frac{1}{x \cdot n}}} \]
      2. sqrt-unprod93.1%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{x \cdot n} \cdot \frac{1}{x \cdot n}}} \]
      3. inv-pow93.1%

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

        \[\leadsto \sqrt{{\left(x \cdot n\right)}^{-1} \cdot \color{blue}{{\left(x \cdot n\right)}^{-1}}} \]
      5. pow-prod-up93.1%

        \[\leadsto \sqrt{\color{blue}{{\left(x \cdot n\right)}^{\left(-1 + -1\right)}}} \]
      6. metadata-eval93.1%

        \[\leadsto \sqrt{{\left(x \cdot n\right)}^{\color{blue}{-2}}} \]
    10. Applied egg-rr93.1%

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

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

Alternative 3: 66.9% accurate, 1.7× 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 -1 \cdot 10^{+251}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{1}{n} \leq -4:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\frac{1}{n} \leq 5000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+195}:\\ \;\;\;\;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) -1e+251)
     t_1
     (if (<= (/ 1.0 n) -4.0)
       t_0
       (if (<= (/ 1.0 n) 5000.0)
         t_1
         (if (<= (/ 1.0 n) 5e+195) 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) <= -1e+251) {
		tmp = t_1;
	} else if ((1.0 / n) <= -4.0) {
		tmp = t_0;
	} else if ((1.0 / n) <= 5000.0) {
		tmp = t_1;
	} else if ((1.0 / n) <= 5e+195) {
		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) <= (-1d+251)) then
        tmp = t_1
    else if ((1.0d0 / n) <= (-4.0d0)) then
        tmp = t_0
    else if ((1.0d0 / n) <= 5000.0d0) then
        tmp = t_1
    else if ((1.0d0 / n) <= 5d+195) 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) <= -1e+251) {
		tmp = t_1;
	} else if ((1.0 / n) <= -4.0) {
		tmp = t_0;
	} else if ((1.0 / n) <= 5000.0) {
		tmp = t_1;
	} else if ((1.0 / n) <= 5e+195) {
		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) <= -1e+251:
		tmp = t_1
	elif (1.0 / n) <= -4.0:
		tmp = t_0
	elif (1.0 / n) <= 5000.0:
		tmp = t_1
	elif (1.0 / n) <= 5e+195:
		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) <= -1e+251)
		tmp = t_1;
	elseif (Float64(1.0 / n) <= -4.0)
		tmp = t_0;
	elseif (Float64(1.0 / n) <= 5000.0)
		tmp = t_1;
	elseif (Float64(1.0 / n) <= 5e+195)
		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) <= -1e+251)
		tmp = t_1;
	elseif ((1.0 / n) <= -4.0)
		tmp = t_0;
	elseif ((1.0 / n) <= 5000.0)
		tmp = t_1;
	elseif ((1.0 / n) <= 5e+195)
		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], -1e+251], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], -4.0], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5000.0], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+195], 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 -1 \cdot 10^{+251}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;\frac{1}{n} \leq 5000:\\
\;\;\;\;t_1\\

\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+195}:\\
\;\;\;\;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) < -1e251 or -4 < (/.f64 1 n) < 5e3

    1. Initial program 34.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 76.6%

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

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

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

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

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

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

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

    if -1e251 < (/.f64 1 n) < -4 or 5e3 < (/.f64 1 n) < 4.9999999999999998e195

    1. Initial program 94.1%

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

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

    if 4.9999999999999998e195 < (/.f64 1 n)

    1. Initial program 10.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 20.9%

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

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

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

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

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

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

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

Alternative 4: 67.0% accurate, 1.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

    if -1e251 < (/.f64 1 n) < -4 or 5e3 < (/.f64 1 n) < 4.9999999999999998e195

    1. Initial program 94.1%

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

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

    if -4 < (/.f64 1 n) < 5e3

    1. Initial program 27.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 77.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 4.9999999999999998e195 < (/.f64 1 n)

    1. Initial program 10.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 20.9%

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

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

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

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

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

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

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+195}:\\
\;\;\;\;\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-18

    1. Initial program 96.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 0 96.3%

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

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

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

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

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

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

        \[\leadsto \frac{e^{-1 \cdot \color{blue}{\left(-1 \cdot \frac{\log x}{n}\right)}}}{n \cdot x} \]
      4. associate-*r*100.0%

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

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

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

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

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

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

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

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

    if -2.0000000000000001e-18 < (/.f64 1 n) < 5e3

    1. Initial program 28.4%

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

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

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

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

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

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

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

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

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

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

    if 5e3 < (/.f64 1 n) < 4.9999999999999998e195

    1. Initial program 79.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 79.8%

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

    if 4.9999999999999998e195 < (/.f64 1 n)

    1. Initial program 10.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 20.9%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-18}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 5000:\\ \;\;\;\;-\frac{\log \left(\frac{x}{1 + x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+195}:\\ \;\;\;\;\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.4% accurate, 1.8× speedup?

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

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

\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+195}:\\
\;\;\;\;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-18

    1. Initial program 96.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 0 96.3%

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

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

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

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

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

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

        \[\leadsto \frac{e^{-1 \cdot \color{blue}{\left(-1 \cdot \frac{\log x}{n}\right)}}}{n \cdot x} \]
      4. associate-*r*100.0%

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

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

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

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

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

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

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

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

    if -2.0000000000000001e-18 < (/.f64 1 n) < 5e3

    1. Initial program 28.4%

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

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

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

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

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

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

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

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

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

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

    if 5e3 < (/.f64 1 n) < 4.9999999999999998e195

    1. Initial program 79.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 79.6%

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

    if 4.9999999999999998e195 < (/.f64 1 n)

    1. Initial program 10.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 20.9%

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

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

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

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

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

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

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

Alternative 7: 59.0% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{if}\;x \leq 7.5 \cdot 10^{-227}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.6 \cdot 10^{-208}:\\ \;\;\;\;\log x \cdot \frac{-1}{n}\\ \mathbf{elif}\;x \leq 5.5 \cdot 10^{-173}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.8 \cdot 10^{-38}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 2.3 \cdot 10^{-25}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{elif}\;x \leq 2.6 \cdot 10^{+128}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{0}{n}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (- 1.0 (pow x (/ 1.0 n)))))
   (if (<= x 7.5e-227)
     t_0
     (if (<= x 2.6e-208)
       (* (log x) (/ -1.0 n))
       (if (<= x 5.5e-173)
         t_0
         (if (<= x 2.8e-38)
           (/ (- (log x)) n)
           (if (<= x 2.3e-25)
             t_0
             (if (<= x 1.0)
               (/ (- x (log x)) n)
               (if (<= x 2.6e+128) (/ (/ 1.0 n) x) (/ 0.0 n))))))))))
double code(double x, double n) {
	double t_0 = 1.0 - pow(x, (1.0 / n));
	double tmp;
	if (x <= 7.5e-227) {
		tmp = t_0;
	} else if (x <= 2.6e-208) {
		tmp = log(x) * (-1.0 / n);
	} else if (x <= 5.5e-173) {
		tmp = t_0;
	} else if (x <= 2.8e-38) {
		tmp = -log(x) / n;
	} else if (x <= 2.3e-25) {
		tmp = t_0;
	} else if (x <= 1.0) {
		tmp = (x - log(x)) / n;
	} else if (x <= 2.6e+128) {
		tmp = (1.0 / n) / x;
	} else {
		tmp = 0.0 / 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 = 1.0d0 - (x ** (1.0d0 / n))
    if (x <= 7.5d-227) then
        tmp = t_0
    else if (x <= 2.6d-208) then
        tmp = log(x) * ((-1.0d0) / n)
    else if (x <= 5.5d-173) then
        tmp = t_0
    else if (x <= 2.8d-38) then
        tmp = -log(x) / n
    else if (x <= 2.3d-25) then
        tmp = t_0
    else if (x <= 1.0d0) then
        tmp = (x - log(x)) / n
    else if (x <= 2.6d+128) then
        tmp = (1.0d0 / n) / x
    else
        tmp = 0.0d0 / n
    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 <= 7.5e-227) {
		tmp = t_0;
	} else if (x <= 2.6e-208) {
		tmp = Math.log(x) * (-1.0 / n);
	} else if (x <= 5.5e-173) {
		tmp = t_0;
	} else if (x <= 2.8e-38) {
		tmp = -Math.log(x) / n;
	} else if (x <= 2.3e-25) {
		tmp = t_0;
	} else if (x <= 1.0) {
		tmp = (x - Math.log(x)) / n;
	} else if (x <= 2.6e+128) {
		tmp = (1.0 / n) / x;
	} else {
		tmp = 0.0 / n;
	}
	return tmp;
}
def code(x, n):
	t_0 = 1.0 - math.pow(x, (1.0 / n))
	tmp = 0
	if x <= 7.5e-227:
		tmp = t_0
	elif x <= 2.6e-208:
		tmp = math.log(x) * (-1.0 / n)
	elif x <= 5.5e-173:
		tmp = t_0
	elif x <= 2.8e-38:
		tmp = -math.log(x) / n
	elif x <= 2.3e-25:
		tmp = t_0
	elif x <= 1.0:
		tmp = (x - math.log(x)) / n
	elif x <= 2.6e+128:
		tmp = (1.0 / n) / x
	else:
		tmp = 0.0 / n
	return tmp
function code(x, n)
	t_0 = Float64(1.0 - (x ^ Float64(1.0 / n)))
	tmp = 0.0
	if (x <= 7.5e-227)
		tmp = t_0;
	elseif (x <= 2.6e-208)
		tmp = Float64(log(x) * Float64(-1.0 / n));
	elseif (x <= 5.5e-173)
		tmp = t_0;
	elseif (x <= 2.8e-38)
		tmp = Float64(Float64(-log(x)) / n);
	elseif (x <= 2.3e-25)
		tmp = t_0;
	elseif (x <= 1.0)
		tmp = Float64(Float64(x - log(x)) / n);
	elseif (x <= 2.6e+128)
		tmp = Float64(Float64(1.0 / n) / x);
	else
		tmp = Float64(0.0 / n);
	end
	return tmp
end
function tmp_2 = code(x, n)
	t_0 = 1.0 - (x ^ (1.0 / n));
	tmp = 0.0;
	if (x <= 7.5e-227)
		tmp = t_0;
	elseif (x <= 2.6e-208)
		tmp = log(x) * (-1.0 / n);
	elseif (x <= 5.5e-173)
		tmp = t_0;
	elseif (x <= 2.8e-38)
		tmp = -log(x) / n;
	elseif (x <= 2.3e-25)
		tmp = t_0;
	elseif (x <= 1.0)
		tmp = (x - log(x)) / n;
	elseif (x <= 2.6e+128)
		tmp = (1.0 / n) / x;
	else
		tmp = 0.0 / n;
	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, 7.5e-227], t$95$0, If[LessEqual[x, 2.6e-208], N[(N[Log[x], $MachinePrecision] * N[(-1.0 / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.5e-173], t$95$0, If[LessEqual[x, 2.8e-38], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 2.3e-25], t$95$0, If[LessEqual[x, 1.0], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 2.6e+128], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], N[(0.0 / n), $MachinePrecision]]]]]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;x \leq 5.5 \cdot 10^{-173}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;x \leq 2.3 \cdot 10^{-25}:\\
\;\;\;\;t_0\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 6 regimes
  2. if x < 7.49999999999999988e-227 or 2.60000000000000017e-208 < x < 5.50000000000000022e-173 or 2.8e-38 < x < 2.2999999999999999e-25

    1. Initial program 60.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 60.2%

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

    if 7.49999999999999988e-227 < x < 2.60000000000000017e-208

    1. Initial program 21.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 21.7%

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

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

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

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

      \[\leadsto \color{blue}{\frac{-\log x}{n}} \]
    7. Step-by-step derivation
      1. frac-2neg77.0%

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

        \[\leadsto \color{blue}{\left(-\left(-\log x\right)\right) \cdot \frac{1}{-n}} \]
      3. remove-double-neg77.2%

        \[\leadsto \color{blue}{\log x} \cdot \frac{1}{-n} \]
      4. metadata-eval77.2%

        \[\leadsto \log x \cdot \frac{\color{blue}{-1 \cdot -1}}{-n} \]
      5. associate-*l/77.2%

        \[\leadsto \log x \cdot \color{blue}{\left(\frac{-1}{-n} \cdot -1\right)} \]
      6. metadata-eval77.2%

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

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

        \[\leadsto \log x \cdot \color{blue}{\frac{1 \cdot -1}{n}} \]
      9. metadata-eval77.2%

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

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

    if 5.50000000000000022e-173 < x < 2.8e-38

    1. Initial program 28.8%

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

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

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

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

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

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

    if 2.2999999999999999e-25 < x < 1

    1. Initial program 43.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 44.0%

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

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

    if 1 < x < 2.6e128

    1. Initial program 32.1%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{e^{\frac{\log x}{n}}}{x}}{n}} \]
      2. div-inv95.0%

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

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

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

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

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

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

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

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

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

    if 2.6e128 < x

    1. Initial program 83.2%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 7.5 \cdot 10^{-227}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 2.6 \cdot 10^{-208}:\\ \;\;\;\;\log x \cdot \frac{-1}{n}\\ \mathbf{elif}\;x \leq 5.5 \cdot 10^{-173}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 2.8 \cdot 10^{-38}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 2.3 \cdot 10^{-25}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{elif}\;x \leq 2.6 \cdot 10^{+128}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{0}{n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 59.9% accurate, 2.0× speedup?

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

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

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

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


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

    1. Initial program 45.3%

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

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

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

    if 1 < x < 3.7999999999999999e128

    1. Initial program 32.1%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{e^{\frac{\log x}{n}}}{x}}{n}} \]
      2. div-inv95.0%

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

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

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

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

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

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

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

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

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

    if 3.7999999999999999e128 < x

    1. Initial program 83.2%

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

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

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

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

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

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

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

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

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

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

Alternative 9: 59.6% accurate, 2.0× speedup?

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

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

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

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


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

    1. Initial program 45.3%

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

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

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

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

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

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

    if 0.55000000000000004 < x < 3.10000000000000004e128

    1. Initial program 32.1%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{e^{\frac{\log x}{n}}}{x}}{n}} \]
      2. div-inv95.0%

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

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

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

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

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

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

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

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

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

    if 3.10000000000000004e128 < x

    1. Initial program 83.2%

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

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

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

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

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

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

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

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

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

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

Alternative 10: 44.7% accurate, 29.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.8 \cdot 10^{+128}:\\
\;\;\;\;\frac{\frac{1}{n}}{x}\\

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


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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{e^{\frac{\log x}{n}}}{x}}{n}} \]
      2. div-inv44.2%

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

        \[\leadsto \frac{e^{\color{blue}{\log x \cdot \frac{1}{n}}}}{x} \cdot \frac{1}{n} \]
      4. pow-to-exp44.2%

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

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

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

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

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

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

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

    if 2.79999999999999983e128 < x

    1. Initial program 83.2%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 2.8 \cdot 10^{+128}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{0}{n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 40.4% 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 52.6%

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{x \cdot n}} \]
  8. Simplified41.4%

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

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

Alternative 12: 40.9% 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 52.6%

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{e^{\color{blue}{\log x \cdot \frac{1}{n}}}}{x} \cdot \frac{1}{n} \]
    4. pow-to-exp57.7%

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

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

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

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

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

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

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

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

Alternative 13: 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 52.6%

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

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

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

    \[\leadsto \color{blue}{\frac{x}{n}} \]
  6. Final simplification4.5%

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

Reproduce

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