2nthrt (problem 3.4.6)

Percentage Accurate: 54.6% → 85.3%
Time: 40.2s
Alternatives: 11
Speedup: 1.9×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 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.6% accurate, 1.0× speedup?

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

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

Alternative 1: 85.3% accurate, 0.3× speedup?

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.99999999999999999e-55 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000002e-35

    1. Initial program 30.1%

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

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

        \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) + \left(0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n} - \log x\right)}{n}} \]

      if 2.00000000000000002e-35 < (/.f64 #s(literal 1 binary64) n)

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

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

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

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

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

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

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

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

    Alternative 2: 85.3% accurate, 0.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if -1.99999999999999999e-55 < (/.f64 #s(literal 1 binary64) n) < 2.00000000000000002e-35

      1. Initial program 30.1%

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

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

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

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

      if 2.00000000000000002e-35 < (/.f64 #s(literal 1 binary64) n)

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

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

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

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

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

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

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

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

    Alternative 3: 82.0% 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^{-55}:\\ \;\;\;\;\frac{t\_0}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{-7}:\\ \;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\left(1 + x \cdot \left(\frac{1}{n} + x \cdot \frac{\frac{0.5}{n} + -0.5}{n}\right)\right) - t\_0\\ \end{array} \end{array} \]
    (FPCore (x n)
     :precision binary64
     (let* ((t_0 (pow x (/ 1.0 n))))
       (if (<= (/ 1.0 n) -2e-55)
         (/ t_0 (* n x))
         (if (<= (/ 1.0 n) 1e-7)
           (/ (- (log1p x) (log x)) n)
           (- (+ 1.0 (* x (+ (/ 1.0 n) (* x (/ (+ (/ 0.5 n) -0.5) n))))) t_0)))))
    double code(double x, double n) {
    	double t_0 = pow(x, (1.0 / n));
    	double tmp;
    	if ((1.0 / n) <= -2e-55) {
    		tmp = t_0 / (n * x);
    	} else if ((1.0 / n) <= 1e-7) {
    		tmp = (log1p(x) - log(x)) / n;
    	} else {
    		tmp = (1.0 + (x * ((1.0 / n) + (x * (((0.5 / n) + -0.5) / n))))) - t_0;
    	}
    	return tmp;
    }
    
    public static double code(double x, double n) {
    	double t_0 = Math.pow(x, (1.0 / n));
    	double tmp;
    	if ((1.0 / n) <= -2e-55) {
    		tmp = t_0 / (n * x);
    	} else if ((1.0 / n) <= 1e-7) {
    		tmp = (Math.log1p(x) - Math.log(x)) / n;
    	} else {
    		tmp = (1.0 + (x * ((1.0 / n) + (x * (((0.5 / n) + -0.5) / n))))) - t_0;
    	}
    	return tmp;
    }
    
    def code(x, n):
    	t_0 = math.pow(x, (1.0 / n))
    	tmp = 0
    	if (1.0 / n) <= -2e-55:
    		tmp = t_0 / (n * x)
    	elif (1.0 / n) <= 1e-7:
    		tmp = (math.log1p(x) - math.log(x)) / n
    	else:
    		tmp = (1.0 + (x * ((1.0 / n) + (x * (((0.5 / n) + -0.5) / 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-55)
    		tmp = Float64(t_0 / Float64(n * x));
    	elseif (Float64(1.0 / n) <= 1e-7)
    		tmp = Float64(Float64(log1p(x) - log(x)) / n);
    	else
    		tmp = Float64(Float64(1.0 + Float64(x * Float64(Float64(1.0 / n) + Float64(x * Float64(Float64(Float64(0.5 / n) + -0.5) / n))))) - t_0);
    	end
    	return tmp
    end
    
    code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-55], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-7], N[(N[(N[Log[1 + x], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[(1.0 + N[(x * N[(N[(1.0 / n), $MachinePrecision] + N[(x * N[(N[(N[(0.5 / n), $MachinePrecision] + -0.5), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := {x}^{\left(\frac{1}{n}\right)}\\
    \mathbf{if}\;\frac{1}{n} \leq -2 \cdot 10^{-55}:\\
    \;\;\;\;\frac{t\_0}{n \cdot x}\\
    
    \mathbf{elif}\;\frac{1}{n} \leq 10^{-7}:\\
    \;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n}\\
    
    \mathbf{else}:\\
    \;\;\;\;\left(1 + x \cdot \left(\frac{1}{n} + x \cdot \frac{\frac{0.5}{n} + -0.5}{n}\right)\right) - t\_0\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if (/.f64 #s(literal 1 binary64) n) < -1.99999999999999999e-55

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

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

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

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

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

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

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

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

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

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

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

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

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

      if -1.99999999999999999e-55 < (/.f64 #s(literal 1 binary64) n) < 9.9999999999999995e-8

      1. Initial program 29.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 76.1%

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

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

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

      if 9.9999999999999995e-8 < (/.f64 #s(literal 1 binary64) n)

      1. Initial program 53.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 83.5%

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

        \[\leadsto \left(1 + x \cdot \left(x \cdot \color{blue}{\frac{0.5 \cdot \frac{1}{n} - 0.5}{n}} + \frac{1}{n}\right)\right) - {x}^{\left(\frac{1}{n}\right)} \]
      5. Step-by-step derivation
        1. sub-neg83.5%

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

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

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

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

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

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

    Alternative 4: 70.8% accurate, 1.0× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 5.2 \cdot 10^{-53}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x}{n}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\ \end{array} \end{array} \]
    (FPCore (x n)
     :precision binary64
     (if (<= x 5.2e-53)
       (/ (log x) (- n))
       (if (<= x 1.0) (log1p (expm1 (/ x n))) (/ (pow x (/ 1.0 n)) (* n x)))))
    double code(double x, double n) {
    	double tmp;
    	if (x <= 5.2e-53) {
    		tmp = log(x) / -n;
    	} else if (x <= 1.0) {
    		tmp = log1p(expm1((x / n)));
    	} else {
    		tmp = pow(x, (1.0 / n)) / (n * x);
    	}
    	return tmp;
    }
    
    public static double code(double x, double n) {
    	double tmp;
    	if (x <= 5.2e-53) {
    		tmp = Math.log(x) / -n;
    	} else if (x <= 1.0) {
    		tmp = Math.log1p(Math.expm1((x / n)));
    	} else {
    		tmp = Math.pow(x, (1.0 / n)) / (n * x);
    	}
    	return tmp;
    }
    
    def code(x, n):
    	tmp = 0
    	if x <= 5.2e-53:
    		tmp = math.log(x) / -n
    	elif x <= 1.0:
    		tmp = math.log1p(math.expm1((x / n)))
    	else:
    		tmp = math.pow(x, (1.0 / n)) / (n * x)
    	return tmp
    
    function code(x, n)
    	tmp = 0.0
    	if (x <= 5.2e-53)
    		tmp = Float64(log(x) / Float64(-n));
    	elseif (x <= 1.0)
    		tmp = log1p(expm1(Float64(x / n)));
    	else
    		tmp = Float64((x ^ Float64(1.0 / n)) / Float64(n * x));
    	end
    	return tmp
    end
    
    code[x_, n_] := If[LessEqual[x, 5.2e-53], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 1.0], N[Log[1 + N[(Exp[N[(x / n), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision], N[(N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;x \leq 5.2 \cdot 10^{-53}:\\
    \;\;\;\;\frac{\log x}{-n}\\
    
    \mathbf{elif}\;x \leq 1:\\
    \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x}{n}\right)\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if x < 5.19999999999999993e-53

      1. Initial program 38.9%

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

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

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

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

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

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

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

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

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

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

      if 5.19999999999999993e-53 < x < 1

      1. Initial program 36.0%

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

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

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

          \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x}{n}\right)\right)} \]
      6. Applied egg-rr70.0%

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

      if 1 < x

      1. Initial program 69.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 inf 98.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 5: 71.0% accurate, 1.8× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 0.78:\\ \;\;\;\;\frac{x \cdot \left(1 + x \cdot -0.5\right) - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\ \end{array} \end{array} \]
    (FPCore (x n)
     :precision binary64
     (if (<= x 0.78)
       (/ (- (* x (+ 1.0 (* x -0.5))) (log x)) n)
       (/ (pow x (/ 1.0 n)) (* n x))))
    double code(double x, double n) {
    	double tmp;
    	if (x <= 0.78) {
    		tmp = ((x * (1.0 + (x * -0.5))) - log(x)) / n;
    	} else {
    		tmp = pow(x, (1.0 / n)) / (n * x);
    	}
    	return tmp;
    }
    
    real(8) function code(x, n)
        real(8), intent (in) :: x
        real(8), intent (in) :: n
        real(8) :: tmp
        if (x <= 0.78d0) then
            tmp = ((x * (1.0d0 + (x * (-0.5d0)))) - log(x)) / n
        else
            tmp = (x ** (1.0d0 / n)) / (n * x)
        end if
        code = tmp
    end function
    
    public static double code(double x, double n) {
    	double tmp;
    	if (x <= 0.78) {
    		tmp = ((x * (1.0 + (x * -0.5))) - Math.log(x)) / n;
    	} else {
    		tmp = Math.pow(x, (1.0 / n)) / (n * x);
    	}
    	return tmp;
    }
    
    def code(x, n):
    	tmp = 0
    	if x <= 0.78:
    		tmp = ((x * (1.0 + (x * -0.5))) - math.log(x)) / n
    	else:
    		tmp = math.pow(x, (1.0 / n)) / (n * x)
    	return tmp
    
    function code(x, n)
    	tmp = 0.0
    	if (x <= 0.78)
    		tmp = Float64(Float64(Float64(x * Float64(1.0 + Float64(x * -0.5))) - log(x)) / n);
    	else
    		tmp = Float64((x ^ Float64(1.0 / n)) / Float64(n * x));
    	end
    	return tmp
    end
    
    function tmp_2 = code(x, n)
    	tmp = 0.0;
    	if (x <= 0.78)
    		tmp = ((x * (1.0 + (x * -0.5))) - log(x)) / n;
    	else
    		tmp = (x ^ (1.0 / n)) / (n * x);
    	end
    	tmp_2 = tmp;
    end
    
    code[x_, n_] := If[LessEqual[x, 0.78], N[(N[(N[(x * N[(1.0 + N[(x * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;x \leq 0.78:\\
    \;\;\;\;\frac{x \cdot \left(1 + x \cdot -0.5\right) - \log x}{n}\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if x < 0.78000000000000003

      1. Initial program 38.4%

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

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

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

          \[\leadsto \frac{x \cdot \left(1 + \color{blue}{x \cdot -0.5}\right) - \log x}{n} \]
      6. Simplified52.5%

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

      if 0.78000000000000003 < x

      1. Initial program 69.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 inf 98.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 6: 70.9% accurate, 1.9× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 0.78:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\ \end{array} \end{array} \]
    (FPCore (x n)
     :precision binary64
     (if (<= x 0.78) (/ (- x (log x)) n) (/ (pow x (/ 1.0 n)) (* n x))))
    double code(double x, double n) {
    	double tmp;
    	if (x <= 0.78) {
    		tmp = (x - log(x)) / n;
    	} else {
    		tmp = pow(x, (1.0 / n)) / (n * x);
    	}
    	return tmp;
    }
    
    real(8) function code(x, n)
        real(8), intent (in) :: x
        real(8), intent (in) :: n
        real(8) :: tmp
        if (x <= 0.78d0) then
            tmp = (x - log(x)) / n
        else
            tmp = (x ** (1.0d0 / n)) / (n * x)
        end if
        code = tmp
    end function
    
    public static double code(double x, double n) {
    	double tmp;
    	if (x <= 0.78) {
    		tmp = (x - Math.log(x)) / n;
    	} else {
    		tmp = Math.pow(x, (1.0 / n)) / (n * x);
    	}
    	return tmp;
    }
    
    def code(x, n):
    	tmp = 0
    	if x <= 0.78:
    		tmp = (x - math.log(x)) / n
    	else:
    		tmp = math.pow(x, (1.0 / n)) / (n * x)
    	return tmp
    
    function code(x, n)
    	tmp = 0.0
    	if (x <= 0.78)
    		tmp = Float64(Float64(x - log(x)) / n);
    	else
    		tmp = Float64((x ^ Float64(1.0 / n)) / Float64(n * x));
    	end
    	return tmp
    end
    
    function tmp_2 = code(x, n)
    	tmp = 0.0;
    	if (x <= 0.78)
    		tmp = (x - log(x)) / n;
    	else
    		tmp = (x ^ (1.0 / n)) / (n * x);
    	end
    	tmp_2 = tmp;
    end
    
    code[x_, n_] := If[LessEqual[x, 0.78], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    \mathbf{if}\;x \leq 0.78:\\
    \;\;\;\;\frac{x - \log x}{n}\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if x < 0.78000000000000003

      1. Initial program 38.4%

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

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

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

      if 0.78000000000000003 < x

      1. Initial program 69.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 inf 98.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

    Alternative 7: 56.4% accurate, 1.9× speedup?

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

      1. Initial program 37.9%

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

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

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

      if 0.76000000000000001 < x

      1. Initial program 69.8%

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

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

          \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) + \left(0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n} - \log x\right)}{n}} \]
        2. Taylor expanded in x around inf 59.1%

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

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

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

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

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

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

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

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

          \[\leadsto \frac{\color{blue}{\frac{1}{x}}}{n} \]
      5. Recombined 2 regimes into one program.
      6. Add Preprocessing

      Alternative 8: 56.1% accurate, 1.9× speedup?

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

        1. Initial program 37.9%

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

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

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

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

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

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

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

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

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

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

        if 0.55000000000000004 < x

        1. Initial program 69.8%

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

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

            \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) + \left(0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n} - \log x\right)}{n}} \]
          2. Taylor expanded in x around inf 59.1%

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

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

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

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

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

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

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

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

            \[\leadsto \frac{\color{blue}{\frac{1}{x}}}{n} \]
        5. Recombined 2 regimes into one program.
        6. Final simplification55.9%

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

        Alternative 9: 40.7% accurate, 42.2× speedup?

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

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

          \[\leadsto \color{blue}{\frac{\left(\log \left(1 + x\right) + 0.5 \cdot \frac{{\log \left(1 + x\right)}^{2}}{n}\right) - \left(\log x + 0.5 \cdot \frac{{\log x}^{2}}{n}\right)}{n}} \]
        4. Step-by-step derivation
          1. Simplified66.6%

            \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) + \left(0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n} - \log x\right)}{n}} \]
          2. Taylor expanded in x around inf 38.8%

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

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

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

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

              \[\leadsto \frac{\frac{1 + \left(-\color{blue}{-1 \cdot \frac{\log x}{n}}\right)}{x}}{n} \]
            5. mul-1-neg38.8%

              \[\leadsto \frac{\frac{1 + \left(-\color{blue}{\left(-\frac{\log x}{n}\right)}\right)}{x}}{n} \]
            6. remove-double-neg38.8%

              \[\leadsto \frac{\frac{1 + \color{blue}{\frac{\log x}{n}}}{x}}{n} \]
          4. Simplified38.8%

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

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

          Alternative 10: 40.2% 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 53.3%

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

            \[\leadsto \color{blue}{\frac{\left(\log \left(1 + x\right) + 0.5 \cdot \frac{{\log \left(1 + x\right)}^{2}}{n}\right) - \left(\log x + 0.5 \cdot \frac{{\log x}^{2}}{n}\right)}{n}} \]
          4. Step-by-step derivation
            1. Simplified66.6%

              \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) + \left(0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n} - \log x\right)}{n}} \]
            2. Taylor expanded in x around inf 38.8%

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

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

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

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

                \[\leadsto \frac{\frac{1 + \left(-\color{blue}{-1 \cdot \frac{\log x}{n}}\right)}{x}}{n} \]
              5. mul-1-neg38.8%

                \[\leadsto \frac{\frac{1 + \left(-\color{blue}{\left(-\frac{\log x}{n}\right)}\right)}{x}}{n} \]
              6. remove-double-neg38.8%

                \[\leadsto \frac{\frac{1 + \color{blue}{\frac{\log x}{n}}}{x}}{n} \]
            4. Simplified38.8%

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

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

            Alternative 11: 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 53.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 25.5%

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

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

            Reproduce

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