2nthrt (problem 3.4.6)

Percentage Accurate: 53.4% → 90.9%
Time: 39.9s
Alternatives: 24
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 24 alternatives:

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

Initial Program: 53.4% accurate, 1.0× speedup?

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

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

Alternative 1: 90.9% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 330:\\ \;\;\;\;\frac{\log \left(\frac{x}{e^{\mathsf{log1p}\left(x\right) + \frac{\mathsf{fma}\left(0.5, {\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}, 0.16666666666666666 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}}{n}\right)}{n}}}\right)}{-n}\\ \mathbf{else}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{x \cdot n}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= x 330.0)
   (/
    (log
     (/
      x
      (exp
       (+
        (log1p x)
        (/
         (fma
          0.5
          (- (pow (log1p x) 2.0) (pow (log x) 2.0))
          (*
           0.16666666666666666
           (/ (- (pow (log1p x) 3.0) (pow (log x) 3.0)) n)))
         n)))))
    (- n))
   (/ (pow x (/ 1.0 n)) (* x n))))
double code(double x, double n) {
	double tmp;
	if (x <= 330.0) {
		tmp = log((x / exp((log1p(x) + (fma(0.5, (pow(log1p(x), 2.0) - pow(log(x), 2.0)), (0.16666666666666666 * ((pow(log1p(x), 3.0) - pow(log(x), 3.0)) / n))) / n))))) / -n;
	} else {
		tmp = pow(x, (1.0 / n)) / (x * n);
	}
	return tmp;
}
function code(x, n)
	tmp = 0.0
	if (x <= 330.0)
		tmp = Float64(log(Float64(x / exp(Float64(log1p(x) + Float64(fma(0.5, Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0)), Float64(0.16666666666666666 * Float64(Float64((log1p(x) ^ 3.0) - (log(x) ^ 3.0)) / n))) / n))))) / Float64(-n));
	else
		tmp = Float64((x ^ Float64(1.0 / n)) / Float64(x * n));
	end
	return tmp
end
code[x_, n_] := If[LessEqual[x, 330.0], N[(N[Log[N[(x / N[Exp[N[(N[Log[1 + x], $MachinePrecision] + N[(N[(0.5 * N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[(0.16666666666666666 * N[(N[(N[Power[N[Log[1 + x], $MachinePrecision], 3.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision], N[(N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 330:\\
\;\;\;\;\frac{\log \left(\frac{x}{e^{\mathsf{log1p}\left(x\right) + \frac{\mathsf{fma}\left(0.5, {\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}, 0.16666666666666666 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}}{n}\right)}{n}}}\right)}{-n}\\

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


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

    1. Initial program 48.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 74.9%

      \[\leadsto \color{blue}{-1 \cdot \frac{\left(-1 \cdot \log \left(1 + x\right) + -1 \cdot \frac{\left(-1 \cdot \frac{-0.16666666666666666 \cdot {\log \left(1 + x\right)}^{3} - -0.16666666666666666 \cdot {\log x}^{3}}{n} + 0.5 \cdot {\log \left(1 + x\right)}^{2}\right) - 0.5 \cdot {\log x}^{2}}{n}\right) - -1 \cdot \log x}{n}} \]
    4. Simplified74.9%

      \[\leadsto \color{blue}{\frac{\log x - \left(\mathsf{log1p}\left(x\right) + \frac{0.5 \cdot \left({\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}\right) + 0.16666666666666666 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}}{n}}{n}\right)}{-n}} \]
    5. Step-by-step derivation
      1. add-log-exp83.2%

        \[\leadsto \frac{\log x - \color{blue}{\log \left(e^{\mathsf{log1p}\left(x\right) + \frac{0.5 \cdot \left({\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}\right) + 0.16666666666666666 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}}{n}}{n}}\right)}}{-n} \]
      2. diff-log83.2%

        \[\leadsto \frac{\color{blue}{\log \left(\frac{x}{e^{\mathsf{log1p}\left(x\right) + \frac{0.5 \cdot \left({\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}\right) + 0.16666666666666666 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}}{n}}{n}}}\right)}}{-n} \]
      3. fma-define83.2%

        \[\leadsto \frac{\log \left(\frac{x}{e^{\mathsf{log1p}\left(x\right) + \frac{\color{blue}{\mathsf{fma}\left(0.5, {\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}, 0.16666666666666666 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}}{n}\right)}}{n}}}\right)}{-n} \]
    6. Applied egg-rr83.2%

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

    if 330 < x

    1. Initial program 68.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 98.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-neg98.5%

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 85.5% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{if}\;{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - t\_0 \leq 2 \cdot 10^{-8}:\\ \;\;\;\;\frac{\log \left(\frac{\sqrt{e^{\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}} \cdot \left(x + 1\right)}{x}\right)}{n}\\ \mathbf{else}:\\ \;\;\;\;e^{x \cdot \left(\frac{1}{n} + -0.5 \cdot \frac{x}{n}\right)} - t\_0\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (pow x (/ 1.0 n))))
   (if (<= (- (pow (+ x 1.0) (/ 1.0 n)) t_0) 2e-8)
     (/
      (log
       (/
        (*
         (sqrt (exp (/ (- (pow (log1p x) 2.0) (pow (log x) 2.0)) n)))
         (+ x 1.0))
        x))
      n)
     (- (exp (* x (+ (/ 1.0 n) (* -0.5 (/ x n))))) t_0))))
double code(double x, double n) {
	double t_0 = pow(x, (1.0 / n));
	double tmp;
	if ((pow((x + 1.0), (1.0 / n)) - t_0) <= 2e-8) {
		tmp = log(((sqrt(exp(((pow(log1p(x), 2.0) - pow(log(x), 2.0)) / n))) * (x + 1.0)) / x)) / n;
	} else {
		tmp = exp((x * ((1.0 / n) + (-0.5 * (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 ((Math.pow((x + 1.0), (1.0 / n)) - t_0) <= 2e-8) {
		tmp = Math.log(((Math.sqrt(Math.exp(((Math.pow(Math.log1p(x), 2.0) - Math.pow(Math.log(x), 2.0)) / n))) * (x + 1.0)) / x)) / n;
	} else {
		tmp = Math.exp((x * ((1.0 / n) + (-0.5 * (x / n))))) - t_0;
	}
	return tmp;
}
def code(x, n):
	t_0 = math.pow(x, (1.0 / n))
	tmp = 0
	if (math.pow((x + 1.0), (1.0 / n)) - t_0) <= 2e-8:
		tmp = math.log(((math.sqrt(math.exp(((math.pow(math.log1p(x), 2.0) - math.pow(math.log(x), 2.0)) / n))) * (x + 1.0)) / x)) / n
	else:
		tmp = math.exp((x * ((1.0 / n) + (-0.5 * (x / n))))) - t_0
	return tmp
function code(x, n)
	t_0 = x ^ Float64(1.0 / n)
	tmp = 0.0
	if (Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - t_0) <= 2e-8)
		tmp = Float64(log(Float64(Float64(sqrt(exp(Float64(Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0)) / n))) * Float64(x + 1.0)) / x)) / n);
	else
		tmp = Float64(exp(Float64(x * Float64(Float64(1.0 / n) + Float64(-0.5 * Float64(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[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision], 2e-8], N[(N[Log[N[(N[(N[Sqrt[N[Exp[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]], $MachinePrecision] * N[(x + 1.0), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(x * N[(N[(1.0 / n), $MachinePrecision] + N[(-0.5 * N[(x / 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}\;{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - t\_0 \leq 2 \cdot 10^{-8}:\\
\;\;\;\;\frac{\log \left(\frac{\sqrt{e^{\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}} \cdot \left(x + 1\right)}{x}\right)}{n}\\

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


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

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

      \[\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. associate--l+62.2%

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

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

        \[\leadsto \frac{\mathsf{log1p}\left(x\right) + \left(0.5 \cdot \frac{{\log \left(1 + x\right)}^{2}}{n} - \color{blue}{\left(0.5 \cdot \frac{{\log x}^{2}}{n} + \log x\right)}\right)}{n} \]
      4. associate--r+77.1%

        \[\leadsto \frac{\mathsf{log1p}\left(x\right) + \color{blue}{\left(\left(0.5 \cdot \frac{{\log \left(1 + x\right)}^{2}}{n} - 0.5 \cdot \frac{{\log x}^{2}}{n}\right) - \log x\right)}}{n} \]
      5. distribute-lft-out--77.1%

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

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

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

      \[\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}} \]
    6. Step-by-step derivation
      1. add-log-exp85.5%

        \[\leadsto \frac{\color{blue}{\log \left(e^{\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)}\right)}}{n} \]
      2. associate-+r-85.5%

        \[\leadsto \frac{\log \left(e^{\color{blue}{\left(\mathsf{log1p}\left(x\right) + 0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}\right) - \log x}}\right)}{n} \]
      3. exp-diff85.5%

        \[\leadsto \frac{\log \color{blue}{\left(\frac{e^{\mathsf{log1p}\left(x\right) + 0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}}{e^{\log x}}\right)}}{n} \]
      4. add-exp-log57.3%

        \[\leadsto \frac{\log \left(\frac{e^{\mathsf{log1p}\left(x\right) + 0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}}{\color{blue}{x}}\right)}{n} \]
    7. Applied egg-rr57.3%

      \[\leadsto \frac{\color{blue}{\log \left(\frac{e^{\mathsf{log1p}\left(x\right) + 0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}}{x}\right)}}{n} \]
    8. Step-by-step derivation
      1. +-commutative57.3%

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

        \[\leadsto \frac{\log \left(\frac{\color{blue}{e^{0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}} \cdot e^{\mathsf{log1p}\left(x\right)}}}{x}\right)}{n} \]
      3. *-commutative57.3%

        \[\leadsto \frac{\log \left(\frac{e^{\color{blue}{\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n} \cdot 0.5}} \cdot e^{\mathsf{log1p}\left(x\right)}}{x}\right)}{n} \]
      4. exp-prod57.3%

        \[\leadsto \frac{\log \left(\frac{\color{blue}{{\left(e^{\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}\right)}^{0.5}} \cdot e^{\mathsf{log1p}\left(x\right)}}{x}\right)}{n} \]
      5. unpow1/257.3%

        \[\leadsto \frac{\log \left(\frac{\color{blue}{\sqrt{e^{\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}}} \cdot e^{\mathsf{log1p}\left(x\right)}}{x}\right)}{n} \]
      6. log1p-define57.3%

        \[\leadsto \frac{\log \left(\frac{\sqrt{e^{\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}} \cdot e^{\color{blue}{\log \left(1 + x\right)}}}{x}\right)}{n} \]
      7. rem-exp-log85.6%

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

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

    if 2e-8 < (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n)))

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

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

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

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

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

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

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

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

Alternative 3: 86.1% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -40:\\ \;\;\;\;{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {\left({\left(\sqrt[3]{x}\right)}^{2}\right)}^{\left(\frac{1}{n}\right)} \cdot {\left(\sqrt[3]{x}\right)}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-11}:\\ \;\;\;\;\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^{x \cdot \left(\frac{1}{n} + -0.5 \cdot \frac{x}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= (/ 1.0 n) -40.0)
   (-
    (pow (+ x 1.0) (/ 1.0 n))
    (* (pow (pow (cbrt x) 2.0) (/ 1.0 n)) (pow (cbrt x) (/ 1.0 n))))
   (if (<= (/ 1.0 n) 5e-11)
     (/
      (+
       (log1p x)
       (- (* 0.5 (/ (- (pow (log1p x) 2.0) (pow (log x) 2.0)) n)) (log x)))
      n)
     (- (exp (* x (+ (/ 1.0 n) (* -0.5 (/ x n))))) (pow x (/ 1.0 n))))))
double code(double x, double n) {
	double tmp;
	if ((1.0 / n) <= -40.0) {
		tmp = pow((x + 1.0), (1.0 / n)) - (pow(pow(cbrt(x), 2.0), (1.0 / n)) * pow(cbrt(x), (1.0 / n)));
	} else if ((1.0 / n) <= 5e-11) {
		tmp = (log1p(x) + ((0.5 * ((pow(log1p(x), 2.0) - pow(log(x), 2.0)) / n)) - log(x))) / n;
	} else {
		tmp = exp((x * ((1.0 / n) + (-0.5 * (x / n))))) - pow(x, (1.0 / n));
	}
	return tmp;
}
public static double code(double x, double n) {
	double tmp;
	if ((1.0 / n) <= -40.0) {
		tmp = Math.pow((x + 1.0), (1.0 / n)) - (Math.pow(Math.pow(Math.cbrt(x), 2.0), (1.0 / n)) * Math.pow(Math.cbrt(x), (1.0 / n)));
	} else if ((1.0 / n) <= 5e-11) {
		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((x * ((1.0 / n) + (-0.5 * (x / n))))) - Math.pow(x, (1.0 / n));
	}
	return tmp;
}
function code(x, n)
	tmp = 0.0
	if (Float64(1.0 / n) <= -40.0)
		tmp = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - Float64(((cbrt(x) ^ 2.0) ^ Float64(1.0 / n)) * (cbrt(x) ^ Float64(1.0 / n))));
	elseif (Float64(1.0 / n) <= 5e-11)
		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(x * Float64(Float64(1.0 / n) + Float64(-0.5 * Float64(x / n))))) - (x ^ Float64(1.0 / n)));
	end
	return tmp
end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -40.0], N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - N[(N[Power[N[Power[N[Power[x, 1/3], $MachinePrecision], 2.0], $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] * N[Power[N[Power[x, 1/3], $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-11], 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[(x * N[(N[(1.0 / n), $MachinePrecision] + N[(-0.5 * N[(x / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -40:\\
\;\;\;\;{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {\left({\left(\sqrt[3]{x}\right)}^{2}\right)}^{\left(\frac{1}{n}\right)} \cdot {\left(\sqrt[3]{x}\right)}^{\left(\frac{1}{n}\right)}\\

\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-11}:\\
\;\;\;\;\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^{x \cdot \left(\frac{1}{n} + -0.5 \cdot \frac{x}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\\


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

    1. Initial program 99.9%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-cube-cbrt99.9%

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

        \[\leadsto {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - \color{blue}{{\left(\sqrt[3]{x} \cdot \sqrt[3]{x}\right)}^{\left(\frac{1}{n}\right)} \cdot {\left(\sqrt[3]{x}\right)}^{\left(\frac{1}{n}\right)}} \]
      3. pow2100.0%

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

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

    if -40 < (/.f64 #s(literal 1 binary64) n) < 5.00000000000000018e-11

    1. Initial program 27.5%

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

      \[\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. associate--l+78.9%

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

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

        \[\leadsto \frac{\mathsf{log1p}\left(x\right) + \left(0.5 \cdot \frac{{\log \left(1 + x\right)}^{2}}{n} - \color{blue}{\left(0.5 \cdot \frac{{\log x}^{2}}{n} + \log x\right)}\right)}{n} \]
      4. associate--r+78.9%

        \[\leadsto \frac{\mathsf{log1p}\left(x\right) + \color{blue}{\left(\left(0.5 \cdot \frac{{\log \left(1 + x\right)}^{2}}{n} - 0.5 \cdot \frac{{\log x}^{2}}{n}\right) - \log x\right)}}{n} \]
      5. distribute-lft-out--78.9%

        \[\leadsto \frac{\mathsf{log1p}\left(x\right) + \left(\color{blue}{0.5 \cdot \left(\frac{{\log \left(1 + x\right)}^{2}}{n} - \frac{{\log x}^{2}}{n}\right)} - \log x\right)}{n} \]
      6. div-sub78.9%

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

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

      \[\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 5.00000000000000018e-11 < (/.f64 #s(literal 1 binary64) n)

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

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

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

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

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

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

      \[\leadsto e^{\color{blue}{x \cdot \left(-0.5 \cdot \frac{x}{n} + \frac{1}{n}\right)}} - {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 -40:\\ \;\;\;\;{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {\left({\left(\sqrt[3]{x}\right)}^{2}\right)}^{\left(\frac{1}{n}\right)} \cdot {\left(\sqrt[3]{x}\right)}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-11}:\\ \;\;\;\;\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^{x \cdot \left(\frac{1}{n} + -0.5 \cdot \frac{x}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 86.1% accurate, 0.3× speedup?

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

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

\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-11}:\\
\;\;\;\;\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^{x \cdot \left(\frac{1}{n} + -0.5 \cdot \frac{x}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\\


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

    1. Initial program 99.9%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt99.9%

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

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

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

    if -40 < (/.f64 #s(literal 1 binary64) n) < 5.00000000000000018e-11

    1. Initial program 27.5%

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

      \[\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. associate--l+78.9%

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

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

        \[\leadsto \frac{\mathsf{log1p}\left(x\right) + \left(0.5 \cdot \frac{{\log \left(1 + x\right)}^{2}}{n} - \color{blue}{\left(0.5 \cdot \frac{{\log x}^{2}}{n} + \log x\right)}\right)}{n} \]
      4. associate--r+78.9%

        \[\leadsto \frac{\mathsf{log1p}\left(x\right) + \color{blue}{\left(\left(0.5 \cdot \frac{{\log \left(1 + x\right)}^{2}}{n} - 0.5 \cdot \frac{{\log x}^{2}}{n}\right) - \log x\right)}}{n} \]
      5. distribute-lft-out--78.9%

        \[\leadsto \frac{\mathsf{log1p}\left(x\right) + \left(\color{blue}{0.5 \cdot \left(\frac{{\log \left(1 + x\right)}^{2}}{n} - \frac{{\log x}^{2}}{n}\right)} - \log x\right)}{n} \]
      6. div-sub78.9%

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

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

      \[\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 5.00000000000000018e-11 < (/.f64 #s(literal 1 binary64) n)

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

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

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

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

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

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

      \[\leadsto e^{\color{blue}{x \cdot \left(-0.5 \cdot \frac{x}{n} + \frac{1}{n}\right)}} - {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 -40:\\ \;\;\;\;{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {\left(\sqrt{x}\right)}^{\left(\frac{1}{n}\right)} \cdot {\left(\sqrt{x}\right)}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-11}:\\ \;\;\;\;\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^{x \cdot \left(\frac{1}{n} + -0.5 \cdot \frac{x}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 86.2% accurate, 0.5× speedup?

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

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

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

\mathbf{else}:\\
\;\;\;\;\log \left(e^{e^{x \cdot \left(\frac{1}{n} + -0.5 \cdot \frac{x}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}}\right)\\


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

    1. Initial program 99.2%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt99.3%

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

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

      \[\leadsto {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - \color{blue}{{\left(\sqrt{x}\right)}^{\left(\frac{1}{n}\right)} \cdot {\left(\sqrt{x}\right)}^{\left(\frac{1}{n}\right)}} \]
    5. Step-by-step derivation
      1. pow-sqr99.3%

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

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

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

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

    if -1.99999999999999996e-12 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999997e-12

    1. Initial program 26.5%

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

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

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

        \[\leadsto \frac{\mathsf{log1p}\left(x\right) + \left(0.5 \cdot \frac{{\log \left(1 + x\right)}^{2}}{n} - \color{blue}{\left(0.5 \cdot \frac{{\log x}^{2}}{n} + \log x\right)}\right)}{n} \]
      4. associate--r+78.6%

        \[\leadsto \frac{\mathsf{log1p}\left(x\right) + \color{blue}{\left(\left(0.5 \cdot \frac{{\log \left(1 + x\right)}^{2}}{n} - 0.5 \cdot \frac{{\log x}^{2}}{n}\right) - \log x\right)}}{n} \]
      5. distribute-lft-out--78.6%

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

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

        \[\leadsto \frac{\mathsf{log1p}\left(x\right) + \left(0.5 \cdot \frac{{\color{blue}{\left(\mathsf{log1p}\left(x\right)\right)}}^{2} - {\log x}^{2}}{n} - \log x\right)}{n} \]
    5. Simplified78.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}} \]
    6. Step-by-step derivation
      1. add-log-exp78.6%

        \[\leadsto \frac{\color{blue}{\log \left(e^{\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)}\right)}}{n} \]
      2. associate-+r-78.6%

        \[\leadsto \frac{\log \left(e^{\color{blue}{\left(\mathsf{log1p}\left(x\right) + 0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}\right) - \log x}}\right)}{n} \]
      3. exp-diff78.5%

        \[\leadsto \frac{\log \color{blue}{\left(\frac{e^{\mathsf{log1p}\left(x\right) + 0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}}{e^{\log x}}\right)}}{n} \]
      4. add-exp-log58.8%

        \[\leadsto \frac{\log \left(\frac{e^{\mathsf{log1p}\left(x\right) + 0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}}{\color{blue}{x}}\right)}{n} \]
    7. Applied egg-rr58.8%

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

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

        \[\leadsto \frac{\log \left(\frac{\color{blue}{e^{0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}} \cdot e^{\mathsf{log1p}\left(x\right)}}}{x}\right)}{n} \]
      3. *-commutative58.8%

        \[\leadsto \frac{\log \left(\frac{e^{\color{blue}{\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n} \cdot 0.5}} \cdot e^{\mathsf{log1p}\left(x\right)}}{x}\right)}{n} \]
      4. exp-prod58.8%

        \[\leadsto \frac{\log \left(\frac{\color{blue}{{\left(e^{\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}\right)}^{0.5}} \cdot e^{\mathsf{log1p}\left(x\right)}}{x}\right)}{n} \]
      5. unpow1/258.8%

        \[\leadsto \frac{\log \left(\frac{\color{blue}{\sqrt{e^{\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}}} \cdot e^{\mathsf{log1p}\left(x\right)}}{x}\right)}{n} \]
      6. log1p-define58.8%

        \[\leadsto \frac{\log \left(\frac{\sqrt{e^{\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}} \cdot e^{\color{blue}{\log \left(1 + x\right)}}}{x}\right)}{n} \]
      7. rem-exp-log78.6%

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

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

      \[\leadsto \frac{\log \color{blue}{\left(1 + \left(-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n \cdot x} + \frac{1}{x}\right)\right)}}{n} \]
    11. Step-by-step derivation
      1. associate-+r+78.4%

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

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

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

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

        \[\leadsto \frac{\log \left(\left(1 + \frac{-\frac{\color{blue}{-\log x}}{n}}{x}\right) + \frac{1}{x}\right)}{n} \]
      6. distribute-neg-frac78.4%

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

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

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

    if 4.9999999999999997e-12 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 71.0%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-log-exp71.2%

        \[\leadsto \color{blue}{\log \left(e^{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)}}\right)} \]
      2. pow-to-exp71.2%

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

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

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

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

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

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

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

Alternative 6: 86.3% accurate, 0.7× speedup?

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

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

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

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


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

    1. Initial program 99.2%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt99.3%

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

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

      \[\leadsto {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - \color{blue}{{\left(\sqrt{x}\right)}^{\left(\frac{1}{n}\right)} \cdot {\left(\sqrt{x}\right)}^{\left(\frac{1}{n}\right)}} \]
    5. Step-by-step derivation
      1. pow-sqr99.3%

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

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

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

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

    if -1.99999999999999996e-12 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999997e-12

    1. Initial program 26.5%

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

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

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

        \[\leadsto \frac{\mathsf{log1p}\left(x\right) + \left(0.5 \cdot \frac{{\log \left(1 + x\right)}^{2}}{n} - \color{blue}{\left(0.5 \cdot \frac{{\log x}^{2}}{n} + \log x\right)}\right)}{n} \]
      4. associate--r+78.6%

        \[\leadsto \frac{\mathsf{log1p}\left(x\right) + \color{blue}{\left(\left(0.5 \cdot \frac{{\log \left(1 + x\right)}^{2}}{n} - 0.5 \cdot \frac{{\log x}^{2}}{n}\right) - \log x\right)}}{n} \]
      5. distribute-lft-out--78.6%

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

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

        \[\leadsto \frac{\mathsf{log1p}\left(x\right) + \left(0.5 \cdot \frac{{\color{blue}{\left(\mathsf{log1p}\left(x\right)\right)}}^{2} - {\log x}^{2}}{n} - \log x\right)}{n} \]
    5. Simplified78.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}} \]
    6. Step-by-step derivation
      1. add-log-exp78.6%

        \[\leadsto \frac{\color{blue}{\log \left(e^{\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)}\right)}}{n} \]
      2. associate-+r-78.6%

        \[\leadsto \frac{\log \left(e^{\color{blue}{\left(\mathsf{log1p}\left(x\right) + 0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}\right) - \log x}}\right)}{n} \]
      3. exp-diff78.5%

        \[\leadsto \frac{\log \color{blue}{\left(\frac{e^{\mathsf{log1p}\left(x\right) + 0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}}{e^{\log x}}\right)}}{n} \]
      4. add-exp-log58.8%

        \[\leadsto \frac{\log \left(\frac{e^{\mathsf{log1p}\left(x\right) + 0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}}{\color{blue}{x}}\right)}{n} \]
    7. Applied egg-rr58.8%

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

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

        \[\leadsto \frac{\log \left(\frac{\color{blue}{e^{0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}} \cdot e^{\mathsf{log1p}\left(x\right)}}}{x}\right)}{n} \]
      3. *-commutative58.8%

        \[\leadsto \frac{\log \left(\frac{e^{\color{blue}{\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n} \cdot 0.5}} \cdot e^{\mathsf{log1p}\left(x\right)}}{x}\right)}{n} \]
      4. exp-prod58.8%

        \[\leadsto \frac{\log \left(\frac{\color{blue}{{\left(e^{\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}\right)}^{0.5}} \cdot e^{\mathsf{log1p}\left(x\right)}}{x}\right)}{n} \]
      5. unpow1/258.8%

        \[\leadsto \frac{\log \left(\frac{\color{blue}{\sqrt{e^{\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}}} \cdot e^{\mathsf{log1p}\left(x\right)}}{x}\right)}{n} \]
      6. log1p-define58.8%

        \[\leadsto \frac{\log \left(\frac{\sqrt{e^{\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}} \cdot e^{\color{blue}{\log \left(1 + x\right)}}}{x}\right)}{n} \]
      7. rem-exp-log78.6%

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

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

      \[\leadsto \frac{\log \color{blue}{\left(1 + \left(-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n \cdot x} + \frac{1}{x}\right)\right)}}{n} \]
    11. Step-by-step derivation
      1. associate-+r+78.4%

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

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

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

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

        \[\leadsto \frac{\log \left(\left(1 + \frac{-\frac{\color{blue}{-\log x}}{n}}{x}\right) + \frac{1}{x}\right)}{n} \]
      6. distribute-neg-frac78.4%

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

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

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

    if 4.9999999999999997e-12 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 71.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 71.0%

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

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

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

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

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

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

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

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

Alternative 7: 86.3% accurate, 0.9× speedup?

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

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

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


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

    1. Initial program 99.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 99.3%

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

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

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

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

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

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

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

    if -1.99999999999999996e-12 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999997e-12

    1. Initial program 26.5%

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

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

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

        \[\leadsto \frac{\mathsf{log1p}\left(x\right) + \left(0.5 \cdot \frac{{\log \left(1 + x\right)}^{2}}{n} - \color{blue}{\left(0.5 \cdot \frac{{\log x}^{2}}{n} + \log x\right)}\right)}{n} \]
      4. associate--r+78.6%

        \[\leadsto \frac{\mathsf{log1p}\left(x\right) + \color{blue}{\left(\left(0.5 \cdot \frac{{\log \left(1 + x\right)}^{2}}{n} - 0.5 \cdot \frac{{\log x}^{2}}{n}\right) - \log x\right)}}{n} \]
      5. distribute-lft-out--78.6%

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

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

        \[\leadsto \frac{\mathsf{log1p}\left(x\right) + \left(0.5 \cdot \frac{{\color{blue}{\left(\mathsf{log1p}\left(x\right)\right)}}^{2} - {\log x}^{2}}{n} - \log x\right)}{n} \]
    5. Simplified78.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}} \]
    6. Step-by-step derivation
      1. add-log-exp78.6%

        \[\leadsto \frac{\color{blue}{\log \left(e^{\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)}\right)}}{n} \]
      2. associate-+r-78.6%

        \[\leadsto \frac{\log \left(e^{\color{blue}{\left(\mathsf{log1p}\left(x\right) + 0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}\right) - \log x}}\right)}{n} \]
      3. exp-diff78.5%

        \[\leadsto \frac{\log \color{blue}{\left(\frac{e^{\mathsf{log1p}\left(x\right) + 0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}}{e^{\log x}}\right)}}{n} \]
      4. add-exp-log58.8%

        \[\leadsto \frac{\log \left(\frac{e^{\mathsf{log1p}\left(x\right) + 0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}}{\color{blue}{x}}\right)}{n} \]
    7. Applied egg-rr58.8%

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

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

        \[\leadsto \frac{\log \left(\frac{\color{blue}{e^{0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}} \cdot e^{\mathsf{log1p}\left(x\right)}}}{x}\right)}{n} \]
      3. *-commutative58.8%

        \[\leadsto \frac{\log \left(\frac{e^{\color{blue}{\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n} \cdot 0.5}} \cdot e^{\mathsf{log1p}\left(x\right)}}{x}\right)}{n} \]
      4. exp-prod58.8%

        \[\leadsto \frac{\log \left(\frac{\color{blue}{{\left(e^{\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}\right)}^{0.5}} \cdot e^{\mathsf{log1p}\left(x\right)}}{x}\right)}{n} \]
      5. unpow1/258.8%

        \[\leadsto \frac{\log \left(\frac{\color{blue}{\sqrt{e^{\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}}} \cdot e^{\mathsf{log1p}\left(x\right)}}{x}\right)}{n} \]
      6. log1p-define58.8%

        \[\leadsto \frac{\log \left(\frac{\sqrt{e^{\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}} \cdot e^{\color{blue}{\log \left(1 + x\right)}}}{x}\right)}{n} \]
      7. rem-exp-log78.6%

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

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

      \[\leadsto \frac{\log \color{blue}{\left(1 + \left(-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n \cdot x} + \frac{1}{x}\right)\right)}}{n} \]
    11. Step-by-step derivation
      1. associate-+r+78.4%

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

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

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

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

        \[\leadsto \frac{\log \left(\left(1 + \frac{-\frac{\color{blue}{-\log x}}{n}}{x}\right) + \frac{1}{x}\right)}{n} \]
      6. distribute-neg-frac78.4%

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

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

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

    if 4.9999999999999997e-12 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 71.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 71.0%

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

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

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

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

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

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

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

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

Alternative 8: 82.3% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{if}\;\frac{1}{n} \leq -40:\\ \;\;\;\;\frac{t\_0}{x \cdot n}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-14}:\\ \;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+178}:\\ \;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\ \mathbf{else}:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x}{n}\right)\right)\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (pow x (/ 1.0 n))))
   (if (<= (/ 1.0 n) -40.0)
     (/ t_0 (* x n))
     (if (<= (/ 1.0 n) 2e-14)
       (/ (log (/ (+ x 1.0) x)) n)
       (if (<= (/ 1.0 n) 5e+178)
         (- (+ 1.0 (/ x n)) t_0)
         (log1p (expm1 (/ x n))))))))
double code(double x, double n) {
	double t_0 = pow(x, (1.0 / n));
	double tmp;
	if ((1.0 / n) <= -40.0) {
		tmp = t_0 / (x * n);
	} else if ((1.0 / n) <= 2e-14) {
		tmp = log(((x + 1.0) / x)) / n;
	} else if ((1.0 / n) <= 5e+178) {
		tmp = (1.0 + (x / n)) - t_0;
	} else {
		tmp = log1p(expm1((x / n)));
	}
	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) <= -40.0) {
		tmp = t_0 / (x * n);
	} else if ((1.0 / n) <= 2e-14) {
		tmp = Math.log(((x + 1.0) / x)) / n;
	} else if ((1.0 / n) <= 5e+178) {
		tmp = (1.0 + (x / n)) - t_0;
	} else {
		tmp = Math.log1p(Math.expm1((x / n)));
	}
	return tmp;
}
def code(x, n):
	t_0 = math.pow(x, (1.0 / n))
	tmp = 0
	if (1.0 / n) <= -40.0:
		tmp = t_0 / (x * n)
	elif (1.0 / n) <= 2e-14:
		tmp = math.log(((x + 1.0) / x)) / n
	elif (1.0 / n) <= 5e+178:
		tmp = (1.0 + (x / n)) - t_0
	else:
		tmp = math.log1p(math.expm1((x / n)))
	return tmp
function code(x, n)
	t_0 = x ^ Float64(1.0 / n)
	tmp = 0.0
	if (Float64(1.0 / n) <= -40.0)
		tmp = Float64(t_0 / Float64(x * n));
	elseif (Float64(1.0 / n) <= 2e-14)
		tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n);
	elseif (Float64(1.0 / n) <= 5e+178)
		tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0);
	else
		tmp = log1p(expm1(Float64(x / n)));
	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], -40.0], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-14], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+178], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[Log[1 + N[(Exp[N[(x / n), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}

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

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

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

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


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

    1. Initial program 99.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 inf 98.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2e-14 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999999e178

    1. Initial program 82.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 77.0%

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

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

    1. Initial program 31.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 6.7%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{x \cdot n}} \]
    9. Step-by-step derivation
      1. log1p-expm1-u73.6%

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

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\frac{\frac{1}{x}}{n}}\right)\right) \]
      3. add-exp-log73.6%

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

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{\color{blue}{e^{-\log x}}}{n}\right)\right) \]
      5. add-sqr-sqrt73.6%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{e^{\color{blue}{\sqrt{-\log x} \cdot \sqrt{-\log x}}}}{n}\right)\right) \]
      6. sqrt-unprod73.6%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{e^{\color{blue}{\sqrt{\left(-\log x\right) \cdot \left(-\log x\right)}}}}{n}\right)\right) \]
      7. sqr-neg73.6%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{e^{\sqrt{\color{blue}{\log x \cdot \log x}}}}{n}\right)\right) \]
      8. sqrt-prod0.0%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{e^{\color{blue}{\sqrt{\log x} \cdot \sqrt{\log x}}}}{n}\right)\right) \]
      9. add-sqr-sqrt75.7%

        \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{e^{\color{blue}{\log x}}}{n}\right)\right) \]
      10. add-exp-log75.7%

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

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

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

Alternative 9: 86.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq -380000000000 \lor \neg \left(n \leq 23000000000\right):\\ \;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\ \mathbf{else}:\\ \;\;\;\;e^{\frac{x}{n}} - {x}^{\left(\frac{1}{n}\right)}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (or (<= n -380000000000.0) (not (<= n 23000000000.0)))
   (/ (log (/ (+ x 1.0) x)) n)
   (- (exp (/ x n)) (pow x (/ 1.0 n)))))
double code(double x, double n) {
	double tmp;
	if ((n <= -380000000000.0) || !(n <= 23000000000.0)) {
		tmp = log(((x + 1.0) / x)) / n;
	} else {
		tmp = exp((x / n)) - pow(x, (1.0 / n));
	}
	return tmp;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    real(8) :: tmp
    if ((n <= (-380000000000.0d0)) .or. (.not. (n <= 23000000000.0d0))) then
        tmp = log(((x + 1.0d0) / x)) / n
    else
        tmp = exp((x / n)) - (x ** (1.0d0 / n))
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double tmp;
	if ((n <= -380000000000.0) || !(n <= 23000000000.0)) {
		tmp = Math.log(((x + 1.0) / x)) / n;
	} else {
		tmp = Math.exp((x / n)) - Math.pow(x, (1.0 / n));
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if (n <= -380000000000.0) or not (n <= 23000000000.0):
		tmp = math.log(((x + 1.0) / x)) / n
	else:
		tmp = math.exp((x / n)) - math.pow(x, (1.0 / n))
	return tmp
function code(x, n)
	tmp = 0.0
	if ((n <= -380000000000.0) || !(n <= 23000000000.0))
		tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n);
	else
		tmp = Float64(exp(Float64(x / n)) - (x ^ Float64(1.0 / n)));
	end
	return tmp
end
function tmp_2 = code(x, n)
	tmp = 0.0;
	if ((n <= -380000000000.0) || ~((n <= 23000000000.0)))
		tmp = log(((x + 1.0) / x)) / n;
	else
		tmp = exp((x / n)) - (x ^ (1.0 / n));
	end
	tmp_2 = tmp;
end
code[x_, n_] := If[Or[LessEqual[n, -380000000000.0], N[Not[LessEqual[n, 23000000000.0]], $MachinePrecision]], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if n < -3.8e11 or 2.3e10 < n

    1. Initial program 26.5%

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

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

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

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

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

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

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

    if -3.8e11 < n < 2.3e10

    1. Initial program 89.6%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -380000000000 \lor \neg \left(n \leq 23000000000\right):\\ \;\;\;\;\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 10: 86.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq -380000000000:\\ \;\;\;\;\frac{\log \left(\left(1 + \frac{\frac{\log x}{n}}{x}\right) + \frac{1}{x}\right)}{n}\\ \mathbf{elif}\;n \leq 26000000000:\\ \;\;\;\;e^{\frac{x}{n}} - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= n -380000000000.0)
   (/ (log (+ (+ 1.0 (/ (/ (log x) n) x)) (/ 1.0 x))) n)
   (if (<= n 26000000000.0)
     (- (exp (/ x n)) (pow x (/ 1.0 n)))
     (/ (log (/ (+ x 1.0) x)) n))))
double code(double x, double n) {
	double tmp;
	if (n <= -380000000000.0) {
		tmp = log(((1.0 + ((log(x) / n) / x)) + (1.0 / x))) / n;
	} else if (n <= 26000000000.0) {
		tmp = exp((x / n)) - pow(x, (1.0 / n));
	} else {
		tmp = log(((x + 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 (n <= (-380000000000.0d0)) then
        tmp = log(((1.0d0 + ((log(x) / n) / x)) + (1.0d0 / x))) / n
    else if (n <= 26000000000.0d0) then
        tmp = exp((x / n)) - (x ** (1.0d0 / n))
    else
        tmp = log(((x + 1.0d0) / x)) / n
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double tmp;
	if (n <= -380000000000.0) {
		tmp = Math.log(((1.0 + ((Math.log(x) / n) / x)) + (1.0 / x))) / n;
	} else if (n <= 26000000000.0) {
		tmp = Math.exp((x / n)) - Math.pow(x, (1.0 / n));
	} else {
		tmp = Math.log(((x + 1.0) / x)) / n;
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if n <= -380000000000.0:
		tmp = math.log(((1.0 + ((math.log(x) / n) / x)) + (1.0 / x))) / n
	elif n <= 26000000000.0:
		tmp = math.exp((x / n)) - math.pow(x, (1.0 / n))
	else:
		tmp = math.log(((x + 1.0) / x)) / n
	return tmp
function code(x, n)
	tmp = 0.0
	if (n <= -380000000000.0)
		tmp = Float64(log(Float64(Float64(1.0 + Float64(Float64(log(x) / n) / x)) + Float64(1.0 / x))) / n);
	elseif (n <= 26000000000.0)
		tmp = Float64(exp(Float64(x / n)) - (x ^ Float64(1.0 / n)));
	else
		tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n);
	end
	return tmp
end
function tmp_2 = code(x, n)
	tmp = 0.0;
	if (n <= -380000000000.0)
		tmp = log(((1.0 + ((log(x) / n) / x)) + (1.0 / x))) / n;
	elseif (n <= 26000000000.0)
		tmp = exp((x / n)) - (x ^ (1.0 / n));
	else
		tmp = log(((x + 1.0) / x)) / n;
	end
	tmp_2 = tmp;
end
code[x_, n_] := If[LessEqual[n, -380000000000.0], N[(N[Log[N[(N[(1.0 + N[(N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[n, 26000000000.0], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]]]
\begin{array}{l}

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if n < -3.8e11

    1. Initial program 34.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 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. associate--l+76.7%

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

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

        \[\leadsto \frac{\mathsf{log1p}\left(x\right) + \left(0.5 \cdot \frac{{\log \left(1 + x\right)}^{2}}{n} - \color{blue}{\left(0.5 \cdot \frac{{\log x}^{2}}{n} + \log x\right)}\right)}{n} \]
      4. associate--r+76.7%

        \[\leadsto \frac{\mathsf{log1p}\left(x\right) + \color{blue}{\left(\left(0.5 \cdot \frac{{\log \left(1 + x\right)}^{2}}{n} - 0.5 \cdot \frac{{\log x}^{2}}{n}\right) - \log x\right)}}{n} \]
      5. distribute-lft-out--76.7%

        \[\leadsto \frac{\mathsf{log1p}\left(x\right) + \left(\color{blue}{0.5 \cdot \left(\frac{{\log \left(1 + x\right)}^{2}}{n} - \frac{{\log x}^{2}}{n}\right)} - \log x\right)}{n} \]
      6. div-sub76.7%

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

        \[\leadsto \frac{\mathsf{log1p}\left(x\right) + \left(0.5 \cdot \frac{{\color{blue}{\left(\mathsf{log1p}\left(x\right)\right)}}^{2} - {\log x}^{2}}{n} - \log x\right)}{n} \]
    5. 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}} \]
    6. Step-by-step derivation
      1. add-log-exp76.7%

        \[\leadsto \frac{\color{blue}{\log \left(e^{\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)}\right)}}{n} \]
      2. associate-+r-76.7%

        \[\leadsto \frac{\log \left(e^{\color{blue}{\left(\mathsf{log1p}\left(x\right) + 0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}\right) - \log x}}\right)}{n} \]
      3. exp-diff76.7%

        \[\leadsto \frac{\log \color{blue}{\left(\frac{e^{\mathsf{log1p}\left(x\right) + 0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}}{e^{\log x}}\right)}}{n} \]
      4. add-exp-log49.2%

        \[\leadsto \frac{\log \left(\frac{e^{\mathsf{log1p}\left(x\right) + 0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}}{\color{blue}{x}}\right)}{n} \]
    7. Applied egg-rr49.2%

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

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

        \[\leadsto \frac{\log \left(\frac{\color{blue}{e^{0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}} \cdot e^{\mathsf{log1p}\left(x\right)}}}{x}\right)}{n} \]
      3. *-commutative49.2%

        \[\leadsto \frac{\log \left(\frac{e^{\color{blue}{\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n} \cdot 0.5}} \cdot e^{\mathsf{log1p}\left(x\right)}}{x}\right)}{n} \]
      4. exp-prod49.2%

        \[\leadsto \frac{\log \left(\frac{\color{blue}{{\left(e^{\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}\right)}^{0.5}} \cdot e^{\mathsf{log1p}\left(x\right)}}{x}\right)}{n} \]
      5. unpow1/249.2%

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

        \[\leadsto \frac{\log \left(\frac{\sqrt{e^{\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}} \cdot e^{\color{blue}{\log \left(1 + x\right)}}}{x}\right)}{n} \]
      7. rem-exp-log76.9%

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

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

      \[\leadsto \frac{\log \color{blue}{\left(1 + \left(-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n \cdot x} + \frac{1}{x}\right)\right)}}{n} \]
    11. Step-by-step derivation
      1. associate-+r+76.4%

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

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

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

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

        \[\leadsto \frac{\log \left(\left(1 + \frac{-\frac{\color{blue}{-\log x}}{n}}{x}\right) + \frac{1}{x}\right)}{n} \]
      6. distribute-neg-frac76.4%

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

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

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

    if -3.8e11 < n < 2.6e10

    1. Initial program 89.6%

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

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

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

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

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

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

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

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

    if 2.6e10 < n

    1. Initial program 20.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 80.0%

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

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

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

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

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

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

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

Alternative 11: 81.3% accurate, 1.6× speedup?

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

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

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

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

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


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

    1. Initial program 99.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 inf 98.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2e-14 < (/.f64 #s(literal 1 binary64) n) < 1.9999999999999999e214

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

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

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

    1. Initial program 6.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 8.2%

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{1}{n}}{x}} \]
    9. Simplified83.9%

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

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

Alternative 12: 81.9% accurate, 1.7× speedup?

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

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

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

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

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


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

    1. Initial program 99.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 inf 98.9%

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

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

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

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

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

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

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

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

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

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

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

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

    if -40 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999997e-12

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

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

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

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

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

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

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

    if 4.9999999999999997e-12 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999999e178

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

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

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

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

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

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

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

    1. Initial program 31.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 6.7%

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

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

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

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

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

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

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

        \[\leadsto \frac{-\mathsf{log1p}\left(\color{blue}{e^{\log x} - 1}\right)}{n} \]
      3. add-exp-log65.0%

        \[\leadsto \frac{-\mathsf{log1p}\left(\color{blue}{x} - 1\right)}{n} \]
    10. Applied egg-rr65.0%

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

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

Alternative 13: 74.6% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -4000000000000:\\ \;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-12}:\\ \;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{+178}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{log1p}\left(x + -1\right)}{-n}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= (/ 1.0 n) -4000000000000.0)
   (/ 0.3333333333333333 (* n (pow x 3.0)))
   (if (<= (/ 1.0 n) 5e-12)
     (/ (log (/ (+ x 1.0) x)) n)
     (if (<= (/ 1.0 n) 5e+178)
       (- 1.0 (pow x (/ 1.0 n)))
       (/ (log1p (+ x -1.0)) (- n))))))
double code(double x, double n) {
	double tmp;
	if ((1.0 / n) <= -4000000000000.0) {
		tmp = 0.3333333333333333 / (n * pow(x, 3.0));
	} else if ((1.0 / n) <= 5e-12) {
		tmp = log(((x + 1.0) / x)) / n;
	} else if ((1.0 / n) <= 5e+178) {
		tmp = 1.0 - pow(x, (1.0 / n));
	} else {
		tmp = log1p((x + -1.0)) / -n;
	}
	return tmp;
}
public static double code(double x, double n) {
	double tmp;
	if ((1.0 / n) <= -4000000000000.0) {
		tmp = 0.3333333333333333 / (n * Math.pow(x, 3.0));
	} else if ((1.0 / n) <= 5e-12) {
		tmp = Math.log(((x + 1.0) / x)) / n;
	} else if ((1.0 / n) <= 5e+178) {
		tmp = 1.0 - Math.pow(x, (1.0 / n));
	} else {
		tmp = Math.log1p((x + -1.0)) / -n;
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if (1.0 / n) <= -4000000000000.0:
		tmp = 0.3333333333333333 / (n * math.pow(x, 3.0))
	elif (1.0 / n) <= 5e-12:
		tmp = math.log(((x + 1.0) / x)) / n
	elif (1.0 / n) <= 5e+178:
		tmp = 1.0 - math.pow(x, (1.0 / n))
	else:
		tmp = math.log1p((x + -1.0)) / -n
	return tmp
function code(x, n)
	tmp = 0.0
	if (Float64(1.0 / n) <= -4000000000000.0)
		tmp = Float64(0.3333333333333333 / Float64(n * (x ^ 3.0)));
	elseif (Float64(1.0 / n) <= 5e-12)
		tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n);
	elseif (Float64(1.0 / n) <= 5e+178)
		tmp = Float64(1.0 - (x ^ Float64(1.0 / n)));
	else
		tmp = Float64(log1p(Float64(x + -1.0)) / Float64(-n));
	end
	return tmp
end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -4000000000000.0], N[(0.3333333333333333 / N[(n * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-12], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e+178], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Log[1 + N[(x + -1.0), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -4000000000000:\\
\;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\

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

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

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


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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{0.3333333333333333}{n \cdot {x}^{3}}} \]

    if -4e12 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999997e-12

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

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

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

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

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

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

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

    if 4.9999999999999997e-12 < (/.f64 #s(literal 1 binary64) n) < 4.9999999999999999e178

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

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

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

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

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

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

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

    1. Initial program 31.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 6.7%

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

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

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

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

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

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

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

        \[\leadsto \frac{-\mathsf{log1p}\left(\color{blue}{e^{\log x} - 1}\right)}{n} \]
      3. add-exp-log65.0%

        \[\leadsto \frac{-\mathsf{log1p}\left(\color{blue}{x} - 1\right)}{n} \]
    10. Applied egg-rr65.0%

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

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

Alternative 14: 60.2% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{x - \log x}{n}\\
\mathbf{if}\;n \leq -1.15 \cdot 10^{+89}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{-0.5 + \frac{0.3333333333333333}{x}}{x \cdot n}}{x}\\

\mathbf{elif}\;n \leq -1.58:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;n \leq 7.6 \cdot 10^{-215}:\\
\;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if n < -1.1499999999999999e89

    1. Initial program 44.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-define78.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. Taylor expanded in x around -inf 65.4%

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

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

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

    if -1.1499999999999999e89 < n < -1.5800000000000001 or 3.5e10 < n

    1. Initial program 19.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 77.6%

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

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

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

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

    if -1.5800000000000001 < n < 7.59999999999999954e-215

    1. Initial program 93.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 45.6%

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

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

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

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

      \[\leadsto \color{blue}{\frac{0.3333333333333333}{n \cdot {x}^{3}}} \]

    if 7.59999999999999954e-215 < n < 3.5e10

    1. Initial program 82.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.8%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -1.15 \cdot 10^{+89}:\\ \;\;\;\;\frac{\frac{1}{n} + \frac{-0.5 + \frac{0.3333333333333333}{x}}{x \cdot n}}{x}\\ \mathbf{elif}\;n \leq -1.58:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{elif}\;n \leq 7.6 \cdot 10^{-215}:\\ \;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\ \mathbf{elif}\;n \leq 35000000000:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{x - \log x}{n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 60.1% accurate, 1.7× speedup?

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

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

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

\mathbf{elif}\;x \leq 1.8 \cdot 10^{-154}:\\
\;\;\;\;t\_0\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if x < 6.49999999999999981e-276 or 4.3500000000000003e-240 < x < 1.8000000000000001e-154

    1. Initial program 63.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 63.9%

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

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

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

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

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

    if 6.49999999999999981e-276 < x < 4.3500000000000003e-240

    1. Initial program 33.6%

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

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

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

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

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

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

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

    if 1.8000000000000001e-154 < x < 0.73999999999999999

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

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

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

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

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

    if 0.73999999999999999 < x < 3.1000000000000002e165

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1 + -1 \cdot \frac{0.5 - 0.3333333333333333 \cdot \frac{1}{x}}{x}}{n \cdot x}} \]
    8. Step-by-step derivation
      1. mul-1-neg70.7%

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

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

        \[\leadsto \frac{1 - \frac{0.5 - \color{blue}{\frac{0.3333333333333333 \cdot 1}{x}}}{x}}{n \cdot x} \]
      4. metadata-eval70.7%

        \[\leadsto \frac{1 - \frac{0.5 - \frac{\color{blue}{0.3333333333333333}}{x}}{x}}{n \cdot x} \]
      5. *-commutative70.7%

        \[\leadsto \frac{1 - \frac{0.5 - \frac{0.3333333333333333}{x}}{x}}{\color{blue}{x \cdot n}} \]
    9. Simplified70.7%

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

    if 3.1000000000000002e165 < x

    1. Initial program 95.9%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-log-exp95.9%

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

        \[\leadsto \log \left(e^{\color{blue}{e^{\log \left(x + 1\right) \cdot \frac{1}{n}}} - {x}^{\left(\frac{1}{n}\right)}}\right) \]
      3. un-div-inv95.9%

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

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

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

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

      \[\leadsto \log \color{blue}{1} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification68.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 6.5 \cdot 10^{-276}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 4.35 \cdot 10^{-240}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 1.8 \cdot 10^{-154}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 0.74:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{elif}\;x \leq 3.1 \cdot 10^{+165}:\\ \;\;\;\;\frac{1 + \frac{\frac{0.3333333333333333}{x} - 0.5}{x}}{x \cdot n}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 16: 60.6% accurate, 1.9× speedup?

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

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

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

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


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

    1. Initial program 48.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 51.4%

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

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

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

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

    if 0.73999999999999999 < x < 5.4999999999999998e165

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1 + -1 \cdot \frac{0.5 - 0.3333333333333333 \cdot \frac{1}{x}}{x}}{n \cdot x}} \]
    8. Step-by-step derivation
      1. mul-1-neg70.7%

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

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

        \[\leadsto \frac{1 - \frac{0.5 - \color{blue}{\frac{0.3333333333333333 \cdot 1}{x}}}{x}}{n \cdot x} \]
      4. metadata-eval70.7%

        \[\leadsto \frac{1 - \frac{0.5 - \frac{\color{blue}{0.3333333333333333}}{x}}{x}}{n \cdot x} \]
      5. *-commutative70.7%

        \[\leadsto \frac{1 - \frac{0.5 - \frac{0.3333333333333333}{x}}{x}}{\color{blue}{x \cdot n}} \]
    9. Simplified70.7%

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

    if 5.4999999999999998e165 < x

    1. Initial program 95.9%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-log-exp95.9%

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

        \[\leadsto \log \left(e^{\color{blue}{e^{\log \left(x + 1\right) \cdot \frac{1}{n}}} - {x}^{\left(\frac{1}{n}\right)}}\right) \]
      3. un-div-inv95.9%

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

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

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

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

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

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

Alternative 17: 60.3% accurate, 1.9× speedup?

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

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

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

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


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

    1. Initial program 48.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 51.4%

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

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

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

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

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

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

    if 0.599999999999999978 < x < 3.54999999999999988e165

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1 + -1 \cdot \frac{0.5 - 0.3333333333333333 \cdot \frac{1}{x}}{x}}{n \cdot x}} \]
    8. Step-by-step derivation
      1. mul-1-neg70.7%

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

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

        \[\leadsto \frac{1 - \frac{0.5 - \color{blue}{\frac{0.3333333333333333 \cdot 1}{x}}}{x}}{n \cdot x} \]
      4. metadata-eval70.7%

        \[\leadsto \frac{1 - \frac{0.5 - \frac{\color{blue}{0.3333333333333333}}{x}}{x}}{n \cdot x} \]
      5. *-commutative70.7%

        \[\leadsto \frac{1 - \frac{0.5 - \frac{0.3333333333333333}{x}}{x}}{\color{blue}{x \cdot n}} \]
    9. Simplified70.7%

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

    if 3.54999999999999988e165 < x

    1. Initial program 95.9%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-log-exp95.9%

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

        \[\leadsto \log \left(e^{\color{blue}{e^{\log \left(x + 1\right) \cdot \frac{1}{n}}} - {x}^{\left(\frac{1}{n}\right)}}\right) \]
      3. un-div-inv95.9%

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

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

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

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

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

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

Alternative 18: 49.6% accurate, 11.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.2 \cdot 10^{+166}:\\
\;\;\;\;\frac{1 + \frac{\frac{0.3333333333333333}{x} - 0.5}{x}}{x \cdot n}\\

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


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

    1. Initial program 49.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 51.1%

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

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

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

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

      \[\leadsto \color{blue}{\frac{1 + -1 \cdot \frac{0.5 - 0.3333333333333333 \cdot \frac{1}{x}}{x}}{n \cdot x}} \]
    8. Step-by-step derivation
      1. mul-1-neg39.8%

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

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

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

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

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

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

    if 1.19999999999999996e166 < x

    1. Initial program 95.9%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-log-exp95.9%

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

        \[\leadsto \log \left(e^{\color{blue}{e^{\log \left(x + 1\right) \cdot \frac{1}{n}}} - {x}^{\left(\frac{1}{n}\right)}}\right) \]
      3. un-div-inv95.9%

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

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

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

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

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

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

Alternative 19: 46.4% accurate, 14.1× speedup?

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

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

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

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

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

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

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

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

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

Alternative 20: 46.4% accurate, 15.1× speedup?

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

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

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

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

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

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

    \[\leadsto -1 \cdot \frac{\color{blue}{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{n}}}{x} \]
  8. Step-by-step derivation
    1. sub-neg41.2%

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

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

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

      \[\leadsto -1 \cdot \frac{\frac{\frac{-1 \cdot \left(0.3333333333333333 \cdot \frac{1}{x} + \color{blue}{-0.5}\right)}{x} + \left(-1\right)}{n}}{x} \]
    5. distribute-lft-in41.2%

      \[\leadsto -1 \cdot \frac{\frac{\frac{\color{blue}{-1 \cdot \left(0.3333333333333333 \cdot \frac{1}{x}\right) + -1 \cdot -0.5}}{x} + \left(-1\right)}{n}}{x} \]
    6. neg-mul-141.2%

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

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

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

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

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

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

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

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

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

Alternative 21: 45.8% accurate, 16.2× speedup?

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{1 + -1 \cdot \frac{0.5 - 0.3333333333333333 \cdot \frac{1}{x}}{x}}{n \cdot x}} \]
  8. Step-by-step derivation
    1. mul-1-neg41.0%

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

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

      \[\leadsto \frac{1 - \frac{0.5 - \color{blue}{\frac{0.3333333333333333 \cdot 1}{x}}}{x}}{n \cdot x} \]
    4. metadata-eval41.0%

      \[\leadsto \frac{1 - \frac{0.5 - \frac{\color{blue}{0.3333333333333333}}{x}}{x}}{n \cdot x} \]
    5. *-commutative41.0%

      \[\leadsto \frac{1 - \frac{0.5 - \frac{0.3333333333333333}{x}}{x}}{\color{blue}{x \cdot n}} \]
  9. Simplified41.0%

    \[\leadsto \color{blue}{\frac{1 - \frac{0.5 - \frac{0.3333333333333333}{x}}{x}}{x \cdot n}} \]
  10. Final simplification41.0%

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

Alternative 22: 40.6% 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 56.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 57.8%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{1}{n}}{x}} \]
  9. Simplified34.9%

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

Alternative 23: 40.1% accurate, 42.2× speedup?

\[\begin{array}{l} \\ \frac{1}{x \cdot 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(1.0 / Float64(x * n))
end
function tmp = code(x, n)
	tmp = 1.0 / (x * n);
end
code[x_, n_] := N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1}{x \cdot n}
\end{array}
Derivation
  1. Initial program 56.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 57.8%

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

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

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

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

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

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

Alternative 24: 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 56.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 57.8%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{x} \cdot \frac{1}{n}} \]
    3. add-exp-log34.0%

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

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

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

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

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

      \[\leadsto e^{\color{blue}{\sqrt{\log x} \cdot \sqrt{\log x}}} \cdot \frac{1}{n} \]
    9. add-sqr-sqrt4.6%

      \[\leadsto e^{\color{blue}{\log x}} \cdot \frac{1}{n} \]
    10. add-exp-log4.6%

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

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

      \[\leadsto \color{blue}{\frac{x \cdot 1}{n}} \]
    2. *-rgt-identity4.6%

      \[\leadsto \frac{\color{blue}{x}}{n} \]
  12. Simplified4.6%

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

Reproduce

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