2nthrt (problem 3.4.6)

Percentage Accurate: 54.8% → 85.8%
Time: 28.5s
Alternatives: 18
Speedup: 1.8×

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 18 alternatives:

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

Initial Program: 54.8% accurate, 1.0× speedup?

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

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

Alternative 1: 85.8% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq -21000000000 \lor \neg \left(n \leq 10^{+24}\right):\\ \;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\ \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
 (if (or (<= n -21000000000.0) (not (<= n 1e+24)))
   (/ (log (/ (+ x 1.0) x)) n)
   (- (exp (/ (log1p x) n)) (pow x (/ 1.0 n)))))
double code(double x, double n) {
	double tmp;
	if ((n <= -21000000000.0) || !(n <= 1e+24)) {
		tmp = log(((x + 1.0) / x)) / n;
	} else {
		tmp = exp((log1p(x) / n)) - pow(x, (1.0 / n));
	}
	return tmp;
}
public static double code(double x, double n) {
	double tmp;
	if ((n <= -21000000000.0) || !(n <= 1e+24)) {
		tmp = Math.log(((x + 1.0) / x)) / n;
	} else {
		tmp = Math.exp((Math.log1p(x) / n)) - Math.pow(x, (1.0 / n));
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if (n <= -21000000000.0) or not (n <= 1e+24):
		tmp = math.log(((x + 1.0) / x)) / n
	else:
		tmp = math.exp((math.log1p(x) / n)) - math.pow(x, (1.0 / n))
	return tmp
function code(x, n)
	tmp = 0.0
	if ((n <= -21000000000.0) || !(n <= 1e+24))
		tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n);
	else
		tmp = Float64(exp(Float64(log1p(x) / n)) - (x ^ Float64(1.0 / n)));
	end
	return tmp
end
code[x_, n_] := If[Or[LessEqual[n, -21000000000.0], N[Not[LessEqual[n, 1e+24]], $MachinePrecision]], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], 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}
\mathbf{if}\;n \leq -21000000000 \lor \neg \left(n \leq 10^{+24}\right):\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\

\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 2 regimes
  2. if n < -2.1e10 or 9.9999999999999998e23 < n

    1. Initial program 24.3%

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

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

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

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

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

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

    if -2.1e10 < n < 9.9999999999999998e23

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

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

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

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

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

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

        \[\leadsto e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - \color{blue}{{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)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification87.4%

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

Alternative 2: 82.5% accurate, 1.0× speedup?

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

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

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

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


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

    1. Initial program 99.7%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Add Preprocessing

    if -5.00000000000000024e-5 < (/.f64 1 n) < 5.00000000000000024e-5

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

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

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

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

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

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

    if 5.00000000000000024e-5 < (/.f64 1 n)

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

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

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

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

Alternative 3: 59.1% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := n \cdot -0.3333333333333333 + n \cdot 0.25\\ t_1 := 1 - {x}^{\left(\frac{1}{n}\right)}\\ t_2 := \frac{\log x}{-n}\\ \mathbf{if}\;x \leq 6.8 \cdot 10^{-298}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 2.6 \cdot 10^{-283}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;x \leq 3.6 \cdot 10^{-257}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 2.8 \cdot 10^{-163}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{-152}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 1.2 \cdot 10^{-135}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;x \leq 9.2 \cdot 10^{-94}:\\ \;\;\;\;\frac{\frac{1}{n} - \frac{\frac{1}{n} \cdot 0.5 - 0.3333333333333333 \cdot \frac{1}{n \cdot x}}{x}}{x}\\ \mathbf{elif}\;x \leq 5 \cdot 10^{-79}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;x \leq 2.1 \cdot 10^{-43}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 0.5:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{elif}\;x \leq 3.7 \cdot 10^{+73}:\\ \;\;\;\;\frac{1}{x \cdot \left(n - \frac{\frac{\left(-0.5 \cdot \frac{t\_0}{x} + \left(\frac{n}{x} \cdot -0.25 + \frac{n}{x} \cdot 0.16666666666666666\right)\right) - t\_0}{x} + n \cdot -0.5}{x}\right)}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (+ (* n -0.3333333333333333) (* n 0.25)))
        (t_1 (- 1.0 (pow x (/ 1.0 n))))
        (t_2 (/ (log x) (- n))))
   (if (<= x 6.8e-298)
     t_1
     (if (<= x 2.6e-283)
       t_2
       (if (<= x 3.6e-257)
         t_1
         (if (<= x 2.8e-163)
           t_2
           (if (<= x 1.4e-152)
             t_1
             (if (<= x 1.2e-135)
               t_2
               (if (<= x 9.2e-94)
                 (/
                  (-
                   (/ 1.0 n)
                   (/
                    (-
                     (* (/ 1.0 n) 0.5)
                     (* 0.3333333333333333 (/ 1.0 (* n x))))
                    x))
                  x)
                 (if (<= x 5e-79)
                   t_2
                   (if (<= x 2.1e-43)
                     t_1
                     (if (<= x 0.5)
                       (/ (- x (log x)) n)
                       (if (<= x 3.7e+73)
                         (/
                          1.0
                          (*
                           x
                           (-
                            n
                            (/
                             (+
                              (/
                               (-
                                (+
                                 (* -0.5 (/ t_0 x))
                                 (+
                                  (* (/ n x) -0.25)
                                  (* (/ n x) 0.16666666666666666)))
                                t_0)
                               x)
                              (* n -0.5))
                             x))))
                         0.0)))))))))))))
double code(double x, double n) {
	double t_0 = (n * -0.3333333333333333) + (n * 0.25);
	double t_1 = 1.0 - pow(x, (1.0 / n));
	double t_2 = log(x) / -n;
	double tmp;
	if (x <= 6.8e-298) {
		tmp = t_1;
	} else if (x <= 2.6e-283) {
		tmp = t_2;
	} else if (x <= 3.6e-257) {
		tmp = t_1;
	} else if (x <= 2.8e-163) {
		tmp = t_2;
	} else if (x <= 1.4e-152) {
		tmp = t_1;
	} else if (x <= 1.2e-135) {
		tmp = t_2;
	} else if (x <= 9.2e-94) {
		tmp = ((1.0 / n) - ((((1.0 / n) * 0.5) - (0.3333333333333333 * (1.0 / (n * x)))) / x)) / x;
	} else if (x <= 5e-79) {
		tmp = t_2;
	} else if (x <= 2.1e-43) {
		tmp = t_1;
	} else if (x <= 0.5) {
		tmp = (x - log(x)) / n;
	} else if (x <= 3.7e+73) {
		tmp = 1.0 / (x * (n - ((((((-0.5 * (t_0 / x)) + (((n / x) * -0.25) + ((n / x) * 0.16666666666666666))) - t_0) / x) + (n * -0.5)) / x)));
	} else {
		tmp = 0.0;
	}
	return tmp;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_0 = (n * (-0.3333333333333333d0)) + (n * 0.25d0)
    t_1 = 1.0d0 - (x ** (1.0d0 / n))
    t_2 = log(x) / -n
    if (x <= 6.8d-298) then
        tmp = t_1
    else if (x <= 2.6d-283) then
        tmp = t_2
    else if (x <= 3.6d-257) then
        tmp = t_1
    else if (x <= 2.8d-163) then
        tmp = t_2
    else if (x <= 1.4d-152) then
        tmp = t_1
    else if (x <= 1.2d-135) then
        tmp = t_2
    else if (x <= 9.2d-94) then
        tmp = ((1.0d0 / n) - ((((1.0d0 / n) * 0.5d0) - (0.3333333333333333d0 * (1.0d0 / (n * x)))) / x)) / x
    else if (x <= 5d-79) then
        tmp = t_2
    else if (x <= 2.1d-43) then
        tmp = t_1
    else if (x <= 0.5d0) then
        tmp = (x - log(x)) / n
    else if (x <= 3.7d+73) then
        tmp = 1.0d0 / (x * (n - (((((((-0.5d0) * (t_0 / x)) + (((n / x) * (-0.25d0)) + ((n / x) * 0.16666666666666666d0))) - t_0) / x) + (n * (-0.5d0))) / x)))
    else
        tmp = 0.0d0
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double t_0 = (n * -0.3333333333333333) + (n * 0.25);
	double t_1 = 1.0 - Math.pow(x, (1.0 / n));
	double t_2 = Math.log(x) / -n;
	double tmp;
	if (x <= 6.8e-298) {
		tmp = t_1;
	} else if (x <= 2.6e-283) {
		tmp = t_2;
	} else if (x <= 3.6e-257) {
		tmp = t_1;
	} else if (x <= 2.8e-163) {
		tmp = t_2;
	} else if (x <= 1.4e-152) {
		tmp = t_1;
	} else if (x <= 1.2e-135) {
		tmp = t_2;
	} else if (x <= 9.2e-94) {
		tmp = ((1.0 / n) - ((((1.0 / n) * 0.5) - (0.3333333333333333 * (1.0 / (n * x)))) / x)) / x;
	} else if (x <= 5e-79) {
		tmp = t_2;
	} else if (x <= 2.1e-43) {
		tmp = t_1;
	} else if (x <= 0.5) {
		tmp = (x - Math.log(x)) / n;
	} else if (x <= 3.7e+73) {
		tmp = 1.0 / (x * (n - ((((((-0.5 * (t_0 / x)) + (((n / x) * -0.25) + ((n / x) * 0.16666666666666666))) - t_0) / x) + (n * -0.5)) / x)));
	} else {
		tmp = 0.0;
	}
	return tmp;
}
def code(x, n):
	t_0 = (n * -0.3333333333333333) + (n * 0.25)
	t_1 = 1.0 - math.pow(x, (1.0 / n))
	t_2 = math.log(x) / -n
	tmp = 0
	if x <= 6.8e-298:
		tmp = t_1
	elif x <= 2.6e-283:
		tmp = t_2
	elif x <= 3.6e-257:
		tmp = t_1
	elif x <= 2.8e-163:
		tmp = t_2
	elif x <= 1.4e-152:
		tmp = t_1
	elif x <= 1.2e-135:
		tmp = t_2
	elif x <= 9.2e-94:
		tmp = ((1.0 / n) - ((((1.0 / n) * 0.5) - (0.3333333333333333 * (1.0 / (n * x)))) / x)) / x
	elif x <= 5e-79:
		tmp = t_2
	elif x <= 2.1e-43:
		tmp = t_1
	elif x <= 0.5:
		tmp = (x - math.log(x)) / n
	elif x <= 3.7e+73:
		tmp = 1.0 / (x * (n - ((((((-0.5 * (t_0 / x)) + (((n / x) * -0.25) + ((n / x) * 0.16666666666666666))) - t_0) / x) + (n * -0.5)) / x)))
	else:
		tmp = 0.0
	return tmp
function code(x, n)
	t_0 = Float64(Float64(n * -0.3333333333333333) + Float64(n * 0.25))
	t_1 = Float64(1.0 - (x ^ Float64(1.0 / n)))
	t_2 = Float64(log(x) / Float64(-n))
	tmp = 0.0
	if (x <= 6.8e-298)
		tmp = t_1;
	elseif (x <= 2.6e-283)
		tmp = t_2;
	elseif (x <= 3.6e-257)
		tmp = t_1;
	elseif (x <= 2.8e-163)
		tmp = t_2;
	elseif (x <= 1.4e-152)
		tmp = t_1;
	elseif (x <= 1.2e-135)
		tmp = t_2;
	elseif (x <= 9.2e-94)
		tmp = Float64(Float64(Float64(1.0 / n) - Float64(Float64(Float64(Float64(1.0 / n) * 0.5) - Float64(0.3333333333333333 * Float64(1.0 / Float64(n * x)))) / x)) / x);
	elseif (x <= 5e-79)
		tmp = t_2;
	elseif (x <= 2.1e-43)
		tmp = t_1;
	elseif (x <= 0.5)
		tmp = Float64(Float64(x - log(x)) / n);
	elseif (x <= 3.7e+73)
		tmp = Float64(1.0 / Float64(x * Float64(n - Float64(Float64(Float64(Float64(Float64(Float64(-0.5 * Float64(t_0 / x)) + Float64(Float64(Float64(n / x) * -0.25) + Float64(Float64(n / x) * 0.16666666666666666))) - t_0) / x) + Float64(n * -0.5)) / x))));
	else
		tmp = 0.0;
	end
	return tmp
end
function tmp_2 = code(x, n)
	t_0 = (n * -0.3333333333333333) + (n * 0.25);
	t_1 = 1.0 - (x ^ (1.0 / n));
	t_2 = log(x) / -n;
	tmp = 0.0;
	if (x <= 6.8e-298)
		tmp = t_1;
	elseif (x <= 2.6e-283)
		tmp = t_2;
	elseif (x <= 3.6e-257)
		tmp = t_1;
	elseif (x <= 2.8e-163)
		tmp = t_2;
	elseif (x <= 1.4e-152)
		tmp = t_1;
	elseif (x <= 1.2e-135)
		tmp = t_2;
	elseif (x <= 9.2e-94)
		tmp = ((1.0 / n) - ((((1.0 / n) * 0.5) - (0.3333333333333333 * (1.0 / (n * x)))) / x)) / x;
	elseif (x <= 5e-79)
		tmp = t_2;
	elseif (x <= 2.1e-43)
		tmp = t_1;
	elseif (x <= 0.5)
		tmp = (x - log(x)) / n;
	elseif (x <= 3.7e+73)
		tmp = 1.0 / (x * (n - ((((((-0.5 * (t_0 / x)) + (((n / x) * -0.25) + ((n / x) * 0.16666666666666666))) - t_0) / x) + (n * -0.5)) / x)));
	else
		tmp = 0.0;
	end
	tmp_2 = tmp;
end
code[x_, n_] := Block[{t$95$0 = N[(N[(n * -0.3333333333333333), $MachinePrecision] + N[(n * 0.25), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision]}, If[LessEqual[x, 6.8e-298], t$95$1, If[LessEqual[x, 2.6e-283], t$95$2, If[LessEqual[x, 3.6e-257], t$95$1, If[LessEqual[x, 2.8e-163], t$95$2, If[LessEqual[x, 1.4e-152], t$95$1, If[LessEqual[x, 1.2e-135], t$95$2, If[LessEqual[x, 9.2e-94], N[(N[(N[(1.0 / n), $MachinePrecision] - N[(N[(N[(N[(1.0 / n), $MachinePrecision] * 0.5), $MachinePrecision] - N[(0.3333333333333333 * N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, 5e-79], t$95$2, If[LessEqual[x, 2.1e-43], t$95$1, If[LessEqual[x, 0.5], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 3.7e+73], N[(1.0 / N[(x * N[(n - N[(N[(N[(N[(N[(N[(-0.5 * N[(t$95$0 / x), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(n / x), $MachinePrecision] * -0.25), $MachinePrecision] + N[(N[(n / x), $MachinePrecision] * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision] / x), $MachinePrecision] + N[(n * -0.5), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]]]]]]]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq 2.6 \cdot 10^{-283}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;x \leq 3.6 \cdot 10^{-257}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 2.8 \cdot 10^{-163}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;x \leq 1.4 \cdot 10^{-152}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 1.2 \cdot 10^{-135}:\\
\;\;\;\;t\_2\\

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

\mathbf{elif}\;x \leq 5 \cdot 10^{-79}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;x \leq 2.1 \cdot 10^{-43}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;x \leq 3.7 \cdot 10^{+73}:\\
\;\;\;\;\frac{1}{x \cdot \left(n - \frac{\frac{\left(-0.5 \cdot \frac{t\_0}{x} + \left(\frac{n}{x} \cdot -0.25 + \frac{n}{x} \cdot 0.16666666666666666\right)\right) - t\_0}{x} + n \cdot -0.5}{x}\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 6 regimes
  2. if x < 6.8e-298 or 2.6000000000000001e-283 < x < 3.60000000000000007e-257 or 2.8e-163 < x < 1.39999999999999992e-152 or 4.99999999999999999e-79 < x < 2.1000000000000001e-43

    1. Initial program 79.9%

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

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

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

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

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

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

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

    if 6.8e-298 < x < 2.6000000000000001e-283 or 3.60000000000000007e-257 < x < 2.8e-163 or 1.39999999999999992e-152 < x < 1.1999999999999999e-135 or 9.1999999999999997e-94 < x < 4.99999999999999999e-79

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

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

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

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

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

    if 1.1999999999999999e-135 < x < 9.1999999999999997e-94

    1. Initial program 35.9%

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

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

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

    if 2.1000000000000001e-43 < x < 0.5

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

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

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

    if 0.5 < x < 3.69999999999999973e73

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

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

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

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

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

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

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

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

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

    if 3.69999999999999973e73 < x

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

      \[\leadsto \color{blue}{1 - e^{\frac{\log x}{n}}} \]
    4. Taylor expanded in n around inf 80.4%

      \[\leadsto 1 - \color{blue}{1} \]
  3. Recombined 6 regimes into one program.
  4. Final simplification76.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 6.8 \cdot 10^{-298}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 2.6 \cdot 10^{-283}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 3.6 \cdot 10^{-257}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 2.8 \cdot 10^{-163}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{-152}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 1.2 \cdot 10^{-135}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 9.2 \cdot 10^{-94}:\\ \;\;\;\;\frac{\frac{1}{n} - \frac{\frac{1}{n} \cdot 0.5 - 0.3333333333333333 \cdot \frac{1}{n \cdot x}}{x}}{x}\\ \mathbf{elif}\;x \leq 5 \cdot 10^{-79}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 2.1 \cdot 10^{-43}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 0.5:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{elif}\;x \leq 3.7 \cdot 10^{+73}:\\ \;\;\;\;\frac{1}{x \cdot \left(n - \frac{\frac{\left(-0.5 \cdot \frac{n \cdot -0.3333333333333333 + n \cdot 0.25}{x} + \left(\frac{n}{x} \cdot -0.25 + \frac{n}{x} \cdot 0.16666666666666666\right)\right) - \left(n \cdot -0.3333333333333333 + n \cdot 0.25\right)}{x} + n \cdot -0.5}{x}\right)}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 59.1% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := n \cdot -0.3333333333333333 + n \cdot 0.25\\ t_1 := 1 - {x}^{\left(\frac{1}{n}\right)}\\ t_2 := \frac{-1}{\frac{n}{\log x}}\\ t_3 := \frac{\log x}{-n}\\ \mathbf{if}\;x \leq 5.8 \cdot 10^{-298}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 4.8 \cdot 10^{-282}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;x \leq 1.9 \cdot 10^{-257}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 2.75 \cdot 10^{-163}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{-152}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 1.2 \cdot 10^{-135}:\\ \;\;\;\;t\_3\\ \mathbf{elif}\;x \leq 3.1 \cdot 10^{-94}:\\ \;\;\;\;\frac{\frac{1}{n} - \frac{\frac{1}{n} \cdot 0.5 - 0.3333333333333333 \cdot \frac{1}{n \cdot x}}{x}}{x}\\ \mathbf{elif}\;x \leq 6 \cdot 10^{-79}:\\ \;\;\;\;t\_3\\ \mathbf{elif}\;x \leq 7.5 \cdot 10^{-43}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 0.5:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{elif}\;x \leq 1.12 \cdot 10^{+74}:\\ \;\;\;\;\frac{1}{x \cdot \left(n - \frac{\frac{\left(-0.5 \cdot \frac{t\_0}{x} + \left(\frac{n}{x} \cdot -0.25 + \frac{n}{x} \cdot 0.16666666666666666\right)\right) - t\_0}{x} + n \cdot -0.5}{x}\right)}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (+ (* n -0.3333333333333333) (* n 0.25)))
        (t_1 (- 1.0 (pow x (/ 1.0 n))))
        (t_2 (/ -1.0 (/ n (log x))))
        (t_3 (/ (log x) (- n))))
   (if (<= x 5.8e-298)
     t_1
     (if (<= x 4.8e-282)
       t_2
       (if (<= x 1.9e-257)
         t_1
         (if (<= x 2.75e-163)
           t_2
           (if (<= x 1.5e-152)
             t_1
             (if (<= x 1.2e-135)
               t_3
               (if (<= x 3.1e-94)
                 (/
                  (-
                   (/ 1.0 n)
                   (/
                    (-
                     (* (/ 1.0 n) 0.5)
                     (* 0.3333333333333333 (/ 1.0 (* n x))))
                    x))
                  x)
                 (if (<= x 6e-79)
                   t_3
                   (if (<= x 7.5e-43)
                     t_1
                     (if (<= x 0.5)
                       (/ (- x (log x)) n)
                       (if (<= x 1.12e+74)
                         (/
                          1.0
                          (*
                           x
                           (-
                            n
                            (/
                             (+
                              (/
                               (-
                                (+
                                 (* -0.5 (/ t_0 x))
                                 (+
                                  (* (/ n x) -0.25)
                                  (* (/ n x) 0.16666666666666666)))
                                t_0)
                               x)
                              (* n -0.5))
                             x))))
                         0.0)))))))))))))
double code(double x, double n) {
	double t_0 = (n * -0.3333333333333333) + (n * 0.25);
	double t_1 = 1.0 - pow(x, (1.0 / n));
	double t_2 = -1.0 / (n / log(x));
	double t_3 = log(x) / -n;
	double tmp;
	if (x <= 5.8e-298) {
		tmp = t_1;
	} else if (x <= 4.8e-282) {
		tmp = t_2;
	} else if (x <= 1.9e-257) {
		tmp = t_1;
	} else if (x <= 2.75e-163) {
		tmp = t_2;
	} else if (x <= 1.5e-152) {
		tmp = t_1;
	} else if (x <= 1.2e-135) {
		tmp = t_3;
	} else if (x <= 3.1e-94) {
		tmp = ((1.0 / n) - ((((1.0 / n) * 0.5) - (0.3333333333333333 * (1.0 / (n * x)))) / x)) / x;
	} else if (x <= 6e-79) {
		tmp = t_3;
	} else if (x <= 7.5e-43) {
		tmp = t_1;
	} else if (x <= 0.5) {
		tmp = (x - log(x)) / n;
	} else if (x <= 1.12e+74) {
		tmp = 1.0 / (x * (n - ((((((-0.5 * (t_0 / x)) + (((n / x) * -0.25) + ((n / x) * 0.16666666666666666))) - t_0) / x) + (n * -0.5)) / x)));
	} else {
		tmp = 0.0;
	}
	return tmp;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: t_3
    real(8) :: tmp
    t_0 = (n * (-0.3333333333333333d0)) + (n * 0.25d0)
    t_1 = 1.0d0 - (x ** (1.0d0 / n))
    t_2 = (-1.0d0) / (n / log(x))
    t_3 = log(x) / -n
    if (x <= 5.8d-298) then
        tmp = t_1
    else if (x <= 4.8d-282) then
        tmp = t_2
    else if (x <= 1.9d-257) then
        tmp = t_1
    else if (x <= 2.75d-163) then
        tmp = t_2
    else if (x <= 1.5d-152) then
        tmp = t_1
    else if (x <= 1.2d-135) then
        tmp = t_3
    else if (x <= 3.1d-94) then
        tmp = ((1.0d0 / n) - ((((1.0d0 / n) * 0.5d0) - (0.3333333333333333d0 * (1.0d0 / (n * x)))) / x)) / x
    else if (x <= 6d-79) then
        tmp = t_3
    else if (x <= 7.5d-43) then
        tmp = t_1
    else if (x <= 0.5d0) then
        tmp = (x - log(x)) / n
    else if (x <= 1.12d+74) then
        tmp = 1.0d0 / (x * (n - (((((((-0.5d0) * (t_0 / x)) + (((n / x) * (-0.25d0)) + ((n / x) * 0.16666666666666666d0))) - t_0) / x) + (n * (-0.5d0))) / x)))
    else
        tmp = 0.0d0
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double t_0 = (n * -0.3333333333333333) + (n * 0.25);
	double t_1 = 1.0 - Math.pow(x, (1.0 / n));
	double t_2 = -1.0 / (n / Math.log(x));
	double t_3 = Math.log(x) / -n;
	double tmp;
	if (x <= 5.8e-298) {
		tmp = t_1;
	} else if (x <= 4.8e-282) {
		tmp = t_2;
	} else if (x <= 1.9e-257) {
		tmp = t_1;
	} else if (x <= 2.75e-163) {
		tmp = t_2;
	} else if (x <= 1.5e-152) {
		tmp = t_1;
	} else if (x <= 1.2e-135) {
		tmp = t_3;
	} else if (x <= 3.1e-94) {
		tmp = ((1.0 / n) - ((((1.0 / n) * 0.5) - (0.3333333333333333 * (1.0 / (n * x)))) / x)) / x;
	} else if (x <= 6e-79) {
		tmp = t_3;
	} else if (x <= 7.5e-43) {
		tmp = t_1;
	} else if (x <= 0.5) {
		tmp = (x - Math.log(x)) / n;
	} else if (x <= 1.12e+74) {
		tmp = 1.0 / (x * (n - ((((((-0.5 * (t_0 / x)) + (((n / x) * -0.25) + ((n / x) * 0.16666666666666666))) - t_0) / x) + (n * -0.5)) / x)));
	} else {
		tmp = 0.0;
	}
	return tmp;
}
def code(x, n):
	t_0 = (n * -0.3333333333333333) + (n * 0.25)
	t_1 = 1.0 - math.pow(x, (1.0 / n))
	t_2 = -1.0 / (n / math.log(x))
	t_3 = math.log(x) / -n
	tmp = 0
	if x <= 5.8e-298:
		tmp = t_1
	elif x <= 4.8e-282:
		tmp = t_2
	elif x <= 1.9e-257:
		tmp = t_1
	elif x <= 2.75e-163:
		tmp = t_2
	elif x <= 1.5e-152:
		tmp = t_1
	elif x <= 1.2e-135:
		tmp = t_3
	elif x <= 3.1e-94:
		tmp = ((1.0 / n) - ((((1.0 / n) * 0.5) - (0.3333333333333333 * (1.0 / (n * x)))) / x)) / x
	elif x <= 6e-79:
		tmp = t_3
	elif x <= 7.5e-43:
		tmp = t_1
	elif x <= 0.5:
		tmp = (x - math.log(x)) / n
	elif x <= 1.12e+74:
		tmp = 1.0 / (x * (n - ((((((-0.5 * (t_0 / x)) + (((n / x) * -0.25) + ((n / x) * 0.16666666666666666))) - t_0) / x) + (n * -0.5)) / x)))
	else:
		tmp = 0.0
	return tmp
function code(x, n)
	t_0 = Float64(Float64(n * -0.3333333333333333) + Float64(n * 0.25))
	t_1 = Float64(1.0 - (x ^ Float64(1.0 / n)))
	t_2 = Float64(-1.0 / Float64(n / log(x)))
	t_3 = Float64(log(x) / Float64(-n))
	tmp = 0.0
	if (x <= 5.8e-298)
		tmp = t_1;
	elseif (x <= 4.8e-282)
		tmp = t_2;
	elseif (x <= 1.9e-257)
		tmp = t_1;
	elseif (x <= 2.75e-163)
		tmp = t_2;
	elseif (x <= 1.5e-152)
		tmp = t_1;
	elseif (x <= 1.2e-135)
		tmp = t_3;
	elseif (x <= 3.1e-94)
		tmp = Float64(Float64(Float64(1.0 / n) - Float64(Float64(Float64(Float64(1.0 / n) * 0.5) - Float64(0.3333333333333333 * Float64(1.0 / Float64(n * x)))) / x)) / x);
	elseif (x <= 6e-79)
		tmp = t_3;
	elseif (x <= 7.5e-43)
		tmp = t_1;
	elseif (x <= 0.5)
		tmp = Float64(Float64(x - log(x)) / n);
	elseif (x <= 1.12e+74)
		tmp = Float64(1.0 / Float64(x * Float64(n - Float64(Float64(Float64(Float64(Float64(Float64(-0.5 * Float64(t_0 / x)) + Float64(Float64(Float64(n / x) * -0.25) + Float64(Float64(n / x) * 0.16666666666666666))) - t_0) / x) + Float64(n * -0.5)) / x))));
	else
		tmp = 0.0;
	end
	return tmp
end
function tmp_2 = code(x, n)
	t_0 = (n * -0.3333333333333333) + (n * 0.25);
	t_1 = 1.0 - (x ^ (1.0 / n));
	t_2 = -1.0 / (n / log(x));
	t_3 = log(x) / -n;
	tmp = 0.0;
	if (x <= 5.8e-298)
		tmp = t_1;
	elseif (x <= 4.8e-282)
		tmp = t_2;
	elseif (x <= 1.9e-257)
		tmp = t_1;
	elseif (x <= 2.75e-163)
		tmp = t_2;
	elseif (x <= 1.5e-152)
		tmp = t_1;
	elseif (x <= 1.2e-135)
		tmp = t_3;
	elseif (x <= 3.1e-94)
		tmp = ((1.0 / n) - ((((1.0 / n) * 0.5) - (0.3333333333333333 * (1.0 / (n * x)))) / x)) / x;
	elseif (x <= 6e-79)
		tmp = t_3;
	elseif (x <= 7.5e-43)
		tmp = t_1;
	elseif (x <= 0.5)
		tmp = (x - log(x)) / n;
	elseif (x <= 1.12e+74)
		tmp = 1.0 / (x * (n - ((((((-0.5 * (t_0 / x)) + (((n / x) * -0.25) + ((n / x) * 0.16666666666666666))) - t_0) / x) + (n * -0.5)) / x)));
	else
		tmp = 0.0;
	end
	tmp_2 = tmp;
end
code[x_, n_] := Block[{t$95$0 = N[(N[(n * -0.3333333333333333), $MachinePrecision] + N[(n * 0.25), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(-1.0 / N[(n / N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision]}, If[LessEqual[x, 5.8e-298], t$95$1, If[LessEqual[x, 4.8e-282], t$95$2, If[LessEqual[x, 1.9e-257], t$95$1, If[LessEqual[x, 2.75e-163], t$95$2, If[LessEqual[x, 1.5e-152], t$95$1, If[LessEqual[x, 1.2e-135], t$95$3, If[LessEqual[x, 3.1e-94], N[(N[(N[(1.0 / n), $MachinePrecision] - N[(N[(N[(N[(1.0 / n), $MachinePrecision] * 0.5), $MachinePrecision] - N[(0.3333333333333333 * N[(1.0 / N[(n * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[x, 6e-79], t$95$3, If[LessEqual[x, 7.5e-43], t$95$1, If[LessEqual[x, 0.5], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 1.12e+74], N[(1.0 / N[(x * N[(n - N[(N[(N[(N[(N[(N[(-0.5 * N[(t$95$0 / x), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(n / x), $MachinePrecision] * -0.25), $MachinePrecision] + N[(N[(n / x), $MachinePrecision] * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision] / x), $MachinePrecision] + N[(n * -0.5), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.0]]]]]]]]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq 4.8 \cdot 10^{-282}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;x \leq 1.9 \cdot 10^{-257}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 2.75 \cdot 10^{-163}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;x \leq 1.5 \cdot 10^{-152}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 1.2 \cdot 10^{-135}:\\
\;\;\;\;t\_3\\

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

\mathbf{elif}\;x \leq 6 \cdot 10^{-79}:\\
\;\;\;\;t\_3\\

\mathbf{elif}\;x \leq 7.5 \cdot 10^{-43}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;x \leq 1.12 \cdot 10^{+74}:\\
\;\;\;\;\frac{1}{x \cdot \left(n - \frac{\frac{\left(-0.5 \cdot \frac{t\_0}{x} + \left(\frac{n}{x} \cdot -0.25 + \frac{n}{x} \cdot 0.16666666666666666\right)\right) - t\_0}{x} + n \cdot -0.5}{x}\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 7 regimes
  2. if x < 5.8000000000000003e-298 or 4.79999999999999994e-282 < x < 1.9000000000000002e-257 or 2.7499999999999999e-163 < x < 1.5e-152 or 5.99999999999999999e-79 < x < 7.50000000000000068e-43

    1. Initial program 79.9%

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

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

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

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

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

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

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

    if 5.8000000000000003e-298 < x < 4.79999999999999994e-282 or 1.9000000000000002e-257 < x < 2.7499999999999999e-163

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\frac{\color{blue}{-n}}{\log x}} \]
    10. Simplified71.9%

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

    if 1.5e-152 < x < 1.1999999999999999e-135 or 3.0999999999999998e-94 < x < 5.99999999999999999e-79

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

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

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

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

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

    if 1.1999999999999999e-135 < x < 3.0999999999999998e-94

    1. Initial program 35.9%

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

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

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

    if 7.50000000000000068e-43 < x < 0.5

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

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

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

    if 0.5 < x < 1.12000000000000003e74

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

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

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

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

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

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

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

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

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

    if 1.12000000000000003e74 < x

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

      \[\leadsto \color{blue}{1 - e^{\frac{\log x}{n}}} \]
    4. Taylor expanded in n around inf 80.4%

      \[\leadsto 1 - \color{blue}{1} \]
  3. Recombined 7 regimes into one program.
  4. Final simplification76.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 5.8 \cdot 10^{-298}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 4.8 \cdot 10^{-282}:\\ \;\;\;\;\frac{-1}{\frac{n}{\log x}}\\ \mathbf{elif}\;x \leq 1.9 \cdot 10^{-257}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 2.75 \cdot 10^{-163}:\\ \;\;\;\;\frac{-1}{\frac{n}{\log x}}\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{-152}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 1.2 \cdot 10^{-135}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 3.1 \cdot 10^{-94}:\\ \;\;\;\;\frac{\frac{1}{n} - \frac{\frac{1}{n} \cdot 0.5 - 0.3333333333333333 \cdot \frac{1}{n \cdot x}}{x}}{x}\\ \mathbf{elif}\;x \leq 6 \cdot 10^{-79}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 7.5 \cdot 10^{-43}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 0.5:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{elif}\;x \leq 1.12 \cdot 10^{+74}:\\ \;\;\;\;\frac{1}{x \cdot \left(n - \frac{\frac{\left(-0.5 \cdot \frac{n \cdot -0.3333333333333333 + n \cdot 0.25}{x} + \left(\frac{n}{x} \cdot -0.25 + \frac{n}{x} \cdot 0.16666666666666666\right)\right) - \left(n \cdot -0.3333333333333333 + n \cdot 0.25\right)}{x} + n \cdot -0.5}{x}\right)}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 82.8% accurate, 1.5× speedup?

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1e-27 < (/.f64 1 n) < 5.00000000000000024e-5

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

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

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

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

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

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

    if 5.00000000000000024e-5 < (/.f64 1 n)

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

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

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

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

Alternative 6: 82.0% accurate, 1.6× speedup?

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1e-27 < (/.f64 1 n) < 5.00000000000000024e-5

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

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

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

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

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

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

    if 5.00000000000000024e-5 < (/.f64 1 n) < 4.99999999999999983e218

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

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

    if 4.99999999999999983e218 < (/.f64 1 n)

    1. Initial program 25.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{e^{\mathsf{log1p}\left(\frac{-n}{\log x}\right)} - 1}} \]
    13. Step-by-step derivation
      1. sub-neg92.5%

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

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

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

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

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

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

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

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

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

Alternative 7: 61.3% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{x - \log x}{n}\\ \mathbf{if}\;n \leq -2.5:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;n \leq 2.1 \cdot 10^{-219}:\\ \;\;\;\;\frac{\frac{0.25}{n}}{{x}^{4}}\\ \mathbf{elif}\;n \leq 10^{+24}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;n \leq 3 \cdot 10^{+139} \lor \neg \left(n \leq 2.85 \cdot 10^{+197}\right):\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x \cdot \left(n + 0.5 \cdot \frac{n}{x}\right)}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (/ (- x (log x)) n)))
   (if (<= n -2.5)
     t_0
     (if (<= n 2.1e-219)
       (/ (/ 0.25 n) (pow x 4.0))
       (if (<= n 1e+24)
         (- 1.0 (pow x (/ 1.0 n)))
         (if (or (<= n 3e+139) (not (<= n 2.85e+197)))
           t_0
           (/ 1.0 (* x (+ n (* 0.5 (/ n x)))))))))))
double code(double x, double n) {
	double t_0 = (x - log(x)) / n;
	double tmp;
	if (n <= -2.5) {
		tmp = t_0;
	} else if (n <= 2.1e-219) {
		tmp = (0.25 / n) / pow(x, 4.0);
	} else if (n <= 1e+24) {
		tmp = 1.0 - pow(x, (1.0 / n));
	} else if ((n <= 3e+139) || !(n <= 2.85e+197)) {
		tmp = t_0;
	} else {
		tmp = 1.0 / (x * (n + (0.5 * (n / x))));
	}
	return tmp;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (x - log(x)) / n
    if (n <= (-2.5d0)) then
        tmp = t_0
    else if (n <= 2.1d-219) then
        tmp = (0.25d0 / n) / (x ** 4.0d0)
    else if (n <= 1d+24) then
        tmp = 1.0d0 - (x ** (1.0d0 / n))
    else if ((n <= 3d+139) .or. (.not. (n <= 2.85d+197))) then
        tmp = t_0
    else
        tmp = 1.0d0 / (x * (n + (0.5d0 * (n / x))))
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double t_0 = (x - Math.log(x)) / n;
	double tmp;
	if (n <= -2.5) {
		tmp = t_0;
	} else if (n <= 2.1e-219) {
		tmp = (0.25 / n) / Math.pow(x, 4.0);
	} else if (n <= 1e+24) {
		tmp = 1.0 - Math.pow(x, (1.0 / n));
	} else if ((n <= 3e+139) || !(n <= 2.85e+197)) {
		tmp = t_0;
	} else {
		tmp = 1.0 / (x * (n + (0.5 * (n / x))));
	}
	return tmp;
}
def code(x, n):
	t_0 = (x - math.log(x)) / n
	tmp = 0
	if n <= -2.5:
		tmp = t_0
	elif n <= 2.1e-219:
		tmp = (0.25 / n) / math.pow(x, 4.0)
	elif n <= 1e+24:
		tmp = 1.0 - math.pow(x, (1.0 / n))
	elif (n <= 3e+139) or not (n <= 2.85e+197):
		tmp = t_0
	else:
		tmp = 1.0 / (x * (n + (0.5 * (n / x))))
	return tmp
function code(x, n)
	t_0 = Float64(Float64(x - log(x)) / n)
	tmp = 0.0
	if (n <= -2.5)
		tmp = t_0;
	elseif (n <= 2.1e-219)
		tmp = Float64(Float64(0.25 / n) / (x ^ 4.0));
	elseif (n <= 1e+24)
		tmp = Float64(1.0 - (x ^ Float64(1.0 / n)));
	elseif ((n <= 3e+139) || !(n <= 2.85e+197))
		tmp = t_0;
	else
		tmp = Float64(1.0 / Float64(x * Float64(n + Float64(0.5 * Float64(n / x)))));
	end
	return tmp
end
function tmp_2 = code(x, n)
	t_0 = (x - log(x)) / n;
	tmp = 0.0;
	if (n <= -2.5)
		tmp = t_0;
	elseif (n <= 2.1e-219)
		tmp = (0.25 / n) / (x ^ 4.0);
	elseif (n <= 1e+24)
		tmp = 1.0 - (x ^ (1.0 / n));
	elseif ((n <= 3e+139) || ~((n <= 2.85e+197)))
		tmp = t_0;
	else
		tmp = 1.0 / (x * (n + (0.5 * (n / x))));
	end
	tmp_2 = tmp;
end
code[x_, n_] := Block[{t$95$0 = N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[n, -2.5], t$95$0, If[LessEqual[n, 2.1e-219], N[(N[(0.25 / n), $MachinePrecision] / N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1e+24], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[n, 3e+139], N[Not[LessEqual[n, 2.85e+197]], $MachinePrecision]], t$95$0, N[(1.0 / N[(x * N[(n + N[(0.5 * N[(n / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{x - \log x}{n}\\
\mathbf{if}\;n \leq -2.5:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;n \leq 2.1 \cdot 10^{-219}:\\
\;\;\;\;\frac{\frac{0.25}{n}}{{x}^{4}}\\

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

\mathbf{elif}\;n \leq 3 \cdot 10^{+139} \lor \neg \left(n \leq 2.85 \cdot 10^{+197}\right):\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if n < -2.5 or 9.9999999999999998e23 < n < 3e139 or 2.85000000000000011e197 < n

    1. Initial program 22.8%

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

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

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

    if -2.5 < n < 2.1e-219

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}}}{n} \]
    5. Step-by-step derivation
      1. add-sqr-sqrt0.0%

        \[\leadsto \frac{-1 \cdot \color{blue}{\left(\sqrt{\frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}} \cdot \sqrt{\frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}}\right)}}{n} \]
      2. sqrt-unprod17.5%

        \[\leadsto \frac{-1 \cdot \color{blue}{\sqrt{\frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x} \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}}}}{n} \]
      3. sqr-neg17.5%

        \[\leadsto \frac{-1 \cdot \sqrt{\color{blue}{\left(-\frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}\right) \cdot \left(-\frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}\right)}}}{n} \]
      4. mul-1-neg17.5%

        \[\leadsto \frac{-1 \cdot \sqrt{\color{blue}{\left(-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}\right)} \cdot \left(-\frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}\right)}}{n} \]
      5. mul-1-neg17.5%

        \[\leadsto \frac{-1 \cdot \sqrt{\left(-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}\right) \cdot \color{blue}{\left(-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}\right)}}}{n} \]
      6. sqrt-unprod1.2%

        \[\leadsto \frac{-1 \cdot \color{blue}{\left(\sqrt{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}} \cdot \sqrt{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}}\right)}}{n} \]
      7. add-sqr-sqrt53.9%

        \[\leadsto \frac{-1 \cdot \color{blue}{\left(-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}\right)}}{n} \]
    6. Applied egg-rr53.9%

      \[\leadsto \frac{-1 \cdot \color{blue}{\left(0 - \frac{\frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x} + -0.5}{x} + -1}{x}\right)}}{n} \]
    7. Step-by-step derivation
      1. neg-sub053.9%

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

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

      \[\leadsto \frac{-1 \cdot \color{blue}{\frac{1 + \frac{0.5 + \frac{0.3333333333333333 + \frac{-0.25}{x}}{x}}{x}}{x}}}{n} \]
    9. Taylor expanded in x around 0 81.5%

      \[\leadsto \color{blue}{\frac{0.25}{n \cdot {x}^{4}}} \]
    10. Step-by-step derivation
      1. associate-/r*81.5%

        \[\leadsto \color{blue}{\frac{\frac{0.25}{n}}{{x}^{4}}} \]
    11. Simplified81.5%

      \[\leadsto \color{blue}{\frac{\frac{0.25}{n}}{{x}^{4}}} \]

    if 2.1e-219 < n < 9.9999999999999998e23

    1. Initial program 76.2%

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

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

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

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

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

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

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

    if 3e139 < n < 2.85000000000000011e197

    1. Initial program 55.3%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -2.5:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{elif}\;n \leq 2.1 \cdot 10^{-219}:\\ \;\;\;\;\frac{\frac{0.25}{n}}{{x}^{4}}\\ \mathbf{elif}\;n \leq 10^{+24}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;n \leq 3 \cdot 10^{+139} \lor \neg \left(n \leq 2.85 \cdot 10^{+197}\right):\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x \cdot \left(n + 0.5 \cdot \frac{n}{x}\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 81.9% accurate, 1.6× speedup?

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1e-27 < (/.f64 1 n) < 5.00000000000000024e-5

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

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

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

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

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

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

    if 5.00000000000000024e-5 < (/.f64 1 n) < 4.99999999999999983e218

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

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

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

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

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

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

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

    if 4.99999999999999983e218 < (/.f64 1 n)

    1. Initial program 25.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{e^{\mathsf{log1p}\left(\frac{-n}{\log x}\right)} - 1}} \]
    13. Step-by-step derivation
      1. sub-neg92.5%

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

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

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

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

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

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

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

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

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

Alternative 9: 75.9% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{\frac{0.25}{n}}{{x}^{4}}\\
\mathbf{if}\;\frac{1}{n} \leq -2000000:\\
\;\;\;\;t\_0\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 1 n) < -2e6 or 4.99999999999999983e218 < (/.f64 1 n)

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}}}{n} \]
    5. Step-by-step derivation
      1. add-sqr-sqrt0.0%

        \[\leadsto \frac{-1 \cdot \color{blue}{\left(\sqrt{\frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}} \cdot \sqrt{\frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}}\right)}}{n} \]
      2. sqrt-unprod17.5%

        \[\leadsto \frac{-1 \cdot \color{blue}{\sqrt{\frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x} \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}}}}{n} \]
      3. sqr-neg17.5%

        \[\leadsto \frac{-1 \cdot \sqrt{\color{blue}{\left(-\frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}\right) \cdot \left(-\frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}\right)}}}{n} \]
      4. mul-1-neg17.5%

        \[\leadsto \frac{-1 \cdot \sqrt{\color{blue}{\left(-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}\right)} \cdot \left(-\frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}\right)}}{n} \]
      5. mul-1-neg17.5%

        \[\leadsto \frac{-1 \cdot \sqrt{\left(-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}\right) \cdot \color{blue}{\left(-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}\right)}}}{n} \]
      6. sqrt-unprod1.2%

        \[\leadsto \frac{-1 \cdot \color{blue}{\left(\sqrt{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}} \cdot \sqrt{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}}\right)}}{n} \]
      7. add-sqr-sqrt53.9%

        \[\leadsto \frac{-1 \cdot \color{blue}{\left(-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}\right)}}{n} \]
    6. Applied egg-rr53.9%

      \[\leadsto \frac{-1 \cdot \color{blue}{\left(0 - \frac{\frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x} + -0.5}{x} + -1}{x}\right)}}{n} \]
    7. Step-by-step derivation
      1. neg-sub053.9%

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

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

      \[\leadsto \frac{-1 \cdot \color{blue}{\frac{1 + \frac{0.5 + \frac{0.3333333333333333 + \frac{-0.25}{x}}{x}}{x}}{x}}}{n} \]
    9. Taylor expanded in x around 0 81.5%

      \[\leadsto \color{blue}{\frac{0.25}{n \cdot {x}^{4}}} \]
    10. Step-by-step derivation
      1. associate-/r*81.5%

        \[\leadsto \color{blue}{\frac{\frac{0.25}{n}}{{x}^{4}}} \]
    11. Simplified81.5%

      \[\leadsto \color{blue}{\frac{\frac{0.25}{n}}{{x}^{4}}} \]

    if -2e6 < (/.f64 1 n) < 5.00000000000000024e-5

    1. Initial program 26.8%

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

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

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

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

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

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

    if 5.00000000000000024e-5 < (/.f64 1 n) < 4.99999999999999983e218

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

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

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

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

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

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

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

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

Alternative 10: 81.7% accurate, 1.7× speedup?

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

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

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

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{0.25}{n}}{{x}^{4}}\\


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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1e-27 < (/.f64 1 n) < 5.00000000000000024e-5

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

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

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

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

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

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

    if 5.00000000000000024e-5 < (/.f64 1 n) < 4.99999999999999983e218

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

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

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

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

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

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

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

    if 4.99999999999999983e218 < (/.f64 1 n)

    1. Initial program 25.5%

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}}}{n} \]
    5. Step-by-step derivation
      1. add-sqr-sqrt0.1%

        \[\leadsto \frac{-1 \cdot \color{blue}{\left(\sqrt{\frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}} \cdot \sqrt{\frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}}\right)}}{n} \]
      2. sqrt-unprod0.1%

        \[\leadsto \frac{-1 \cdot \color{blue}{\sqrt{\frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x} \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}}}}{n} \]
      3. sqr-neg0.1%

        \[\leadsto \frac{-1 \cdot \sqrt{\color{blue}{\left(-\frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}\right) \cdot \left(-\frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}\right)}}}{n} \]
      4. mul-1-neg0.1%

        \[\leadsto \frac{-1 \cdot \sqrt{\color{blue}{\left(-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}\right)} \cdot \left(-\frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}\right)}}{n} \]
      5. mul-1-neg0.1%

        \[\leadsto \frac{-1 \cdot \sqrt{\left(-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}\right) \cdot \color{blue}{\left(-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}\right)}}}{n} \]
      6. sqrt-unprod0.0%

        \[\leadsto \frac{-1 \cdot \color{blue}{\left(\sqrt{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}} \cdot \sqrt{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}}\right)}}{n} \]
      7. add-sqr-sqrt79.0%

        \[\leadsto \frac{-1 \cdot \color{blue}{\left(-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}\right)}}{n} \]
    6. Applied egg-rr79.0%

      \[\leadsto \frac{-1 \cdot \color{blue}{\left(0 - \frac{\frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x} + -0.5}{x} + -1}{x}\right)}}{n} \]
    7. Step-by-step derivation
      1. neg-sub079.0%

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

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

      \[\leadsto \frac{-1 \cdot \color{blue}{\frac{1 + \frac{0.5 + \frac{0.3333333333333333 + \frac{-0.25}{x}}{x}}{x}}{x}}}{n} \]
    9. Taylor expanded in x around 0 79.0%

      \[\leadsto \color{blue}{\frac{0.25}{n \cdot {x}^{4}}} \]
    10. Step-by-step derivation
      1. associate-/r*79.0%

        \[\leadsto \color{blue}{\frac{\frac{0.25}{n}}{{x}^{4}}} \]
    11. Simplified79.0%

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

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

Alternative 11: 59.6% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
t_0 := n \cdot -0.3333333333333333 + n \cdot 0.25\\
\mathbf{if}\;x \leq 9.5 \cdot 10^{-136}:\\
\;\;\;\;\frac{\log x}{-n}\\

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

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

\mathbf{elif}\;x \leq 8.8 \cdot 10^{+73}:\\
\;\;\;\;\frac{1}{x \cdot \left(n - \frac{\frac{\left(-0.5 \cdot \frac{t\_0}{x} + \left(\frac{n}{x} \cdot -0.25 + \frac{n}{x} \cdot 0.16666666666666666\right)\right) - t\_0}{x} + n \cdot -0.5}{x}\right)}\\

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


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

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

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

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

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

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

    if 9.5000000000000007e-136 < x < 4.5000000000000002e-94

    1. Initial program 35.9%

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

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

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

    if 4.5000000000000002e-94 < x < 0.5

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

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

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

    if 0.5 < x < 8.8e73

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

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

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

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

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

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

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

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

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

    if 8.8e73 < x

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

      \[\leadsto \color{blue}{1 - e^{\frac{\log x}{n}}} \]
    4. Taylor expanded in n around inf 80.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 9.5 \cdot 10^{-136}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 4.5 \cdot 10^{-94}:\\ \;\;\;\;\frac{\frac{1}{n} - \frac{\frac{1}{n} \cdot 0.5 - 0.3333333333333333 \cdot \frac{1}{n \cdot x}}{x}}{x}\\ \mathbf{elif}\;x \leq 0.5:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{elif}\;x \leq 8.8 \cdot 10^{+73}:\\ \;\;\;\;\frac{1}{x \cdot \left(n - \frac{\frac{\left(-0.5 \cdot \frac{n \cdot -0.3333333333333333 + n \cdot 0.25}{x} + \left(\frac{n}{x} \cdot -0.25 + \frac{n}{x} \cdot 0.16666666666666666\right)\right) - \left(n \cdot -0.3333333333333333 + n \cdot 0.25\right)}{x} + n \cdot -0.5}{x}\right)}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 59.3% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{\log x}{-n}\\
t_1 := n \cdot -0.3333333333333333 + n \cdot 0.25\\
\mathbf{if}\;x \leq 1.2 \cdot 10^{-135}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;x \leq 0.35:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 1.16 \cdot 10^{+73}:\\
\;\;\;\;\frac{1}{x \cdot \left(n - \frac{\frac{\left(-0.5 \cdot \frac{t\_1}{x} + \left(\frac{n}{x} \cdot -0.25 + \frac{n}{x} \cdot 0.16666666666666666\right)\right) - t\_1}{x} + n \cdot -0.5}{x}\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < 1.1999999999999999e-135 or 3.3000000000000001e-94 < x < 0.34999999999999998

    1. Initial program 44.5%

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

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

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

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

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

    if 1.1999999999999999e-135 < x < 3.3000000000000001e-94

    1. Initial program 35.9%

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

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

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

    if 0.34999999999999998 < x < 1.16000000000000007e73

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

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

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

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

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

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

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

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

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

    if 1.16000000000000007e73 < x

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

      \[\leadsto \color{blue}{1 - e^{\frac{\log x}{n}}} \]
    4. Taylor expanded in n around inf 80.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.2 \cdot 10^{-135}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 3.3 \cdot 10^{-94}:\\ \;\;\;\;\frac{\frac{1}{n} - \frac{\frac{1}{n} \cdot 0.5 - 0.3333333333333333 \cdot \frac{1}{n \cdot x}}{x}}{x}\\ \mathbf{elif}\;x \leq 0.35:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 1.16 \cdot 10^{+73}:\\ \;\;\;\;\frac{1}{x \cdot \left(n - \frac{\frac{\left(-0.5 \cdot \frac{n \cdot -0.3333333333333333 + n \cdot 0.25}{x} + \left(\frac{n}{x} \cdot -0.25 + \frac{n}{x} \cdot 0.16666666666666666\right)\right) - \left(n \cdot -0.3333333333333333 + n \cdot 0.25\right)}{x} + n \cdot -0.5}{x}\right)}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 52.0% accurate, 9.6× speedup?

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

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

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


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

    1. Initial program 41.3%

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}}}{n} \]
    5. Applied egg-rr36.9%

      \[\leadsto \color{blue}{1 \cdot \frac{1 + \frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x} + -0.5}{x}}{x \cdot n}} \]
    6. Step-by-step derivation
      1. *-lft-identity36.9%

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

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

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

    if 1.12000000000000003e74 < x

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

      \[\leadsto \color{blue}{1 - e^{\frac{\log x}{n}}} \]
    4. Taylor expanded in n around inf 80.4%

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

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

Alternative 14: 51.5% accurate, 11.1× speedup?

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

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

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


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

    1. Initial program 41.3%

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

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

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

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

        \[\leadsto \frac{\log \left(\frac{\color{blue}{x + 1}}{x}\right)}{n} \]
    7. Simplified49.9%

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}}}{n} \]
    9. Step-by-step derivation
      1. mul-1-neg35.5%

        \[\leadsto \frac{\color{blue}{-\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}}}{n} \]
      2. distribute-neg-frac235.5%

        \[\leadsto \frac{\color{blue}{\frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{-x}}}{n} \]
      3. sub-neg35.5%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{\frac{\frac{-0.3333333333333333}{x} + \color{blue}{0.5}}{x} + \left(-1\right)}{-x}}{n} \]
      13. metadata-eval35.5%

        \[\leadsto \frac{\frac{\frac{\frac{-0.3333333333333333}{x} + 0.5}{x} + \color{blue}{-1}}{-x}}{n} \]
    10. Simplified35.5%

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

    if 8.8e73 < x

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

      \[\leadsto \color{blue}{1 - e^{\frac{\log x}{n}}} \]
    4. Taylor expanded in n around inf 80.4%

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

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

Alternative 15: 49.5% accurate, 13.2× speedup?

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

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

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


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

    1. Initial program 41.3%

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}}}{n} \]
    5. Step-by-step derivation
      1. add-cube-cbrt12.3%

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

        \[\leadsto \frac{-1 \cdot \color{blue}{{\left(\sqrt[3]{\frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}}\right)}^{3}}}{n} \]
    6. Applied egg-rr12.0%

      \[\leadsto \frac{-1 \cdot \color{blue}{{\left(\sqrt[3]{\frac{\frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x} + -0.5}{x} + -1}{x}}\right)}^{3}}}{n} \]
    7. Taylor expanded in x around inf 34.1%

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

        \[\leadsto \frac{\frac{1}{n} + \color{blue}{\frac{0.5 \cdot 1}{n \cdot x}}}{x} \]
      2. metadata-eval34.1%

        \[\leadsto \frac{\frac{1}{n} + \frac{\color{blue}{0.5}}{n \cdot x}}{x} \]
      3. *-commutative34.1%

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

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

    if 2.80000000000000008e73 < x

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

      \[\leadsto \color{blue}{1 - e^{\frac{\log x}{n}}} \]
    4. Taylor expanded in n around inf 80.4%

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

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

Alternative 16: 49.5% accurate, 14.1× speedup?

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

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

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


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

    1. Initial program 41.3%

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}}}{n} \]
    5. Step-by-step derivation
      1. add-cube-cbrt12.3%

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

        \[\leadsto \frac{-1 \cdot \color{blue}{{\left(\sqrt[3]{\frac{-1 \cdot \frac{-1 \cdot \frac{0.25 \cdot \frac{1}{x} - 0.3333333333333333}{x} - 0.5}{x} - 1}{x}}\right)}^{3}}}{n} \]
    6. Applied egg-rr12.0%

      \[\leadsto \frac{-1 \cdot \color{blue}{{\left(\sqrt[3]{\frac{\frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x} + -0.5}{x} + -1}{x}}\right)}^{3}}}{n} \]
    7. Taylor expanded in x around inf 34.0%

      \[\leadsto \frac{-1 \cdot \color{blue}{\left(-1 \cdot \frac{1 + 0.5 \cdot \frac{1}{x}}{x}\right)}}{n} \]
    8. Step-by-step derivation
      1. associate-*r/34.0%

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

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

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

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

        \[\leadsto \frac{-1 \cdot \frac{-1 + \left(-\color{blue}{\frac{0.5 \cdot 1}{x}}\right)}{x}}{n} \]
      6. metadata-eval34.0%

        \[\leadsto \frac{-1 \cdot \frac{-1 + \left(-\frac{\color{blue}{0.5}}{x}\right)}{x}}{n} \]
      7. distribute-neg-frac34.0%

        \[\leadsto \frac{-1 \cdot \frac{-1 + \color{blue}{\frac{-0.5}{x}}}{x}}{n} \]
      8. metadata-eval34.0%

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

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

    if 1.12000000000000003e74 < x

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

      \[\leadsto \color{blue}{1 - e^{\frac{\log x}{n}}} \]
    4. Taylor expanded in n around inf 80.4%

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

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

Alternative 17: 45.2% accurate, 21.1× speedup?

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

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

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


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

    1. Initial program 41.3%

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

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

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

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

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

    if 1.15e72 < x

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

      \[\leadsto \color{blue}{1 - e^{\frac{\log x}{n}}} \]
    4. Taylor expanded in n around inf 80.4%

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

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

Alternative 18: 32.2% accurate, 211.0× speedup?

\[\begin{array}{l} \\ 0 \end{array} \]
(FPCore (x n) :precision binary64 0.0)
double code(double x, double n) {
	return 0.0;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    code = 0.0d0
end function
public static double code(double x, double n) {
	return 0.0;
}
def code(x, n):
	return 0.0
function code(x, n)
	return 0.0
end
function tmp = code(x, n)
	tmp = 0.0;
end
code[x_, n_] := 0.0
\begin{array}{l}

\\
0
\end{array}
Derivation
  1. Initial program 51.3%

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

    \[\leadsto \color{blue}{1 - e^{\frac{\log x}{n}}} \]
  4. Taylor expanded in n around inf 26.1%

    \[\leadsto 1 - \color{blue}{1} \]
  5. Final simplification26.1%

    \[\leadsto 0 \]
  6. Add Preprocessing

Reproduce

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