2nthrt (problem 3.4.6)

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

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

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

Alternative 1: 98.8% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 0.056:\\ \;\;\;\;\sqrt[3]{{\left(e^{3}\right)}^{\left(\frac{\mathsf{log1p}\left(x\right)}{n}\right)}} - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{e^{2 \cdot \log \left({x}^{\left(\frac{\frac{1}{n}}{2}\right)}\right)}}{x \cdot n}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= x 0.056)
   (- (cbrt (pow (exp 3.0) (/ (log1p x) n))) (pow x (/ 1.0 n)))
   (/ (exp (* 2.0 (log (pow x (/ (/ 1.0 n) 2.0))))) (* x n))))
double code(double x, double n) {
	double tmp;
	if (x <= 0.056) {
		tmp = cbrt(pow(exp(3.0), (log1p(x) / n))) - pow(x, (1.0 / n));
	} else {
		tmp = exp((2.0 * log(pow(x, ((1.0 / n) / 2.0))))) / (x * n);
	}
	return tmp;
}
public static double code(double x, double n) {
	double tmp;
	if (x <= 0.056) {
		tmp = Math.cbrt(Math.pow(Math.exp(3.0), (Math.log1p(x) / n))) - Math.pow(x, (1.0 / n));
	} else {
		tmp = Math.exp((2.0 * Math.log(Math.pow(x, ((1.0 / n) / 2.0))))) / (x * n);
	}
	return tmp;
}
function code(x, n)
	tmp = 0.0
	if (x <= 0.056)
		tmp = Float64(cbrt((exp(3.0) ^ Float64(log1p(x) / n))) - (x ^ Float64(1.0 / n)));
	else
		tmp = Float64(exp(Float64(2.0 * log((x ^ Float64(Float64(1.0 / n) / 2.0))))) / Float64(x * n));
	end
	return tmp
end
code[x_, n_] := If[LessEqual[x, 0.056], N[(N[Power[N[Power[N[Exp[3.0], $MachinePrecision], N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Exp[N[(2.0 * N[Log[N[Power[x, N[(N[(1.0 / n), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.056:\\
\;\;\;\;\sqrt[3]{{\left(e^{3}\right)}^{\left(\frac{\mathsf{log1p}\left(x\right)}{n}\right)}} - {x}^{\left(\frac{1}{n}\right)}\\

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


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

    1. Initial program 78.6%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Step-by-step derivation
      1. add-cbrt-cube78.6%

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

        \[\leadsto \sqrt[3]{\color{blue}{{\left({\left(x + 1\right)}^{\left(\frac{1}{n}\right)}\right)}^{3}}} - {x}^{\left(\frac{1}{n}\right)} \]
      3. pow-to-exp78.6%

        \[\leadsto \sqrt[3]{{\color{blue}{\left(e^{\log \left(x + 1\right) \cdot \frac{1}{n}}\right)}}^{3}} - {x}^{\left(\frac{1}{n}\right)} \]
      4. pow-exp78.6%

        \[\leadsto \sqrt[3]{\color{blue}{e^{\left(\log \left(x + 1\right) \cdot \frac{1}{n}\right) \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
      5. un-div-inv78.6%

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

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

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

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

      \[\leadsto \sqrt[3]{\color{blue}{e^{3 \cdot \frac{\mathsf{log1p}\left(x\right)}{n}}}} - {x}^{\left(\frac{1}{n}\right)} \]
    5. Step-by-step derivation
      1. exp-prod98.9%

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

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

    if 0.0560000000000000012 < x

    1. Initial program 6.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 0.056:\\ \;\;\;\;\sqrt[3]{{\left(e^{3}\right)}^{\left(\frac{\mathsf{log1p}\left(x\right)}{n}\right)}} - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{e^{2 \cdot \log \left({x}^{\left(\frac{\frac{1}{n}}{2}\right)}\right)}}{x \cdot n}\\ \end{array} \]

Alternative 2: 98.8% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.056:\\
\;\;\;\;\sqrt[3]{e^{3 \cdot \frac{x}{n}}} - {x}^{\left(\frac{1}{n}\right)}\\

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


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

    1. Initial program 78.6%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Step-by-step derivation
      1. add-cbrt-cube78.6%

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

        \[\leadsto \sqrt[3]{\color{blue}{{\left({\left(x + 1\right)}^{\left(\frac{1}{n}\right)}\right)}^{3}}} - {x}^{\left(\frac{1}{n}\right)} \]
      3. pow-to-exp78.6%

        \[\leadsto \sqrt[3]{{\color{blue}{\left(e^{\log \left(x + 1\right) \cdot \frac{1}{n}}\right)}}^{3}} - {x}^{\left(\frac{1}{n}\right)} \]
      4. pow-exp78.6%

        \[\leadsto \sqrt[3]{\color{blue}{e^{\left(\log \left(x + 1\right) \cdot \frac{1}{n}\right) \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
      5. un-div-inv78.6%

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

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

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

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

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

    if 0.0560000000000000012 < x

    1. Initial program 6.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 0.056:\\ \;\;\;\;\sqrt[3]{e^{3 \cdot \frac{x}{n}}} - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{e^{2 \cdot \log \left({x}^{\left(\frac{\frac{1}{n}}{2}\right)}\right)}}{x \cdot n}\\ \end{array} \]

Alternative 3: 98.8% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{if}\;x \leq 0.056:\\ \;\;\;\;\sqrt[3]{e^{3 \cdot \frac{x}{n}}} - t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{t_0}{x \cdot n}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (pow x (/ 1.0 n))))
   (if (<= x 0.056) (- (cbrt (exp (* 3.0 (/ x n)))) t_0) (/ t_0 (* x n)))))
double code(double x, double n) {
	double t_0 = pow(x, (1.0 / n));
	double tmp;
	if (x <= 0.056) {
		tmp = cbrt(exp((3.0 * (x / n)))) - t_0;
	} else {
		tmp = t_0 / (x * n);
	}
	return tmp;
}
public static double code(double x, double n) {
	double t_0 = Math.pow(x, (1.0 / n));
	double tmp;
	if (x <= 0.056) {
		tmp = Math.cbrt(Math.exp((3.0 * (x / n)))) - t_0;
	} else {
		tmp = t_0 / (x * n);
	}
	return tmp;
}
function code(x, n)
	t_0 = x ^ Float64(1.0 / n)
	tmp = 0.0
	if (x <= 0.056)
		tmp = Float64(cbrt(exp(Float64(3.0 * Float64(x / n)))) - t_0);
	else
		tmp = Float64(t_0 / Float64(x * n));
	end
	return tmp
end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 0.056], N[(N[Power[N[Exp[N[(3.0 * N[(x / n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 1/3], $MachinePrecision] - t$95$0), $MachinePrecision], N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 0.056:\\
\;\;\;\;\sqrt[3]{e^{3 \cdot \frac{x}{n}}} - t_0\\

\mathbf{else}:\\
\;\;\;\;\frac{t_0}{x \cdot n}\\


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

    1. Initial program 78.6%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Step-by-step derivation
      1. add-cbrt-cube78.6%

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

        \[\leadsto \sqrt[3]{\color{blue}{{\left({\left(x + 1\right)}^{\left(\frac{1}{n}\right)}\right)}^{3}}} - {x}^{\left(\frac{1}{n}\right)} \]
      3. pow-to-exp78.6%

        \[\leadsto \sqrt[3]{{\color{blue}{\left(e^{\log \left(x + 1\right) \cdot \frac{1}{n}}\right)}}^{3}} - {x}^{\left(\frac{1}{n}\right)} \]
      4. pow-exp78.6%

        \[\leadsto \sqrt[3]{\color{blue}{e^{\left(\log \left(x + 1\right) \cdot \frac{1}{n}\right) \cdot 3}}} - {x}^{\left(\frac{1}{n}\right)} \]
      5. un-div-inv78.6%

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

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

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

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

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

    if 0.0560000000000000012 < x

    1. Initial program 6.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 0.056:\\ \;\;\;\;\sqrt[3]{e^{3 \cdot \frac{x}{n}}} - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{x \cdot n}\\ \end{array} \]

Alternative 4: 98.9% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
t_0 := {x}^{\left(\frac{1}{n}\right)}\\
\mathbf{if}\;x \leq 0.056:\\
\;\;\;\;e^{\frac{x}{n}} - t_0\\

\mathbf{else}:\\
\;\;\;\;\frac{t_0}{x \cdot n}\\


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

    1. Initial program 78.6%

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

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

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

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

    if 0.0560000000000000012 < x

    1. Initial program 6.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 0.056:\\ \;\;\;\;e^{\frac{x}{n}} - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{x \cdot n}\\ \end{array} \]

Alternative 5: 90.3% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;x \leq 0.056:\\
\;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{x \cdot n}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{t_0}{x \cdot n}\\


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

    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 91.9%

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

    if 1.49999999999999992e-141 < x < 0.0560000000000000012

    1. Initial program 60.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 0.0560000000000000012 < x

    1. Initial program 6.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.5 \cdot 10^{-141}:\\ \;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 0.056:\\ \;\;\;\;\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{x \cdot n}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{x \cdot n}\\ \end{array} \]

Alternative 6: 87.9% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\frac{1}{n}}{x}\\ t_1 := {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{if}\;x \leq 7 \cdot 10^{-142}:\\ \;\;\;\;\left(1 + \frac{x}{n}\right) - t_1\\ \mathbf{elif}\;x \leq 1.2 \cdot 10^{-5}:\\ \;\;\;\;\sqrt[3]{t_0 \cdot \frac{t_0}{x \cdot n}}\\ \mathbf{else}:\\ \;\;\;\;\frac{t_1}{x \cdot n}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (/ (/ 1.0 n) x)) (t_1 (pow x (/ 1.0 n))))
   (if (<= x 7e-142)
     (- (+ 1.0 (/ x n)) t_1)
     (if (<= x 1.2e-5) (cbrt (* t_0 (/ t_0 (* x n)))) (/ t_1 (* x n))))))
double code(double x, double n) {
	double t_0 = (1.0 / n) / x;
	double t_1 = pow(x, (1.0 / n));
	double tmp;
	if (x <= 7e-142) {
		tmp = (1.0 + (x / n)) - t_1;
	} else if (x <= 1.2e-5) {
		tmp = cbrt((t_0 * (t_0 / (x * n))));
	} else {
		tmp = t_1 / (x * n);
	}
	return tmp;
}
public static double code(double x, double n) {
	double t_0 = (1.0 / n) / x;
	double t_1 = Math.pow(x, (1.0 / n));
	double tmp;
	if (x <= 7e-142) {
		tmp = (1.0 + (x / n)) - t_1;
	} else if (x <= 1.2e-5) {
		tmp = Math.cbrt((t_0 * (t_0 / (x * n))));
	} else {
		tmp = t_1 / (x * n);
	}
	return tmp;
}
function code(x, n)
	t_0 = Float64(Float64(1.0 / n) / x)
	t_1 = x ^ Float64(1.0 / n)
	tmp = 0.0
	if (x <= 7e-142)
		tmp = Float64(Float64(1.0 + Float64(x / n)) - t_1);
	elseif (x <= 1.2e-5)
		tmp = cbrt(Float64(t_0 * Float64(t_0 / Float64(x * n))));
	else
		tmp = Float64(t_1 / Float64(x * n));
	end
	return tmp
end
code[x_, n_] := Block[{t$95$0 = N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]}, Block[{t$95$1 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 7e-142], N[(N[(1.0 + N[(x / n), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision], If[LessEqual[x, 1.2e-5], N[Power[N[(t$95$0 * N[(t$95$0 / N[(x * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], N[(t$95$1 / N[(x * n), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq 1.2 \cdot 10^{-5}:\\
\;\;\;\;\sqrt[3]{t_0 \cdot \frac{t_0}{x \cdot n}}\\

\mathbf{else}:\\
\;\;\;\;\frac{t_1}{x \cdot n}\\


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

    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 91.9%

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

    if 7.00000000000000029e-142 < x < 1.2e-5

    1. Initial program 58.1%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Taylor expanded in n around 0 58.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-def99.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{x \cdot n}} \]
    11. Step-by-step derivation
      1. add-cbrt-cube85.0%

        \[\leadsto \color{blue}{\sqrt[3]{\left(\frac{1}{x \cdot n} \cdot \frac{1}{x \cdot n}\right) \cdot \frac{1}{x \cdot n}}} \]
    12. Applied egg-rr85.0%

      \[\leadsto \color{blue}{\sqrt[3]{\left(\frac{1}{x \cdot n} \cdot \frac{1}{x \cdot n}\right) \cdot \frac{1}{x \cdot n}}} \]
    13. Step-by-step derivation
      1. associate-*l*85.0%

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

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

        \[\leadsto \sqrt[3]{\color{blue}{\frac{\frac{1}{n}}{x}} \cdot \left(\frac{1}{x \cdot n} \cdot \frac{1}{x \cdot n}\right)} \]
      4. associate-*l/85.0%

        \[\leadsto \sqrt[3]{\frac{\frac{1}{n}}{x} \cdot \color{blue}{\frac{1 \cdot \frac{1}{x \cdot n}}{x \cdot n}}} \]
      5. *-lft-identity85.0%

        \[\leadsto \sqrt[3]{\frac{\frac{1}{n}}{x} \cdot \frac{\color{blue}{\frac{1}{x \cdot n}}}{x \cdot n}} \]
      6. *-commutative85.0%

        \[\leadsto \sqrt[3]{\frac{\frac{1}{n}}{x} \cdot \frac{\frac{1}{\color{blue}{n \cdot x}}}{x \cdot n}} \]
      7. associate-/r*85.0%

        \[\leadsto \sqrt[3]{\frac{\frac{1}{n}}{x} \cdot \frac{\color{blue}{\frac{\frac{1}{n}}{x}}}{x \cdot n}} \]
    14. Simplified85.0%

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

    if 1.2e-5 < x

    1. Initial program 10.5%

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

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

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

      \[\leadsto \color{blue}{e^{\frac{\mathsf{log1p}\left(x\right)}{n}}} - {x}^{\left(\frac{1}{n}\right)} \]
    5. 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}} \]
    6. Step-by-step derivation
      1. mul-1-neg98.8%

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 7 \cdot 10^{-142}:\\ \;\;\;\;\left(1 + \frac{x}{n}\right) - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{elif}\;x \leq 1.2 \cdot 10^{-5}:\\ \;\;\;\;\sqrt[3]{\frac{\frac{1}{n}}{x} \cdot \frac{\frac{\frac{1}{n}}{x}}{x \cdot n}}\\ \mathbf{else}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{x \cdot n}\\ \end{array} \]

Alternative 7: 83.4% accurate, 1.9× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{t_0}{x \cdot n}\\


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

    1. Initial program 78.6%

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

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

    if 0.0560000000000000012 < x

    1. Initial program 6.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 83.0% accurate, 1.9× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{t_0}{x \cdot n}\\


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

    1. Initial program 78.6%

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

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

    if 0.0560000000000000012 < x

    1. Initial program 6.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 0.056:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{{x}^{\left(\frac{1}{n}\right)}}{x \cdot n}\\ \end{array} \]

Alternative 9: 65.5% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 1:\\ \;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{x - \log x}{n}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= x 1.0) (- 1.0 (pow x (/ 1.0 n))) (/ (- x (log x)) n)))
double code(double x, double n) {
	double tmp;
	if (x <= 1.0) {
		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 (x <= 1.0d0) 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 (x <= 1.0) {
		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 x <= 1.0:
		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 (x <= 1.0)
		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 (x <= 1.0)
		tmp = 1.0 - (x ^ (1.0 / n));
	else
		tmp = (x - log(x)) / n;
	end
	tmp_2 = tmp;
end
code[x_, n_] := If[LessEqual[x, 1.0], 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}\;x \leq 1:\\
\;\;\;\;1 - {x}^{\left(\frac{1}{n}\right)}\\

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


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

    1. Initial program 79.0%

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

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

    if 1 < x

    1. Initial program 3.6%

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

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

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

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

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

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

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

Alternative 10: 42.9% accurate, 2.0× speedup?

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

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

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


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

    1. Initial program 74.5%

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

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

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

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

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

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

        \[\leadsto \frac{e^{-\frac{\color{blue}{-\log x}}{n}}}{n \cdot x} \]
      3. distribute-frac-neg54.9%

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{n \cdot x}} \]
    9. Step-by-step derivation
      1. *-commutative36.3%

        \[\leadsto \frac{1}{\color{blue}{x \cdot n}} \]
    10. Simplified36.3%

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

    if 4.2000000000000003e23 < x

    1. Initial program 0.3%

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 4.2 \cdot 10^{+23}:\\ \;\;\;\;\frac{1}{x \cdot n}\\ \mathbf{else}:\\ \;\;\;\;\frac{x - \log x}{n}\\ \end{array} \]

Alternative 11: 28.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 52.2%

    \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
  2. Taylor expanded in n around 0 52.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-def65.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Reproduce

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