2nthrt (problem 3.4.6)

Percentage Accurate: 53.0% → 91.3%
Time: 1.3min
Alternatives: 15
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 15 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.0% 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: 91.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 1:\\ \;\;\;\;\frac{x}{n} - \mathsf{expm1}\left(\frac{\log x}{n}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{x \cdot n}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= x 1.0)
   (- (/ x n) (expm1 (/ (log x) n)))
   (/ (pow x (/ 1.0 n)) (* x n))))
double code(double x, double n) {
	double tmp;
	if (x <= 1.0) {
		tmp = (x / n) - expm1((log(x) / n));
	} else {
		tmp = pow(x, (1.0 / n)) / (x * n);
	}
	return tmp;
}
public static double code(double x, double n) {
	double tmp;
	if (x <= 1.0) {
		tmp = (x / n) - Math.expm1((Math.log(x) / n));
	} else {
		tmp = Math.pow(x, (1.0 / n)) / (x * n);
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if x <= 1.0:
		tmp = (x / n) - math.expm1((math.log(x) / n))
	else:
		tmp = math.pow(x, (1.0 / n)) / (x * n)
	return tmp
function code(x, n)
	tmp = 0.0
	if (x <= 1.0)
		tmp = Float64(Float64(x / n) - expm1(Float64(log(x) / n)));
	else
		tmp = Float64((x ^ Float64(1.0 / n)) / Float64(x * n));
	end
	return tmp
end
code[x_, n_] := If[LessEqual[x, 1.0], N[(N[(x / n), $MachinePrecision] - N[(Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 49.1%

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(\frac{x}{n} - {x}^{\left(\frac{1}{n}\right)}\right) + 1} \]
      6. associate-+l-49.3%

        \[\leadsto \color{blue}{\frac{x}{n} - \left({x}^{\left(\frac{1}{n}\right)} - 1\right)} \]
      7. exp-to-pow49.3%

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

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

        \[\leadsto \frac{x}{n} - \left(e^{\frac{\color{blue}{\log x}}{n}} - 1\right) \]
      10. expm1-define93.6%

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

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

    if 1 < x

    1. Initial program 67.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 inf 96.0%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 78.0% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {x}^{\left(\frac{1}{n}\right)}\\ t_1 := \frac{\log \left(\frac{x + 1}{x}\right)}{n}\\ \mathbf{if}\;\frac{1}{n} \leq -40000:\\ \;\;\;\;\frac{t\_0}{x \cdot n}\\ \mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-75}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{-90}:\\ \;\;\;\;\frac{\frac{1 + \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{x}}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-6}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;\left(\left(\frac{x}{n} + 2\right) + -1\right) - t\_0\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ (log (/ (+ x 1.0) x)) n)))
   (if (<= (/ 1.0 n) -40000.0)
     (/ t_0 (* x n))
     (if (<= (/ 1.0 n) -2e-75)
       t_1
       (if (<= (/ 1.0 n) -5e-90)
         (/ (/ (+ 1.0 (/ (+ -0.5 (/ 0.3333333333333333 x)) x)) x) n)
         (if (<= (/ 1.0 n) 2e-6) t_1 (- (+ (+ (/ x n) 2.0) -1.0) t_0)))))))
double code(double x, double n) {
	double t_0 = pow(x, (1.0 / n));
	double t_1 = log(((x + 1.0) / x)) / n;
	double tmp;
	if ((1.0 / n) <= -40000.0) {
		tmp = t_0 / (x * n);
	} else if ((1.0 / n) <= -2e-75) {
		tmp = t_1;
	} else if ((1.0 / n) <= -5e-90) {
		tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n;
	} else if ((1.0 / n) <= 2e-6) {
		tmp = t_1;
	} else {
		tmp = (((x / n) + 2.0) + -1.0) - 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 = log(((x + 1.0d0) / x)) / n
    if ((1.0d0 / n) <= (-40000.0d0)) then
        tmp = t_0 / (x * n)
    else if ((1.0d0 / n) <= (-2d-75)) then
        tmp = t_1
    else if ((1.0d0 / n) <= (-5d-90)) then
        tmp = ((1.0d0 + (((-0.5d0) + (0.3333333333333333d0 / x)) / x)) / x) / n
    else if ((1.0d0 / n) <= 2d-6) then
        tmp = t_1
    else
        tmp = (((x / n) + 2.0d0) + (-1.0d0)) - 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.log(((x + 1.0) / x)) / n;
	double tmp;
	if ((1.0 / n) <= -40000.0) {
		tmp = t_0 / (x * n);
	} else if ((1.0 / n) <= -2e-75) {
		tmp = t_1;
	} else if ((1.0 / n) <= -5e-90) {
		tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n;
	} else if ((1.0 / n) <= 2e-6) {
		tmp = t_1;
	} else {
		tmp = (((x / n) + 2.0) + -1.0) - t_0;
	}
	return tmp;
}
def code(x, n):
	t_0 = math.pow(x, (1.0 / n))
	t_1 = math.log(((x + 1.0) / x)) / n
	tmp = 0
	if (1.0 / n) <= -40000.0:
		tmp = t_0 / (x * n)
	elif (1.0 / n) <= -2e-75:
		tmp = t_1
	elif (1.0 / n) <= -5e-90:
		tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n
	elif (1.0 / n) <= 2e-6:
		tmp = t_1
	else:
		tmp = (((x / n) + 2.0) + -1.0) - t_0
	return tmp
function code(x, n)
	t_0 = x ^ Float64(1.0 / n)
	t_1 = Float64(log(Float64(Float64(x + 1.0) / x)) / n)
	tmp = 0.0
	if (Float64(1.0 / n) <= -40000.0)
		tmp = Float64(t_0 / Float64(x * n));
	elseif (Float64(1.0 / n) <= -2e-75)
		tmp = t_1;
	elseif (Float64(1.0 / n) <= -5e-90)
		tmp = Float64(Float64(Float64(1.0 + Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x)) / x) / n);
	elseif (Float64(1.0 / n) <= 2e-6)
		tmp = t_1;
	else
		tmp = Float64(Float64(Float64(Float64(x / n) + 2.0) + -1.0) - t_0);
	end
	return tmp
end
function tmp_2 = code(x, n)
	t_0 = x ^ (1.0 / n);
	t_1 = log(((x + 1.0) / x)) / n;
	tmp = 0.0;
	if ((1.0 / n) <= -40000.0)
		tmp = t_0 / (x * n);
	elseif ((1.0 / n) <= -2e-75)
		tmp = t_1;
	elseif ((1.0 / n) <= -5e-90)
		tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n;
	elseif ((1.0 / n) <= 2e-6)
		tmp = t_1;
	else
		tmp = (((x / n) + 2.0) + -1.0) - t_0;
	end
	tmp_2 = tmp;
end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -40000.0], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-75], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-90], N[(N[(N[(1.0 + N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-6], t$95$1, N[(N[(N[(N[(x / n), $MachinePrecision] + 2.0), $MachinePrecision] + -1.0), $MachinePrecision] - t$95$0), $MachinePrecision]]]]]]]
\begin{array}{l}

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

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

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

        \[\leadsto \frac{e^{\frac{\color{blue}{--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. *-rgt-identity100.0%

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

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

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

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

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

    if -4e4 < (/.f64 #s(literal 1 binary64) n) < -1.9999999999999999e-75 or -5.00000000000000019e-90 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999991e-6

    1. Initial program 31.2%

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

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

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

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

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

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

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

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

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

    if -1.9999999999999999e-75 < (/.f64 #s(literal 1 binary64) n) < -5.00000000000000019e-90

    1. Initial program 4.6%

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

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

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

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

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

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

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

    if 1.99999999999999991e-6 < (/.f64 #s(literal 1 binary64) n)

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

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

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

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

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

      \[\leadsto \color{blue}{\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}} \]
    6. Step-by-step derivation
      1. expm1-log1p-u66.7%

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

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

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

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

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

        \[\leadsto \left(\color{blue}{\left(1 + \left(1 + \frac{x}{n}\right)\right)} + \left(-1\right)\right) - {x}^{\left(\frac{1}{n}\right)} \]
      4. associate-+r+66.8%

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

        \[\leadsto \left(\left(\color{blue}{2} + \frac{x}{n}\right) + \left(-1\right)\right) - {x}^{\left(\frac{1}{n}\right)} \]
      6. metadata-eval66.8%

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

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

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

Alternative 3: 78.0% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {x}^{\left(\frac{1}{n}\right)}\\ t_1 := \frac{\log \left(\frac{x + 1}{x}\right)}{n}\\ \mathbf{if}\;\frac{1}{n} \leq -40000:\\ \;\;\;\;\frac{t\_0}{x \cdot n}\\ \mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-75}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{-90}:\\ \;\;\;\;\frac{\frac{1 + \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{x}}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-6}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;\left(1 + \frac{x}{n}\right) - t\_0\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ (log (/ (+ x 1.0) x)) n)))
   (if (<= (/ 1.0 n) -40000.0)
     (/ t_0 (* x n))
     (if (<= (/ 1.0 n) -2e-75)
       t_1
       (if (<= (/ 1.0 n) -5e-90)
         (/ (/ (+ 1.0 (/ (+ -0.5 (/ 0.3333333333333333 x)) x)) x) n)
         (if (<= (/ 1.0 n) 2e-6) t_1 (- (+ 1.0 (/ x n)) t_0)))))))
double code(double x, double n) {
	double t_0 = pow(x, (1.0 / n));
	double t_1 = log(((x + 1.0) / x)) / n;
	double tmp;
	if ((1.0 / n) <= -40000.0) {
		tmp = t_0 / (x * n);
	} else if ((1.0 / n) <= -2e-75) {
		tmp = t_1;
	} else if ((1.0 / n) <= -5e-90) {
		tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n;
	} else if ((1.0 / n) <= 2e-6) {
		tmp = t_1;
	} else {
		tmp = (1.0 + (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 = log(((x + 1.0d0) / x)) / n
    if ((1.0d0 / n) <= (-40000.0d0)) then
        tmp = t_0 / (x * n)
    else if ((1.0d0 / n) <= (-2d-75)) then
        tmp = t_1
    else if ((1.0d0 / n) <= (-5d-90)) then
        tmp = ((1.0d0 + (((-0.5d0) + (0.3333333333333333d0 / x)) / x)) / x) / n
    else if ((1.0d0 / n) <= 2d-6) then
        tmp = t_1
    else
        tmp = (1.0d0 + (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.log(((x + 1.0) / x)) / n;
	double tmp;
	if ((1.0 / n) <= -40000.0) {
		tmp = t_0 / (x * n);
	} else if ((1.0 / n) <= -2e-75) {
		tmp = t_1;
	} else if ((1.0 / n) <= -5e-90) {
		tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n;
	} else if ((1.0 / n) <= 2e-6) {
		tmp = t_1;
	} else {
		tmp = (1.0 + (x / n)) - t_0;
	}
	return tmp;
}
def code(x, n):
	t_0 = math.pow(x, (1.0 / n))
	t_1 = math.log(((x + 1.0) / x)) / n
	tmp = 0
	if (1.0 / n) <= -40000.0:
		tmp = t_0 / (x * n)
	elif (1.0 / n) <= -2e-75:
		tmp = t_1
	elif (1.0 / n) <= -5e-90:
		tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n
	elif (1.0 / n) <= 2e-6:
		tmp = t_1
	else:
		tmp = (1.0 + (x / n)) - t_0
	return tmp
function code(x, n)
	t_0 = x ^ Float64(1.0 / n)
	t_1 = Float64(log(Float64(Float64(x + 1.0) / x)) / n)
	tmp = 0.0
	if (Float64(1.0 / n) <= -40000.0)
		tmp = Float64(t_0 / Float64(x * n));
	elseif (Float64(1.0 / n) <= -2e-75)
		tmp = t_1;
	elseif (Float64(1.0 / n) <= -5e-90)
		tmp = Float64(Float64(Float64(1.0 + Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x)) / x) / n);
	elseif (Float64(1.0 / n) <= 2e-6)
		tmp = t_1;
	else
		tmp = Float64(Float64(1.0 + Float64(x / n)) - t_0);
	end
	return tmp
end
function tmp_2 = code(x, n)
	t_0 = x ^ (1.0 / n);
	t_1 = log(((x + 1.0) / x)) / n;
	tmp = 0.0;
	if ((1.0 / n) <= -40000.0)
		tmp = t_0 / (x * n);
	elseif ((1.0 / n) <= -2e-75)
		tmp = t_1;
	elseif ((1.0 / n) <= -5e-90)
		tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n;
	elseif ((1.0 / n) <= 2e-6)
		tmp = t_1;
	else
		tmp = (1.0 + (x / n)) - t_0;
	end
	tmp_2 = tmp;
end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -40000.0], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-75], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-90], N[(N[(N[(1.0 + N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-6], t$95$1, N[(N[(1.0 + 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 := \frac{\log \left(\frac{x + 1}{x}\right)}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -40000:\\
\;\;\;\;\frac{t\_0}{x \cdot n}\\

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

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

        \[\leadsto \frac{e^{\frac{\color{blue}{--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. *-rgt-identity100.0%

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

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

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

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

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

    if -4e4 < (/.f64 #s(literal 1 binary64) n) < -1.9999999999999999e-75 or -5.00000000000000019e-90 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999991e-6

    1. Initial program 31.2%

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

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

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

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

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

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

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

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

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

    if -1.9999999999999999e-75 < (/.f64 #s(literal 1 binary64) n) < -5.00000000000000019e-90

    1. Initial program 4.6%

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

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

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

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

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

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

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

    if 1.99999999999999991e-6 < (/.f64 #s(literal 1 binary64) n)

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

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

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

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

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

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

Alternative 4: 77.8% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {x}^{\left(\frac{1}{n}\right)}\\ t_1 := \frac{\log \left(\frac{x + 1}{x}\right)}{n}\\ \mathbf{if}\;\frac{1}{n} \leq -40000:\\ \;\;\;\;\frac{t\_0}{x \cdot n}\\ \mathbf{elif}\;\frac{1}{n} \leq -2 \cdot 10^{-75}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;\frac{1}{n} \leq -5 \cdot 10^{-90}:\\ \;\;\;\;\frac{\frac{1 + \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{x}}{n}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-6}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;1 - t\_0\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (pow x (/ 1.0 n))) (t_1 (/ (log (/ (+ x 1.0) x)) n)))
   (if (<= (/ 1.0 n) -40000.0)
     (/ t_0 (* x n))
     (if (<= (/ 1.0 n) -2e-75)
       t_1
       (if (<= (/ 1.0 n) -5e-90)
         (/ (/ (+ 1.0 (/ (+ -0.5 (/ 0.3333333333333333 x)) x)) x) n)
         (if (<= (/ 1.0 n) 2e-6) t_1 (- 1.0 t_0)))))))
double code(double x, double n) {
	double t_0 = pow(x, (1.0 / n));
	double t_1 = log(((x + 1.0) / x)) / n;
	double tmp;
	if ((1.0 / n) <= -40000.0) {
		tmp = t_0 / (x * n);
	} else if ((1.0 / n) <= -2e-75) {
		tmp = t_1;
	} else if ((1.0 / n) <= -5e-90) {
		tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n;
	} else if ((1.0 / n) <= 2e-6) {
		tmp = t_1;
	} else {
		tmp = 1.0 - 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 = log(((x + 1.0d0) / x)) / n
    if ((1.0d0 / n) <= (-40000.0d0)) then
        tmp = t_0 / (x * n)
    else if ((1.0d0 / n) <= (-2d-75)) then
        tmp = t_1
    else if ((1.0d0 / n) <= (-5d-90)) then
        tmp = ((1.0d0 + (((-0.5d0) + (0.3333333333333333d0 / x)) / x)) / x) / n
    else if ((1.0d0 / n) <= 2d-6) then
        tmp = t_1
    else
        tmp = 1.0d0 - 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.log(((x + 1.0) / x)) / n;
	double tmp;
	if ((1.0 / n) <= -40000.0) {
		tmp = t_0 / (x * n);
	} else if ((1.0 / n) <= -2e-75) {
		tmp = t_1;
	} else if ((1.0 / n) <= -5e-90) {
		tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n;
	} else if ((1.0 / n) <= 2e-6) {
		tmp = t_1;
	} else {
		tmp = 1.0 - t_0;
	}
	return tmp;
}
def code(x, n):
	t_0 = math.pow(x, (1.0 / n))
	t_1 = math.log(((x + 1.0) / x)) / n
	tmp = 0
	if (1.0 / n) <= -40000.0:
		tmp = t_0 / (x * n)
	elif (1.0 / n) <= -2e-75:
		tmp = t_1
	elif (1.0 / n) <= -5e-90:
		tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n
	elif (1.0 / n) <= 2e-6:
		tmp = t_1
	else:
		tmp = 1.0 - t_0
	return tmp
function code(x, n)
	t_0 = x ^ Float64(1.0 / n)
	t_1 = Float64(log(Float64(Float64(x + 1.0) / x)) / n)
	tmp = 0.0
	if (Float64(1.0 / n) <= -40000.0)
		tmp = Float64(t_0 / Float64(x * n));
	elseif (Float64(1.0 / n) <= -2e-75)
		tmp = t_1;
	elseif (Float64(1.0 / n) <= -5e-90)
		tmp = Float64(Float64(Float64(1.0 + Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x)) / x) / n);
	elseif (Float64(1.0 / n) <= 2e-6)
		tmp = t_1;
	else
		tmp = Float64(1.0 - t_0);
	end
	return tmp
end
function tmp_2 = code(x, n)
	t_0 = x ^ (1.0 / n);
	t_1 = log(((x + 1.0) / x)) / n;
	tmp = 0.0;
	if ((1.0 / n) <= -40000.0)
		tmp = t_0 / (x * n);
	elseif ((1.0 / n) <= -2e-75)
		tmp = t_1;
	elseif ((1.0 / n) <= -5e-90)
		tmp = ((1.0 + ((-0.5 + (0.3333333333333333 / x)) / x)) / x) / n;
	elseif ((1.0 / n) <= 2e-6)
		tmp = t_1;
	else
		tmp = 1.0 - t_0;
	end
	tmp_2 = tmp;
end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -40000.0], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], -2e-75], t$95$1, If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-90], N[(N[(N[(1.0 + N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-6], t$95$1, N[(1.0 - t$95$0), $MachinePrecision]]]]]]]
\begin{array}{l}

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

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

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

        \[\leadsto \frac{e^{\frac{\color{blue}{--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. *-rgt-identity100.0%

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

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

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

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

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

    if -4e4 < (/.f64 #s(literal 1 binary64) n) < -1.9999999999999999e-75 or -5.00000000000000019e-90 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999991e-6

    1. Initial program 31.2%

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

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

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

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

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

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

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

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

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

    if -1.9999999999999999e-75 < (/.f64 #s(literal 1 binary64) n) < -5.00000000000000019e-90

    1. Initial program 4.6%

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

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

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

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

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

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

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

    if 1.99999999999999991e-6 < (/.f64 #s(literal 1 binary64) n)

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

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

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

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

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

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

Alternative 5: 70.9% accurate, 1.6× speedup?

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

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

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

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

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

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


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

    1. Initial program 100.0%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{0.3333333333333333}{n}}{{x}^{3}}} \]
    9. Simplified79.1%

      \[\leadsto \color{blue}{\frac{\frac{0.3333333333333333}{n}}{{x}^{3}}} \]
    10. Step-by-step derivation
      1. clear-num79.1%

        \[\leadsto \color{blue}{\frac{1}{\frac{{x}^{3}}{\frac{0.3333333333333333}{n}}}} \]
      2. associate-/r/79.1%

        \[\leadsto \color{blue}{\frac{1}{{x}^{3}} \cdot \frac{0.3333333333333333}{n}} \]
      3. pow-flip79.1%

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

        \[\leadsto {x}^{\color{blue}{-3}} \cdot \frac{0.3333333333333333}{n} \]
    11. Applied egg-rr79.1%

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

    if -4e4 < (/.f64 #s(literal 1 binary64) n) < -1.9999999999999999e-75 or -5.00000000000000019e-90 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999991e-6

    1. Initial program 31.2%

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

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

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

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

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

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

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

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

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

    if -1.9999999999999999e-75 < (/.f64 #s(literal 1 binary64) n) < -5.00000000000000019e-90

    1. Initial program 4.6%

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

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

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

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

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

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

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

    if 1.99999999999999991e-6 < (/.f64 #s(literal 1 binary64) n)

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

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

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

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

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

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

Alternative 6: 58.4% 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 4.7 \cdot 10^{-287}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 2 \cdot 10^{-224}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 2.7 \cdot 10^{-189}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 4.9 \cdot 10^{-36}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 3.1 \cdot 10^{+127}:\\ \;\;\;\;\frac{\frac{1}{x} + \frac{\frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{x}}{n}\\ \mathbf{else}:\\ \;\;\;\;{x}^{-3} \cdot \frac{0.3333333333333333}{n}\\ \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 4.7e-287)
     t_0
     (if (<= x 2e-224)
       t_1
       (if (<= x 2.7e-189)
         t_0
         (if (<= x 4.9e-36)
           t_1
           (if (<= x 3.1e+127)
             (/ (+ (/ 1.0 x) (/ (/ (+ -0.5 (/ 0.3333333333333333 x)) x) x)) n)
             (* (pow x -3.0) (/ 0.3333333333333333 n)))))))))
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 <= 4.7e-287) {
		tmp = t_0;
	} else if (x <= 2e-224) {
		tmp = t_1;
	} else if (x <= 2.7e-189) {
		tmp = t_0;
	} else if (x <= 4.9e-36) {
		tmp = t_1;
	} else if (x <= 3.1e+127) {
		tmp = ((1.0 / x) + (((-0.5 + (0.3333333333333333 / x)) / x) / x)) / n;
	} else {
		tmp = pow(x, -3.0) * (0.3333333333333333 / n);
	}
	return tmp;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = 1.0d0 - (x ** (1.0d0 / n))
    t_1 = log(x) / -n
    if (x <= 4.7d-287) then
        tmp = t_0
    else if (x <= 2d-224) then
        tmp = t_1
    else if (x <= 2.7d-189) then
        tmp = t_0
    else if (x <= 4.9d-36) then
        tmp = t_1
    else if (x <= 3.1d+127) then
        tmp = ((1.0d0 / x) + ((((-0.5d0) + (0.3333333333333333d0 / x)) / x) / x)) / n
    else
        tmp = (x ** (-3.0d0)) * (0.3333333333333333d0 / n)
    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 <= 4.7e-287) {
		tmp = t_0;
	} else if (x <= 2e-224) {
		tmp = t_1;
	} else if (x <= 2.7e-189) {
		tmp = t_0;
	} else if (x <= 4.9e-36) {
		tmp = t_1;
	} else if (x <= 3.1e+127) {
		tmp = ((1.0 / x) + (((-0.5 + (0.3333333333333333 / x)) / x) / x)) / n;
	} else {
		tmp = Math.pow(x, -3.0) * (0.3333333333333333 / n);
	}
	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 <= 4.7e-287:
		tmp = t_0
	elif x <= 2e-224:
		tmp = t_1
	elif x <= 2.7e-189:
		tmp = t_0
	elif x <= 4.9e-36:
		tmp = t_1
	elif x <= 3.1e+127:
		tmp = ((1.0 / x) + (((-0.5 + (0.3333333333333333 / x)) / x) / x)) / n
	else:
		tmp = math.pow(x, -3.0) * (0.3333333333333333 / n)
	return tmp
function code(x, n)
	t_0 = Float64(1.0 - (x ^ Float64(1.0 / n)))
	t_1 = Float64(log(x) / Float64(-n))
	tmp = 0.0
	if (x <= 4.7e-287)
		tmp = t_0;
	elseif (x <= 2e-224)
		tmp = t_1;
	elseif (x <= 2.7e-189)
		tmp = t_0;
	elseif (x <= 4.9e-36)
		tmp = t_1;
	elseif (x <= 3.1e+127)
		tmp = Float64(Float64(Float64(1.0 / x) + Float64(Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x) / x)) / n);
	else
		tmp = Float64((x ^ -3.0) * Float64(0.3333333333333333 / n));
	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 <= 4.7e-287)
		tmp = t_0;
	elseif (x <= 2e-224)
		tmp = t_1;
	elseif (x <= 2.7e-189)
		tmp = t_0;
	elseif (x <= 4.9e-36)
		tmp = t_1;
	elseif (x <= 3.1e+127)
		tmp = ((1.0 / x) + (((-0.5 + (0.3333333333333333 / x)) / x) / x)) / n;
	else
		tmp = (x ^ -3.0) * (0.3333333333333333 / n);
	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, 4.7e-287], t$95$0, If[LessEqual[x, 2e-224], t$95$1, If[LessEqual[x, 2.7e-189], t$95$0, If[LessEqual[x, 4.9e-36], t$95$1, If[LessEqual[x, 3.1e+127], N[(N[(N[(1.0 / x), $MachinePrecision] + N[(N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], N[(N[Power[x, -3.0], $MachinePrecision] * N[(0.3333333333333333 / n), $MachinePrecision]), $MachinePrecision]]]]]]]]
\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 4.7 \cdot 10^{-287}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 2 \cdot 10^{-224}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 2.7 \cdot 10^{-189}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 4.9 \cdot 10^{-36}:\\
\;\;\;\;t\_1\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < 4.6999999999999999e-287 or 2e-224 < x < 2.6999999999999999e-189

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

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

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

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

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

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

    if 4.6999999999999999e-287 < x < 2e-224 or 2.6999999999999999e-189 < x < 4.8999999999999997e-36

    1. Initial program 41.6%

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

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

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

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

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

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

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

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

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

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

    if 4.8999999999999997e-36 < x < 3.1000000000000002e127

    1. Initial program 50.3%

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

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

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

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

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

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

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

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

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

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

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

    if 3.1000000000000002e127 < x

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{0.3333333333333333}{n}}{{x}^{3}}} \]
    9. Simplified89.1%

      \[\leadsto \color{blue}{\frac{\frac{0.3333333333333333}{n}}{{x}^{3}}} \]
    10. Step-by-step derivation
      1. clear-num89.1%

        \[\leadsto \color{blue}{\frac{1}{\frac{{x}^{3}}{\frac{0.3333333333333333}{n}}}} \]
      2. associate-/r/89.1%

        \[\leadsto \color{blue}{\frac{1}{{x}^{3}} \cdot \frac{0.3333333333333333}{n}} \]
      3. pow-flip89.1%

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

        \[\leadsto {x}^{\color{blue}{-3}} \cdot \frac{0.3333333333333333}{n} \]
    11. Applied egg-rr89.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 4.7 \cdot 10^{-287}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 2 \cdot 10^{-224}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 2.7 \cdot 10^{-189}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 4.9 \cdot 10^{-36}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 3.1 \cdot 10^{+127}:\\ \;\;\;\;\frac{\frac{1}{x} + \frac{\frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{x}}{n}\\ \mathbf{else}:\\ \;\;\;\;{x}^{-3} \cdot \frac{0.3333333333333333}{n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 57.5% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}\\
t_1 := \frac{\log x}{-n}\\
\mathbf{if}\;x \leq 2 \cdot 10^{-224}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;x \leq 4.9 \cdot 10^{-36}:\\
\;\;\;\;t\_1\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < 2e-224 or 6.4000000000000001e-189 < x < 4.8999999999999997e-36

    1. Initial program 44.6%

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

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

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

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

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

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

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

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

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

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

    if 2e-224 < x < 6.4000000000000001e-189

    1. Initial program 74.8%

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

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

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

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

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

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

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

    if 4.8999999999999997e-36 < x < 1.89999999999999995e128

    1. Initial program 50.3%

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

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

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

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

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

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

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

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

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

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

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

    if 1.89999999999999995e128 < x

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{0.3333333333333333}{n}}{{x}^{3}}} \]
    9. Simplified89.1%

      \[\leadsto \color{blue}{\frac{\frac{0.3333333333333333}{n}}{{x}^{3}}} \]
    10. Step-by-step derivation
      1. clear-num89.1%

        \[\leadsto \color{blue}{\frac{1}{\frac{{x}^{3}}{\frac{0.3333333333333333}{n}}}} \]
      2. associate-/r/89.1%

        \[\leadsto \color{blue}{\frac{1}{{x}^{3}} \cdot \frac{0.3333333333333333}{n}} \]
      3. pow-flip89.1%

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

        \[\leadsto {x}^{\color{blue}{-3}} \cdot \frac{0.3333333333333333}{n} \]
    11. Applied egg-rr89.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 2 \cdot 10^{-224}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 6.4 \cdot 10^{-189}:\\ \;\;\;\;\frac{\frac{1 + \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{x}}{n}\\ \mathbf{elif}\;x \leq 4.9 \cdot 10^{-36}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 1.9 \cdot 10^{+128}:\\ \;\;\;\;\frac{\frac{1}{x} + \frac{\frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{x}}{n}\\ \mathbf{else}:\\ \;\;\;\;{x}^{-3} \cdot \frac{0.3333333333333333}{n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 54.0% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}\\
t_1 := \frac{\log x}{-n}\\
\mathbf{if}\;x \leq 1.6 \cdot 10^{-224}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;x \leq 4.9 \cdot 10^{-36}:\\
\;\;\;\;t\_1\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x} + \frac{t\_0}{x}}{n}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 1.5999999999999999e-224 or 1.1e-188 < x < 4.8999999999999997e-36

    1. Initial program 44.6%

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

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

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

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

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

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

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

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

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

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

    if 1.5999999999999999e-224 < x < 1.1e-188

    1. Initial program 74.8%

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

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

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

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

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

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

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

    if 4.8999999999999997e-36 < x

    1. Initial program 68.3%

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

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

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

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

      \[\leadsto \frac{\color{blue}{-1 \cdot \frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{x}}}{n} \]
    7. Step-by-step derivation
      1. div-sub65.9%

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

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

        \[\leadsto \frac{-1 \cdot \left(\frac{-\frac{\color{blue}{0.3333333333333333 \cdot \frac{1}{x} + \left(-0.5\right)}}{x}}{x} - \frac{1}{x}\right)}{n} \]
      4. un-div-inv65.9%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.6 \cdot 10^{-224}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 1.1 \cdot 10^{-188}:\\ \;\;\;\;\frac{\frac{1 + \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{x}}{n}\\ \mathbf{elif}\;x \leq 4.9 \cdot 10^{-36}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x} + \frac{\frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{x}}{n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 47.1% accurate, 12.4× speedup?

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

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

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

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

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

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

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

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

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

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

Alternative 10: 47.1% accurate, 14.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 11: 47.1% accurate, 16.2× speedup?

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

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

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

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

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

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

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

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

Alternative 12: 40.9% accurate, 42.2× speedup?

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

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

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

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

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

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

Alternative 13: 40.9% accurate, 42.2× speedup?

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{\frac{1}{n} - 0.5 \cdot \frac{1}{n \cdot x}}{x}} \]
  7. Step-by-step derivation
    1. sub-neg26.9%

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

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

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

      \[\leadsto \frac{\frac{1}{n} + \color{blue}{\frac{-0.5}{n \cdot x}}}{x} \]
    5. metadata-eval26.9%

      \[\leadsto \frac{\frac{1}{n} + \frac{\color{blue}{-0.5}}{n \cdot x}}{x} \]
    6. *-commutative26.9%

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

    \[\leadsto \color{blue}{\frac{\frac{1}{n} + \frac{-0.5}{x \cdot n}}{x}} \]
  9. Taylor expanded in x around inf 41.7%

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

Alternative 14: 40.3% accurate, 42.2× speedup?

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

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

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

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

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

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

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

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

Alternative 15: 4.5% accurate, 70.3× speedup?

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

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

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

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

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

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

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

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

Reproduce

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