2nthrt (problem 3.4.6)

Percentage Accurate: 53.4% → 83.4%
Time: 50.3s
Alternatives: 21
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 21 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.4% 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: 83.4% accurate, 0.3× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 2.3999999999999998e-280

    1. Initial program 78.1%

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

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

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

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

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

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

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

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

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

    if 2.3999999999999998e-280 < x < 1400

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{log1p}\left(x\right) + \left(0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n} - \log x\right)}{n}} \]
    6. Step-by-step derivation
      1. add-log-exp77.4%

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

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

        \[\leadsto \frac{\log \color{blue}{\left(\frac{e^{\mathsf{log1p}\left(x\right) + 0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}}{e^{\log x}}\right)}}{n} \]
      4. add-exp-log77.4%

        \[\leadsto \frac{\log \left(\frac{e^{\mathsf{log1p}\left(x\right) + 0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n}}}{\color{blue}{x}}\right)}{n} \]
    7. Applied egg-rr77.4%

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

        \[\leadsto \frac{\log \left(\frac{e^{\color{blue}{0.5 \cdot \frac{{\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}}{n} + \mathsf{log1p}\left(x\right)}}}{x}\right)}{n} \]
      2. associate-*r/77.4%

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

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

    if 1400 < x

    1. Initial program 63.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 85.3% accurate, 0.7× speedup?

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.0999999999999999e-78 < (/.f64 #s(literal 1 binary64) n) < 5.0000000000000002e-23

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

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

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

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

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

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

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

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

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

    if 5.0000000000000002e-23 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 48.7%

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

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

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

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

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

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

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

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

Alternative 3: 80.6% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
t_0 := \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{x \cdot n}\right)\right)\\
t_1 := x \cdot \left(\frac{1}{n} - \frac{\log x}{x \cdot n}\right)\\
\mathbf{if}\;x \leq 1.8 \cdot 10^{-48}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 1.55 \cdot 10^{-33}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 1.25 \cdot 10^{-7}:\\
\;\;\;\;t\_1\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 1.8000000000000001e-48 or 1.54999999999999998e-33 < x < 1.24999999999999994e-7

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto x \cdot \color{blue}{\left(\frac{1}{n} - \frac{\log x}{n \cdot x}\right)} \]
      4. *-commutative74.4%

        \[\leadsto x \cdot \left(\frac{1}{n} - \frac{\log x}{\color{blue}{x \cdot n}}\right) \]
    13. Simplified74.4%

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

    if 1.8000000000000001e-48 < x < 1.54999999999999998e-33 or 1.24999999999999994e-7 < x < 1

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

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

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

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

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

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

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

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

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

    if 1 < x

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 85.4% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;\frac{1}{n} \leq 0.0001:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.0999999999999999e-78 < (/.f64 #s(literal 1 binary64) n) < 1.00000000000000005e-4

    1. Initial program 28.9%

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

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

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

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

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

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

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

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

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

    if 1.00000000000000005e-4 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 51.2%

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

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

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

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

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

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

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

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

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

Alternative 5: 74.6% accurate, 1.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -5:\\
\;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\

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

\mathbf{elif}\;\frac{1}{n} \leq 0.0001:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x \cdot n} + \frac{-0.5}{n}}{x}}{x}\\


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

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

    if -5 < (/.f64 #s(literal 1 binary64) n) < -1.0999999999999999e-78

    1. Initial program 17.5%

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

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

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

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

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

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

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

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

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

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

    if -1.0999999999999999e-78 < (/.f64 #s(literal 1 binary64) n) < 1.00000000000000005e-4

    1. Initial program 28.9%

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

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

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

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

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

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

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

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

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

    if 1.00000000000000005e-4 < (/.f64 #s(literal 1 binary64) n) < 5e163

    1. Initial program 74.9%

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

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

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

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

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

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

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

    if 5e163 < (/.f64 #s(literal 1 binary64) n)

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

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

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

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

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

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

      \[\leadsto \color{blue}{-\frac{\left(-\frac{\left(-\frac{\frac{0.25}{x \cdot n} - \frac{0.3333333333333333}{n}}{x}\right) - \frac{0.5}{n}}{x}\right) - \frac{1}{n}}{x}} \]
    9. Step-by-step derivation
      1. *-un-lft-identity0.2%

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

      \[\leadsto -\frac{\left(-\color{blue}{1 \cdot \frac{\frac{\frac{\frac{0.25}{x} - 0.3333333333333333}{n}}{x} + \frac{-0.5}{n}}{x}}\right) - \frac{1}{n}}{x} \]
    11. Step-by-step derivation
      1. *-lft-identity72.5%

        \[\leadsto -\frac{\left(-\color{blue}{\frac{\frac{\frac{\frac{0.25}{x} - 0.3333333333333333}{n}}{x} + \frac{-0.5}{n}}{x}}\right) - \frac{1}{n}}{x} \]
      2. associate-/l/72.5%

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

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

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

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

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

Alternative 6: 59.8% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 4.1 \cdot 10^{-233}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 1.05 \cdot 10^{-144}:\\ \;\;\;\;\frac{-1}{\frac{n}{\log x}}\\ \mathbf{elif}\;x \leq 4.7 \cdot 10^{-122}:\\ \;\;\;\;\frac{\frac{-0.5 + \frac{0.3333333333333333}{x}}{x} + 1}{x \cdot n}\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{-7}:\\ \;\;\;\;\frac{x}{n} - \frac{\log x}{n}\\ \mathbf{elif}\;x \leq 9.5 \cdot 10^{+172}:\\ \;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} - \frac{0.5}{n}}{x}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= x 4.1e-233)
   (- 1.0 (pow x (/ 1.0 n)))
   (if (<= x 1.05e-144)
     (/ -1.0 (/ n (log x)))
     (if (<= x 4.7e-122)
       (/ (+ (/ (+ -0.5 (/ 0.3333333333333333 x)) x) 1.0) (* x n))
       (if (<= x 1.4e-7)
         (- (/ x n) (/ (log x) n))
         (if (<= x 9.5e+172)
           (/
            (+ (/ 1.0 n) (/ (- (/ 0.3333333333333333 (* x n)) (/ 0.5 n)) x))
            x)
           (/ 0.3333333333333333 (* n (pow x 3.0)))))))))
double code(double x, double n) {
	double tmp;
	if (x <= 4.1e-233) {
		tmp = 1.0 - pow(x, (1.0 / n));
	} else if (x <= 1.05e-144) {
		tmp = -1.0 / (n / log(x));
	} else if (x <= 4.7e-122) {
		tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n);
	} else if (x <= 1.4e-7) {
		tmp = (x / n) - (log(x) / n);
	} else if (x <= 9.5e+172) {
		tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
	} else {
		tmp = 0.3333333333333333 / (n * pow(x, 3.0));
	}
	return tmp;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    real(8) :: tmp
    if (x <= 4.1d-233) then
        tmp = 1.0d0 - (x ** (1.0d0 / n))
    else if (x <= 1.05d-144) then
        tmp = (-1.0d0) / (n / log(x))
    else if (x <= 4.7d-122) then
        tmp = ((((-0.5d0) + (0.3333333333333333d0 / x)) / x) + 1.0d0) / (x * n)
    else if (x <= 1.4d-7) then
        tmp = (x / n) - (log(x) / n)
    else if (x <= 9.5d+172) then
        tmp = ((1.0d0 / n) + (((0.3333333333333333d0 / (x * n)) - (0.5d0 / n)) / x)) / x
    else
        tmp = 0.3333333333333333d0 / (n * (x ** 3.0d0))
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double tmp;
	if (x <= 4.1e-233) {
		tmp = 1.0 - Math.pow(x, (1.0 / n));
	} else if (x <= 1.05e-144) {
		tmp = -1.0 / (n / Math.log(x));
	} else if (x <= 4.7e-122) {
		tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n);
	} else if (x <= 1.4e-7) {
		tmp = (x / n) - (Math.log(x) / n);
	} else if (x <= 9.5e+172) {
		tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
	} else {
		tmp = 0.3333333333333333 / (n * Math.pow(x, 3.0));
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if x <= 4.1e-233:
		tmp = 1.0 - math.pow(x, (1.0 / n))
	elif x <= 1.05e-144:
		tmp = -1.0 / (n / math.log(x))
	elif x <= 4.7e-122:
		tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n)
	elif x <= 1.4e-7:
		tmp = (x / n) - (math.log(x) / n)
	elif x <= 9.5e+172:
		tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x
	else:
		tmp = 0.3333333333333333 / (n * math.pow(x, 3.0))
	return tmp
function code(x, n)
	tmp = 0.0
	if (x <= 4.1e-233)
		tmp = Float64(1.0 - (x ^ Float64(1.0 / n)));
	elseif (x <= 1.05e-144)
		tmp = Float64(-1.0 / Float64(n / log(x)));
	elseif (x <= 4.7e-122)
		tmp = Float64(Float64(Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x) + 1.0) / Float64(x * n));
	elseif (x <= 1.4e-7)
		tmp = Float64(Float64(x / n) - Float64(log(x) / n));
	elseif (x <= 9.5e+172)
		tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(x * n)) - Float64(0.5 / n)) / x)) / x);
	else
		tmp = Float64(0.3333333333333333 / Float64(n * (x ^ 3.0)));
	end
	return tmp
end
function tmp_2 = code(x, n)
	tmp = 0.0;
	if (x <= 4.1e-233)
		tmp = 1.0 - (x ^ (1.0 / n));
	elseif (x <= 1.05e-144)
		tmp = -1.0 / (n / log(x));
	elseif (x <= 4.7e-122)
		tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n);
	elseif (x <= 1.4e-7)
		tmp = (x / n) - (log(x) / n);
	elseif (x <= 9.5e+172)
		tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
	else
		tmp = 0.3333333333333333 / (n * (x ^ 3.0));
	end
	tmp_2 = tmp;
end
code[x_, n_] := If[LessEqual[x, 4.1e-233], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.05e-144], N[(-1.0 / N[(n / N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4.7e-122], N[(N[(N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + 1.0), $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.4e-7], N[(N[(x / n), $MachinePrecision] - N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 9.5e+172], 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], N[(0.3333333333333333 / N[(n * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq 1.05 \cdot 10^{-144}:\\
\;\;\;\;\frac{-1}{\frac{n}{\log x}}\\

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

\mathbf{elif}\;x \leq 1.4 \cdot 10^{-7}:\\
\;\;\;\;\frac{x}{n} - \frac{\log x}{n}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 6 regimes
  2. if x < 4.1000000000000004e-233

    1. Initial program 61.9%

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

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

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

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

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

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

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

    if 4.1000000000000004e-233 < x < 1.0500000000000001e-144

    1. Initial program 34.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 1.0500000000000001e-144 < x < 4.6999999999999999e-122

    1. Initial program 55.5%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{n \cdot x}} \]
    12. Simplified77.5%

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

    if 4.6999999999999999e-122 < x < 1.4000000000000001e-7

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{-\log x}{n}} + \frac{x}{n} \]
      3. log-rec56.2%

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

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

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

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

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

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

    if 1.4000000000000001e-7 < x < 9.50000000000000027e172

    1. Initial program 50.5%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in n around inf 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 65.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-neg65.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. mul-1-neg65.8%

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

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

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

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

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

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

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

    if 9.50000000000000027e172 < x

    1. Initial program 81.9%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 4.1 \cdot 10^{-233}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 1.05 \cdot 10^{-144}:\\ \;\;\;\;\frac{-1}{\frac{n}{\log x}}\\ \mathbf{elif}\;x \leq 4.7 \cdot 10^{-122}:\\ \;\;\;\;\frac{\frac{-0.5 + \frac{0.3333333333333333}{x}}{x} + 1}{x \cdot n}\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{-7}:\\ \;\;\;\;\frac{x}{n} - \frac{\log x}{n}\\ \mathbf{elif}\;x \leq 9.5 \cdot 10^{+172}:\\ \;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} - \frac{0.5}{n}}{x}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 59.8% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 6 \cdot 10^{-232}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 2.4 \cdot 10^{-144}:\\ \;\;\;\;\frac{-1}{\frac{n}{\log x}}\\ \mathbf{elif}\;x \leq 1.48 \cdot 10^{-120}:\\ \;\;\;\;\frac{\frac{-0.5 + \frac{0.3333333333333333}{x}}{x} + 1}{x \cdot n}\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{-7}:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{elif}\;x \leq 10^{+173}:\\ \;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} - \frac{0.5}{n}}{x}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= x 6e-232)
   (- 1.0 (pow x (/ 1.0 n)))
   (if (<= x 2.4e-144)
     (/ -1.0 (/ n (log x)))
     (if (<= x 1.48e-120)
       (/ (+ (/ (+ -0.5 (/ 0.3333333333333333 x)) x) 1.0) (* x n))
       (if (<= x 1.4e-7)
         (/ (- x (log x)) n)
         (if (<= x 1e+173)
           (/
            (+ (/ 1.0 n) (/ (- (/ 0.3333333333333333 (* x n)) (/ 0.5 n)) x))
            x)
           (/ 0.3333333333333333 (* n (pow x 3.0)))))))))
double code(double x, double n) {
	double tmp;
	if (x <= 6e-232) {
		tmp = 1.0 - pow(x, (1.0 / n));
	} else if (x <= 2.4e-144) {
		tmp = -1.0 / (n / log(x));
	} else if (x <= 1.48e-120) {
		tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n);
	} else if (x <= 1.4e-7) {
		tmp = (x - log(x)) / n;
	} else if (x <= 1e+173) {
		tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
	} else {
		tmp = 0.3333333333333333 / (n * pow(x, 3.0));
	}
	return tmp;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    real(8) :: tmp
    if (x <= 6d-232) then
        tmp = 1.0d0 - (x ** (1.0d0 / n))
    else if (x <= 2.4d-144) then
        tmp = (-1.0d0) / (n / log(x))
    else if (x <= 1.48d-120) then
        tmp = ((((-0.5d0) + (0.3333333333333333d0 / x)) / x) + 1.0d0) / (x * n)
    else if (x <= 1.4d-7) then
        tmp = (x - log(x)) / n
    else if (x <= 1d+173) then
        tmp = ((1.0d0 / n) + (((0.3333333333333333d0 / (x * n)) - (0.5d0 / n)) / x)) / x
    else
        tmp = 0.3333333333333333d0 / (n * (x ** 3.0d0))
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double tmp;
	if (x <= 6e-232) {
		tmp = 1.0 - Math.pow(x, (1.0 / n));
	} else if (x <= 2.4e-144) {
		tmp = -1.0 / (n / Math.log(x));
	} else if (x <= 1.48e-120) {
		tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n);
	} else if (x <= 1.4e-7) {
		tmp = (x - Math.log(x)) / n;
	} else if (x <= 1e+173) {
		tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
	} else {
		tmp = 0.3333333333333333 / (n * Math.pow(x, 3.0));
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if x <= 6e-232:
		tmp = 1.0 - math.pow(x, (1.0 / n))
	elif x <= 2.4e-144:
		tmp = -1.0 / (n / math.log(x))
	elif x <= 1.48e-120:
		tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n)
	elif x <= 1.4e-7:
		tmp = (x - math.log(x)) / n
	elif x <= 1e+173:
		tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x
	else:
		tmp = 0.3333333333333333 / (n * math.pow(x, 3.0))
	return tmp
function code(x, n)
	tmp = 0.0
	if (x <= 6e-232)
		tmp = Float64(1.0 - (x ^ Float64(1.0 / n)));
	elseif (x <= 2.4e-144)
		tmp = Float64(-1.0 / Float64(n / log(x)));
	elseif (x <= 1.48e-120)
		tmp = Float64(Float64(Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x) + 1.0) / Float64(x * n));
	elseif (x <= 1.4e-7)
		tmp = Float64(Float64(x - log(x)) / n);
	elseif (x <= 1e+173)
		tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(x * n)) - Float64(0.5 / n)) / x)) / x);
	else
		tmp = Float64(0.3333333333333333 / Float64(n * (x ^ 3.0)));
	end
	return tmp
end
function tmp_2 = code(x, n)
	tmp = 0.0;
	if (x <= 6e-232)
		tmp = 1.0 - (x ^ (1.0 / n));
	elseif (x <= 2.4e-144)
		tmp = -1.0 / (n / log(x));
	elseif (x <= 1.48e-120)
		tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n);
	elseif (x <= 1.4e-7)
		tmp = (x - log(x)) / n;
	elseif (x <= 1e+173)
		tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
	else
		tmp = 0.3333333333333333 / (n * (x ^ 3.0));
	end
	tmp_2 = tmp;
end
code[x_, n_] := If[LessEqual[x, 6e-232], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.4e-144], N[(-1.0 / N[(n / N[Log[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.48e-120], N[(N[(N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + 1.0), $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.4e-7], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 1e+173], 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], N[(0.3333333333333333 / N[(n * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq 2.4 \cdot 10^{-144}:\\
\;\;\;\;\frac{-1}{\frac{n}{\log x}}\\

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

\mathbf{elif}\;x \leq 1.4 \cdot 10^{-7}:\\
\;\;\;\;\frac{x - \log x}{n}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 6 regimes
  2. if x < 5.99999999999999979e-232

    1. Initial program 61.9%

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

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

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

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

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

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

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

    if 5.99999999999999979e-232 < x < 2.39999999999999994e-144

    1. Initial program 34.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.39999999999999994e-144 < x < 1.4800000000000001e-120

    1. Initial program 55.5%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{n \cdot x}} \]
    12. Simplified77.5%

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

    if 1.4800000000000001e-120 < x < 1.4000000000000001e-7

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

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

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

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

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

    if 1.4000000000000001e-7 < x < 1e173

    1. Initial program 50.5%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in n around inf 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 65.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-neg65.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. mul-1-neg65.8%

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

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

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

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

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

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

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

    if 1e173 < x

    1. Initial program 81.9%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 6 \cdot 10^{-232}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 2.4 \cdot 10^{-144}:\\ \;\;\;\;\frac{-1}{\frac{n}{\log x}}\\ \mathbf{elif}\;x \leq 1.48 \cdot 10^{-120}:\\ \;\;\;\;\frac{\frac{-0.5 + \frac{0.3333333333333333}{x}}{x} + 1}{x \cdot n}\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{-7}:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{elif}\;x \leq 10^{+173}:\\ \;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} - \frac{0.5}{n}}{x}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 59.8% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 1.05 \cdot 10^{-232}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 1.95 \cdot 10^{-144}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 4.2 \cdot 10^{-122}:\\ \;\;\;\;\frac{\frac{-0.5 + \frac{0.3333333333333333}{x}}{x} + 1}{x \cdot n}\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{-7}:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{elif}\;x \leq 8.6 \cdot 10^{+172}:\\ \;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} - \frac{0.5}{n}}{x}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= x 1.05e-232)
   (- 1.0 (pow x (/ 1.0 n)))
   (if (<= x 1.95e-144)
     (/ (log x) (- n))
     (if (<= x 4.2e-122)
       (/ (+ (/ (+ -0.5 (/ 0.3333333333333333 x)) x) 1.0) (* x n))
       (if (<= x 1.4e-7)
         (/ (- x (log x)) n)
         (if (<= x 8.6e+172)
           (/
            (+ (/ 1.0 n) (/ (- (/ 0.3333333333333333 (* x n)) (/ 0.5 n)) x))
            x)
           (/ 0.3333333333333333 (* n (pow x 3.0)))))))))
double code(double x, double n) {
	double tmp;
	if (x <= 1.05e-232) {
		tmp = 1.0 - pow(x, (1.0 / n));
	} else if (x <= 1.95e-144) {
		tmp = log(x) / -n;
	} else if (x <= 4.2e-122) {
		tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n);
	} else if (x <= 1.4e-7) {
		tmp = (x - log(x)) / n;
	} else if (x <= 8.6e+172) {
		tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
	} else {
		tmp = 0.3333333333333333 / (n * pow(x, 3.0));
	}
	return tmp;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    real(8) :: tmp
    if (x <= 1.05d-232) then
        tmp = 1.0d0 - (x ** (1.0d0 / n))
    else if (x <= 1.95d-144) then
        tmp = log(x) / -n
    else if (x <= 4.2d-122) then
        tmp = ((((-0.5d0) + (0.3333333333333333d0 / x)) / x) + 1.0d0) / (x * n)
    else if (x <= 1.4d-7) then
        tmp = (x - log(x)) / n
    else if (x <= 8.6d+172) then
        tmp = ((1.0d0 / n) + (((0.3333333333333333d0 / (x * n)) - (0.5d0 / n)) / x)) / x
    else
        tmp = 0.3333333333333333d0 / (n * (x ** 3.0d0))
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double tmp;
	if (x <= 1.05e-232) {
		tmp = 1.0 - Math.pow(x, (1.0 / n));
	} else if (x <= 1.95e-144) {
		tmp = Math.log(x) / -n;
	} else if (x <= 4.2e-122) {
		tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n);
	} else if (x <= 1.4e-7) {
		tmp = (x - Math.log(x)) / n;
	} else if (x <= 8.6e+172) {
		tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
	} else {
		tmp = 0.3333333333333333 / (n * Math.pow(x, 3.0));
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if x <= 1.05e-232:
		tmp = 1.0 - math.pow(x, (1.0 / n))
	elif x <= 1.95e-144:
		tmp = math.log(x) / -n
	elif x <= 4.2e-122:
		tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n)
	elif x <= 1.4e-7:
		tmp = (x - math.log(x)) / n
	elif x <= 8.6e+172:
		tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x
	else:
		tmp = 0.3333333333333333 / (n * math.pow(x, 3.0))
	return tmp
function code(x, n)
	tmp = 0.0
	if (x <= 1.05e-232)
		tmp = Float64(1.0 - (x ^ Float64(1.0 / n)));
	elseif (x <= 1.95e-144)
		tmp = Float64(log(x) / Float64(-n));
	elseif (x <= 4.2e-122)
		tmp = Float64(Float64(Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x) + 1.0) / Float64(x * n));
	elseif (x <= 1.4e-7)
		tmp = Float64(Float64(x - log(x)) / n);
	elseif (x <= 8.6e+172)
		tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(x * n)) - Float64(0.5 / n)) / x)) / x);
	else
		tmp = Float64(0.3333333333333333 / Float64(n * (x ^ 3.0)));
	end
	return tmp
end
function tmp_2 = code(x, n)
	tmp = 0.0;
	if (x <= 1.05e-232)
		tmp = 1.0 - (x ^ (1.0 / n));
	elseif (x <= 1.95e-144)
		tmp = log(x) / -n;
	elseif (x <= 4.2e-122)
		tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n);
	elseif (x <= 1.4e-7)
		tmp = (x - log(x)) / n;
	elseif (x <= 8.6e+172)
		tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
	else
		tmp = 0.3333333333333333 / (n * (x ^ 3.0));
	end
	tmp_2 = tmp;
end
code[x_, n_] := If[LessEqual[x, 1.05e-232], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.95e-144], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 4.2e-122], N[(N[(N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + 1.0), $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.4e-7], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 8.6e+172], 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], N[(0.3333333333333333 / N[(n * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq 1.95 \cdot 10^{-144}:\\
\;\;\;\;\frac{\log x}{-n}\\

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

\mathbf{elif}\;x \leq 1.4 \cdot 10^{-7}:\\
\;\;\;\;\frac{x - \log x}{n}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 6 regimes
  2. if x < 1.05e-232

    1. Initial program 61.9%

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

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

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

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

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

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

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

    if 1.05e-232 < x < 1.95000000000000007e-144

    1. Initial program 34.7%

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

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

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

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

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

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

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

    if 1.95000000000000007e-144 < x < 4.19999999999999985e-122

    1. Initial program 55.5%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{n \cdot x}} \]
    12. Simplified77.5%

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

    if 4.19999999999999985e-122 < x < 1.4000000000000001e-7

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

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

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

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

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

    if 1.4000000000000001e-7 < x < 8.6000000000000005e172

    1. Initial program 50.5%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Add Preprocessing
    3. Taylor expanded in n around inf 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 65.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-neg65.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. mul-1-neg65.8%

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

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

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

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

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

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

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

    if 8.6000000000000005e172 < x

    1. Initial program 81.9%

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.05 \cdot 10^{-232}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 1.95 \cdot 10^{-144}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 4.2 \cdot 10^{-122}:\\ \;\;\;\;\frac{\frac{-0.5 + \frac{0.3333333333333333}{x}}{x} + 1}{x \cdot n}\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{-7}:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{elif}\;x \leq 8.6 \cdot 10^{+172}:\\ \;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} - \frac{0.5}{n}}{x}}{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.3333333333333333}{n \cdot {x}^{3}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 81.5% accurate, 1.6× speedup?

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

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

\mathbf{elif}\;\frac{1}{n} \leq 0.0001:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x \cdot n} + \frac{-0.5}{n}}{x}}{x}\\


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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.0999999999999999e-78 < (/.f64 #s(literal 1 binary64) n) < 1.00000000000000005e-4

    1. Initial program 28.9%

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

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

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

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

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

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

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

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

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

    if 1.00000000000000005e-4 < (/.f64 #s(literal 1 binary64) n) < 5e163

    1. Initial program 74.9%

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

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

    if 5e163 < (/.f64 #s(literal 1 binary64) n)

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

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

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

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

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

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

      \[\leadsto \color{blue}{-\frac{\left(-\frac{\left(-\frac{\frac{0.25}{x \cdot n} - \frac{0.3333333333333333}{n}}{x}\right) - \frac{0.5}{n}}{x}\right) - \frac{1}{n}}{x}} \]
    9. Step-by-step derivation
      1. *-un-lft-identity0.2%

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

      \[\leadsto -\frac{\left(-\color{blue}{1 \cdot \frac{\frac{\frac{\frac{0.25}{x} - 0.3333333333333333}{n}}{x} + \frac{-0.5}{n}}{x}}\right) - \frac{1}{n}}{x} \]
    11. Step-by-step derivation
      1. *-lft-identity72.5%

        \[\leadsto -\frac{\left(-\color{blue}{\frac{\frac{\frac{\frac{0.25}{x} - 0.3333333333333333}{n}}{x} + \frac{-0.5}{n}}{x}}\right) - \frac{1}{n}}{x} \]
      2. associate-/l/72.5%

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

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

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

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

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

Alternative 10: 81.4% accurate, 1.7× speedup?

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

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

\mathbf{elif}\;\frac{1}{n} \leq 0.0001:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x \cdot n} + \frac{-0.5}{n}}{x}}{x}\\


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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.0999999999999999e-78 < (/.f64 #s(literal 1 binary64) n) < 1.00000000000000005e-4

    1. Initial program 28.9%

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

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

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

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

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

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

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

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

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

    if 1.00000000000000005e-4 < (/.f64 #s(literal 1 binary64) n) < 5e163

    1. Initial program 74.9%

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

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

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

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

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

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

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

    if 5e163 < (/.f64 #s(literal 1 binary64) n)

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

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

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

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

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

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

      \[\leadsto \color{blue}{-\frac{\left(-\frac{\left(-\frac{\frac{0.25}{x \cdot n} - \frac{0.3333333333333333}{n}}{x}\right) - \frac{0.5}{n}}{x}\right) - \frac{1}{n}}{x}} \]
    9. Step-by-step derivation
      1. *-un-lft-identity0.2%

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

      \[\leadsto -\frac{\left(-\color{blue}{1 \cdot \frac{\frac{\frac{\frac{0.25}{x} - 0.3333333333333333}{n}}{x} + \frac{-0.5}{n}}{x}}\right) - \frac{1}{n}}{x} \]
    11. Step-by-step derivation
      1. *-lft-identity72.5%

        \[\leadsto -\frac{\left(-\color{blue}{\frac{\frac{\frac{\frac{0.25}{x} - 0.3333333333333333}{n}}{x} + \frac{-0.5}{n}}{x}}\right) - \frac{1}{n}}{x} \]
      2. associate-/l/72.5%

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

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

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

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

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

Alternative 11: 56.4% accurate, 1.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 7.5 \cdot 10^{-233}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 1.65 \cdot 10^{-144}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 5.8 \cdot 10^{-122}:\\ \;\;\;\;\frac{\frac{-0.5 + \frac{0.3333333333333333}{x}}{x} + 1}{x \cdot n}\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{-7}:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} - \frac{0.5}{n}}{x}}{x}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= x 7.5e-233)
   (- 1.0 (pow x (/ 1.0 n)))
   (if (<= x 1.65e-144)
     (/ (log x) (- n))
     (if (<= x 5.8e-122)
       (/ (+ (/ (+ -0.5 (/ 0.3333333333333333 x)) x) 1.0) (* x n))
       (if (<= x 1.4e-7)
         (/ (- x (log x)) n)
         (/
          (+ (/ 1.0 n) (/ (- (/ 0.3333333333333333 (* x n)) (/ 0.5 n)) x))
          x))))))
double code(double x, double n) {
	double tmp;
	if (x <= 7.5e-233) {
		tmp = 1.0 - pow(x, (1.0 / n));
	} else if (x <= 1.65e-144) {
		tmp = log(x) / -n;
	} else if (x <= 5.8e-122) {
		tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n);
	} else if (x <= 1.4e-7) {
		tmp = (x - log(x)) / n;
	} else {
		tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
	}
	return tmp;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    real(8) :: tmp
    if (x <= 7.5d-233) then
        tmp = 1.0d0 - (x ** (1.0d0 / n))
    else if (x <= 1.65d-144) then
        tmp = log(x) / -n
    else if (x <= 5.8d-122) then
        tmp = ((((-0.5d0) + (0.3333333333333333d0 / x)) / x) + 1.0d0) / (x * n)
    else if (x <= 1.4d-7) then
        tmp = (x - log(x)) / n
    else
        tmp = ((1.0d0 / n) + (((0.3333333333333333d0 / (x * n)) - (0.5d0 / n)) / x)) / x
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double tmp;
	if (x <= 7.5e-233) {
		tmp = 1.0 - Math.pow(x, (1.0 / n));
	} else if (x <= 1.65e-144) {
		tmp = Math.log(x) / -n;
	} else if (x <= 5.8e-122) {
		tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n);
	} else if (x <= 1.4e-7) {
		tmp = (x - Math.log(x)) / n;
	} else {
		tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if x <= 7.5e-233:
		tmp = 1.0 - math.pow(x, (1.0 / n))
	elif x <= 1.65e-144:
		tmp = math.log(x) / -n
	elif x <= 5.8e-122:
		tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n)
	elif x <= 1.4e-7:
		tmp = (x - math.log(x)) / n
	else:
		tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x
	return tmp
function code(x, n)
	tmp = 0.0
	if (x <= 7.5e-233)
		tmp = Float64(1.0 - (x ^ Float64(1.0 / n)));
	elseif (x <= 1.65e-144)
		tmp = Float64(log(x) / Float64(-n));
	elseif (x <= 5.8e-122)
		tmp = Float64(Float64(Float64(Float64(-0.5 + Float64(0.3333333333333333 / x)) / x) + 1.0) / Float64(x * n));
	elseif (x <= 1.4e-7)
		tmp = Float64(Float64(x - log(x)) / n);
	else
		tmp = Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(0.3333333333333333 / Float64(x * n)) - Float64(0.5 / n)) / x)) / x);
	end
	return tmp
end
function tmp_2 = code(x, n)
	tmp = 0.0;
	if (x <= 7.5e-233)
		tmp = 1.0 - (x ^ (1.0 / n));
	elseif (x <= 1.65e-144)
		tmp = log(x) / -n;
	elseif (x <= 5.8e-122)
		tmp = (((-0.5 + (0.3333333333333333 / x)) / x) + 1.0) / (x * n);
	elseif (x <= 1.4e-7)
		tmp = (x - log(x)) / n;
	else
		tmp = ((1.0 / n) + (((0.3333333333333333 / (x * n)) - (0.5 / n)) / x)) / x;
	end
	tmp_2 = tmp;
end
code[x_, n_] := If[LessEqual[x, 7.5e-233], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.65e-144], N[(N[Log[x], $MachinePrecision] / (-n)), $MachinePrecision], If[LessEqual[x, 5.8e-122], N[(N[(N[(N[(-0.5 + N[(0.3333333333333333 / x), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + 1.0), $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.4e-7], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], 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}

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

\mathbf{elif}\;x \leq 1.65 \cdot 10^{-144}:\\
\;\;\;\;\frac{\log x}{-n}\\

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

\mathbf{elif}\;x \leq 1.4 \cdot 10^{-7}:\\
\;\;\;\;\frac{x - \log x}{n}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} - \frac{0.5}{n}}{x}}{x}\\


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

    1. Initial program 61.9%

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

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

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

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

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

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

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

    if 7.49999999999999974e-233 < x < 1.64999999999999998e-144

    1. Initial program 34.7%

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

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

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

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

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

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

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

    if 1.64999999999999998e-144 < x < 5.8000000000000005e-122

    1. Initial program 55.5%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{n \cdot x}} \]
    12. Simplified77.5%

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

    if 5.8000000000000005e-122 < x < 1.4000000000000001e-7

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

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

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

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

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

    if 1.4000000000000001e-7 < x

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

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

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

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

      \[\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-neg60.9%

        \[\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. mul-1-neg60.9%

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

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

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

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

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

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

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

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

Alternative 12: 56.6% accurate, 1.8× speedup?

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

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

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

\mathbf{elif}\;x \leq 1.4 \cdot 10^{-7}:\\
\;\;\;\;\frac{x - \log x}{n}\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} - \frac{0.5}{n}}{x}}{x}\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < 2.4999999999999999e-144

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

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

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

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

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

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

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

    if 2.4999999999999999e-144 < x < 2.0999999999999999e-121

    1. Initial program 55.5%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{n \cdot x}} \]
    12. Simplified77.5%

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

    if 2.0999999999999999e-121 < x < 1.4000000000000001e-7

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

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

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

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

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

    if 1.4000000000000001e-7 < x

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

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

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

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

      \[\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-neg60.9%

        \[\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. mul-1-neg60.9%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 2.5 \cdot 10^{-144}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 2.1 \cdot 10^{-121}:\\ \;\;\;\;\frac{\frac{-0.5 + \frac{0.3333333333333333}{x}}{x} + 1}{x \cdot n}\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{-7}:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} - \frac{0.5}{n}}{x}}{x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 56.5% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{\log x}{-n}\\
\mathbf{if}\;x \leq 2 \cdot 10^{-144}:\\
\;\;\;\;t\_0\\

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

\mathbf{elif}\;x \leq 1.4 \cdot 10^{-7}:\\
\;\;\;\;t\_0\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} - \frac{0.5}{n}}{x}}{x}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < 1.9999999999999999e-144 or 4.4999999999999998e-122 < x < 1.4000000000000001e-7

    1. Initial program 43.7%

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

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

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

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

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

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

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

    if 1.9999999999999999e-144 < x < 4.4999999999999998e-122

    1. Initial program 55.5%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{n \cdot x}} \]
    12. Simplified77.5%

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

    if 1.4000000000000001e-7 < x

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

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

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

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

      \[\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-neg60.9%

        \[\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. mul-1-neg60.9%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 2 \cdot 10^{-144}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{elif}\;x \leq 4.5 \cdot 10^{-122}:\\ \;\;\;\;\frac{\frac{-0.5 + \frac{0.3333333333333333}{x}}{x} + 1}{x \cdot n}\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{-7}:\\ \;\;\;\;\frac{\log x}{-n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{n} + \frac{\frac{0.3333333333333333}{x \cdot n} - \frac{0.5}{n}}{x}}{x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 80.8% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 7.2 \cdot 10^{-6}:\\
\;\;\;\;x \cdot \left(\frac{1}{n} - \frac{\log x}{x \cdot n}\right)\\

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


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

    1. Initial program 45.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 7.19999999999999967e-6 < x

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 15: 47.6% accurate, 10.0× speedup?

\[\begin{array}{l} \\ \frac{\frac{1}{n} + \frac{\frac{\frac{0.25}{x} + -0.3333333333333333}{x \cdot n} + \frac{-0.5}{n}}{x}}{x} \end{array} \]
(FPCore (x n)
 :precision binary64
 (/
  (+
   (/ 1.0 n)
   (/ (+ (/ (+ (/ 0.25 x) -0.3333333333333333) (* x n)) (/ -0.5 n)) x))
  x))
double code(double x, double n) {
	return ((1.0 / n) + (((((0.25 / x) + -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.25d0 / x) + (-0.3333333333333333d0)) / (x * n)) + ((-0.5d0) / n)) / x)) / x
end function
public static double code(double x, double n) {
	return ((1.0 / n) + (((((0.25 / x) + -0.3333333333333333) / (x * n)) + (-0.5 / n)) / x)) / x;
}
def code(x, n):
	return ((1.0 / n) + (((((0.25 / x) + -0.3333333333333333) / (x * n)) + (-0.5 / n)) / x)) / x
function code(x, n)
	return Float64(Float64(Float64(1.0 / n) + Float64(Float64(Float64(Float64(Float64(0.25 / x) + -0.3333333333333333) / Float64(x * n)) + Float64(-0.5 / n)) / x)) / x)
end
function tmp = code(x, n)
	tmp = ((1.0 / n) + (((((0.25 / x) + -0.3333333333333333) / (x * n)) + (-0.5 / n)) / x)) / x;
end
code[x_, n_] := N[(N[(N[(1.0 / n), $MachinePrecision] + N[(N[(N[(N[(N[(0.25 / x), $MachinePrecision] + -0.3333333333333333), $MachinePrecision] / 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{\frac{0.25}{x} + -0.3333333333333333}{x \cdot n} + \frac{-0.5}{n}}{x}}{x}
\end{array}
Derivation
  1. Initial program 53.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 54.9%

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

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

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

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

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

    \[\leadsto \color{blue}{-\frac{\left(-\frac{\left(-\frac{\frac{0.25}{x \cdot n} - \frac{0.3333333333333333}{n}}{x}\right) - \frac{0.5}{n}}{x}\right) - \frac{1}{n}}{x}} \]
  9. Step-by-step derivation
    1. *-un-lft-identity29.1%

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

    \[\leadsto -\frac{\left(-\color{blue}{1 \cdot \frac{\frac{\frac{\frac{0.25}{x} - 0.3333333333333333}{n}}{x} + \frac{-0.5}{n}}{x}}\right) - \frac{1}{n}}{x} \]
  11. Step-by-step derivation
    1. *-lft-identity49.1%

      \[\leadsto -\frac{\left(-\color{blue}{\frac{\frac{\frac{\frac{0.25}{x} - 0.3333333333333333}{n}}{x} + \frac{-0.5}{n}}{x}}\right) - \frac{1}{n}}{x} \]
    2. associate-/l/49.1%

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

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

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

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

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

Alternative 16: 46.9% 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 53.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 54.9%

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

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

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

    \[\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-neg49.0%

      \[\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. mul-1-neg49.0%

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

      \[\leadsto -\frac{\left(-\frac{\color{blue}{\frac{0.3333333333333333 \cdot 1}{n \cdot x}} - 0.5 \cdot \frac{1}{n}}{x}\right) - \frac{1}{n}}{x} \]
    4. metadata-eval49.0%

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

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

      \[\leadsto -\frac{\left(-\frac{\frac{0.3333333333333333}{x \cdot n} - \color{blue}{\frac{0.5 \cdot 1}{n}}}{x}\right) - \frac{1}{n}}{x} \]
    7. metadata-eval49.0%

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

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

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

Alternative 17: 46.9% 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 53.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 54.9%

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

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

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

      \[\leadsto \frac{\color{blue}{\sqrt{\mathsf{log1p}\left(x\right) - \log x} \cdot \sqrt{\mathsf{log1p}\left(x\right) - \log x}}}{n} \]
    2. pow254.7%

      \[\leadsto \frac{\color{blue}{{\left(\sqrt{\mathsf{log1p}\left(x\right) - \log x}\right)}^{2}}}{n} \]
  7. Applied egg-rr54.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 18: 46.4% accurate, 16.2× speedup?

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{\frac{n}{\mathsf{log1p}\left(x\right) - \log x}}} \]
    2. inv-pow54.8%

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

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

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

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

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

    \[\leadsto \color{blue}{-1 \cdot \frac{-1 \cdot \frac{0.3333333333333333 \cdot \frac{1}{x} - 0.5}{x} - 1}{n \cdot x}} \]
  12. Simplified48.7%

    \[\leadsto \color{blue}{\frac{1 + \frac{-0.5 + \frac{0.3333333333333333}{x}}{x}}{x \cdot n}} \]
  13. Final simplification48.7%

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

Alternative 19: 40.7% 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 53.8%

    \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
  2. Add Preprocessing
  3. Taylor expanded in x around inf 62.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. associate-/r*62.5%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 20: 40.1% accurate, 42.2× speedup?

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

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

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

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

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

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

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

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

Alternative 21: 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 53.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 54.9%

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

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

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

      \[\leadsto \color{blue}{\frac{1}{\frac{n}{\mathsf{log1p}\left(x\right) - \log x}}} \]
    2. inv-pow54.8%

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

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

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

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

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

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

Reproduce

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