2nthrt (problem 3.4.6)

Percentage Accurate: 53.8% → 86.2%
Time: 1.6min
Alternatives: 17
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 17 alternatives:

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

Initial Program: 53.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: 86.2% accurate, 0.2× speedup?

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq 100000:\\
\;\;\;\;\frac{t\_1}{{x}^{2}} \cdot \left(\frac{0.5}{{n}^{2}} + \frac{-0.5}{n}\right) + \left(\frac{t\_1}{n \cdot x} + \frac{t\_1}{{x}^{3}} \cdot \left(\frac{0.16666666666666666}{{n}^{3}} + \left(\frac{0.3333333333333333}{n} + \frac{-0.5}{{n}^{2}}\right)\right)\right)\\

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


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

    1. Initial program 96.1%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Taylor expanded in x around 0 100.0%

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

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

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

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

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

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

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

    if -3.99999999999999992e-12 < (/.f64 1 n) < 5.00000000000000004e-36

    1. Initial program 39.4%

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

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

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

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

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

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

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

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

    if 5.00000000000000004e-36 < (/.f64 1 n) < 1e5

    1. Initial program 17.5%

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

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

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

    if 1e5 < (/.f64 1 n)

    1. Initial program 42.2%

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

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

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

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

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

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

Alternative 2: 86.2% accurate, 0.3× speedup?

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq 3 \cdot 10^{-15}:\\
\;\;\;\;\frac{t\_0}{n \cdot x} + \frac{t\_0}{\frac{{x}^{2}}{\frac{0.5}{{n}^{2}} + \frac{-0.5}{n}}}\\

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


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

    1. Initial program 96.1%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Taylor expanded in x around 0 100.0%

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

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

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

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

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

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

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

    if -3.99999999999999992e-12 < (/.f64 1 n) < 5.00000000000000004e-36

    1. Initial program 39.4%

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

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

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

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

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

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

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

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

    if 5.00000000000000004e-36 < (/.f64 1 n) < 3e-15

    1. Initial program 5.1%

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

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

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

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

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

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

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

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

        \[\leadsto \frac{e^{\frac{\log x}{n}}}{\color{blue}{x \cdot n}} + \frac{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}} \cdot \left(0.5 \cdot \frac{1}{{n}^{2}} - 0.5 \cdot \frac{1}{n}\right)}{{x}^{2}} \]
      8. associate-/l*88.4%

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

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

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

    1. Initial program 41.9%

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

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

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

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

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

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

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

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

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

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

Alternative 3: 81.7% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{if}\;\frac{1}{n} \leq -4 \cdot 10^{-12}:\\ \;\;\;\;\frac{t\_0}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-77}:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 100000:\\ \;\;\;\;\frac{1}{x} \cdot \frac{t\_0}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+93}:\\ \;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\ \mathbf{else}:\\ \;\;\;\;\sqrt{{\left(n \cdot x\right)}^{-2}}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (pow x (/ 1.0 n))))
   (if (<= (/ 1.0 n) -4e-12)
     (/ t_0 (* n x))
     (if (<= (/ 1.0 n) 2e-77)
       (/ (log (/ (+ 1.0 x) x)) n)
       (if (<= (/ 1.0 n) 100000.0)
         (* (/ 1.0 x) (/ t_0 n))
         (if (<= (/ 1.0 n) 2e+93)
           (- (+ 1.0 (/ x n)) t_0)
           (sqrt (pow (* n x) -2.0))))))))
double code(double x, double n) {
	double t_0 = pow(x, (1.0 / n));
	double tmp;
	if ((1.0 / n) <= -4e-12) {
		tmp = t_0 / (n * x);
	} else if ((1.0 / n) <= 2e-77) {
		tmp = log(((1.0 + x) / x)) / n;
	} else if ((1.0 / n) <= 100000.0) {
		tmp = (1.0 / x) * (t_0 / n);
	} else if ((1.0 / n) <= 2e+93) {
		tmp = (1.0 + (x / n)) - t_0;
	} else {
		tmp = sqrt(pow((n * x), -2.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) <= (-4d-12)) then
        tmp = t_0 / (n * x)
    else if ((1.0d0 / n) <= 2d-77) then
        tmp = log(((1.0d0 + x) / x)) / n
    else if ((1.0d0 / n) <= 100000.0d0) then
        tmp = (1.0d0 / x) * (t_0 / n)
    else if ((1.0d0 / n) <= 2d+93) then
        tmp = (1.0d0 + (x / n)) - t_0
    else
        tmp = sqrt(((n * x) ** (-2.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) <= -4e-12) {
		tmp = t_0 / (n * x);
	} else if ((1.0 / n) <= 2e-77) {
		tmp = Math.log(((1.0 + x) / x)) / n;
	} else if ((1.0 / n) <= 100000.0) {
		tmp = (1.0 / x) * (t_0 / n);
	} else if ((1.0 / n) <= 2e+93) {
		tmp = (1.0 + (x / n)) - t_0;
	} else {
		tmp = Math.sqrt(Math.pow((n * x), -2.0));
	}
	return tmp;
}
def code(x, n):
	t_0 = math.pow(x, (1.0 / n))
	tmp = 0
	if (1.0 / n) <= -4e-12:
		tmp = t_0 / (n * x)
	elif (1.0 / n) <= 2e-77:
		tmp = math.log(((1.0 + x) / x)) / n
	elif (1.0 / n) <= 100000.0:
		tmp = (1.0 / x) * (t_0 / n)
	elif (1.0 / n) <= 2e+93:
		tmp = (1.0 + (x / n)) - t_0
	else:
		tmp = math.sqrt(math.pow((n * x), -2.0))
	return tmp
function code(x, n)
	t_0 = x ^ Float64(1.0 / n)
	tmp = 0.0
	if (Float64(1.0 / n) <= -4e-12)
		tmp = Float64(t_0 / Float64(n * x));
	elseif (Float64(1.0 / n) <= 2e-77)
		tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n);
	elseif (Float64(1.0 / n) <= 100000.0)
		tmp = Float64(Float64(1.0 / x) * Float64(t_0 / n));
	elseif (Float64(1.0 / n) <= 2e+93)
		tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0);
	else
		tmp = sqrt((Float64(n * x) ^ -2.0));
	end
	return tmp
end
function tmp_2 = code(x, n)
	t_0 = x ^ (1.0 / n);
	tmp = 0.0;
	if ((1.0 / n) <= -4e-12)
		tmp = t_0 / (n * x);
	elseif ((1.0 / n) <= 2e-77)
		tmp = log(((1.0 + x) / x)) / n;
	elseif ((1.0 / n) <= 100000.0)
		tmp = (1.0 / x) * (t_0 / n);
	elseif ((1.0 / n) <= 2e+93)
		tmp = (1.0 + (x / n)) - t_0;
	else
		tmp = sqrt(((n * x) ^ -2.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], -4e-12], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-77], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 100000.0], N[(N[(1.0 / x), $MachinePrecision] * N[(t$95$0 / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e+93], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision], N[Sqrt[N[Power[N[(n * x), $MachinePrecision], -2.0], $MachinePrecision]], $MachinePrecision]]]]]]
\begin{array}{l}

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

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

\mathbf{elif}\;\frac{1}{n} \leq 100000:\\
\;\;\;\;\frac{1}{x} \cdot \frac{t\_0}{n}\\

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

\mathbf{else}:\\
\;\;\;\;\sqrt{{\left(n \cdot x\right)}^{-2}}\\


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

    1. Initial program 96.1%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Taylor expanded in x around 0 100.0%

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

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

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

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

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

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

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

    if -3.99999999999999992e-12 < (/.f64 1 n) < 1.9999999999999999e-77

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

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

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

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

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

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

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

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

    if 1.9999999999999999e-77 < (/.f64 1 n) < 1e5

    1. Initial program 13.5%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Step-by-step derivation
      1. div-inv65.7%

        \[\leadsto \frac{e^{\color{blue}{\log x \cdot \frac{1}{n}}}}{x \cdot n} \]
      2. pow-to-exp65.7%

        \[\leadsto \frac{\color{blue}{{x}^{\left(\frac{1}{n}\right)}}}{x \cdot n} \]
      3. *-un-lft-identity65.7%

        \[\leadsto \frac{\color{blue}{1 \cdot {x}^{\left(\frac{1}{n}\right)}}}{x \cdot n} \]
      4. times-frac65.7%

        \[\leadsto \color{blue}{\frac{1}{x} \cdot \frac{{x}^{\left(\frac{1}{n}\right)}}{n}} \]
    7. Applied egg-rr65.7%

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

    if 1e5 < (/.f64 1 n) < 2.00000000000000009e93

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

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

    if 2.00000000000000009e93 < (/.f64 1 n)

    1. Initial program 18.8%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Taylor expanded in n around inf 46.5%

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

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

      \[\leadsto \color{blue}{\frac{1}{x \cdot n}} \]
    9. Step-by-step derivation
      1. add-sqr-sqrt46.5%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{x \cdot n}} \cdot \sqrt{\frac{1}{x \cdot n}}} \]
      2. sqrt-unprod83.2%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{x \cdot n} \cdot \frac{1}{x \cdot n}}} \]
      3. inv-pow83.2%

        \[\leadsto \sqrt{\color{blue}{{\left(x \cdot n\right)}^{-1}} \cdot \frac{1}{x \cdot n}} \]
      4. inv-pow83.2%

        \[\leadsto \sqrt{{\left(x \cdot n\right)}^{-1} \cdot \color{blue}{{\left(x \cdot n\right)}^{-1}}} \]
      5. pow-prod-up83.2%

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

        \[\leadsto \sqrt{{\left(x \cdot n\right)}^{\color{blue}{-2}}} \]
    10. Applied egg-rr83.2%

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

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

Alternative 4: 86.2% accurate, 0.9× speedup?

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq 100000:\\
\;\;\;\;\frac{1}{x} \cdot \frac{t\_0}{n}\\

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


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

    1. Initial program 96.1%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Taylor expanded in x around 0 100.0%

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

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

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

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

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

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

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

    if -3.99999999999999992e-12 < (/.f64 1 n) < 1.9999999999999999e-77

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

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

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

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

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

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

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

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

    if 1.9999999999999999e-77 < (/.f64 1 n) < 1e5

    1. Initial program 13.5%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Step-by-step derivation
      1. div-inv65.7%

        \[\leadsto \frac{e^{\color{blue}{\log x \cdot \frac{1}{n}}}}{x \cdot n} \]
      2. pow-to-exp65.7%

        \[\leadsto \frac{\color{blue}{{x}^{\left(\frac{1}{n}\right)}}}{x \cdot n} \]
      3. *-un-lft-identity65.7%

        \[\leadsto \frac{\color{blue}{1 \cdot {x}^{\left(\frac{1}{n}\right)}}}{x \cdot n} \]
      4. times-frac65.7%

        \[\leadsto \color{blue}{\frac{1}{x} \cdot \frac{{x}^{\left(\frac{1}{n}\right)}}{n}} \]
    7. Applied egg-rr65.7%

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

    if 1e5 < (/.f64 1 n)

    1. Initial program 42.2%

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

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

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

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

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

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

Alternative 5: 66.9% accurate, 1.4× speedup?

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq -4 \cdot 10^{-12}:\\
\;\;\;\;t\_0\\

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

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

\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{+93}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (/.f64 1 n) < -5.00000000000000007e42 or 3e-15 < (/.f64 1 n) < 2.00000000000000009e93

    1. Initial program 94.7%

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

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

    if -5.00000000000000007e42 < (/.f64 1 n) < -1e14 or -3.99999999999999992e-12 < (/.f64 1 n) < 1.9999999999999999e-77

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

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

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

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

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

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

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

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

    if -1e14 < (/.f64 1 n) < -3.99999999999999992e-12 or 2.00000000000000009e93 < (/.f64 1 n)

    1. Initial program 25.8%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Taylor expanded in n around inf 42.4%

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

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

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

        \[\leadsto \frac{1}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(x\right)\right)} \cdot n} \]
      2. expm1-udef77.7%

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

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

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

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

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

    if 1.9999999999999999e-77 < (/.f64 1 n) < 3e-15

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

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

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

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

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

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

Alternative 6: 81.6% accurate, 1.5× speedup?

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq 100000:\\
\;\;\;\;\frac{1}{x} \cdot \frac{t\_0}{n}\\

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

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


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

    1. Initial program 96.1%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Taylor expanded in x around 0 100.0%

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

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

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

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

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

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

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

    if -3.99999999999999992e-12 < (/.f64 1 n) < 1.9999999999999999e-77

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

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

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

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

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

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

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

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

    if 1.9999999999999999e-77 < (/.f64 1 n) < 1e5

    1. Initial program 13.5%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Step-by-step derivation
      1. div-inv65.7%

        \[\leadsto \frac{e^{\color{blue}{\log x \cdot \frac{1}{n}}}}{x \cdot n} \]
      2. pow-to-exp65.7%

        \[\leadsto \frac{\color{blue}{{x}^{\left(\frac{1}{n}\right)}}}{x \cdot n} \]
      3. *-un-lft-identity65.7%

        \[\leadsto \frac{\color{blue}{1 \cdot {x}^{\left(\frac{1}{n}\right)}}}{x \cdot n} \]
      4. times-frac65.7%

        \[\leadsto \color{blue}{\frac{1}{x} \cdot \frac{{x}^{\left(\frac{1}{n}\right)}}{n}} \]
    7. Applied egg-rr65.7%

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

    if 1e5 < (/.f64 1 n) < 2.00000000000000009e93

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

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

    if 2.00000000000000009e93 < (/.f64 1 n)

    1. Initial program 18.8%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Taylor expanded in n around inf 46.5%

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\left(\color{blue}{\left(x + 1\right)} - 1\right) \cdot n} \]
    10. Applied egg-rr79.2%

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

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

Alternative 7: 57.6% accurate, 1.6× speedup?

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

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

\mathbf{elif}\;x \leq 2.8 \cdot 10^{-223}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 8 \cdot 10^{-218}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 4.8 \cdot 10^{-111}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 2.8 \cdot 10^{-87}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 7.4 \cdot 10^{-60}:\\
\;\;\;\;t\_1\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < 2.64999999999999993e-275 or 2.80000000000000015e-223 < x < 8.0000000000000003e-218 or 4.8000000000000001e-111 < x < 2.8000000000000001e-87

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

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

    if 2.64999999999999993e-275 < x < 2.80000000000000015e-223 or 8.0000000000000003e-218 < x < 4.8000000000000001e-111 or 2.8000000000000001e-87 < x < 7.4000000000000005e-60

    1. Initial program 34.4%

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

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

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

        \[\leadsto \color{blue}{-\frac{\log x}{n}} \]
      2. distribute-neg-frac60.9%

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

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

    if 7.4000000000000005e-60 < x < 1.08e216

    1. Initial program 50.0%

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

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

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

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

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

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

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

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

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

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

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

    if 1.08e216 < x

    1. Initial program 93.0%

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

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

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

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

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

        \[\leadsto \log \left(e^{e^{\frac{1}{n} \cdot \color{blue}{\mathsf{log1p}\left(x\right)}} - {x}^{\left(\frac{1}{n}\right)}}\right) \]
      6. *-commutative93.0%

        \[\leadsto \log \left(e^{e^{\color{blue}{\mathsf{log1p}\left(x\right) \cdot \frac{1}{n}}} - {x}^{\left(\frac{1}{n}\right)}}\right) \]
      7. un-div-inv93.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 2.65 \cdot 10^{-275}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 2.8 \cdot 10^{-223}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 8 \cdot 10^{-218}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 4.8 \cdot 10^{-111}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 2.8 \cdot 10^{-87}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 7.4 \cdot 10^{-60}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 1.08 \cdot 10^{+216}:\\ \;\;\;\;\frac{\frac{1}{\left(1 + x\right) + -1}}{n}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 81.5% accurate, 1.6× speedup?

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

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (/.f64 1 n) < -3.99999999999999992e-12 or 1.9999999999999999e-77 < (/.f64 1 n) < 1e5

    1. Initial program 78.1%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Step-by-step derivation
      1. div-inv92.5%

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

        \[\leadsto \frac{\color{blue}{{x}^{\left(\frac{1}{n}\right)}}}{x \cdot n} \]
      3. *-un-lft-identity92.5%

        \[\leadsto \frac{\color{blue}{1 \cdot {x}^{\left(\frac{1}{n}\right)}}}{x \cdot n} \]
      4. times-frac92.6%

        \[\leadsto \color{blue}{\frac{1}{x} \cdot \frac{{x}^{\left(\frac{1}{n}\right)}}{n}} \]
    7. Applied egg-rr92.6%

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

        \[\leadsto \color{blue}{\frac{1 \cdot \frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}} \]
      2. *-un-lft-identity92.5%

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

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

    if -3.99999999999999992e-12 < (/.f64 1 n) < 1.9999999999999999e-77

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

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

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

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

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

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

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

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

    if 1e5 < (/.f64 1 n) < 2.00000000000000009e93

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

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

    if 2.00000000000000009e93 < (/.f64 1 n)

    1. Initial program 18.8%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Taylor expanded in n around inf 46.5%

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\left(\color{blue}{\left(x + 1\right)} - 1\right) \cdot n} \]
    10. Applied egg-rr79.2%

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

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

Alternative 9: 81.5% accurate, 1.6× speedup?

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq 100000:\\
\;\;\;\;\frac{\frac{t\_0}{n}}{x}\\

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

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


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

    1. Initial program 96.1%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Taylor expanded in x around 0 100.0%

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

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

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

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

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

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

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

    if -3.99999999999999992e-12 < (/.f64 1 n) < 1.9999999999999999e-77

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

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

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

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

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

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

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

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

    if 1.9999999999999999e-77 < (/.f64 1 n) < 1e5

    1. Initial program 13.5%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Step-by-step derivation
      1. div-inv65.7%

        \[\leadsto \frac{e^{\color{blue}{\log x \cdot \frac{1}{n}}}}{x \cdot n} \]
      2. pow-to-exp65.7%

        \[\leadsto \frac{\color{blue}{{x}^{\left(\frac{1}{n}\right)}}}{x \cdot n} \]
      3. *-un-lft-identity65.7%

        \[\leadsto \frac{\color{blue}{1 \cdot {x}^{\left(\frac{1}{n}\right)}}}{x \cdot n} \]
      4. times-frac65.7%

        \[\leadsto \color{blue}{\frac{1}{x} \cdot \frac{{x}^{\left(\frac{1}{n}\right)}}{n}} \]
    7. Applied egg-rr65.7%

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

        \[\leadsto \color{blue}{\frac{1 \cdot \frac{{x}^{\left(\frac{1}{n}\right)}}{n}}{x}} \]
      2. *-un-lft-identity65.7%

        \[\leadsto \frac{\color{blue}{\frac{{x}^{\left(\frac{1}{n}\right)}}{n}}}{x} \]
    9. Applied egg-rr65.7%

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

    if 1e5 < (/.f64 1 n) < 2.00000000000000009e93

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

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

    if 2.00000000000000009e93 < (/.f64 1 n)

    1. Initial program 18.8%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Taylor expanded in n around inf 46.5%

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\left(\color{blue}{\left(x + 1\right)} - 1\right) \cdot n} \]
    10. Applied egg-rr79.2%

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

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

Alternative 10: 81.5% accurate, 1.6× speedup?

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

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

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

\mathbf{elif}\;\frac{1}{n} \leq 100000:\\
\;\;\;\;\frac{1}{x} \cdot \frac{t\_0}{n}\\

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

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


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

    1. Initial program 96.1%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Taylor expanded in x around 0 100.0%

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

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

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

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

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

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

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

    if -3.99999999999999992e-12 < (/.f64 1 n) < 1.9999999999999999e-77

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

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

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

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

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

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

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

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

    if 1.9999999999999999e-77 < (/.f64 1 n) < 1e5

    1. Initial program 13.5%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Step-by-step derivation
      1. div-inv65.7%

        \[\leadsto \frac{e^{\color{blue}{\log x \cdot \frac{1}{n}}}}{x \cdot n} \]
      2. pow-to-exp65.7%

        \[\leadsto \frac{\color{blue}{{x}^{\left(\frac{1}{n}\right)}}}{x \cdot n} \]
      3. *-un-lft-identity65.7%

        \[\leadsto \frac{\color{blue}{1 \cdot {x}^{\left(\frac{1}{n}\right)}}}{x \cdot n} \]
      4. times-frac65.7%

        \[\leadsto \color{blue}{\frac{1}{x} \cdot \frac{{x}^{\left(\frac{1}{n}\right)}}{n}} \]
    7. Applied egg-rr65.7%

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

    if 1e5 < (/.f64 1 n) < 2.00000000000000009e93

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

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

    if 2.00000000000000009e93 < (/.f64 1 n)

    1. Initial program 18.8%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Taylor expanded in n around inf 46.5%

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\left(\color{blue}{\left(x + 1\right)} - 1\right) \cdot n} \]
    10. Applied egg-rr79.2%

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

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

Alternative 11: 57.9% accurate, 1.8× speedup?

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

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

\mathbf{elif}\;x \leq 10^{-82}:\\
\;\;\;\;\frac{1}{n \cdot t\_0}\\

\mathbf{elif}\;x \leq 8.8 \cdot 10^{-60}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 2.2 \cdot 10^{+216}:\\
\;\;\;\;\frac{\frac{1}{t\_0}}{n}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < 6.3000000000000001e-109 or 1e-82 < x < 8.7999999999999995e-60

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

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

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

        \[\leadsto \color{blue}{-\frac{\log x}{n}} \]
      2. distribute-neg-frac55.4%

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

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

    if 6.3000000000000001e-109 < x < 1e-82

    1. Initial program 83.9%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    6. Taylor expanded in n around inf 37.6%

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

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

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

        \[\leadsto \frac{1}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(x\right)\right)} \cdot n} \]
      2. expm1-udef83.9%

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

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

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

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

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

    if 8.7999999999999995e-60 < x < 2.2e216

    1. Initial program 50.0%

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

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

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

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

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

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

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

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

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

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

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

    if 2.2e216 < x

    1. Initial program 93.0%

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

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

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

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

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

        \[\leadsto \log \left(e^{e^{\frac{1}{n} \cdot \color{blue}{\mathsf{log1p}\left(x\right)}} - {x}^{\left(\frac{1}{n}\right)}}\right) \]
      6. *-commutative93.0%

        \[\leadsto \log \left(e^{e^{\color{blue}{\mathsf{log1p}\left(x\right) \cdot \frac{1}{n}}} - {x}^{\left(\frac{1}{n}\right)}}\right) \]
      7. un-div-inv93.0%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 6.3 \cdot 10^{-109}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 10^{-82}:\\ \;\;\;\;\frac{1}{n \cdot \left(\left(1 + x\right) + -1\right)}\\ \mathbf{elif}\;x \leq 8.8 \cdot 10^{-60}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 2.2 \cdot 10^{+216}:\\ \;\;\;\;\frac{\frac{1}{\left(1 + x\right) + -1}}{n}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 51.8% accurate, 15.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 8.2 \cdot 10^{+215}:\\ \;\;\;\;\frac{\frac{1}{\left(1 + x\right) + -1}}{n}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= x 8.2e+215) (/ (/ 1.0 (+ (+ 1.0 x) -1.0)) n) 0.0))
double code(double x, double n) {
	double tmp;
	if (x <= 8.2e+215) {
		tmp = (1.0 / ((1.0 + x) + -1.0)) / 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.2d+215) then
        tmp = (1.0d0 / ((1.0d0 + x) + (-1.0d0))) / n
    else
        tmp = 0.0d0
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double tmp;
	if (x <= 8.2e+215) {
		tmp = (1.0 / ((1.0 + x) + -1.0)) / n;
	} else {
		tmp = 0.0;
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if x <= 8.2e+215:
		tmp = (1.0 / ((1.0 + x) + -1.0)) / n
	else:
		tmp = 0.0
	return tmp
function code(x, n)
	tmp = 0.0
	if (x <= 8.2e+215)
		tmp = Float64(Float64(1.0 / Float64(Float64(1.0 + x) + -1.0)) / n);
	else
		tmp = 0.0;
	end
	return tmp
end
function tmp_2 = code(x, n)
	tmp = 0.0;
	if (x <= 8.2e+215)
		tmp = (1.0 / ((1.0 + x) + -1.0)) / n;
	else
		tmp = 0.0;
	end
	tmp_2 = tmp;
end
code[x_, n_] := If[LessEqual[x, 8.2e+215], N[(N[(1.0 / N[(N[(1.0 + x), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], 0.0]
\begin{array}{l}

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

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


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

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

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

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

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

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

        \[\leadsto \frac{1}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(x\right)\right)} \cdot n} \]
      2. expm1-udef52.3%

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

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

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

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

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

    if 8.2000000000000007e215 < x

    1. Initial program 93.0%

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

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

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

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

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

        \[\leadsto \log \left(e^{e^{\frac{1}{n} \cdot \color{blue}{\mathsf{log1p}\left(x\right)}} - {x}^{\left(\frac{1}{n}\right)}}\right) \]
      6. *-commutative93.0%

        \[\leadsto \log \left(e^{e^{\color{blue}{\mathsf{log1p}\left(x\right) \cdot \frac{1}{n}}} - {x}^{\left(\frac{1}{n}\right)}}\right) \]
      7. un-div-inv93.0%

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

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

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

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

Alternative 13: 48.0% accurate, 23.4× speedup?

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

\\
\frac{1}{n \cdot \left(\left(1 + x\right) + -1\right)}
\end{array}
Derivation
  1. Initial program 54.5%

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
  6. Taylor expanded in n around inf 46.8%

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

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

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

      \[\leadsto \frac{1}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(x\right)\right)} \cdot n} \]
    2. expm1-udef55.8%

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

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

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

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

    \[\leadsto \frac{1}{\color{blue}{\left(\left(x + 1\right) - 1\right)} \cdot n} \]
  11. Final simplification56.7%

    \[\leadsto \frac{1}{n \cdot \left(\left(1 + x\right) + -1\right)} \]
  12. Add Preprocessing

Alternative 14: 48.6% accurate, 23.4× speedup?

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

\\
\frac{\frac{1}{\left(1 + x\right) + -1}}{n}
\end{array}
Derivation
  1. Initial program 54.5%

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(x\right)\right)} \cdot n} \]
    2. expm1-udef55.8%

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

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

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

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

    \[\leadsto \frac{\frac{1}{\color{blue}{\left(x + 1\right) - 1}}}{n} \]
  9. Final simplification56.9%

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

Alternative 15: 40.4% accurate, 42.2× speedup?

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

\\
\frac{1}{n \cdot x}
\end{array}
Derivation
  1. Initial program 54.5%

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
  6. Taylor expanded in n around inf 46.8%

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

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

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

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

Alternative 16: 41.0% accurate, 42.2× speedup?

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

\\
\frac{\frac{1}{n}}{x}
\end{array}
Derivation
  1. Initial program 54.5%

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
  6. Taylor expanded in n around inf 46.8%

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

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

    \[\leadsto \color{blue}{\frac{1}{x \cdot n}} \]
  9. Step-by-step derivation
    1. add-sqr-sqrt32.0%

      \[\leadsto \color{blue}{\sqrt{\frac{1}{x \cdot n}} \cdot \sqrt{\frac{1}{x \cdot n}}} \]
    2. pow232.0%

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

      \[\leadsto {\left(\sqrt{\color{blue}{{\left(x \cdot n\right)}^{-1}}}\right)}^{2} \]
    4. sqrt-pow132.0%

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

      \[\leadsto {\left({\left(x \cdot n\right)}^{\color{blue}{-0.5}}\right)}^{2} \]
  10. Applied egg-rr32.0%

    \[\leadsto \color{blue}{{\left({\left(x \cdot n\right)}^{-0.5}\right)}^{2}} \]
  11. Step-by-step derivation
    1. pow-pow46.8%

      \[\leadsto \color{blue}{{\left(x \cdot n\right)}^{\left(-0.5 \cdot 2\right)}} \]
    2. metadata-eval46.8%

      \[\leadsto {\left(x \cdot n\right)}^{\color{blue}{-1}} \]
    3. inv-pow46.8%

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

      \[\leadsto \frac{1}{\color{blue}{n \cdot x}} \]
    5. associate-/r*47.0%

      \[\leadsto \color{blue}{\frac{\frac{1}{n}}{x}} \]
  12. Applied egg-rr47.0%

    \[\leadsto \color{blue}{\frac{\frac{1}{n}}{x}} \]
  13. Final simplification47.0%

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

Alternative 17: 4.5% accurate, 70.3× speedup?

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

\\
\frac{x}{n}
\end{array}
Derivation
  1. Initial program 54.5%

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

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

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

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

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

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

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

    \[\leadsto \frac{\color{blue}{x - \log x}}{n} \]
  9. Taylor expanded in x around inf 4.4%

    \[\leadsto \color{blue}{\frac{x}{n}} \]
  10. Final simplification4.4%

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

Reproduce

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