2nthrt (problem 3.4.6)

Percentage Accurate: 53.2% → 85.0%
Time: 38.1s
Alternatives: 13
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 13 alternatives:

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

Initial Program: 53.2% accurate, 1.0× speedup?

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

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

Alternative 1: 85.0% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {x}^{\left(\frac{1}{n}\right)}\\ t_1 := {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - t\_0\\ \mathbf{if}\;t\_1 \leq -\infty:\\ \;\;\;\;1 - t\_0\\ \mathbf{elif}\;t\_1 \leq 0:\\ \;\;\;\;\frac{\log \left(\frac{x}{x + 1}\right)}{-n}\\ \mathbf{else}:\\ \;\;\;\;e^{\frac{x}{n}} - t\_0\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (pow x (/ 1.0 n))) (t_1 (- (pow (+ x 1.0) (/ 1.0 n)) t_0)))
   (if (<= t_1 (- INFINITY))
     (- 1.0 t_0)
     (if (<= t_1 0.0) (/ (log (/ x (+ x 1.0))) (- n)) (- (exp (/ x n)) t_0)))))
double code(double x, double n) {
	double t_0 = pow(x, (1.0 / n));
	double t_1 = pow((x + 1.0), (1.0 / n)) - t_0;
	double tmp;
	if (t_1 <= -((double) INFINITY)) {
		tmp = 1.0 - t_0;
	} else if (t_1 <= 0.0) {
		tmp = log((x / (x + 1.0))) / -n;
	} else {
		tmp = exp((x / n)) - t_0;
	}
	return tmp;
}
public static double code(double x, double n) {
	double t_0 = Math.pow(x, (1.0 / n));
	double t_1 = Math.pow((x + 1.0), (1.0 / n)) - t_0;
	double tmp;
	if (t_1 <= -Double.POSITIVE_INFINITY) {
		tmp = 1.0 - t_0;
	} else if (t_1 <= 0.0) {
		tmp = Math.log((x / (x + 1.0))) / -n;
	} else {
		tmp = Math.exp((x / n)) - t_0;
	}
	return tmp;
}
def code(x, n):
	t_0 = math.pow(x, (1.0 / n))
	t_1 = math.pow((x + 1.0), (1.0 / n)) - t_0
	tmp = 0
	if t_1 <= -math.inf:
		tmp = 1.0 - t_0
	elif t_1 <= 0.0:
		tmp = math.log((x / (x + 1.0))) / -n
	else:
		tmp = math.exp((x / n)) - t_0
	return tmp
function code(x, n)
	t_0 = x ^ Float64(1.0 / n)
	t_1 = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - t_0)
	tmp = 0.0
	if (t_1 <= Float64(-Inf))
		tmp = Float64(1.0 - t_0);
	elseif (t_1 <= 0.0)
		tmp = Float64(log(Float64(x / Float64(x + 1.0))) / Float64(-n));
	else
		tmp = Float64(exp(Float64(x / n)) - t_0);
	end
	return tmp
end
function tmp_2 = code(x, n)
	t_0 = x ^ (1.0 / n);
	t_1 = ((x + 1.0) ^ (1.0 / n)) - t_0;
	tmp = 0.0;
	if (t_1 <= -Inf)
		tmp = 1.0 - t_0;
	elseif (t_1 <= 0.0)
		tmp = log((x / (x + 1.0))) / -n;
	else
		tmp = exp((x / n)) - t_0;
	end
	tmp_2 = tmp;
end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(1.0 - t$95$0), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(N[Log[N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]]]]]
\begin{array}{l}

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) < -inf.0

    1. Initial program 100.0%

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

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

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

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

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

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

    if -inf.0 < (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n))) < 0.0

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

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

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

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

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

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

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

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

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

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

    if 0.0 < (-.f64 (pow.f64 (+.f64 x 1) (/.f64 1 n)) (pow.f64 x (/.f64 1 n)))

    1. Initial program 51.3%

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

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

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

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

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

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

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

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

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

Alternative 2: 73.5% accurate, 1.4× speedup?

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

\\
\begin{array}{l}
t_0 := 1 - {x}^{\left(\frac{1}{n}\right)}\\
t_1 := \frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
t_2 := \frac{0.3333333333333333}{n \cdot {x}^{3}}\\
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{+37}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;\frac{1}{n} \leq -500000000:\\
\;\;\;\;t\_0\\

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

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

\mathbf{elif}\;\frac{1}{n} \leq 0.001:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;\frac{1}{n} \leq 10^{+199}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (/.f64 1 n) < -4.99999999999999989e37 or 1.0000000000000001e199 < (/.f64 1 n)

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

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

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

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

      \[\leadsto \frac{\color{blue}{\left(0.3333333333333333 \cdot \frac{1}{{x}^{3}} + \frac{1}{x}\right) - 0.5 \cdot \frac{1}{{x}^{2}}}}{n} \]
    7. Step-by-step derivation
      1. associate--l+27.9%

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{0.3333333333333333}{{x}^{3}} + \left(\frac{1}{x} - \frac{0.5}{{x}^{2}}\right)}}{n} \]
    9. Taylor expanded in x around 0 73.1%

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

    if -4.99999999999999989e37 < (/.f64 1 n) < -5e8 or 1e-3 < (/.f64 1 n) < 1.0000000000000001e199

    1. Initial program 74.8%

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

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

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

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

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

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

    if -5e8 < (/.f64 1 n) < -5.0000000000000001e-59 or -1.00000000000000001e-119 < (/.f64 1 n) < 1e-3

    1. Initial program 32.9%

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

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

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

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

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

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

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

    if -5.0000000000000001e-59 < (/.f64 1 n) < -1.00000000000000001e-119

    1. Initial program 12.8%

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{x} - \frac{\color{blue}{0.5}}{{x}^{2}}}{n} \]
    8. Simplified71.4%

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

        \[\leadsto \frac{\frac{1}{x} - \frac{0.5}{\color{blue}{x \cdot x}}}{n} \]
    10. Applied egg-rr71.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{+37}:\\ \;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\ \mathbf{elif}\;\frac{1}{n} \leq -500000000:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{-59}:\\ \;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-119}:\\ \;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 0.001:\\ \;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{+199}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 81.0% accurate, 1.5× speedup?

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

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq 0.001:\\
\;\;\;\;t\_1\\

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

\mathbf{else}:\\
\;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\


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

    1. Initial program 96.8%

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.00000000000000004e-10 < (/.f64 1 n) < -5.0000000000000001e-59 or -1.00000000000000001e-119 < (/.f64 1 n) < 1e-3

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

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

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

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

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

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

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

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

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

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

    if -5.0000000000000001e-59 < (/.f64 1 n) < -1.00000000000000001e-119

    1. Initial program 12.8%

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{x} - \frac{\color{blue}{0.5}}{{x}^{2}}}{n} \]
    8. Simplified71.4%

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

        \[\leadsto \frac{\frac{1}{x} - \frac{0.5}{\color{blue}{x \cdot x}}}{n} \]
    10. Applied egg-rr71.4%

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

    if 1e-3 < (/.f64 1 n) < 1.03e214

    1. Initial program 63.8%

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

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

    if 1.03e214 < (/.f64 1 n)

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

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

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

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

      \[\leadsto \frac{\color{blue}{\left(0.3333333333333333 \cdot \frac{1}{{x}^{3}} + \frac{1}{x}\right) - 0.5 \cdot \frac{1}{{x}^{2}}}}{n} \]
    7. Step-by-step derivation
      1. associate--l+46.4%

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{0.3333333333333333}{{x}^{3}} + \left(\frac{1}{x} - \frac{0.5}{{x}^{2}}\right)}}{n} \]
    9. Taylor expanded in x around 0 74.2%

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

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

Alternative 4: 80.9% accurate, 1.5× speedup?

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

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq 0.001:\\
\;\;\;\;t\_2\\

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

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


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

    1. Initial program 96.8%

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.00000000000000004e-10 < (/.f64 1 n) < -5.0000000000000001e-59 or -1.00000000000000001e-119 < (/.f64 1 n) < 1e-3

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

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

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

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

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

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

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

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

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

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

    if -5.0000000000000001e-59 < (/.f64 1 n) < -1.00000000000000001e-119

    1. Initial program 12.8%

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{x} - \frac{\color{blue}{0.5}}{{x}^{2}}}{n} \]
    8. Simplified71.4%

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

        \[\leadsto \frac{\frac{1}{x} - \frac{0.5}{\color{blue}{x \cdot x}}}{n} \]
    10. Applied egg-rr71.4%

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

    if 1e-3 < (/.f64 1 n) < 1.03e214

    1. Initial program 63.8%

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

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

    if 1.03e214 < (/.f64 1 n)

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{-\mathsf{log1p}\left(\frac{x}{\color{blue}{x + 1}} - 1\right)}{n} \]
    11. Applied egg-rr82.4%

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

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

Alternative 5: 81.1% accurate, 1.5× speedup?

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

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq 0.001:\\
\;\;\;\;t\_1\\

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

\mathbf{else}:\\
\;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\


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

    1. Initial program 96.8%

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.00000000000000004e-10 < (/.f64 1 n) < -5.0000000000000001e-59 or -1.00000000000000001e-119 < (/.f64 1 n) < 1e-3

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

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

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

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

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

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

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

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

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

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

    if -5.0000000000000001e-59 < (/.f64 1 n) < -1.00000000000000001e-119

    1. Initial program 12.8%

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{x} - \frac{\color{blue}{0.5}}{{x}^{2}}}{n} \]
    8. Simplified71.4%

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

        \[\leadsto \frac{\frac{1}{x} - \frac{0.5}{\color{blue}{x \cdot x}}}{n} \]
    10. Applied egg-rr71.4%

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

    if 1e-3 < (/.f64 1 n) < 1.0000000000000001e199

    1. Initial program 64.7%

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

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

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

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

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

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

    if 1.0000000000000001e199 < (/.f64 1 n)

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

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

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

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

      \[\leadsto \frac{\color{blue}{\left(0.3333333333333333 \cdot \frac{1}{{x}^{3}} + \frac{1}{x}\right) - 0.5 \cdot \frac{1}{{x}^{2}}}}{n} \]
    7. Step-by-step derivation
      1. associate--l+47.0%

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{0.3333333333333333}{{x}^{3}} + \left(\frac{1}{x} - \frac{0.5}{{x}^{2}}\right)}}{n} \]
    9. Taylor expanded in x around 0 70.8%

      \[\leadsto \color{blue}{\frac{0.3333333333333333}{n \cdot {x}^{3}}} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification82.0%

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

Alternative 6: 73.2% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\log \left(\frac{x}{x + 1}\right)}{-n}\\ t_1 := 1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{if}\;n \leq -1.7 \cdot 10^{+124}:\\ \;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\ \mathbf{elif}\;n \leq -3.7 \cdot 10^{+58}:\\ \;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\ \mathbf{elif}\;n \leq -3.8 \cdot 10^{-9}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;n \leq -2 \cdot 10^{-38}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;n \leq 9.7 \cdot 10^{-215}:\\ \;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\ \mathbf{elif}\;n \leq 1400:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (/ (log (/ x (+ x 1.0))) (- n))) (t_1 (- 1.0 (pow x (/ 1.0 n)))))
   (if (<= n -1.7e+124)
     (/ (log (/ (+ x 1.0) x)) n)
     (if (<= n -3.7e+58)
       (/ (- (/ 1.0 x) (/ 0.5 (* x x))) n)
       (if (<= n -3.8e-9)
         t_0
         (if (<= n -2e-38)
           t_1
           (if (<= n 9.7e-215)
             (/ 0.3333333333333333 (* n (pow x 3.0)))
             (if (<= n 1400.0) t_1 t_0))))))))
double code(double x, double n) {
	double t_0 = log((x / (x + 1.0))) / -n;
	double t_1 = 1.0 - pow(x, (1.0 / n));
	double tmp;
	if (n <= -1.7e+124) {
		tmp = log(((x + 1.0) / x)) / n;
	} else if (n <= -3.7e+58) {
		tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
	} else if (n <= -3.8e-9) {
		tmp = t_0;
	} else if (n <= -2e-38) {
		tmp = t_1;
	} else if (n <= 9.7e-215) {
		tmp = 0.3333333333333333 / (n * pow(x, 3.0));
	} else if (n <= 1400.0) {
		tmp = t_1;
	} 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) :: t_1
    real(8) :: tmp
    t_0 = log((x / (x + 1.0d0))) / -n
    t_1 = 1.0d0 - (x ** (1.0d0 / n))
    if (n <= (-1.7d+124)) then
        tmp = log(((x + 1.0d0) / x)) / n
    else if (n <= (-3.7d+58)) then
        tmp = ((1.0d0 / x) - (0.5d0 / (x * x))) / n
    else if (n <= (-3.8d-9)) then
        tmp = t_0
    else if (n <= (-2d-38)) then
        tmp = t_1
    else if (n <= 9.7d-215) then
        tmp = 0.3333333333333333d0 / (n * (x ** 3.0d0))
    else if (n <= 1400.0d0) then
        tmp = t_1
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double t_0 = Math.log((x / (x + 1.0))) / -n;
	double t_1 = 1.0 - Math.pow(x, (1.0 / n));
	double tmp;
	if (n <= -1.7e+124) {
		tmp = Math.log(((x + 1.0) / x)) / n;
	} else if (n <= -3.7e+58) {
		tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
	} else if (n <= -3.8e-9) {
		tmp = t_0;
	} else if (n <= -2e-38) {
		tmp = t_1;
	} else if (n <= 9.7e-215) {
		tmp = 0.3333333333333333 / (n * Math.pow(x, 3.0));
	} else if (n <= 1400.0) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, n):
	t_0 = math.log((x / (x + 1.0))) / -n
	t_1 = 1.0 - math.pow(x, (1.0 / n))
	tmp = 0
	if n <= -1.7e+124:
		tmp = math.log(((x + 1.0) / x)) / n
	elif n <= -3.7e+58:
		tmp = ((1.0 / x) - (0.5 / (x * x))) / n
	elif n <= -3.8e-9:
		tmp = t_0
	elif n <= -2e-38:
		tmp = t_1
	elif n <= 9.7e-215:
		tmp = 0.3333333333333333 / (n * math.pow(x, 3.0))
	elif n <= 1400.0:
		tmp = t_1
	else:
		tmp = t_0
	return tmp
function code(x, n)
	t_0 = Float64(log(Float64(x / Float64(x + 1.0))) / Float64(-n))
	t_1 = Float64(1.0 - (x ^ Float64(1.0 / n)))
	tmp = 0.0
	if (n <= -1.7e+124)
		tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n);
	elseif (n <= -3.7e+58)
		tmp = Float64(Float64(Float64(1.0 / x) - Float64(0.5 / Float64(x * x))) / n);
	elseif (n <= -3.8e-9)
		tmp = t_0;
	elseif (n <= -2e-38)
		tmp = t_1;
	elseif (n <= 9.7e-215)
		tmp = Float64(0.3333333333333333 / Float64(n * (x ^ 3.0)));
	elseif (n <= 1400.0)
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, n)
	t_0 = log((x / (x + 1.0))) / -n;
	t_1 = 1.0 - (x ^ (1.0 / n));
	tmp = 0.0;
	if (n <= -1.7e+124)
		tmp = log(((x + 1.0) / x)) / n;
	elseif (n <= -3.7e+58)
		tmp = ((1.0 / x) - (0.5 / (x * x))) / n;
	elseif (n <= -3.8e-9)
		tmp = t_0;
	elseif (n <= -2e-38)
		tmp = t_1;
	elseif (n <= 9.7e-215)
		tmp = 0.3333333333333333 / (n * (x ^ 3.0));
	elseif (n <= 1400.0)
		tmp = t_1;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, n_] := Block[{t$95$0 = N[(N[Log[N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / (-n)), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[n, -1.7e+124], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[n, -3.7e+58], N[(N[(N[(1.0 / x), $MachinePrecision] - N[(0.5 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[n, -3.8e-9], t$95$0, If[LessEqual[n, -2e-38], t$95$1, If[LessEqual[n, 9.7e-215], N[(0.3333333333333333 / N[(n * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1400.0], t$95$1, t$95$0]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;n \leq -3.7 \cdot 10^{+58}:\\
\;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\

\mathbf{elif}\;n \leq -3.8 \cdot 10^{-9}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;n \leq -2 \cdot 10^{-38}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;n \leq 1400:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if n < -1.7e124

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

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

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

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

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

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

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

    if -1.7e124 < n < -3.7000000000000002e58

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{x} - \frac{\color{blue}{0.5}}{{x}^{2}}}{n} \]
    8. Simplified75.0%

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

        \[\leadsto \frac{\frac{1}{x} - \frac{0.5}{\color{blue}{x \cdot x}}}{n} \]
    10. Applied egg-rr75.0%

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

    if -3.7000000000000002e58 < n < -3.80000000000000011e-9 or 1400 < n

    1. Initial program 27.3%

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

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

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

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

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

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

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

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

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

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

    if -3.80000000000000011e-9 < n < -1.9999999999999999e-38 or 9.7000000000000001e-215 < n < 1400

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

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

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

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

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

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

    if -1.9999999999999999e-38 < n < 9.7000000000000001e-215

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

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

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

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

      \[\leadsto \frac{\color{blue}{\left(0.3333333333333333 \cdot \frac{1}{{x}^{3}} + \frac{1}{x}\right) - 0.5 \cdot \frac{1}{{x}^{2}}}}{n} \]
    7. Step-by-step derivation
      1. associate--l+27.1%

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{0.3333333333333333}{{x}^{3}} + \left(\frac{1}{x} - \frac{0.5}{{x}^{2}}\right)}}{n} \]
    9. Taylor expanded in x around 0 73.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -1.7 \cdot 10^{+124}:\\ \;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\ \mathbf{elif}\;n \leq -3.7 \cdot 10^{+58}:\\ \;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\ \mathbf{elif}\;n \leq -3.8 \cdot 10^{-9}:\\ \;\;\;\;\frac{\log \left(\frac{x}{x + 1}\right)}{-n}\\ \mathbf{elif}\;n \leq -2 \cdot 10^{-38}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;n \leq 9.7 \cdot 10^{-215}:\\ \;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\ \mathbf{elif}\;n \leq 1400:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \left(\frac{x}{x + 1}\right)}{-n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 61.1% accurate, 1.8× speedup?

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

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

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

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

\mathbf{elif}\;x \leq 1.3 \cdot 10^{+185}:\\
\;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if x < 7.20000000000000028e-242

    1. Initial program 35.9%

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

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

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

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

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

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

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

    if 7.20000000000000028e-242 < x < 1.44999999999999994e-202

    1. Initial program 61.3%

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

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

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

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

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

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

    if 1.44999999999999994e-202 < x < 0.95999999999999996

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

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

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

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

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

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

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

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

    if 0.95999999999999996 < x < 1.3e185

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{x} - \frac{\color{blue}{0.5}}{{x}^{2}}}{n} \]
    8. Simplified71.4%

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

        \[\leadsto \frac{\frac{1}{x} - \frac{0.5}{\color{blue}{x \cdot x}}}{n} \]
    10. Applied egg-rr71.4%

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

    if 1.3e185 < x

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 7.2 \cdot 10^{-242}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 1.45 \cdot 10^{-202}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 0.96:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{+185}:\\ \;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{0}{n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 61.5% accurate, 1.9× speedup?

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

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

\mathbf{elif}\;x \leq 1.9 \cdot 10^{+185}:\\
\;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\

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


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

    1. Initial program 37.6%

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

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

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

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

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

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

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

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

    if 0.95999999999999996 < x < 1.8999999999999999e185

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{x} - \frac{\color{blue}{0.5}}{{x}^{2}}}{n} \]
    8. Simplified71.4%

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

        \[\leadsto \frac{\frac{1}{x} - \frac{0.5}{\color{blue}{x \cdot x}}}{n} \]
    10. Applied egg-rr71.4%

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

    if 1.8999999999999999e185 < x

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

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

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

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

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

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

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

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

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

Alternative 9: 61.3% accurate, 1.9× speedup?

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

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

\mathbf{elif}\;x \leq 1.05 \cdot 10^{+185}:\\
\;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\

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


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

    1. Initial program 37.6%

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

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

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

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

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

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

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

    if 0.680000000000000049 < x < 1.05e185

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

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

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

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

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

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

        \[\leadsto \frac{\frac{1}{x} - \frac{\color{blue}{0.5}}{{x}^{2}}}{n} \]
    8. Simplified71.4%

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

        \[\leadsto \frac{\frac{1}{x} - \frac{0.5}{\color{blue}{x \cdot x}}}{n} \]
    10. Applied egg-rr71.4%

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

    if 1.05e185 < x

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

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

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

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

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

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

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

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

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

Alternative 10: 47.3% accurate, 17.6× speedup?

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

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

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


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

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

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

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

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

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

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

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

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

    if -5 < (/.f64 1 n)

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

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

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

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

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

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

Alternative 11: 41.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 48.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 60.8%

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

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

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

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

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

Alternative 12: 41.7% accurate, 42.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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