2nthrt (problem 3.4.6)

Percentage Accurate: 52.6% → 80.5%
Time: 28.4s
Alternatives: 19
Speedup: 2.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 19 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: 52.6% accurate, 1.0× speedup?

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

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

Alternative 1: 80.5% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-87}:\\
\;\;\;\;t_2\\

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

\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-112}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-104}:\\
\;\;\;\;t_0 - \frac{0.5}{n \cdot {x}^{2}}\\

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

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

\mathbf{else}:\\
\;\;\;\;t_0\\


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

    1. Initial program 92.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 inf 96.4%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]

    if -1e-30 < (/.f64 1 n) < -1.00000000000000002e-87 or -5.0000000000000003e-116 < (/.f64 1 n) < 1.9999999999999999e-112

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.00000000000000002e-87 < (/.f64 1 n) < -5.0000000000000003e-116

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

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

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

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

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

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

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

    if 1.9999999999999999e-112 < (/.f64 1 n) < 4.99999999999999979e-104

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{x \cdot n}} - 0.5 \cdot \frac{1}{n \cdot {x}^{2}} \]
      2. associate-*r/99.7%

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

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

        \[\leadsto \frac{1}{x \cdot n} - \frac{0.5}{\color{blue}{{x}^{2} \cdot n}} \]
    8. Simplified99.7%

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

    if 4.99999999999999979e-104 < (/.f64 1 n) < 4.99999999999999977e-7

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-\color{blue}{\log \left(\frac{1 + x}{x}\right)}\right) \cdot \frac{1}{-n} \]
      7. neg-log60.8%

        \[\leadsto \color{blue}{\log \left(\frac{1}{\frac{1 + x}{x}}\right)} \cdot \frac{1}{-n} \]
      8. clear-num60.9%

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

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

    if 4.99999999999999977e-7 < (/.f64 1 n) < 9.9999999999999995e213

    1. Initial program 77.4%

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

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

    if 9.9999999999999995e213 < (/.f64 1 n)

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

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

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

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

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

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

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

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

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

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

Alternative 2: 85.5% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{-\log \left(\frac{x}{x + 1}\right)}{n}\\ t_1 := \log \left(x + 1\right)\\ \mathbf{if}\;n \leq -1.62 \cdot 10^{+115}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;n \leq -1.18 \cdot 10^{+88}:\\ \;\;\;\;\frac{\frac{1}{x}}{n}\\ \mathbf{elif}\;n \leq -160000:\\ \;\;\;\;\left(\frac{t_1 - \log x}{n} + \left(\frac{-0.16666666666666666 \cdot {\log x}^{3} - -0.16666666666666666 \cdot {t_1}^{3}}{{n}^{3}} + \left(0.041666666666666664 \cdot \frac{{t_1}^{4}}{{n}^{4}} + 0.5 \cdot \frac{{t_1}^{2}}{{n}^{2}}\right)\right)\right) - \left(0.041666666666666664 \cdot \frac{{\log x}^{4}}{{n}^{4}} + 0.5 \cdot \frac{{\log x}^{2}}{{n}^{2}}\right)\\ \mathbf{elif}\;n \leq 2200000:\\ \;\;\;\;e^{\frac{x}{n}} - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (/ (- (log (/ x (+ x 1.0)))) n)) (t_1 (log (+ x 1.0))))
   (if (<= n -1.62e+115)
     t_0
     (if (<= n -1.18e+88)
       (/ (/ 1.0 x) n)
       (if (<= n -160000.0)
         (-
          (+
           (/ (- t_1 (log x)) n)
           (+
            (/
             (-
              (* -0.16666666666666666 (pow (log x) 3.0))
              (* -0.16666666666666666 (pow t_1 3.0)))
             (pow n 3.0))
            (+
             (* 0.041666666666666664 (/ (pow t_1 4.0) (pow n 4.0)))
             (* 0.5 (/ (pow t_1 2.0) (pow n 2.0))))))
          (+
           (* 0.041666666666666664 (/ (pow (log x) 4.0) (pow n 4.0)))
           (* 0.5 (/ (pow (log x) 2.0) (pow n 2.0)))))
         (if (<= n 2200000.0) (- (exp (/ x n)) (pow x (/ 1.0 n))) t_0))))))
double code(double x, double n) {
	double t_0 = -log((x / (x + 1.0))) / n;
	double t_1 = log((x + 1.0));
	double tmp;
	if (n <= -1.62e+115) {
		tmp = t_0;
	} else if (n <= -1.18e+88) {
		tmp = (1.0 / x) / n;
	} else if (n <= -160000.0) {
		tmp = (((t_1 - log(x)) / n) + ((((-0.16666666666666666 * pow(log(x), 3.0)) - (-0.16666666666666666 * pow(t_1, 3.0))) / pow(n, 3.0)) + ((0.041666666666666664 * (pow(t_1, 4.0) / pow(n, 4.0))) + (0.5 * (pow(t_1, 2.0) / pow(n, 2.0)))))) - ((0.041666666666666664 * (pow(log(x), 4.0) / pow(n, 4.0))) + (0.5 * (pow(log(x), 2.0) / pow(n, 2.0))));
	} else if (n <= 2200000.0) {
		tmp = exp((x / n)) - pow(x, (1.0 / n));
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = -log((x / (x + 1.0d0))) / n
    t_1 = log((x + 1.0d0))
    if (n <= (-1.62d+115)) then
        tmp = t_0
    else if (n <= (-1.18d+88)) then
        tmp = (1.0d0 / x) / n
    else if (n <= (-160000.0d0)) then
        tmp = (((t_1 - log(x)) / n) + (((((-0.16666666666666666d0) * (log(x) ** 3.0d0)) - ((-0.16666666666666666d0) * (t_1 ** 3.0d0))) / (n ** 3.0d0)) + ((0.041666666666666664d0 * ((t_1 ** 4.0d0) / (n ** 4.0d0))) + (0.5d0 * ((t_1 ** 2.0d0) / (n ** 2.0d0)))))) - ((0.041666666666666664d0 * ((log(x) ** 4.0d0) / (n ** 4.0d0))) + (0.5d0 * ((log(x) ** 2.0d0) / (n ** 2.0d0))))
    else if (n <= 2200000.0d0) then
        tmp = exp((x / n)) - (x ** (1.0d0 / n))
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double t_0 = -Math.log((x / (x + 1.0))) / n;
	double t_1 = Math.log((x + 1.0));
	double tmp;
	if (n <= -1.62e+115) {
		tmp = t_0;
	} else if (n <= -1.18e+88) {
		tmp = (1.0 / x) / n;
	} else if (n <= -160000.0) {
		tmp = (((t_1 - Math.log(x)) / n) + ((((-0.16666666666666666 * Math.pow(Math.log(x), 3.0)) - (-0.16666666666666666 * Math.pow(t_1, 3.0))) / Math.pow(n, 3.0)) + ((0.041666666666666664 * (Math.pow(t_1, 4.0) / Math.pow(n, 4.0))) + (0.5 * (Math.pow(t_1, 2.0) / Math.pow(n, 2.0)))))) - ((0.041666666666666664 * (Math.pow(Math.log(x), 4.0) / Math.pow(n, 4.0))) + (0.5 * (Math.pow(Math.log(x), 2.0) / Math.pow(n, 2.0))));
	} else if (n <= 2200000.0) {
		tmp = Math.exp((x / n)) - Math.pow(x, (1.0 / n));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, n):
	t_0 = -math.log((x / (x + 1.0))) / n
	t_1 = math.log((x + 1.0))
	tmp = 0
	if n <= -1.62e+115:
		tmp = t_0
	elif n <= -1.18e+88:
		tmp = (1.0 / x) / n
	elif n <= -160000.0:
		tmp = (((t_1 - math.log(x)) / n) + ((((-0.16666666666666666 * math.pow(math.log(x), 3.0)) - (-0.16666666666666666 * math.pow(t_1, 3.0))) / math.pow(n, 3.0)) + ((0.041666666666666664 * (math.pow(t_1, 4.0) / math.pow(n, 4.0))) + (0.5 * (math.pow(t_1, 2.0) / math.pow(n, 2.0)))))) - ((0.041666666666666664 * (math.pow(math.log(x), 4.0) / math.pow(n, 4.0))) + (0.5 * (math.pow(math.log(x), 2.0) / math.pow(n, 2.0))))
	elif n <= 2200000.0:
		tmp = math.exp((x / n)) - math.pow(x, (1.0 / n))
	else:
		tmp = t_0
	return tmp
function code(x, n)
	t_0 = Float64(Float64(-log(Float64(x / Float64(x + 1.0)))) / n)
	t_1 = log(Float64(x + 1.0))
	tmp = 0.0
	if (n <= -1.62e+115)
		tmp = t_0;
	elseif (n <= -1.18e+88)
		tmp = Float64(Float64(1.0 / x) / n);
	elseif (n <= -160000.0)
		tmp = Float64(Float64(Float64(Float64(t_1 - log(x)) / n) + Float64(Float64(Float64(Float64(-0.16666666666666666 * (log(x) ^ 3.0)) - Float64(-0.16666666666666666 * (t_1 ^ 3.0))) / (n ^ 3.0)) + Float64(Float64(0.041666666666666664 * Float64((t_1 ^ 4.0) / (n ^ 4.0))) + Float64(0.5 * Float64((t_1 ^ 2.0) / (n ^ 2.0)))))) - Float64(Float64(0.041666666666666664 * Float64((log(x) ^ 4.0) / (n ^ 4.0))) + Float64(0.5 * Float64((log(x) ^ 2.0) / (n ^ 2.0)))));
	elseif (n <= 2200000.0)
		tmp = Float64(exp(Float64(x / n)) - (x ^ Float64(1.0 / n)));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, n)
	t_0 = -log((x / (x + 1.0))) / n;
	t_1 = log((x + 1.0));
	tmp = 0.0;
	if (n <= -1.62e+115)
		tmp = t_0;
	elseif (n <= -1.18e+88)
		tmp = (1.0 / x) / n;
	elseif (n <= -160000.0)
		tmp = (((t_1 - log(x)) / n) + ((((-0.16666666666666666 * (log(x) ^ 3.0)) - (-0.16666666666666666 * (t_1 ^ 3.0))) / (n ^ 3.0)) + ((0.041666666666666664 * ((t_1 ^ 4.0) / (n ^ 4.0))) + (0.5 * ((t_1 ^ 2.0) / (n ^ 2.0)))))) - ((0.041666666666666664 * ((log(x) ^ 4.0) / (n ^ 4.0))) + (0.5 * ((log(x) ^ 2.0) / (n ^ 2.0))));
	elseif (n <= 2200000.0)
		tmp = exp((x / n)) - (x ^ (1.0 / n));
	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[Log[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[n, -1.62e+115], t$95$0, If[LessEqual[n, -1.18e+88], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[n, -160000.0], N[(N[(N[(N[(t$95$1 - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] + N[(N[(N[(N[(-0.16666666666666666 * N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision] - N[(-0.16666666666666666 * N[Power[t$95$1, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[n, 3.0], $MachinePrecision]), $MachinePrecision] + N[(N[(0.041666666666666664 * N[(N[Power[t$95$1, 4.0], $MachinePrecision] / N[Power[n, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(N[Power[t$95$1, 2.0], $MachinePrecision] / N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(0.041666666666666664 * N[(N[Power[N[Log[x], $MachinePrecision], 4.0], $MachinePrecision] / N[Power[n, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision] / N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 2200000.0], N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;n \leq -1.18 \cdot 10^{+88}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\

\mathbf{elif}\;n \leq -160000:\\
\;\;\;\;\left(\frac{t_1 - \log x}{n} + \left(\frac{-0.16666666666666666 \cdot {\log x}^{3} - -0.16666666666666666 \cdot {t_1}^{3}}{{n}^{3}} + \left(0.041666666666666664 \cdot \frac{{t_1}^{4}}{{n}^{4}} + 0.5 \cdot \frac{{t_1}^{2}}{{n}^{2}}\right)\right)\right) - \left(0.041666666666666664 \cdot \frac{{\log x}^{4}}{{n}^{4}} + 0.5 \cdot \frac{{\log x}^{2}}{{n}^{2}}\right)\\

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

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if n < -1.62e115 or 2.2e6 < n

    1. Initial program 26.6%

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

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

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

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

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

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

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

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

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

        \[\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 -1.62e115 < n < -1.1799999999999999e88

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

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

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

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

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

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

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

    if -1.1799999999999999e88 < n < -1.6e5

    1. Initial program 10.7%

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

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

    if -1.6e5 < n < 2.2e6

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -1.62 \cdot 10^{+115}:\\ \;\;\;\;\frac{-\log \left(\frac{x}{x + 1}\right)}{n}\\ \mathbf{elif}\;n \leq -1.18 \cdot 10^{+88}:\\ \;\;\;\;\frac{\frac{1}{x}}{n}\\ \mathbf{elif}\;n \leq -160000:\\ \;\;\;\;\left(\frac{\log \left(x + 1\right) - \log x}{n} + \left(\frac{-0.16666666666666666 \cdot {\log x}^{3} - -0.16666666666666666 \cdot {\log \left(x + 1\right)}^{3}}{{n}^{3}} + \left(0.041666666666666664 \cdot \frac{{\log \left(x + 1\right)}^{4}}{{n}^{4}} + 0.5 \cdot \frac{{\log \left(x + 1\right)}^{2}}{{n}^{2}}\right)\right)\right) - \left(0.041666666666666664 \cdot \frac{{\log x}^{4}}{{n}^{4}} + 0.5 \cdot \frac{{\log x}^{2}}{{n}^{2}}\right)\\ \mathbf{elif}\;n \leq 2200000:\\ \;\;\;\;e^{\frac{x}{n}} - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\log \left(\frac{x}{x + 1}\right)}{n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 85.3% accurate, 0.2× speedup?

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

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

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

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

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

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if n < -2.64999999999999993e120 or 2.2e6 < n

    1. Initial program 26.6%

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

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

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

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

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

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

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

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

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

        \[\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 -2.64999999999999993e120 < n < -1.3e88

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

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

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

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

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

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

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

    if -1.3e88 < n < -7.2e5

    1. Initial program 7.2%

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

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

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

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

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

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

        \[\leadsto \frac{-\color{blue}{\left(-\left(\log \left(1 + x\right) - \log x\right)\right)}}{n} + \left(\left(-1 \cdot \frac{-0.16666666666666666 \cdot {\log \left(1 + x\right)}^{3} - -0.16666666666666666 \cdot {\log x}^{3}}{{n}^{3}} + 0.5 \cdot \frac{{\log \left(1 + x\right)}^{2}}{{n}^{2}}\right) - 0.5 \cdot \frac{{\log x}^{2}}{{n}^{2}}\right) \]
      6. remove-double-neg76.5%

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

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

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

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

    if -7.2e5 < n < 2.2e6

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -2.65 \cdot 10^{+120}:\\ \;\;\;\;\frac{-\log \left(\frac{x}{x + 1}\right)}{n}\\ \mathbf{elif}\;n \leq -1.3 \cdot 10^{+88}:\\ \;\;\;\;\frac{\frac{1}{x}}{n}\\ \mathbf{elif}\;n \leq -720000:\\ \;\;\;\;\frac{\mathsf{log1p}\left(x\right) - \log x}{n} + \left(\frac{0.16666666666666666 \cdot \left({\left(\mathsf{log1p}\left(x\right)\right)}^{3} - {\log x}^{3}\right)}{{n}^{3}} + 0.5 \cdot \left(\frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2}}{{n}^{2}} - \frac{{\log x}^{2}}{{n}^{2}}\right)\right)\\ \mathbf{elif}\;n \leq 2200000:\\ \;\;\;\;e^{\frac{x}{n}} - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{-\log \left(\frac{x}{x + 1}\right)}{n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 85.3% accurate, 0.3× speedup?

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

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

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

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

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

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if n < -1.1499999999999999e121 or 2.2e6 < n

    1. Initial program 26.6%

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

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

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

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

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

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

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

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

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

        \[\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 -1.1499999999999999e121 < n < -1.3e88

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

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

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

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

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

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

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

    if -1.3e88 < n < -1.55e7

    1. Initial program 7.2%

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.55e7 < n < 2.2e6

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

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

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

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

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

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

Alternative 5: 84.9% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{-\log \left(\frac{x}{x + 1}\right)}{n}\\ \mathbf{if}\;n \leq -1.62 \cdot 10^{+115}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;n \leq -1.3 \cdot 10^{+88}:\\ \;\;\;\;\frac{\frac{1}{x}}{n}\\ \mathbf{elif}\;n \leq -35000000000 \lor \neg \left(n \leq 6.2 \cdot 10^{+24}\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (/ (- (log (/ x (+ x 1.0)))) n)))
   (if (<= n -1.62e+115)
     t_0
     (if (<= n -1.3e+88)
       (/ (/ 1.0 x) n)
       (if (or (<= n -35000000000.0) (not (<= n 6.2e+24)))
         t_0
         (- (exp (/ (log1p x) n)) (pow x (/ 1.0 n))))))))
double code(double x, double n) {
	double t_0 = -log((x / (x + 1.0))) / n;
	double tmp;
	if (n <= -1.62e+115) {
		tmp = t_0;
	} else if (n <= -1.3e+88) {
		tmp = (1.0 / x) / n;
	} else if ((n <= -35000000000.0) || !(n <= 6.2e+24)) {
		tmp = t_0;
	} else {
		tmp = exp((log1p(x) / n)) - pow(x, (1.0 / n));
	}
	return tmp;
}
public static double code(double x, double n) {
	double t_0 = -Math.log((x / (x + 1.0))) / n;
	double tmp;
	if (n <= -1.62e+115) {
		tmp = t_0;
	} else if (n <= -1.3e+88) {
		tmp = (1.0 / x) / n;
	} else if ((n <= -35000000000.0) || !(n <= 6.2e+24)) {
		tmp = t_0;
	} else {
		tmp = Math.exp((Math.log1p(x) / n)) - Math.pow(x, (1.0 / n));
	}
	return tmp;
}
def code(x, n):
	t_0 = -math.log((x / (x + 1.0))) / n
	tmp = 0
	if n <= -1.62e+115:
		tmp = t_0
	elif n <= -1.3e+88:
		tmp = (1.0 / x) / n
	elif (n <= -35000000000.0) or not (n <= 6.2e+24):
		tmp = t_0
	else:
		tmp = math.exp((math.log1p(x) / n)) - math.pow(x, (1.0 / n))
	return tmp
function code(x, n)
	t_0 = Float64(Float64(-log(Float64(x / Float64(x + 1.0)))) / n)
	tmp = 0.0
	if (n <= -1.62e+115)
		tmp = t_0;
	elseif (n <= -1.3e+88)
		tmp = Float64(Float64(1.0 / x) / n);
	elseif ((n <= -35000000000.0) || !(n <= 6.2e+24))
		tmp = t_0;
	else
		tmp = Float64(exp(Float64(log1p(x) / n)) - (x ^ Float64(1.0 / n)));
	end
	return tmp
end
code[x_, n_] := Block[{t$95$0 = N[((-N[Log[N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / n), $MachinePrecision]}, If[LessEqual[n, -1.62e+115], t$95$0, If[LessEqual[n, -1.3e+88], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], If[Or[LessEqual[n, -35000000000.0], N[Not[LessEqual[n, 6.2e+24]], $MachinePrecision]], t$95$0, N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;n \leq -35000000000 \lor \neg \left(n \leq 6.2 \cdot 10^{+24}\right):\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if n < -1.62e115 or -1.3e88 < n < -3.5e10 or 6.20000000000000022e24 < n

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.62e115 < n < -1.3e88

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

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

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

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

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

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

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

    if -3.5e10 < n < 6.20000000000000022e24

    1. Initial program 83.7%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -1.62 \cdot 10^{+115}:\\ \;\;\;\;\frac{-\log \left(\frac{x}{x + 1}\right)}{n}\\ \mathbf{elif}\;n \leq -1.3 \cdot 10^{+88}:\\ \;\;\;\;\frac{\frac{1}{x}}{n}\\ \mathbf{elif}\;n \leq -35000000000 \lor \neg \left(n \leq 6.2 \cdot 10^{+24}\right):\\ \;\;\;\;\frac{-\log \left(\frac{x}{x + 1}\right)}{n}\\ \mathbf{else}:\\ \;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 85.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{-\log \left(\frac{x}{x + 1}\right)}{n}\\ \mathbf{if}\;n \leq -3.1 \cdot 10^{+116}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;n \leq -1.3 \cdot 10^{+88}:\\ \;\;\;\;\frac{\frac{1}{x}}{n}\\ \mathbf{elif}\;n \leq -2400000000 \lor \neg \left(n \leq 2200000\right):\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;e^{\frac{x}{n}} - {x}^{\left(\frac{1}{n}\right)}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (/ (- (log (/ x (+ x 1.0)))) n)))
   (if (<= n -3.1e+116)
     t_0
     (if (<= n -1.3e+88)
       (/ (/ 1.0 x) n)
       (if (or (<= n -2400000000.0) (not (<= n 2200000.0)))
         t_0
         (- (exp (/ x n)) (pow x (/ 1.0 n))))))))
double code(double x, double n) {
	double t_0 = -log((x / (x + 1.0))) / n;
	double tmp;
	if (n <= -3.1e+116) {
		tmp = t_0;
	} else if (n <= -1.3e+88) {
		tmp = (1.0 / x) / n;
	} else if ((n <= -2400000000.0) || !(n <= 2200000.0)) {
		tmp = t_0;
	} else {
		tmp = exp((x / n)) - pow(x, (1.0 / n));
	}
	return tmp;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    real(8) :: t_0
    real(8) :: tmp
    t_0 = -log((x / (x + 1.0d0))) / n
    if (n <= (-3.1d+116)) then
        tmp = t_0
    else if (n <= (-1.3d+88)) then
        tmp = (1.0d0 / x) / n
    else if ((n <= (-2400000000.0d0)) .or. (.not. (n <= 2200000.0d0))) then
        tmp = t_0
    else
        tmp = exp((x / n)) - (x ** (1.0d0 / n))
    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 tmp;
	if (n <= -3.1e+116) {
		tmp = t_0;
	} else if (n <= -1.3e+88) {
		tmp = (1.0 / x) / n;
	} else if ((n <= -2400000000.0) || !(n <= 2200000.0)) {
		tmp = t_0;
	} else {
		tmp = Math.exp((x / n)) - Math.pow(x, (1.0 / n));
	}
	return tmp;
}
def code(x, n):
	t_0 = -math.log((x / (x + 1.0))) / n
	tmp = 0
	if n <= -3.1e+116:
		tmp = t_0
	elif n <= -1.3e+88:
		tmp = (1.0 / x) / n
	elif (n <= -2400000000.0) or not (n <= 2200000.0):
		tmp = t_0
	else:
		tmp = math.exp((x / n)) - math.pow(x, (1.0 / n))
	return tmp
function code(x, n)
	t_0 = Float64(Float64(-log(Float64(x / Float64(x + 1.0)))) / n)
	tmp = 0.0
	if (n <= -3.1e+116)
		tmp = t_0;
	elseif (n <= -1.3e+88)
		tmp = Float64(Float64(1.0 / x) / n);
	elseif ((n <= -2400000000.0) || !(n <= 2200000.0))
		tmp = t_0;
	else
		tmp = Float64(exp(Float64(x / n)) - (x ^ Float64(1.0 / n)));
	end
	return tmp
end
function tmp_2 = code(x, n)
	t_0 = -log((x / (x + 1.0))) / n;
	tmp = 0.0;
	if (n <= -3.1e+116)
		tmp = t_0;
	elseif (n <= -1.3e+88)
		tmp = (1.0 / x) / n;
	elseif ((n <= -2400000000.0) || ~((n <= 2200000.0)))
		tmp = t_0;
	else
		tmp = exp((x / n)) - (x ^ (1.0 / n));
	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]}, If[LessEqual[n, -3.1e+116], t$95$0, If[LessEqual[n, -1.3e+88], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], If[Or[LessEqual[n, -2400000000.0], N[Not[LessEqual[n, 2200000.0]], $MachinePrecision]], t$95$0, N[(N[Exp[N[(x / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;n \leq -2400000000 \lor \neg \left(n \leq 2200000\right):\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if n < -3.09999999999999996e116 or -1.3e88 < n < -2.4e9 or 2.2e6 < n

    1. Initial program 23.4%

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.09999999999999996e116 < n < -1.3e88

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

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

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

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

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

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

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

    if -2.4e9 < n < 2.2e6

    1. Initial program 86.6%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -3.1 \cdot 10^{+116}:\\ \;\;\;\;\frac{-\log \left(\frac{x}{x + 1}\right)}{n}\\ \mathbf{elif}\;n \leq -1.3 \cdot 10^{+88}:\\ \;\;\;\;\frac{\frac{1}{x}}{n}\\ \mathbf{elif}\;n \leq -2400000000 \lor \neg \left(n \leq 2200000\right):\\ \;\;\;\;\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 7: 66.8% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \log \left(\frac{x}{x + 1}\right)\\ t_1 := {x}^{\left(\frac{1}{n}\right)}\\ t_2 := 1 - t_1\\ t_3 := \frac{-t_0}{n}\\ t_4 := \frac{1}{n \cdot x}\\ \mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{+243}:\\ \;\;\;\;\frac{0}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{+164}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{+25}:\\ \;\;\;\;\frac{0}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-9}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-87}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{-116}:\\ \;\;\;\;\frac{\frac{1}{x}}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-112}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-104}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-7}:\\ \;\;\;\;t_0 \cdot \frac{1}{-n}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{+214}:\\ \;\;\;\;\left(1 + \frac{x}{n}\right) - t_1\\ \mathbf{else}:\\ \;\;\;\;t_4\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (log (/ x (+ x 1.0))))
        (t_1 (pow x (/ 1.0 n)))
        (t_2 (- 1.0 t_1))
        (t_3 (/ (- t_0) n))
        (t_4 (/ 1.0 (* n x))))
   (if (<= (/ 1.0 n) -1e+243)
     (/ 0.0 n)
     (if (<= (/ 1.0 n) -2e+164)
       t_2
       (if (<= (/ 1.0 n) -2e+25)
         (/ 0.0 n)
         (if (<= (/ 1.0 n) -1e-9)
           t_2
           (if (<= (/ 1.0 n) -1e-87)
             t_3
             (if (<= (/ 1.0 n) -5e-116)
               (/ (/ 1.0 x) n)
               (if (<= (/ 1.0 n) 2e-112)
                 t_3
                 (if (<= (/ 1.0 n) 5e-104)
                   t_4
                   (if (<= (/ 1.0 n) 5e-7)
                     (* t_0 (/ 1.0 (- n)))
                     (if (<= (/ 1.0 n) 1e+214)
                       (- (+ 1.0 (/ x n)) t_1)
                       t_4))))))))))))
double code(double x, double n) {
	double t_0 = log((x / (x + 1.0)));
	double t_1 = pow(x, (1.0 / n));
	double t_2 = 1.0 - t_1;
	double t_3 = -t_0 / n;
	double t_4 = 1.0 / (n * x);
	double tmp;
	if ((1.0 / n) <= -1e+243) {
		tmp = 0.0 / n;
	} else if ((1.0 / n) <= -2e+164) {
		tmp = t_2;
	} else if ((1.0 / n) <= -2e+25) {
		tmp = 0.0 / n;
	} else if ((1.0 / n) <= -1e-9) {
		tmp = t_2;
	} else if ((1.0 / n) <= -1e-87) {
		tmp = t_3;
	} else if ((1.0 / n) <= -5e-116) {
		tmp = (1.0 / x) / n;
	} else if ((1.0 / n) <= 2e-112) {
		tmp = t_3;
	} else if ((1.0 / n) <= 5e-104) {
		tmp = t_4;
	} else if ((1.0 / n) <= 5e-7) {
		tmp = t_0 * (1.0 / -n);
	} else if ((1.0 / n) <= 1e+214) {
		tmp = (1.0 + (x / n)) - t_1;
	} else {
		tmp = t_4;
	}
	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) :: t_3
    real(8) :: t_4
    real(8) :: tmp
    t_0 = log((x / (x + 1.0d0)))
    t_1 = x ** (1.0d0 / n)
    t_2 = 1.0d0 - t_1
    t_3 = -t_0 / n
    t_4 = 1.0d0 / (n * x)
    if ((1.0d0 / n) <= (-1d+243)) then
        tmp = 0.0d0 / n
    else if ((1.0d0 / n) <= (-2d+164)) then
        tmp = t_2
    else if ((1.0d0 / n) <= (-2d+25)) then
        tmp = 0.0d0 / n
    else if ((1.0d0 / n) <= (-1d-9)) then
        tmp = t_2
    else if ((1.0d0 / n) <= (-1d-87)) then
        tmp = t_3
    else if ((1.0d0 / n) <= (-5d-116)) then
        tmp = (1.0d0 / x) / n
    else if ((1.0d0 / n) <= 2d-112) then
        tmp = t_3
    else if ((1.0d0 / n) <= 5d-104) then
        tmp = t_4
    else if ((1.0d0 / n) <= 5d-7) then
        tmp = t_0 * (1.0d0 / -n)
    else if ((1.0d0 / n) <= 1d+214) then
        tmp = (1.0d0 + (x / n)) - t_1
    else
        tmp = t_4
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double t_0 = Math.log((x / (x + 1.0)));
	double t_1 = Math.pow(x, (1.0 / n));
	double t_2 = 1.0 - t_1;
	double t_3 = -t_0 / n;
	double t_4 = 1.0 / (n * x);
	double tmp;
	if ((1.0 / n) <= -1e+243) {
		tmp = 0.0 / n;
	} else if ((1.0 / n) <= -2e+164) {
		tmp = t_2;
	} else if ((1.0 / n) <= -2e+25) {
		tmp = 0.0 / n;
	} else if ((1.0 / n) <= -1e-9) {
		tmp = t_2;
	} else if ((1.0 / n) <= -1e-87) {
		tmp = t_3;
	} else if ((1.0 / n) <= -5e-116) {
		tmp = (1.0 / x) / n;
	} else if ((1.0 / n) <= 2e-112) {
		tmp = t_3;
	} else if ((1.0 / n) <= 5e-104) {
		tmp = t_4;
	} else if ((1.0 / n) <= 5e-7) {
		tmp = t_0 * (1.0 / -n);
	} else if ((1.0 / n) <= 1e+214) {
		tmp = (1.0 + (x / n)) - t_1;
	} else {
		tmp = t_4;
	}
	return tmp;
}
def code(x, n):
	t_0 = math.log((x / (x + 1.0)))
	t_1 = math.pow(x, (1.0 / n))
	t_2 = 1.0 - t_1
	t_3 = -t_0 / n
	t_4 = 1.0 / (n * x)
	tmp = 0
	if (1.0 / n) <= -1e+243:
		tmp = 0.0 / n
	elif (1.0 / n) <= -2e+164:
		tmp = t_2
	elif (1.0 / n) <= -2e+25:
		tmp = 0.0 / n
	elif (1.0 / n) <= -1e-9:
		tmp = t_2
	elif (1.0 / n) <= -1e-87:
		tmp = t_3
	elif (1.0 / n) <= -5e-116:
		tmp = (1.0 / x) / n
	elif (1.0 / n) <= 2e-112:
		tmp = t_3
	elif (1.0 / n) <= 5e-104:
		tmp = t_4
	elif (1.0 / n) <= 5e-7:
		tmp = t_0 * (1.0 / -n)
	elif (1.0 / n) <= 1e+214:
		tmp = (1.0 + (x / n)) - t_1
	else:
		tmp = t_4
	return tmp
function code(x, n)
	t_0 = log(Float64(x / Float64(x + 1.0)))
	t_1 = x ^ Float64(1.0 / n)
	t_2 = Float64(1.0 - t_1)
	t_3 = Float64(Float64(-t_0) / n)
	t_4 = Float64(1.0 / Float64(n * x))
	tmp = 0.0
	if (Float64(1.0 / n) <= -1e+243)
		tmp = Float64(0.0 / n);
	elseif (Float64(1.0 / n) <= -2e+164)
		tmp = t_2;
	elseif (Float64(1.0 / n) <= -2e+25)
		tmp = Float64(0.0 / n);
	elseif (Float64(1.0 / n) <= -1e-9)
		tmp = t_2;
	elseif (Float64(1.0 / n) <= -1e-87)
		tmp = t_3;
	elseif (Float64(1.0 / n) <= -5e-116)
		tmp = Float64(Float64(1.0 / x) / n);
	elseif (Float64(1.0 / n) <= 2e-112)
		tmp = t_3;
	elseif (Float64(1.0 / n) <= 5e-104)
		tmp = t_4;
	elseif (Float64(1.0 / n) <= 5e-7)
		tmp = Float64(t_0 * Float64(1.0 / Float64(-n)));
	elseif (Float64(1.0 / n) <= 1e+214)
		tmp = Float64(Float64(1.0 + Float64(x / n)) - t_1);
	else
		tmp = t_4;
	end
	return tmp
end
function tmp_2 = code(x, n)
	t_0 = log((x / (x + 1.0)));
	t_1 = x ^ (1.0 / n);
	t_2 = 1.0 - t_1;
	t_3 = -t_0 / n;
	t_4 = 1.0 / (n * x);
	tmp = 0.0;
	if ((1.0 / n) <= -1e+243)
		tmp = 0.0 / n;
	elseif ((1.0 / n) <= -2e+164)
		tmp = t_2;
	elseif ((1.0 / n) <= -2e+25)
		tmp = 0.0 / n;
	elseif ((1.0 / n) <= -1e-9)
		tmp = t_2;
	elseif ((1.0 / n) <= -1e-87)
		tmp = t_3;
	elseif ((1.0 / n) <= -5e-116)
		tmp = (1.0 / x) / n;
	elseif ((1.0 / n) <= 2e-112)
		tmp = t_3;
	elseif ((1.0 / n) <= 5e-104)
		tmp = t_4;
	elseif ((1.0 / n) <= 5e-7)
		tmp = t_0 * (1.0 / -n);
	elseif ((1.0 / n) <= 1e+214)
		tmp = (1.0 + (x / n)) - t_1;
	else
		tmp = t_4;
	end
	tmp_2 = tmp;
end
code[x_, n_] := Block[{t$95$0 = N[Log[N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(1.0 - t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[((-t$95$0) / n), $MachinePrecision]}, Block[{t$95$4 = N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e+243], N[(0.0 / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e+164], t$95$2, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e+25], N[(0.0 / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-9], t$95$2, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-87], t$95$3, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-116], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-112], t$95$3, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-104], t$95$4, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-7], N[(t$95$0 * N[(1.0 / (-n)), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+214], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision], t$95$4]]]]]]]]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{+164}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{+25}:\\
\;\;\;\;\frac{0}{n}\\

\mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-9}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-87}:\\
\;\;\;\;t_3\\

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

\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-112}:\\
\;\;\;\;t_3\\

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

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

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

\mathbf{else}:\\
\;\;\;\;t_4\\


\end{array}
\end{array}
Derivation
  1. Split input into 7 regimes
  2. if (/.f64 1 n) < -1.0000000000000001e243 or -2e164 < (/.f64 1 n) < -2.00000000000000018e25

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

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

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

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

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

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

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

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

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

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

    if -1.0000000000000001e243 < (/.f64 1 n) < -2e164 or -2.00000000000000018e25 < (/.f64 1 n) < -1.00000000000000006e-9

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

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

    if -1.00000000000000006e-9 < (/.f64 1 n) < -1.00000000000000002e-87 or -5.0000000000000003e-116 < (/.f64 1 n) < 1.9999999999999999e-112

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.00000000000000002e-87 < (/.f64 1 n) < -5.0000000000000003e-116

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

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

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

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

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

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

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

    if 1.9999999999999999e-112 < (/.f64 1 n) < 4.99999999999999979e-104 or 9.9999999999999995e213 < (/.f64 1 n)

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

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

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

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

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

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

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

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

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

    if 4.99999999999999979e-104 < (/.f64 1 n) < 4.99999999999999977e-7

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-\color{blue}{\log \left(\frac{1 + x}{x}\right)}\right) \cdot \frac{1}{-n} \]
      7. neg-log60.8%

        \[\leadsto \color{blue}{\log \left(\frac{1}{\frac{1 + x}{x}}\right)} \cdot \frac{1}{-n} \]
      8. clear-num60.9%

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

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

    if 4.99999999999999977e-7 < (/.f64 1 n) < 9.9999999999999995e213

    1. Initial program 77.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{+243}:\\ \;\;\;\;\frac{0}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{+164}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{+25}:\\ \;\;\;\;\frac{0}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-9}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-87}:\\ \;\;\;\;\frac{-\log \left(\frac{x}{x + 1}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{-116}:\\ \;\;\;\;\frac{\frac{1}{x}}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-112}:\\ \;\;\;\;\frac{-\log \left(\frac{x}{x + 1}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-104}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-7}:\\ \;\;\;\;\log \left(\frac{x}{x + 1}\right) \cdot \frac{1}{-n}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{+214}:\\ \;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 66.7% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{1}{n \cdot x}\\ t_1 := \frac{\log \left(1 + \frac{1}{x}\right)}{n}\\ t_2 := 1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{+243}:\\ \;\;\;\;\frac{0}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{+164}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{+25}:\\ \;\;\;\;\frac{0}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-9}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-87}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{-116}:\\ \;\;\;\;\frac{\frac{1}{x}}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-112}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-104}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-7}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{+214}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (/ 1.0 (* n x)))
        (t_1 (/ (log (+ 1.0 (/ 1.0 x))) n))
        (t_2 (- 1.0 (pow x (/ 1.0 n)))))
   (if (<= (/ 1.0 n) -1e+243)
     (/ 0.0 n)
     (if (<= (/ 1.0 n) -2e+164)
       t_2
       (if (<= (/ 1.0 n) -2e+25)
         (/ 0.0 n)
         (if (<= (/ 1.0 n) -1e-9)
           t_2
           (if (<= (/ 1.0 n) -1e-87)
             t_1
             (if (<= (/ 1.0 n) -5e-116)
               (/ (/ 1.0 x) n)
               (if (<= (/ 1.0 n) 2e-112)
                 t_1
                 (if (<= (/ 1.0 n) 5e-104)
                   t_0
                   (if (<= (/ 1.0 n) 5e-7)
                     t_1
                     (if (<= (/ 1.0 n) 1e+214) t_2 t_0))))))))))))
double code(double x, double n) {
	double t_0 = 1.0 / (n * x);
	double t_1 = log((1.0 + (1.0 / x))) / n;
	double t_2 = 1.0 - pow(x, (1.0 / n));
	double tmp;
	if ((1.0 / n) <= -1e+243) {
		tmp = 0.0 / n;
	} else if ((1.0 / n) <= -2e+164) {
		tmp = t_2;
	} else if ((1.0 / n) <= -2e+25) {
		tmp = 0.0 / n;
	} else if ((1.0 / n) <= -1e-9) {
		tmp = t_2;
	} else if ((1.0 / n) <= -1e-87) {
		tmp = t_1;
	} else if ((1.0 / n) <= -5e-116) {
		tmp = (1.0 / x) / n;
	} else if ((1.0 / n) <= 2e-112) {
		tmp = t_1;
	} else if ((1.0 / n) <= 5e-104) {
		tmp = t_0;
	} else if ((1.0 / n) <= 5e-7) {
		tmp = t_1;
	} else if ((1.0 / n) <= 1e+214) {
		tmp = t_2;
	} 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) :: t_2
    real(8) :: tmp
    t_0 = 1.0d0 / (n * x)
    t_1 = log((1.0d0 + (1.0d0 / x))) / n
    t_2 = 1.0d0 - (x ** (1.0d0 / n))
    if ((1.0d0 / n) <= (-1d+243)) then
        tmp = 0.0d0 / n
    else if ((1.0d0 / n) <= (-2d+164)) then
        tmp = t_2
    else if ((1.0d0 / n) <= (-2d+25)) then
        tmp = 0.0d0 / n
    else if ((1.0d0 / n) <= (-1d-9)) then
        tmp = t_2
    else if ((1.0d0 / n) <= (-1d-87)) then
        tmp = t_1
    else if ((1.0d0 / n) <= (-5d-116)) then
        tmp = (1.0d0 / x) / n
    else if ((1.0d0 / n) <= 2d-112) then
        tmp = t_1
    else if ((1.0d0 / n) <= 5d-104) then
        tmp = t_0
    else if ((1.0d0 / n) <= 5d-7) then
        tmp = t_1
    else if ((1.0d0 / n) <= 1d+214) then
        tmp = t_2
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double t_0 = 1.0 / (n * x);
	double t_1 = Math.log((1.0 + (1.0 / x))) / n;
	double t_2 = 1.0 - Math.pow(x, (1.0 / n));
	double tmp;
	if ((1.0 / n) <= -1e+243) {
		tmp = 0.0 / n;
	} else if ((1.0 / n) <= -2e+164) {
		tmp = t_2;
	} else if ((1.0 / n) <= -2e+25) {
		tmp = 0.0 / n;
	} else if ((1.0 / n) <= -1e-9) {
		tmp = t_2;
	} else if ((1.0 / n) <= -1e-87) {
		tmp = t_1;
	} else if ((1.0 / n) <= -5e-116) {
		tmp = (1.0 / x) / n;
	} else if ((1.0 / n) <= 2e-112) {
		tmp = t_1;
	} else if ((1.0 / n) <= 5e-104) {
		tmp = t_0;
	} else if ((1.0 / n) <= 5e-7) {
		tmp = t_1;
	} else if ((1.0 / n) <= 1e+214) {
		tmp = t_2;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, n):
	t_0 = 1.0 / (n * x)
	t_1 = math.log((1.0 + (1.0 / x))) / n
	t_2 = 1.0 - math.pow(x, (1.0 / n))
	tmp = 0
	if (1.0 / n) <= -1e+243:
		tmp = 0.0 / n
	elif (1.0 / n) <= -2e+164:
		tmp = t_2
	elif (1.0 / n) <= -2e+25:
		tmp = 0.0 / n
	elif (1.0 / n) <= -1e-9:
		tmp = t_2
	elif (1.0 / n) <= -1e-87:
		tmp = t_1
	elif (1.0 / n) <= -5e-116:
		tmp = (1.0 / x) / n
	elif (1.0 / n) <= 2e-112:
		tmp = t_1
	elif (1.0 / n) <= 5e-104:
		tmp = t_0
	elif (1.0 / n) <= 5e-7:
		tmp = t_1
	elif (1.0 / n) <= 1e+214:
		tmp = t_2
	else:
		tmp = t_0
	return tmp
function code(x, n)
	t_0 = Float64(1.0 / Float64(n * x))
	t_1 = Float64(log(Float64(1.0 + Float64(1.0 / x))) / n)
	t_2 = Float64(1.0 - (x ^ Float64(1.0 / n)))
	tmp = 0.0
	if (Float64(1.0 / n) <= -1e+243)
		tmp = Float64(0.0 / n);
	elseif (Float64(1.0 / n) <= -2e+164)
		tmp = t_2;
	elseif (Float64(1.0 / n) <= -2e+25)
		tmp = Float64(0.0 / n);
	elseif (Float64(1.0 / n) <= -1e-9)
		tmp = t_2;
	elseif (Float64(1.0 / n) <= -1e-87)
		tmp = t_1;
	elseif (Float64(1.0 / n) <= -5e-116)
		tmp = Float64(Float64(1.0 / x) / n);
	elseif (Float64(1.0 / n) <= 2e-112)
		tmp = t_1;
	elseif (Float64(1.0 / n) <= 5e-104)
		tmp = t_0;
	elseif (Float64(1.0 / n) <= 5e-7)
		tmp = t_1;
	elseif (Float64(1.0 / n) <= 1e+214)
		tmp = t_2;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, n)
	t_0 = 1.0 / (n * x);
	t_1 = log((1.0 + (1.0 / x))) / n;
	t_2 = 1.0 - (x ^ (1.0 / n));
	tmp = 0.0;
	if ((1.0 / n) <= -1e+243)
		tmp = 0.0 / n;
	elseif ((1.0 / n) <= -2e+164)
		tmp = t_2;
	elseif ((1.0 / n) <= -2e+25)
		tmp = 0.0 / n;
	elseif ((1.0 / n) <= -1e-9)
		tmp = t_2;
	elseif ((1.0 / n) <= -1e-87)
		tmp = t_1;
	elseif ((1.0 / n) <= -5e-116)
		tmp = (1.0 / x) / n;
	elseif ((1.0 / n) <= 2e-112)
		tmp = t_1;
	elseif ((1.0 / n) <= 5e-104)
		tmp = t_0;
	elseif ((1.0 / n) <= 5e-7)
		tmp = t_1;
	elseif ((1.0 / n) <= 1e+214)
		tmp = t_2;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, n_] := Block[{t$95$0 = N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Log[N[(1.0 + N[(1.0 / x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]}, Block[{t$95$2 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e+243], N[(0.0 / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e+164], t$95$2, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e+25], N[(0.0 / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-9], t$95$2, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-87], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-116], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-112], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-104], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-7], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+214], t$95$2, t$95$0]]]]]]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{+164}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{+25}:\\
\;\;\;\;\frac{0}{n}\\

\mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-9}:\\
\;\;\;\;t_2\\

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

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

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq 10^{+214}:\\
\;\;\;\;t_2\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if (/.f64 1 n) < -1.0000000000000001e243 or -2e164 < (/.f64 1 n) < -2.00000000000000018e25

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

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

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

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

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

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

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

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

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

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

    if -1.0000000000000001e243 < (/.f64 1 n) < -2e164 or -2.00000000000000018e25 < (/.f64 1 n) < -1.00000000000000006e-9 or 4.99999999999999977e-7 < (/.f64 1 n) < 9.9999999999999995e213

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

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

    if -1.00000000000000006e-9 < (/.f64 1 n) < -1.00000000000000002e-87 or -5.0000000000000003e-116 < (/.f64 1 n) < 1.9999999999999999e-112 or 4.99999999999999979e-104 < (/.f64 1 n) < 4.99999999999999977e-7

    1. Initial program 24.2%

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

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

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

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

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

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

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

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

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

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

    if -1.00000000000000002e-87 < (/.f64 1 n) < -5.0000000000000003e-116

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

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

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

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

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

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

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

    if 1.9999999999999999e-112 < (/.f64 1 n) < 4.99999999999999979e-104 or 9.9999999999999995e213 < (/.f64 1 n)

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{+243}:\\ \;\;\;\;\frac{0}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{+164}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{+25}:\\ \;\;\;\;\frac{0}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-9}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-87}:\\ \;\;\;\;\frac{\log \left(1 + \frac{1}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{-116}:\\ \;\;\;\;\frac{\frac{1}{x}}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-112}:\\ \;\;\;\;\frac{\log \left(1 + \frac{1}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-104}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-7}:\\ \;\;\;\;\frac{\log \left(1 + \frac{1}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{+214}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 66.7% 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}{x + 1}\right)}{n}\\ t_2 := \frac{1}{n \cdot x}\\ \mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{+243}:\\ \;\;\;\;\frac{0}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{+164}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{+25}:\\ \;\;\;\;\frac{0}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-9}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-87}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{-116}:\\ \;\;\;\;\frac{\frac{1}{x}}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-112}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-104}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-7}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{+214}:\\ \;\;\;\;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 (+ x 1.0)))) n))
        (t_2 (/ 1.0 (* n x))))
   (if (<= (/ 1.0 n) -1e+243)
     (/ 0.0 n)
     (if (<= (/ 1.0 n) -2e+164)
       t_0
       (if (<= (/ 1.0 n) -2e+25)
         (/ 0.0 n)
         (if (<= (/ 1.0 n) -1e-9)
           t_0
           (if (<= (/ 1.0 n) -1e-87)
             t_1
             (if (<= (/ 1.0 n) -5e-116)
               (/ (/ 1.0 x) n)
               (if (<= (/ 1.0 n) 2e-112)
                 t_1
                 (if (<= (/ 1.0 n) 5e-104)
                   t_2
                   (if (<= (/ 1.0 n) 5e-7)
                     t_1
                     (if (<= (/ 1.0 n) 1e+214) 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 / (x + 1.0))) / n;
	double t_2 = 1.0 / (n * x);
	double tmp;
	if ((1.0 / n) <= -1e+243) {
		tmp = 0.0 / n;
	} else if ((1.0 / n) <= -2e+164) {
		tmp = t_0;
	} else if ((1.0 / n) <= -2e+25) {
		tmp = 0.0 / n;
	} else if ((1.0 / n) <= -1e-9) {
		tmp = t_0;
	} else if ((1.0 / n) <= -1e-87) {
		tmp = t_1;
	} else if ((1.0 / n) <= -5e-116) {
		tmp = (1.0 / x) / n;
	} else if ((1.0 / n) <= 2e-112) {
		tmp = t_1;
	} else if ((1.0 / n) <= 5e-104) {
		tmp = t_2;
	} else if ((1.0 / n) <= 5e-7) {
		tmp = t_1;
	} else if ((1.0 / n) <= 1e+214) {
		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 / (x + 1.0d0))) / n
    t_2 = 1.0d0 / (n * x)
    if ((1.0d0 / n) <= (-1d+243)) then
        tmp = 0.0d0 / n
    else if ((1.0d0 / n) <= (-2d+164)) then
        tmp = t_0
    else if ((1.0d0 / n) <= (-2d+25)) then
        tmp = 0.0d0 / n
    else if ((1.0d0 / n) <= (-1d-9)) then
        tmp = t_0
    else if ((1.0d0 / n) <= (-1d-87)) then
        tmp = t_1
    else if ((1.0d0 / n) <= (-5d-116)) then
        tmp = (1.0d0 / x) / n
    else if ((1.0d0 / n) <= 2d-112) then
        tmp = t_1
    else if ((1.0d0 / n) <= 5d-104) then
        tmp = t_2
    else if ((1.0d0 / n) <= 5d-7) then
        tmp = t_1
    else if ((1.0d0 / n) <= 1d+214) 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 / (x + 1.0))) / n;
	double t_2 = 1.0 / (n * x);
	double tmp;
	if ((1.0 / n) <= -1e+243) {
		tmp = 0.0 / n;
	} else if ((1.0 / n) <= -2e+164) {
		tmp = t_0;
	} else if ((1.0 / n) <= -2e+25) {
		tmp = 0.0 / n;
	} else if ((1.0 / n) <= -1e-9) {
		tmp = t_0;
	} else if ((1.0 / n) <= -1e-87) {
		tmp = t_1;
	} else if ((1.0 / n) <= -5e-116) {
		tmp = (1.0 / x) / n;
	} else if ((1.0 / n) <= 2e-112) {
		tmp = t_1;
	} else if ((1.0 / n) <= 5e-104) {
		tmp = t_2;
	} else if ((1.0 / n) <= 5e-7) {
		tmp = t_1;
	} else if ((1.0 / n) <= 1e+214) {
		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 / (x + 1.0))) / n
	t_2 = 1.0 / (n * x)
	tmp = 0
	if (1.0 / n) <= -1e+243:
		tmp = 0.0 / n
	elif (1.0 / n) <= -2e+164:
		tmp = t_0
	elif (1.0 / n) <= -2e+25:
		tmp = 0.0 / n
	elif (1.0 / n) <= -1e-9:
		tmp = t_0
	elif (1.0 / n) <= -1e-87:
		tmp = t_1
	elif (1.0 / n) <= -5e-116:
		tmp = (1.0 / x) / n
	elif (1.0 / n) <= 2e-112:
		tmp = t_1
	elif (1.0 / n) <= 5e-104:
		tmp = t_2
	elif (1.0 / n) <= 5e-7:
		tmp = t_1
	elif (1.0 / n) <= 1e+214:
		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(Float64(-log(Float64(x / Float64(x + 1.0)))) / n)
	t_2 = Float64(1.0 / Float64(n * x))
	tmp = 0.0
	if (Float64(1.0 / n) <= -1e+243)
		tmp = Float64(0.0 / n);
	elseif (Float64(1.0 / n) <= -2e+164)
		tmp = t_0;
	elseif (Float64(1.0 / n) <= -2e+25)
		tmp = Float64(0.0 / n);
	elseif (Float64(1.0 / n) <= -1e-9)
		tmp = t_0;
	elseif (Float64(1.0 / n) <= -1e-87)
		tmp = t_1;
	elseif (Float64(1.0 / n) <= -5e-116)
		tmp = Float64(Float64(1.0 / x) / n);
	elseif (Float64(1.0 / n) <= 2e-112)
		tmp = t_1;
	elseif (Float64(1.0 / n) <= 5e-104)
		tmp = t_2;
	elseif (Float64(1.0 / n) <= 5e-7)
		tmp = t_1;
	elseif (Float64(1.0 / n) <= 1e+214)
		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 / (x + 1.0))) / n;
	t_2 = 1.0 / (n * x);
	tmp = 0.0;
	if ((1.0 / n) <= -1e+243)
		tmp = 0.0 / n;
	elseif ((1.0 / n) <= -2e+164)
		tmp = t_0;
	elseif ((1.0 / n) <= -2e+25)
		tmp = 0.0 / n;
	elseif ((1.0 / n) <= -1e-9)
		tmp = t_0;
	elseif ((1.0 / n) <= -1e-87)
		tmp = t_1;
	elseif ((1.0 / n) <= -5e-116)
		tmp = (1.0 / x) / n;
	elseif ((1.0 / n) <= 2e-112)
		tmp = t_1;
	elseif ((1.0 / n) <= 5e-104)
		tmp = t_2;
	elseif ((1.0 / n) <= 5e-7)
		tmp = t_1;
	elseif ((1.0 / n) <= 1e+214)
		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[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]) / n), $MachinePrecision]}, Block[{t$95$2 = N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e+243], N[(0.0 / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e+164], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e+25], N[(0.0 / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-9], t$95$0, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-87], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-116], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-112], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-104], t$95$2, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-7], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+214], 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}{x + 1}\right)}{n}\\
t_2 := \frac{1}{n \cdot x}\\
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{+243}:\\
\;\;\;\;\frac{0}{n}\\

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

\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{+25}:\\
\;\;\;\;\frac{0}{n}\\

\mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-9}:\\
\;\;\;\;t_0\\

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

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

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

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

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

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

\mathbf{else}:\\
\;\;\;\;t_2\\


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if (/.f64 1 n) < -1.0000000000000001e243 or -2e164 < (/.f64 1 n) < -2.00000000000000018e25

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

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

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

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

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

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

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

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

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

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

    if -1.0000000000000001e243 < (/.f64 1 n) < -2e164 or -2.00000000000000018e25 < (/.f64 1 n) < -1.00000000000000006e-9 or 4.99999999999999977e-7 < (/.f64 1 n) < 9.9999999999999995e213

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

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

    if -1.00000000000000006e-9 < (/.f64 1 n) < -1.00000000000000002e-87 or -5.0000000000000003e-116 < (/.f64 1 n) < 1.9999999999999999e-112 or 4.99999999999999979e-104 < (/.f64 1 n) < 4.99999999999999977e-7

    1. Initial program 24.2%

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.00000000000000002e-87 < (/.f64 1 n) < -5.0000000000000003e-116

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

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

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

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

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

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

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

    if 1.9999999999999999e-112 < (/.f64 1 n) < 4.99999999999999979e-104 or 9.9999999999999995e213 < (/.f64 1 n)

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{+243}:\\ \;\;\;\;\frac{0}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{+164}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{+25}:\\ \;\;\;\;\frac{0}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-9}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-87}:\\ \;\;\;\;\frac{-\log \left(\frac{x}{x + 1}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{-116}:\\ \;\;\;\;\frac{\frac{1}{x}}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-112}:\\ \;\;\;\;\frac{-\log \left(\frac{x}{x + 1}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-104}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-7}:\\ \;\;\;\;\frac{-\log \left(\frac{x}{x + 1}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{+214}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 66.7% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \log \left(\frac{x}{x + 1}\right)\\ t_1 := 1 - {x}^{\left(\frac{1}{n}\right)}\\ t_2 := \frac{-t_0}{n}\\ t_3 := \frac{1}{n \cdot x}\\ \mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{+243}:\\ \;\;\;\;\frac{0}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{+164}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{+25}:\\ \;\;\;\;\frac{0}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-9}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-87}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{-116}:\\ \;\;\;\;\frac{\frac{1}{x}}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-112}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-104}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-7}:\\ \;\;\;\;t_0 \cdot \frac{1}{-n}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{+214}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (log (/ x (+ x 1.0))))
        (t_1 (- 1.0 (pow x (/ 1.0 n))))
        (t_2 (/ (- t_0) n))
        (t_3 (/ 1.0 (* n x))))
   (if (<= (/ 1.0 n) -1e+243)
     (/ 0.0 n)
     (if (<= (/ 1.0 n) -2e+164)
       t_1
       (if (<= (/ 1.0 n) -2e+25)
         (/ 0.0 n)
         (if (<= (/ 1.0 n) -1e-9)
           t_1
           (if (<= (/ 1.0 n) -1e-87)
             t_2
             (if (<= (/ 1.0 n) -5e-116)
               (/ (/ 1.0 x) n)
               (if (<= (/ 1.0 n) 2e-112)
                 t_2
                 (if (<= (/ 1.0 n) 5e-104)
                   t_3
                   (if (<= (/ 1.0 n) 5e-7)
                     (* t_0 (/ 1.0 (- n)))
                     (if (<= (/ 1.0 n) 1e+214) t_1 t_3))))))))))))
double code(double x, double n) {
	double t_0 = log((x / (x + 1.0)));
	double t_1 = 1.0 - pow(x, (1.0 / n));
	double t_2 = -t_0 / n;
	double t_3 = 1.0 / (n * x);
	double tmp;
	if ((1.0 / n) <= -1e+243) {
		tmp = 0.0 / n;
	} else if ((1.0 / n) <= -2e+164) {
		tmp = t_1;
	} else if ((1.0 / n) <= -2e+25) {
		tmp = 0.0 / n;
	} else if ((1.0 / n) <= -1e-9) {
		tmp = t_1;
	} else if ((1.0 / n) <= -1e-87) {
		tmp = t_2;
	} else if ((1.0 / n) <= -5e-116) {
		tmp = (1.0 / x) / n;
	} else if ((1.0 / n) <= 2e-112) {
		tmp = t_2;
	} else if ((1.0 / n) <= 5e-104) {
		tmp = t_3;
	} else if ((1.0 / n) <= 5e-7) {
		tmp = t_0 * (1.0 / -n);
	} else if ((1.0 / n) <= 1e+214) {
		tmp = t_1;
	} else {
		tmp = t_3;
	}
	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) :: t_3
    real(8) :: tmp
    t_0 = log((x / (x + 1.0d0)))
    t_1 = 1.0d0 - (x ** (1.0d0 / n))
    t_2 = -t_0 / n
    t_3 = 1.0d0 / (n * x)
    if ((1.0d0 / n) <= (-1d+243)) then
        tmp = 0.0d0 / n
    else if ((1.0d0 / n) <= (-2d+164)) then
        tmp = t_1
    else if ((1.0d0 / n) <= (-2d+25)) then
        tmp = 0.0d0 / n
    else if ((1.0d0 / n) <= (-1d-9)) then
        tmp = t_1
    else if ((1.0d0 / n) <= (-1d-87)) then
        tmp = t_2
    else if ((1.0d0 / n) <= (-5d-116)) then
        tmp = (1.0d0 / x) / n
    else if ((1.0d0 / n) <= 2d-112) then
        tmp = t_2
    else if ((1.0d0 / n) <= 5d-104) then
        tmp = t_3
    else if ((1.0d0 / n) <= 5d-7) then
        tmp = t_0 * (1.0d0 / -n)
    else if ((1.0d0 / n) <= 1d+214) then
        tmp = t_1
    else
        tmp = t_3
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double t_0 = Math.log((x / (x + 1.0)));
	double t_1 = 1.0 - Math.pow(x, (1.0 / n));
	double t_2 = -t_0 / n;
	double t_3 = 1.0 / (n * x);
	double tmp;
	if ((1.0 / n) <= -1e+243) {
		tmp = 0.0 / n;
	} else if ((1.0 / n) <= -2e+164) {
		tmp = t_1;
	} else if ((1.0 / n) <= -2e+25) {
		tmp = 0.0 / n;
	} else if ((1.0 / n) <= -1e-9) {
		tmp = t_1;
	} else if ((1.0 / n) <= -1e-87) {
		tmp = t_2;
	} else if ((1.0 / n) <= -5e-116) {
		tmp = (1.0 / x) / n;
	} else if ((1.0 / n) <= 2e-112) {
		tmp = t_2;
	} else if ((1.0 / n) <= 5e-104) {
		tmp = t_3;
	} else if ((1.0 / n) <= 5e-7) {
		tmp = t_0 * (1.0 / -n);
	} else if ((1.0 / n) <= 1e+214) {
		tmp = t_1;
	} else {
		tmp = t_3;
	}
	return tmp;
}
def code(x, n):
	t_0 = math.log((x / (x + 1.0)))
	t_1 = 1.0 - math.pow(x, (1.0 / n))
	t_2 = -t_0 / n
	t_3 = 1.0 / (n * x)
	tmp = 0
	if (1.0 / n) <= -1e+243:
		tmp = 0.0 / n
	elif (1.0 / n) <= -2e+164:
		tmp = t_1
	elif (1.0 / n) <= -2e+25:
		tmp = 0.0 / n
	elif (1.0 / n) <= -1e-9:
		tmp = t_1
	elif (1.0 / n) <= -1e-87:
		tmp = t_2
	elif (1.0 / n) <= -5e-116:
		tmp = (1.0 / x) / n
	elif (1.0 / n) <= 2e-112:
		tmp = t_2
	elif (1.0 / n) <= 5e-104:
		tmp = t_3
	elif (1.0 / n) <= 5e-7:
		tmp = t_0 * (1.0 / -n)
	elif (1.0 / n) <= 1e+214:
		tmp = t_1
	else:
		tmp = t_3
	return tmp
function code(x, n)
	t_0 = log(Float64(x / Float64(x + 1.0)))
	t_1 = Float64(1.0 - (x ^ Float64(1.0 / n)))
	t_2 = Float64(Float64(-t_0) / n)
	t_3 = Float64(1.0 / Float64(n * x))
	tmp = 0.0
	if (Float64(1.0 / n) <= -1e+243)
		tmp = Float64(0.0 / n);
	elseif (Float64(1.0 / n) <= -2e+164)
		tmp = t_1;
	elseif (Float64(1.0 / n) <= -2e+25)
		tmp = Float64(0.0 / n);
	elseif (Float64(1.0 / n) <= -1e-9)
		tmp = t_1;
	elseif (Float64(1.0 / n) <= -1e-87)
		tmp = t_2;
	elseif (Float64(1.0 / n) <= -5e-116)
		tmp = Float64(Float64(1.0 / x) / n);
	elseif (Float64(1.0 / n) <= 2e-112)
		tmp = t_2;
	elseif (Float64(1.0 / n) <= 5e-104)
		tmp = t_3;
	elseif (Float64(1.0 / n) <= 5e-7)
		tmp = Float64(t_0 * Float64(1.0 / Float64(-n)));
	elseif (Float64(1.0 / n) <= 1e+214)
		tmp = t_1;
	else
		tmp = t_3;
	end
	return tmp
end
function tmp_2 = code(x, n)
	t_0 = log((x / (x + 1.0)));
	t_1 = 1.0 - (x ^ (1.0 / n));
	t_2 = -t_0 / n;
	t_3 = 1.0 / (n * x);
	tmp = 0.0;
	if ((1.0 / n) <= -1e+243)
		tmp = 0.0 / n;
	elseif ((1.0 / n) <= -2e+164)
		tmp = t_1;
	elseif ((1.0 / n) <= -2e+25)
		tmp = 0.0 / n;
	elseif ((1.0 / n) <= -1e-9)
		tmp = t_1;
	elseif ((1.0 / n) <= -1e-87)
		tmp = t_2;
	elseif ((1.0 / n) <= -5e-116)
		tmp = (1.0 / x) / n;
	elseif ((1.0 / n) <= 2e-112)
		tmp = t_2;
	elseif ((1.0 / n) <= 5e-104)
		tmp = t_3;
	elseif ((1.0 / n) <= 5e-7)
		tmp = t_0 * (1.0 / -n);
	elseif ((1.0 / n) <= 1e+214)
		tmp = t_1;
	else
		tmp = t_3;
	end
	tmp_2 = tmp;
end
code[x_, n_] := Block[{t$95$0 = N[Log[N[(x / N[(x + 1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[((-t$95$0) / n), $MachinePrecision]}, Block[{t$95$3 = N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e+243], N[(0.0 / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e+164], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e+25], N[(0.0 / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-9], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], -1e-87], t$95$2, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-116], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-112], t$95$2, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-104], t$95$3, If[LessEqual[N[(1.0 / n), $MachinePrecision], 5e-7], N[(t$95$0 * N[(1.0 / (-n)), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e+214], t$95$1, t$95$3]]]]]]]]]]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{+25}:\\
\;\;\;\;\frac{0}{n}\\

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

\mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-87}:\\
\;\;\;\;t_2\\

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

\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-112}:\\
\;\;\;\;t_2\\

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

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

\mathbf{elif}\;\frac{1}{n} \leq 10^{+214}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;t_3\\


\end{array}
\end{array}
Derivation
  1. Split input into 6 regimes
  2. if (/.f64 1 n) < -1.0000000000000001e243 or -2e164 < (/.f64 1 n) < -2.00000000000000018e25

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

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

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

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

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

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

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

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

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

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

    if -1.0000000000000001e243 < (/.f64 1 n) < -2e164 or -2.00000000000000018e25 < (/.f64 1 n) < -1.00000000000000006e-9 or 4.99999999999999977e-7 < (/.f64 1 n) < 9.9999999999999995e213

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

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

    if -1.00000000000000006e-9 < (/.f64 1 n) < -1.00000000000000002e-87 or -5.0000000000000003e-116 < (/.f64 1 n) < 1.9999999999999999e-112

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.00000000000000002e-87 < (/.f64 1 n) < -5.0000000000000003e-116

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

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

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

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

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

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

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

    if 1.9999999999999999e-112 < (/.f64 1 n) < 4.99999999999999979e-104 or 9.9999999999999995e213 < (/.f64 1 n)

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

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

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

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

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

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

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

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

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

    if 4.99999999999999979e-104 < (/.f64 1 n) < 4.99999999999999977e-7

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-\color{blue}{\log \left(\frac{1 + x}{x}\right)}\right) \cdot \frac{1}{-n} \]
      7. neg-log60.8%

        \[\leadsto \color{blue}{\log \left(\frac{1}{\frac{1 + x}{x}}\right)} \cdot \frac{1}{-n} \]
      8. clear-num60.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{+243}:\\ \;\;\;\;\frac{0}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{+164}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{+25}:\\ \;\;\;\;\frac{0}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-9}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-87}:\\ \;\;\;\;\frac{-\log \left(\frac{x}{x + 1}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{-116}:\\ \;\;\;\;\frac{\frac{1}{x}}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-112}:\\ \;\;\;\;\frac{-\log \left(\frac{x}{x + 1}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-104}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-7}:\\ \;\;\;\;\log \left(\frac{x}{x + 1}\right) \cdot \frac{1}{-n}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{+214}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{n \cdot x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 78.7% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{1}{n \cdot x}\\
t_1 := \frac{x}{x + 1}\\
t_2 := \log t_1\\
t_3 := \frac{-t_2}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -500:\\
\;\;\;\;\frac{-\mathsf{log1p}\left(-1 + t_1\right)}{n}\\

\mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-87}:\\
\;\;\;\;t_3\\

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

\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-112}:\\
\;\;\;\;t_3\\

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

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

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

\mathbf{else}:\\
\;\;\;\;t_0\\


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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{-\log \left(\frac{x}{1 + x}\right)}}{n} \]
    10. Step-by-step derivation
      1. add-sqr-sqrt46.5%

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

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

        \[\leadsto \frac{-\sqrt{\color{blue}{\left(-\log \left(\frac{x}{1 + x}\right)\right) \cdot \left(-\log \left(\frac{x}{1 + x}\right)\right)}}}{n} \]
      4. sqrt-unprod46.8%

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

        \[\leadsto \frac{-\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\sqrt{-\log \left(\frac{x}{1 + x}\right)} \cdot \sqrt{-\log \left(\frac{x}{1 + x}\right)}\right)\right)}}{n} \]
      6. add-sqr-sqrt46.8%

        \[\leadsto \frac{-\mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{-\log \left(\frac{x}{1 + x}\right)}\right)\right)}{n} \]
      7. neg-log46.8%

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

        \[\leadsto \frac{-\mathsf{log1p}\left(\mathsf{expm1}\left(\log \color{blue}{\left(\frac{1 + x}{x}\right)}\right)\right)}{n} \]
      9. diff-log46.8%

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

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

        \[\leadsto \frac{-\mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\log \left(1 + x\right)} - \log x\right)\right)}{n} \]
      12. diff-log46.8%

        \[\leadsto \frac{-\mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\log \left(\frac{1 + x}{x}\right)}\right)\right)}{n} \]
      13. clear-num46.8%

        \[\leadsto \frac{-\mathsf{log1p}\left(\mathsf{expm1}\left(\log \color{blue}{\left(\frac{1}{\frac{x}{1 + x}}\right)}\right)\right)}{n} \]
      14. neg-log46.8%

        \[\leadsto \frac{-\mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{-\log \left(\frac{x}{1 + x}\right)}\right)\right)}{n} \]
      15. add-sqr-sqrt46.8%

        \[\leadsto \frac{-\mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\sqrt{-\log \left(\frac{x}{1 + x}\right)} \cdot \sqrt{-\log \left(\frac{x}{1 + x}\right)}}\right)\right)}{n} \]
      16. sqrt-unprod46.8%

        \[\leadsto \frac{-\mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\sqrt{\left(-\log \left(\frac{x}{1 + x}\right)\right) \cdot \left(-\log \left(\frac{x}{1 + x}\right)\right)}}\right)\right)}{n} \]
    11. Applied egg-rr93.2%

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

    if -500 < (/.f64 1 n) < -1.00000000000000002e-87 or -5.0000000000000003e-116 < (/.f64 1 n) < 1.9999999999999999e-112

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.00000000000000002e-87 < (/.f64 1 n) < -5.0000000000000003e-116

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

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

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

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

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

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

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

    if 1.9999999999999999e-112 < (/.f64 1 n) < 4.99999999999999979e-104 or 9.9999999999999995e213 < (/.f64 1 n)

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

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

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

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

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

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

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

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

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

    if 4.99999999999999979e-104 < (/.f64 1 n) < 4.99999999999999977e-7

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-\color{blue}{\log \left(\frac{1 + x}{x}\right)}\right) \cdot \frac{1}{-n} \]
      7. neg-log60.8%

        \[\leadsto \color{blue}{\log \left(\frac{1}{\frac{1 + x}{x}}\right)} \cdot \frac{1}{-n} \]
      8. clear-num60.9%

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

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

    if 4.99999999999999977e-7 < (/.f64 1 n) < 9.9999999999999995e213

    1. Initial program 77.4%

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

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

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

Alternative 12: 78.7% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{x}{x + 1}\\
t_1 := \log t_0\\
t_2 := \frac{-t_1}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -500:\\
\;\;\;\;\frac{-\mathsf{log1p}\left(-1 + t_0\right)}{n}\\

\mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-87}:\\
\;\;\;\;t_2\\

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

\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-112}:\\
\;\;\;\;t_2\\

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{-\log \left(\frac{x}{1 + x}\right)}}{n} \]
    10. Step-by-step derivation
      1. add-sqr-sqrt46.5%

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

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

        \[\leadsto \frac{-\sqrt{\color{blue}{\left(-\log \left(\frac{x}{1 + x}\right)\right) \cdot \left(-\log \left(\frac{x}{1 + x}\right)\right)}}}{n} \]
      4. sqrt-unprod46.8%

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

        \[\leadsto \frac{-\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\sqrt{-\log \left(\frac{x}{1 + x}\right)} \cdot \sqrt{-\log \left(\frac{x}{1 + x}\right)}\right)\right)}}{n} \]
      6. add-sqr-sqrt46.8%

        \[\leadsto \frac{-\mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{-\log \left(\frac{x}{1 + x}\right)}\right)\right)}{n} \]
      7. neg-log46.8%

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

        \[\leadsto \frac{-\mathsf{log1p}\left(\mathsf{expm1}\left(\log \color{blue}{\left(\frac{1 + x}{x}\right)}\right)\right)}{n} \]
      9. diff-log46.8%

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

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

        \[\leadsto \frac{-\mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\log \left(1 + x\right)} - \log x\right)\right)}{n} \]
      12. diff-log46.8%

        \[\leadsto \frac{-\mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\log \left(\frac{1 + x}{x}\right)}\right)\right)}{n} \]
      13. clear-num46.8%

        \[\leadsto \frac{-\mathsf{log1p}\left(\mathsf{expm1}\left(\log \color{blue}{\left(\frac{1}{\frac{x}{1 + x}}\right)}\right)\right)}{n} \]
      14. neg-log46.8%

        \[\leadsto \frac{-\mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{-\log \left(\frac{x}{1 + x}\right)}\right)\right)}{n} \]
      15. add-sqr-sqrt46.8%

        \[\leadsto \frac{-\mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\sqrt{-\log \left(\frac{x}{1 + x}\right)} \cdot \sqrt{-\log \left(\frac{x}{1 + x}\right)}}\right)\right)}{n} \]
      16. sqrt-unprod46.8%

        \[\leadsto \frac{-\mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\sqrt{\left(-\log \left(\frac{x}{1 + x}\right)\right) \cdot \left(-\log \left(\frac{x}{1 + x}\right)\right)}}\right)\right)}{n} \]
    11. Applied egg-rr93.2%

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

    if -500 < (/.f64 1 n) < -1.00000000000000002e-87 or -5.0000000000000003e-116 < (/.f64 1 n) < 1.9999999999999999e-112

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.00000000000000002e-87 < (/.f64 1 n) < -5.0000000000000003e-116

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

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

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

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

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

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

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

    if 1.9999999999999999e-112 < (/.f64 1 n) < 4.99999999999999979e-104

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

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

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

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

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

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

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

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

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

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

    if 4.99999999999999979e-104 < (/.f64 1 n) < 4.99999999999999977e-7

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-\color{blue}{\log \left(\frac{1 + x}{x}\right)}\right) \cdot \frac{1}{-n} \]
      7. neg-log60.8%

        \[\leadsto \color{blue}{\log \left(\frac{1}{\frac{1 + x}{x}}\right)} \cdot \frac{1}{-n} \]
      8. clear-num60.9%

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

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

    if 4.99999999999999977e-7 < (/.f64 1 n) < 9.9999999999999995e213

    1. Initial program 77.4%

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

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

    if 9.9999999999999995e213 < (/.f64 1 n)

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

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

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

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

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

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

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

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

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

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

Alternative 13: 78.7% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{1}{n \cdot x}\\
t_1 := \frac{x}{x + 1}\\
t_2 := \log t_1\\
t_3 := \frac{-t_2}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -500:\\
\;\;\;\;\frac{-\mathsf{log1p}\left(-1 + t_1\right)}{n}\\

\mathbf{elif}\;\frac{1}{n} \leq -1 \cdot 10^{-87}:\\
\;\;\;\;t_3\\

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

\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-112}:\\
\;\;\;\;t_3\\

\mathbf{elif}\;\frac{1}{n} \leq 5 \cdot 10^{-104}:\\
\;\;\;\;t_0 - \frac{0.5}{n \cdot {x}^{2}}\\

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

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

\mathbf{else}:\\
\;\;\;\;t_0\\


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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{-\log \left(\frac{x}{1 + x}\right)}}{n} \]
    10. Step-by-step derivation
      1. add-sqr-sqrt46.5%

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

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

        \[\leadsto \frac{-\sqrt{\color{blue}{\left(-\log \left(\frac{x}{1 + x}\right)\right) \cdot \left(-\log \left(\frac{x}{1 + x}\right)\right)}}}{n} \]
      4. sqrt-unprod46.8%

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

        \[\leadsto \frac{-\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\sqrt{-\log \left(\frac{x}{1 + x}\right)} \cdot \sqrt{-\log \left(\frac{x}{1 + x}\right)}\right)\right)}}{n} \]
      6. add-sqr-sqrt46.8%

        \[\leadsto \frac{-\mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{-\log \left(\frac{x}{1 + x}\right)}\right)\right)}{n} \]
      7. neg-log46.8%

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

        \[\leadsto \frac{-\mathsf{log1p}\left(\mathsf{expm1}\left(\log \color{blue}{\left(\frac{1 + x}{x}\right)}\right)\right)}{n} \]
      9. diff-log46.8%

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

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

        \[\leadsto \frac{-\mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\log \left(1 + x\right)} - \log x\right)\right)}{n} \]
      12. diff-log46.8%

        \[\leadsto \frac{-\mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\log \left(\frac{1 + x}{x}\right)}\right)\right)}{n} \]
      13. clear-num46.8%

        \[\leadsto \frac{-\mathsf{log1p}\left(\mathsf{expm1}\left(\log \color{blue}{\left(\frac{1}{\frac{x}{1 + x}}\right)}\right)\right)}{n} \]
      14. neg-log46.8%

        \[\leadsto \frac{-\mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{-\log \left(\frac{x}{1 + x}\right)}\right)\right)}{n} \]
      15. add-sqr-sqrt46.8%

        \[\leadsto \frac{-\mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\sqrt{-\log \left(\frac{x}{1 + x}\right)} \cdot \sqrt{-\log \left(\frac{x}{1 + x}\right)}}\right)\right)}{n} \]
      16. sqrt-unprod46.8%

        \[\leadsto \frac{-\mathsf{log1p}\left(\mathsf{expm1}\left(\color{blue}{\sqrt{\left(-\log \left(\frac{x}{1 + x}\right)\right) \cdot \left(-\log \left(\frac{x}{1 + x}\right)\right)}}\right)\right)}{n} \]
    11. Applied egg-rr93.2%

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

    if -500 < (/.f64 1 n) < -1.00000000000000002e-87 or -5.0000000000000003e-116 < (/.f64 1 n) < 1.9999999999999999e-112

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.00000000000000002e-87 < (/.f64 1 n) < -5.0000000000000003e-116

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

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

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

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

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

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

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

    if 1.9999999999999999e-112 < (/.f64 1 n) < 4.99999999999999979e-104

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{x \cdot n}} - 0.5 \cdot \frac{1}{n \cdot {x}^{2}} \]
      2. associate-*r/99.7%

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

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

        \[\leadsto \frac{1}{x \cdot n} - \frac{0.5}{\color{blue}{{x}^{2} \cdot n}} \]
    8. Simplified99.7%

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

    if 4.99999999999999979e-104 < (/.f64 1 n) < 4.99999999999999977e-7

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \left(-\color{blue}{\log \left(\frac{1 + x}{x}\right)}\right) \cdot \frac{1}{-n} \]
      7. neg-log60.8%

        \[\leadsto \color{blue}{\log \left(\frac{1}{\frac{1 + x}{x}}\right)} \cdot \frac{1}{-n} \]
      8. clear-num60.9%

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

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

    if 4.99999999999999977e-7 < (/.f64 1 n) < 9.9999999999999995e213

    1. Initial program 77.4%

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

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

    if 9.9999999999999995e213 < (/.f64 1 n)

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

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

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

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

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

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

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

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

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

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

Alternative 14: 59.5% accurate, 1.9× speedup?

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

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

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

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

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

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


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

    1. Initial program 37.7%

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

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

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

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

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

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

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

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

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

    if 1.62000000000000007e-74 < x < 7.1999999999999998e-43

    1. Initial program 79.4%

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

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

    if 7.1999999999999998e-43 < x < 1

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

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

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

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

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

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

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

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

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

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

    if 1 < x < 1.1e175

    1. Initial program 51.9%

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

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

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

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

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

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

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

    if 1.1e175 < x

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.62 \cdot 10^{-74}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 7.2 \cdot 10^{-43}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{elif}\;x \leq 1.1 \cdot 10^{+175}:\\ \;\;\;\;\frac{\frac{1}{x}}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{0}{n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 15: 60.6% accurate, 2.0× speedup?

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

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

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

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


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

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

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

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

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

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

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

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

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

    if 1 < x < 2.04999999999999988e173

    1. Initial program 51.9%

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

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

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

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

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

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

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

    if 2.04999999999999988e173 < x

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

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

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

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

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

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

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

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

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

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

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

Alternative 16: 60.3% accurate, 2.0× speedup?

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

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

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

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


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

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

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

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

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

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

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

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

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

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

    if 0.55000000000000004 < x < 1.39999999999999991e173

    1. Initial program 51.9%

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

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

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

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

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

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

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

    if 1.39999999999999991e173 < x

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

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

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

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

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

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

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

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

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

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

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

Alternative 17: 46.4% accurate, 23.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -10000000:\\ \;\;\;\;\frac{0}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x}}{n}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= (/ 1.0 n) -10000000.0) (/ 0.0 n) (/ (/ 1.0 x) n)))
double code(double x, double n) {
	double tmp;
	if ((1.0 / n) <= -10000000.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) <= (-10000000.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) <= -10000000.0) {
		tmp = 0.0 / n;
	} else {
		tmp = (1.0 / x) / n;
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if (1.0 / n) <= -10000000.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) <= -10000000.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) <= -10000000.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], -10000000.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 -10000000:\\
\;\;\;\;\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) < -1e7

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

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

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

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

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

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

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

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

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

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

    if -1e7 < (/.f64 1 n)

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

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

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

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

        \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(x\right)} - \log x}{n} \]
    5. Simplified62.2%

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
    6. Taylor expanded in x around inf 40.6%

      \[\leadsto \frac{\color{blue}{\frac{1}{x}}}{n} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification44.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -10000000:\\ \;\;\;\;\frac{0}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x}}{n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 18: 40.2% accurate, 42.2× speedup?

\[\begin{array}{l} \\ \frac{1}{n \cdot x} \end{array} \]
(FPCore (x n) :precision binary64 (/ 1.0 (* n x)))
double code(double x, double n) {
	return 1.0 / (n * x);
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    code = 1.0d0 / (n * x)
end function
public static double code(double x, double n) {
	return 1.0 / (n * x);
}
def code(x, n):
	return 1.0 / (n * x)
function code(x, n)
	return Float64(1.0 / Float64(n * x))
end
function tmp = code(x, n)
	tmp = 1.0 / (n * x);
end
code[x_, n_] := N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1}{n \cdot x}
\end{array}
Derivation
  1. Initial program 49.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 58.9%

    \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
  4. Step-by-step derivation
    1. +-rgt-identity58.9%

      \[\leadsto \frac{\color{blue}{\left(\log \left(1 + x\right) + 0\right)} - \log x}{n} \]
    2. +-rgt-identity58.9%

      \[\leadsto \frac{\color{blue}{\log \left(1 + x\right)} - \log x}{n} \]
    3. log1p-def58.9%

      \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(x\right)} - \log x}{n} \]
  5. Simplified58.9%

    \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
  6. Taylor expanded in x around inf 34.9%

    \[\leadsto \color{blue}{\frac{1}{n \cdot x}} \]
  7. Step-by-step derivation
    1. *-commutative34.9%

      \[\leadsto \frac{1}{\color{blue}{x \cdot n}} \]
  8. Simplified34.9%

    \[\leadsto \color{blue}{\frac{1}{x \cdot n}} \]
  9. Final simplification34.9%

    \[\leadsto \frac{1}{n \cdot x} \]
  10. Add Preprocessing

Alternative 19: 40.7% accurate, 42.2× speedup?

\[\begin{array}{l} \\ \frac{\frac{1}{x}}{n} \end{array} \]
(FPCore (x n) :precision binary64 (/ (/ 1.0 x) n))
double code(double x, double n) {
	return (1.0 / x) / n;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    code = (1.0d0 / x) / n
end function
public static double code(double x, double n) {
	return (1.0 / x) / n;
}
def code(x, n):
	return (1.0 / x) / n
function code(x, n)
	return Float64(Float64(1.0 / x) / n)
end
function tmp = code(x, n)
	tmp = (1.0 / x) / n;
end
code[x_, n_] := N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]
\begin{array}{l}

\\
\frac{\frac{1}{x}}{n}
\end{array}
Derivation
  1. Initial program 49.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 58.9%

    \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
  4. Step-by-step derivation
    1. +-rgt-identity58.9%

      \[\leadsto \frac{\color{blue}{\left(\log \left(1 + x\right) + 0\right)} - \log x}{n} \]
    2. +-rgt-identity58.9%

      \[\leadsto \frac{\color{blue}{\log \left(1 + x\right)} - \log x}{n} \]
    3. log1p-def58.9%

      \[\leadsto \frac{\color{blue}{\mathsf{log1p}\left(x\right)} - \log x}{n} \]
  5. Simplified58.9%

    \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) - \log x}{n}} \]
  6. Taylor expanded in x around inf 35.0%

    \[\leadsto \frac{\color{blue}{\frac{1}{x}}}{n} \]
  7. Final simplification35.0%

    \[\leadsto \frac{\frac{1}{x}}{n} \]
  8. Add Preprocessing

Reproduce

?
herbie shell --seed 2024011 
(FPCore (x n)
  :name "2nthrt (problem 3.4.6)"
  :precision binary64
  (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))