2nthrt (problem 3.4.6)

Percentage Accurate: 52.8% → 85.5%
Time: 16.1s
Alternatives: 10
Speedup: 2.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 10 alternatives:

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

Initial Program: 52.8% accurate, 1.0× speedup?

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

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

Alternative 1: 85.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{if}\;\frac{1}{n} \leq -1.85 \cdot 10^{-30}:\\ \;\;\;\;\frac{t_0}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 500000:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{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.85e-30)
     (/ t_0 (* n x))
     (if (<= (/ 1.0 n) 500000.0)
       (/ (log (/ (+ 1.0 x) 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.85e-30) {
		tmp = t_0 / (n * x);
	} else if ((1.0 / n) <= 500000.0) {
		tmp = log(((1.0 + x) / 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.85d-30)) then
        tmp = t_0 / (n * x)
    else if ((1.0d0 / n) <= 500000.0d0) then
        tmp = log(((1.0d0 + x) / 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.85e-30) {
		tmp = t_0 / (n * x);
	} else if ((1.0 / n) <= 500000.0) {
		tmp = Math.log(((1.0 + x) / 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.85e-30:
		tmp = t_0 / (n * x)
	elif (1.0 / n) <= 500000.0:
		tmp = math.log(((1.0 + x) / 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.85e-30)
		tmp = Float64(t_0 / Float64(n * x));
	elseif (Float64(1.0 / n) <= 500000.0)
		tmp = Float64(log(Float64(Float64(1.0 + x) / 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.85e-30)
		tmp = t_0 / (n * x);
	elseif ((1.0 / n) <= 500000.0)
		tmp = log(((1.0 + x) / 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.85e-30], N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 500000.0], N[(N[Log[N[(N[(1.0 + x), $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.85 \cdot 10^{-30}:\\
\;\;\;\;\frac{t_0}{n \cdot x}\\

\mathbf{elif}\;\frac{1}{n} \leq 500000:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{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 1 n) < -1.8500000000000002e-30

    1. Initial program 96.8%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    5. Step-by-step derivation
      1. expm1-log1p-u49.8%

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

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

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

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

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

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

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

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

    if -1.8500000000000002e-30 < (/.f64 1 n) < 5e5

    1. Initial program 23.3%

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

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

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

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

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

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

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

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

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

    if 5e5 < (/.f64 1 n)

    1. Initial program 70.1%

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

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

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

      \[\leadsto \color{blue}{e^{\frac{\mathsf{log1p}\left(x\right)}{n}}} - {x}^{\left(\frac{1}{n}\right)} \]
    5. 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. Final simplification88.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -1.85 \cdot 10^{-30}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 500000:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{else}:\\ \;\;\;\;e^{\frac{x}{n}} - {x}^{\left(\frac{1}{n}\right)}\\ \end{array} \]

Alternative 2: 65.0% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{+136} \lor \neg \left(\frac{1}{n} \leq -2 \cdot 10^{+60}\right) \land \frac{1}{n} \leq 500000:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{else}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (or (<= (/ 1.0 n) -1e+136)
         (and (not (<= (/ 1.0 n) -2e+60)) (<= (/ 1.0 n) 500000.0)))
   (/ (log (/ (+ 1.0 x) x)) n)
   (- 1.0 (pow x (/ 1.0 n)))))
double code(double x, double n) {
	double tmp;
	if (((1.0 / n) <= -1e+136) || (!((1.0 / n) <= -2e+60) && ((1.0 / n) <= 500000.0))) {
		tmp = log(((1.0 + x) / x)) / n;
	} else {
		tmp = 1.0 - pow(x, (1.0 / n));
	}
	return tmp;
}
real(8) function code(x, n)
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    real(8) :: tmp
    if (((1.0d0 / n) <= (-1d+136)) .or. (.not. ((1.0d0 / n) <= (-2d+60))) .and. ((1.0d0 / n) <= 500000.0d0)) then
        tmp = log(((1.0d0 + x) / x)) / n
    else
        tmp = 1.0d0 - (x ** (1.0d0 / n))
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double tmp;
	if (((1.0 / n) <= -1e+136) || (!((1.0 / n) <= -2e+60) && ((1.0 / n) <= 500000.0))) {
		tmp = Math.log(((1.0 + x) / x)) / n;
	} else {
		tmp = 1.0 - Math.pow(x, (1.0 / n));
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if ((1.0 / n) <= -1e+136) or (not ((1.0 / n) <= -2e+60) and ((1.0 / n) <= 500000.0)):
		tmp = math.log(((1.0 + x) / x)) / n
	else:
		tmp = 1.0 - math.pow(x, (1.0 / n))
	return tmp
function code(x, n)
	tmp = 0.0
	if ((Float64(1.0 / n) <= -1e+136) || (!(Float64(1.0 / n) <= -2e+60) && (Float64(1.0 / n) <= 500000.0)))
		tmp = Float64(log(Float64(Float64(1.0 + x) / x)) / n);
	else
		tmp = Float64(1.0 - (x ^ Float64(1.0 / n)));
	end
	return tmp
end
function tmp_2 = code(x, n)
	tmp = 0.0;
	if (((1.0 / n) <= -1e+136) || (~(((1.0 / n) <= -2e+60)) && ((1.0 / n) <= 500000.0)))
		tmp = log(((1.0 + x) / x)) / n;
	else
		tmp = 1.0 - (x ^ (1.0 / n));
	end
	tmp_2 = tmp;
end
code[x_, n_] := If[Or[LessEqual[N[(1.0 / n), $MachinePrecision], -1e+136], And[N[Not[LessEqual[N[(1.0 / n), $MachinePrecision], -2e+60]], $MachinePrecision], LessEqual[N[(1.0 / n), $MachinePrecision], 500000.0]]], N[(N[Log[N[(N[(1.0 + x), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(1.0 - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{+136} \lor \neg \left(\frac{1}{n} \leq -2 \cdot 10^{+60}\right) \land \frac{1}{n} \leq 500000:\\
\;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 1 n) < -1.00000000000000006e136 or -1.9999999999999999e60 < (/.f64 1 n) < 5e5

    1. Initial program 47.8%

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

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

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

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

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

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

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

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

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

    if -1.00000000000000006e136 < (/.f64 1 n) < -1.9999999999999999e60 or 5e5 < (/.f64 1 n)

    1. Initial program 83.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -1 \cdot 10^{+136} \lor \neg \left(\frac{1}{n} \leq -2 \cdot 10^{+60}\right) \land \frac{1}{n} \leq 500000:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{else}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \end{array} \]

Alternative 3: 78.9% accurate, 1.8× speedup?

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

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

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

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


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

    1. Initial program 96.8%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    5. Step-by-step derivation
      1. expm1-log1p-u49.8%

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

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

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

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

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

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

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

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

    if -1.8500000000000002e-30 < (/.f64 1 n) < 5e5

    1. Initial program 23.3%

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

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

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

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

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

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

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

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

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

    if 5e5 < (/.f64 1 n)

    1. Initial program 70.1%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -1.85 \cdot 10^{-30}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 500000:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{else}:\\ \;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\ \end{array} \]

Alternative 4: 78.6% accurate, 1.8× speedup?

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

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

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


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

    1. Initial program 96.8%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]
    5. Step-by-step derivation
      1. expm1-log1p-u49.8%

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

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

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

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

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

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

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

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

    if -1.8500000000000002e-30 < (/.f64 1 n) < 5e5

    1. Initial program 23.3%

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

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

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

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

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

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

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

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

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

    if 5e5 < (/.f64 1 n)

    1. Initial program 70.1%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -1.85 \cdot 10^{-30}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 500000:\\ \;\;\;\;\frac{\log \left(\frac{1 + x}{x}\right)}{n}\\ \mathbf{else}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \end{array} \]

Alternative 5: 50.5% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;n \leq -3500000000:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{x - \log x}{n}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if n < -3.5e9

    1. Initial program 26.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{\frac{1}{x}}{n}} \]
    7. Simplified53.0%

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

    if -3.5e9 < n < 2.3999999999999999e-6

    1. Initial program 91.6%

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

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

    if 2.3999999999999999e-6 < n

    1. Initial program 20.9%

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{x - \log x}{n}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification56.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -3500000000:\\ \;\;\;\;\frac{\frac{1}{x}}{n}\\ \mathbf{elif}\;n \leq 2.4 \cdot 10^{-6}:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{x - \log x}{n}\\ \end{array} \]

Alternative 6: 57.9% accurate, 2.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.98:\\
\;\;\;\;\frac{x - \log x}{n}\\

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


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

    1. Initial program 49.2%

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

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

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

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

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

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

    if 0.97999999999999998 < x

    1. Initial program 67.9%

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{1}{x} - 0.5 \cdot \frac{1}{{x}^{2}}}}{n} \]
    6. Step-by-step derivation
      1. unpow256.4%

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

        \[\leadsto \frac{\frac{1}{x} - \color{blue}{\frac{0.5 \cdot 1}{x \cdot x}}}{n} \]
      3. metadata-eval56.4%

        \[\leadsto \frac{\frac{1}{x} - \frac{\color{blue}{0.5}}{x \cdot x}}{n} \]
    7. Simplified56.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 0.98:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\ \end{array} \]

Alternative 7: 57.7% accurate, 2.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.68:\\
\;\;\;\;\frac{-\log x}{n}\\

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


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

    1. Initial program 49.2%

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

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

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

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

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

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

    if 0.680000000000000049 < x

    1. Initial program 67.9%

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{1}{x} - 0.5 \cdot \frac{1}{{x}^{2}}}}{n} \]
    6. Step-by-step derivation
      1. unpow256.4%

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

        \[\leadsto \frac{\frac{1}{x} - \color{blue}{\frac{0.5 \cdot 1}{x \cdot x}}}{n} \]
      3. metadata-eval56.4%

        \[\leadsto \frac{\frac{1}{x} - \frac{\color{blue}{0.5}}{x \cdot x}}{n} \]
    7. Simplified56.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 0.68:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x} - \frac{0.5}{x \cdot x}}{n}\\ \end{array} \]

Alternative 8: 40.2% accurate, 42.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 9: 40.8% accurate, 42.2× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{1}{x}}{n}} \]
  7. Simplified35.5%

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

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

Alternative 10: 4.6% accurate, 70.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{x}{n} + \left(0.5 \cdot \frac{{x}^{2}}{{n}^{2}} + -0.5 \cdot \frac{{x}^{2}}{n}\right)} \]
  6. Step-by-step derivation
    1. fma-def5.1%

      \[\leadsto \frac{x}{n} + \color{blue}{\mathsf{fma}\left(0.5, \frac{{x}^{2}}{{n}^{2}}, -0.5 \cdot \frac{{x}^{2}}{n}\right)} \]
    2. unpow25.1%

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

      \[\leadsto \frac{x}{n} + \mathsf{fma}\left(0.5, \frac{x \cdot x}{\color{blue}{n \cdot n}}, -0.5 \cdot \frac{{x}^{2}}{n}\right) \]
    4. times-frac4.4%

      \[\leadsto \frac{x}{n} + \mathsf{fma}\left(0.5, \color{blue}{\frac{x}{n} \cdot \frac{x}{n}}, -0.5 \cdot \frac{{x}^{2}}{n}\right) \]
    5. unpow24.4%

      \[\leadsto \frac{x}{n} + \mathsf{fma}\left(0.5, \frac{x}{n} \cdot \frac{x}{n}, -0.5 \cdot \frac{\color{blue}{x \cdot x}}{n}\right) \]
  7. Simplified4.4%

    \[\leadsto \color{blue}{\frac{x}{n} + \mathsf{fma}\left(0.5, \frac{x}{n} \cdot \frac{x}{n}, -0.5 \cdot \frac{x \cdot x}{n}\right)} \]
  8. Taylor expanded in x around 0 4.6%

    \[\leadsto \color{blue}{\frac{x}{n}} \]
  9. Final simplification4.6%

    \[\leadsto \frac{x}{n} \]

Reproduce

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