2nthrt (problem 3.4.6)

Percentage Accurate: 53.8% → 86.7%
Time: 45.4s
Alternatives: 14
Speedup: 1.9×

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));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, n)
use fmin_fmax_functions
    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 14 alternatives:

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

Initial Program: 53.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \end{array} \]
(FPCore (x n)
 :precision binary64
 (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))
double code(double x, double n) {
	return pow((x + 1.0), (1.0 / n)) - pow(x, (1.0 / n));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

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

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

Alternative 1: 86.7% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-17}:\\ \;\;\;\;\frac{e^{\frac{\log x}{n}}}{x \cdot n}\\ \mathbf{elif}\;\frac{1}{n} \leq 10^{-12}:\\ \;\;\;\;-\frac{\mathsf{fma}\left(-1, \mathsf{log1p}\left(x\right) + \frac{0.5 \cdot \left({\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}\right)}{n}, \log x\right)}{n}\\ \mathbf{else}:\\ \;\;\;\;e^{\frac{\mathsf{log1p}\left(x\right)}{n}} - {x}^{\left(\frac{1}{n}\right)}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= (/ 1.0 n) -5e-17)
   (/ (exp (/ (log x) n)) (* x n))
   (if (<= (/ 1.0 n) 1e-12)
     (-
      (/
       (fma
        -1.0
        (+ (log1p x) (/ (* 0.5 (- (pow (log1p x) 2.0) (pow (log x) 2.0))) n))
        (log x))
       n))
     (- (exp (/ (log1p x) n)) (pow x (/ 1.0 n))))))
double code(double x, double n) {
	double tmp;
	if ((1.0 / n) <= -5e-17) {
		tmp = exp((log(x) / n)) / (x * n);
	} else if ((1.0 / n) <= 1e-12) {
		tmp = -(fma(-1.0, (log1p(x) + ((0.5 * (pow(log1p(x), 2.0) - pow(log(x), 2.0))) / n)), log(x)) / n);
	} else {
		tmp = exp((log1p(x) / n)) - pow(x, (1.0 / n));
	}
	return tmp;
}
function code(x, n)
	tmp = 0.0
	if (Float64(1.0 / n) <= -5e-17)
		tmp = Float64(exp(Float64(log(x) / n)) / Float64(x * n));
	elseif (Float64(1.0 / n) <= 1e-12)
		tmp = Float64(-Float64(fma(-1.0, Float64(log1p(x) + Float64(Float64(0.5 * Float64((log1p(x) ^ 2.0) - (log(x) ^ 2.0))) / n)), log(x)) / n));
	else
		tmp = Float64(exp(Float64(log1p(x) / n)) - (x ^ Float64(1.0 / n)));
	end
	return tmp
end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-17], N[(N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 1e-12], (-N[(N[(-1.0 * N[(N[Log[1 + x], $MachinePrecision] + N[(N[(0.5 * N[(N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision] - N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] + N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-17}:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{x \cdot n}\\

\mathbf{elif}\;\frac{1}{n} \leq 10^{-12}:\\
\;\;\;\;-\frac{\mathsf{fma}\left(-1, \mathsf{log1p}\left(x\right) + \frac{0.5 \cdot \left({\left(\mathsf{log1p}\left(x\right)\right)}^{2} - {\log x}^{2}\right)}{n}, \log x\right)}{n}\\

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


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

    1. Initial program 96.4%

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]

    if -4.9999999999999999e-17 < (/.f64 #s(literal 1 binary64) n) < 9.9999999999999998e-13

    1. Initial program 29.0%

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

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

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

    if 9.9999999999999998e-13 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 45.6%

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

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

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

Alternative 2: 82.2% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {x}^{\left(\frac{1}{n}\right)}\\ t_1 := {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - t\_0\\ \mathbf{if}\;t\_1 \leq -\infty:\\ \;\;\;\;1 - t\_0\\ \mathbf{elif}\;t\_1 \leq 10^{-9}:\\ \;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, \mathsf{fma}\left(x, \frac{0.5}{n \cdot n} - \frac{0.5}{n}, \frac{1}{n}\right), 1\right) - t\_0\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (pow x (/ 1.0 n))) (t_1 (- (pow (+ x 1.0) (/ 1.0 n)) t_0)))
   (if (<= t_1 (- INFINITY))
     (- 1.0 t_0)
     (if (<= t_1 1e-9)
       (/ (log (/ (+ x 1.0) x)) n)
       (- (fma x (fma x (- (/ 0.5 (* n n)) (/ 0.5 n)) (/ 1.0 n)) 1.0) t_0)))))
double code(double x, double n) {
	double t_0 = pow(x, (1.0 / n));
	double t_1 = pow((x + 1.0), (1.0 / n)) - t_0;
	double tmp;
	if (t_1 <= -((double) INFINITY)) {
		tmp = 1.0 - t_0;
	} else if (t_1 <= 1e-9) {
		tmp = log(((x + 1.0) / x)) / n;
	} else {
		tmp = fma(x, fma(x, ((0.5 / (n * n)) - (0.5 / n)), (1.0 / n)), 1.0) - t_0;
	}
	return tmp;
}
function code(x, n)
	t_0 = x ^ Float64(1.0 / n)
	t_1 = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - t_0)
	tmp = 0.0
	if (t_1 <= Float64(-Inf))
		tmp = Float64(1.0 - t_0);
	elseif (t_1 <= 1e-9)
		tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n);
	else
		tmp = Float64(fma(x, fma(x, Float64(Float64(0.5 / Float64(n * n)) - Float64(0.5 / n)), Float64(1.0 / n)), 1.0) - t_0);
	end
	return tmp
end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(1.0 - t$95$0), $MachinePrecision], If[LessEqual[t$95$1, 1e-9], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[(x * N[(x * N[(N[(0.5 / N[(n * n), $MachinePrecision]), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision] + N[(1.0 / n), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] - t$95$0), $MachinePrecision]]]]]
\begin{array}{l}

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

\mathbf{elif}\;t\_1 \leq 10^{-9}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \mathsf{fma}\left(x, \frac{0.5}{n \cdot n} - \frac{0.5}{n}, \frac{1}{n}\right), 1\right) - t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) < -inf.0

    1. Initial program 100.0%

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

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

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

    if -inf.0 < (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) < 1.00000000000000006e-9

    1. Initial program 42.1%

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

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

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

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

    if 1.00000000000000006e-9 < (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n)))

    1. Initial program 48.2%

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

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

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

Alternative 3: 82.5% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {x}^{\left(\frac{1}{n}\right)}\\ t_1 := {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - t\_0\\ \mathbf{if}\;t\_1 \leq -\infty:\\ \;\;\;\;1 - t\_0\\ \mathbf{elif}\;t\_1 \leq 10^{-9}:\\ \;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, \frac{1 + \mathsf{fma}\left(-0.5, x, 0.5 \cdot \frac{x}{n}\right)}{n}, 1\right) - t\_0\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (pow x (/ 1.0 n))) (t_1 (- (pow (+ x 1.0) (/ 1.0 n)) t_0)))
   (if (<= t_1 (- INFINITY))
     (- 1.0 t_0)
     (if (<= t_1 1e-9)
       (/ (log (/ (+ x 1.0) x)) n)
       (- (fma x (/ (+ 1.0 (fma -0.5 x (* 0.5 (/ x n)))) n) 1.0) t_0)))))
double code(double x, double n) {
	double t_0 = pow(x, (1.0 / n));
	double t_1 = pow((x + 1.0), (1.0 / n)) - t_0;
	double tmp;
	if (t_1 <= -((double) INFINITY)) {
		tmp = 1.0 - t_0;
	} else if (t_1 <= 1e-9) {
		tmp = log(((x + 1.0) / x)) / n;
	} else {
		tmp = fma(x, ((1.0 + fma(-0.5, x, (0.5 * (x / n)))) / n), 1.0) - t_0;
	}
	return tmp;
}
function code(x, n)
	t_0 = x ^ Float64(1.0 / n)
	t_1 = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - t_0)
	tmp = 0.0
	if (t_1 <= Float64(-Inf))
		tmp = Float64(1.0 - t_0);
	elseif (t_1 <= 1e-9)
		tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n);
	else
		tmp = Float64(fma(x, Float64(Float64(1.0 + fma(-0.5, x, Float64(0.5 * Float64(x / n)))) / n), 1.0) - t_0);
	end
	return tmp
end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(1.0 - t$95$0), $MachinePrecision], If[LessEqual[t$95$1, 1e-9], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[(x * N[(N[(1.0 + N[(-0.5 * x + N[(0.5 * N[(x / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] + 1.0), $MachinePrecision] - t$95$0), $MachinePrecision]]]]]
\begin{array}{l}

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

\mathbf{elif}\;t\_1 \leq 10^{-9}:\\
\;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \frac{1 + \mathsf{fma}\left(-0.5, x, 0.5 \cdot \frac{x}{n}\right)}{n}, 1\right) - t\_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) < -inf.0

    1. Initial program 100.0%

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

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

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

    if -inf.0 < (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) < 1.00000000000000006e-9

    1. Initial program 42.1%

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

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

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

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

    if 1.00000000000000006e-9 < (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n)))

    1. Initial program 48.2%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \frac{0.5}{n \cdot n} - \frac{0.5}{n}, \frac{1}{n}\right), 1\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    5. Taylor expanded in n around inf

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

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

Alternative 4: 77.4% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {x}^{\left(\frac{1}{n}\right)}\\ t_1 := {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - t\_0\\ \mathbf{if}\;t\_1 \leq -\infty:\\ \;\;\;\;1 - t\_0\\ \mathbf{elif}\;t\_1 \leq 0.02:\\ \;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\mathsf{fma}\left(1, \frac{\frac{0.5}{n \cdot n} - \frac{0.5}{n}}{x}, \frac{1}{n}\right)}{x}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (pow x (/ 1.0 n))) (t_1 (- (pow (+ x 1.0) (/ 1.0 n)) t_0)))
   (if (<= t_1 (- INFINITY))
     (- 1.0 t_0)
     (if (<= t_1 0.02)
       (/ (log (/ (+ x 1.0) x)) n)
       (/ (fma 1.0 (/ (- (/ 0.5 (* n n)) (/ 0.5 n)) x) (/ 1.0 n)) x)))))
double code(double x, double n) {
	double t_0 = pow(x, (1.0 / n));
	double t_1 = pow((x + 1.0), (1.0 / n)) - t_0;
	double tmp;
	if (t_1 <= -((double) INFINITY)) {
		tmp = 1.0 - t_0;
	} else if (t_1 <= 0.02) {
		tmp = log(((x + 1.0) / x)) / n;
	} else {
		tmp = fma(1.0, (((0.5 / (n * n)) - (0.5 / n)) / x), (1.0 / n)) / x;
	}
	return tmp;
}
function code(x, n)
	t_0 = x ^ Float64(1.0 / n)
	t_1 = Float64((Float64(x + 1.0) ^ Float64(1.0 / n)) - t_0)
	tmp = 0.0
	if (t_1 <= Float64(-Inf))
		tmp = Float64(1.0 - t_0);
	elseif (t_1 <= 0.02)
		tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n);
	else
		tmp = Float64(fma(1.0, Float64(Float64(Float64(0.5 / Float64(n * n)) - Float64(0.5 / n)) / x), Float64(1.0 / n)) / x);
	end
	return tmp
end
code[x_, n_] := Block[{t$95$0 = N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[(x + 1.0), $MachinePrecision], N[(1.0 / n), $MachinePrecision]], $MachinePrecision] - t$95$0), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(1.0 - t$95$0), $MachinePrecision], If[LessEqual[t$95$1, 0.02], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[(1.0 * N[(N[(N[(0.5 / N[(n * n), $MachinePrecision]), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + N[(1.0 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]]]]
\begin{array}{l}

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

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

\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(1, \frac{\frac{0.5}{n \cdot n} - \frac{0.5}{n}}{x}, \frac{1}{n}\right)}{x}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) < -inf.0

    1. Initial program 100.0%

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

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

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

    if -inf.0 < (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n))) < 0.0200000000000000004

    1. Initial program 42.4%

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

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

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

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

    if 0.0200000000000000004 < (-.f64 (pow.f64 (+.f64 x #s(literal 1 binary64)) (/.f64 #s(literal 1 binary64) n)) (pow.f64 x (/.f64 #s(literal 1 binary64) n)))

    1. Initial program 46.6%

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(e^{-\frac{\log x}{-n}}, \frac{\frac{0.5}{n \cdot n} - \frac{0.5}{n}}{x}, \frac{e^{-\frac{\log x}{-n}}}{n}\right)}{x}} \]
    5. Taylor expanded in n around inf

      \[\leadsto \frac{\mathsf{fma}\left(1, \frac{\frac{\frac{1}{2}}{n \cdot n} - \frac{\frac{1}{2}}{n}}{x}, \frac{e^{-\frac{\log x}{-n}}}{n}\right)}{x} \]
    6. Applied rewrites50.5%

      \[\leadsto \frac{\mathsf{fma}\left(1, \frac{\frac{0.5}{n \cdot n} - \frac{0.5}{n}}{x}, \frac{e^{-\frac{\log x}{-n}}}{n}\right)}{x} \]
    7. Taylor expanded in n around inf

      \[\leadsto \frac{\mathsf{fma}\left(1, \frac{\frac{\frac{1}{2}}{n \cdot n} - \frac{\frac{1}{2}}{n}}{x}, \frac{1}{n}\right)}{x} \]
    8. Applied rewrites50.5%

      \[\leadsto \frac{\mathsf{fma}\left(1, \frac{\frac{0.5}{n \cdot n} - \frac{0.5}{n}}{x}, \frac{1}{n}\right)}{x} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 5: 86.7% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-17}:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{x \cdot n}\\

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

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


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

    1. Initial program 96.4%

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]

    if -4.9999999999999999e-17 < (/.f64 #s(literal 1 binary64) n) < 9.9999999999999998e-13

    1. Initial program 29.0%

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

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

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

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

    if 9.9999999999999998e-13 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 45.6%

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

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

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

Alternative 6: 83.1% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-17}:\\ \;\;\;\;\frac{e^{\frac{\log x}{n}}}{x \cdot n}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-11}:\\ \;\;\;\;\frac{\log \left(\frac{x + 1}{x}\right)}{n}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, \mathsf{fma}\left(x, \frac{0.5}{n \cdot n} - \frac{0.5}{n}, \frac{1}{n}\right), 1\right) - {x}^{\left(\frac{1}{n}\right)}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= (/ 1.0 n) -5e-17)
   (/ (exp (/ (log x) n)) (* x n))
   (if (<= (/ 1.0 n) 2e-11)
     (/ (log (/ (+ x 1.0) x)) n)
     (-
      (fma x (fma x (- (/ 0.5 (* n n)) (/ 0.5 n)) (/ 1.0 n)) 1.0)
      (pow x (/ 1.0 n))))))
double code(double x, double n) {
	double tmp;
	if ((1.0 / n) <= -5e-17) {
		tmp = exp((log(x) / n)) / (x * n);
	} else if ((1.0 / n) <= 2e-11) {
		tmp = log(((x + 1.0) / x)) / n;
	} else {
		tmp = fma(x, fma(x, ((0.5 / (n * n)) - (0.5 / n)), (1.0 / n)), 1.0) - pow(x, (1.0 / n));
	}
	return tmp;
}
function code(x, n)
	tmp = 0.0
	if (Float64(1.0 / n) <= -5e-17)
		tmp = Float64(exp(Float64(log(x) / n)) / Float64(x * n));
	elseif (Float64(1.0 / n) <= 2e-11)
		tmp = Float64(log(Float64(Float64(x + 1.0) / x)) / n);
	else
		tmp = Float64(fma(x, fma(x, Float64(Float64(0.5 / Float64(n * n)) - Float64(0.5 / n)), Float64(1.0 / n)), 1.0) - (x ^ Float64(1.0 / n)));
	end
	return tmp
end
code[x_, n_] := If[LessEqual[N[(1.0 / n), $MachinePrecision], -5e-17], N[(N[Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]], $MachinePrecision] / N[(x * n), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-11], N[(N[Log[N[(N[(x + 1.0), $MachinePrecision] / x), $MachinePrecision]], $MachinePrecision] / n), $MachinePrecision], N[(N[(x * N[(x * N[(N[(0.5 / N[(n * n), $MachinePrecision]), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision] + N[(1.0 / n), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{n} \leq -5 \cdot 10^{-17}:\\
\;\;\;\;\frac{e^{\frac{\log x}{n}}}{x \cdot n}\\

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(x, \mathsf{fma}\left(x, \frac{0.5}{n \cdot n} - \frac{0.5}{n}, \frac{1}{n}\right), 1\right) - {x}^{\left(\frac{1}{n}\right)}\\


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

    1. Initial program 96.4%

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

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

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

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

      \[\leadsto \color{blue}{\frac{e^{\frac{\log x}{n}}}{x \cdot n}} \]

    if -4.9999999999999999e-17 < (/.f64 #s(literal 1 binary64) n) < 1.99999999999999988e-11

    1. Initial program 28.8%

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

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

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

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

    if 1.99999999999999988e-11 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 46.9%

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

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

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

Alternative 7: 61.2% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 0.86:\\ \;\;\;\;\frac{x - \log x}{n}\\ \mathbf{elif}\;x \leq 6.2 \cdot 10^{+82}:\\ \;\;\;\;\frac{-\frac{\left(-\frac{\frac{0.3333333333333333}{x} - 0.5}{x}\right) - 1}{x}}{n}\\ \mathbf{else}:\\ \;\;\;\;1 - 1\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= x 0.86)
   (/ (- x (log x)) n)
   (if (<= x 6.2e+82)
     (/ (- (/ (- (- (/ (- (/ 0.3333333333333333 x) 0.5) x)) 1.0) x)) n)
     (- 1.0 1.0))))
double code(double x, double n) {
	double tmp;
	if (x <= 0.86) {
		tmp = (x - log(x)) / n;
	} else if (x <= 6.2e+82) {
		tmp = -((-(((0.3333333333333333 / x) - 0.5) / x) - 1.0) / x) / n;
	} else {
		tmp = 1.0 - 1.0;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, n)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    real(8) :: tmp
    if (x <= 0.86d0) then
        tmp = (x - log(x)) / n
    else if (x <= 6.2d+82) then
        tmp = -((-(((0.3333333333333333d0 / x) - 0.5d0) / x) - 1.0d0) / x) / n
    else
        tmp = 1.0d0 - 1.0d0
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double tmp;
	if (x <= 0.86) {
		tmp = (x - Math.log(x)) / n;
	} else if (x <= 6.2e+82) {
		tmp = -((-(((0.3333333333333333 / x) - 0.5) / x) - 1.0) / x) / n;
	} else {
		tmp = 1.0 - 1.0;
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if x <= 0.86:
		tmp = (x - math.log(x)) / n
	elif x <= 6.2e+82:
		tmp = -((-(((0.3333333333333333 / x) - 0.5) / x) - 1.0) / x) / n
	else:
		tmp = 1.0 - 1.0
	return tmp
function code(x, n)
	tmp = 0.0
	if (x <= 0.86)
		tmp = Float64(Float64(x - log(x)) / n);
	elseif (x <= 6.2e+82)
		tmp = Float64(Float64(-Float64(Float64(Float64(-Float64(Float64(Float64(0.3333333333333333 / x) - 0.5) / x)) - 1.0) / x)) / n);
	else
		tmp = Float64(1.0 - 1.0);
	end
	return tmp
end
function tmp_2 = code(x, n)
	tmp = 0.0;
	if (x <= 0.86)
		tmp = (x - log(x)) / n;
	elseif (x <= 6.2e+82)
		tmp = -((-(((0.3333333333333333 / x) - 0.5) / x) - 1.0) / x) / n;
	else
		tmp = 1.0 - 1.0;
	end
	tmp_2 = tmp;
end
code[x_, n_] := If[LessEqual[x, 0.86], N[(N[(x - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision], If[LessEqual[x, 6.2e+82], N[((-N[(N[((-N[(N[(N[(0.3333333333333333 / x), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision]) - 1.0), $MachinePrecision] / x), $MachinePrecision]) / n), $MachinePrecision], N[(1.0 - 1.0), $MachinePrecision]]]
\begin{array}{l}

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

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

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


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

    1. Initial program 39.7%

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

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

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

      \[\leadsto \frac{x - \log x}{n} \]
    6. Applied rewrites55.8%

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

    if 0.859999999999999987 < x < 6.20000000000000065e82

    1. Initial program 33.6%

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

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

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

      \[\leadsto \frac{-1 \cdot \frac{-1 \cdot \frac{\frac{1}{3} \cdot \frac{1}{x} - \frac{1}{2}}{x} - 1}{x}}{n} \]
    6. Applied rewrites70.9%

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

    if 6.20000000000000065e82 < x

    1. Initial program 82.3%

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

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

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

      \[\leadsto 1 - \color{blue}{1} \]
    6. Applied rewrites82.3%

      \[\leadsto 1 - \color{blue}{1} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 8: 60.6% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 7.2 \cdot 10^{-10}:\\ \;\;\;\;\frac{-\log x}{n}\\ \mathbf{elif}\;x \leq 5.7 \cdot 10^{+82}:\\ \;\;\;\;\frac{\mathsf{fma}\left(1, \frac{\frac{0.5}{n \cdot n} - \frac{0.5}{n}}{x}, \frac{1}{n}\right)}{x}\\ \mathbf{else}:\\ \;\;\;\;1 - 1\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= x 7.2e-10)
   (/ (- (log x)) n)
   (if (<= x 5.7e+82)
     (/ (fma 1.0 (/ (- (/ 0.5 (* n n)) (/ 0.5 n)) x) (/ 1.0 n)) x)
     (- 1.0 1.0))))
double code(double x, double n) {
	double tmp;
	if (x <= 7.2e-10) {
		tmp = -log(x) / n;
	} else if (x <= 5.7e+82) {
		tmp = fma(1.0, (((0.5 / (n * n)) - (0.5 / n)) / x), (1.0 / n)) / x;
	} else {
		tmp = 1.0 - 1.0;
	}
	return tmp;
}
function code(x, n)
	tmp = 0.0
	if (x <= 7.2e-10)
		tmp = Float64(Float64(-log(x)) / n);
	elseif (x <= 5.7e+82)
		tmp = Float64(fma(1.0, Float64(Float64(Float64(0.5 / Float64(n * n)) - Float64(0.5 / n)) / x), Float64(1.0 / n)) / x);
	else
		tmp = Float64(1.0 - 1.0);
	end
	return tmp
end
code[x_, n_] := If[LessEqual[x, 7.2e-10], N[((-N[Log[x], $MachinePrecision]) / n), $MachinePrecision], If[LessEqual[x, 5.7e+82], N[(N[(1.0 * N[(N[(N[(0.5 / N[(n * n), $MachinePrecision]), $MachinePrecision] - N[(0.5 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + N[(1.0 / n), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision], N[(1.0 - 1.0), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq 5.7 \cdot 10^{+82}:\\
\;\;\;\;\frac{\mathsf{fma}\left(1, \frac{\frac{0.5}{n \cdot n} - \frac{0.5}{n}}{x}, \frac{1}{n}\right)}{x}\\

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


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

    1. Initial program 39.2%

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

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

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

      \[\leadsto \frac{-1 \cdot \log x}{n} \]
    6. Applied rewrites55.9%

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

    if 7.2e-10 < x < 5.70000000000000016e82

    1. Initial program 36.8%

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(e^{-\frac{\log x}{-n}}, \frac{\frac{0.5}{n \cdot n} - \frac{0.5}{n}}{x}, \frac{e^{-\frac{\log x}{-n}}}{n}\right)}{x}} \]
    5. Taylor expanded in n around inf

      \[\leadsto \frac{\mathsf{fma}\left(1, \frac{\frac{\frac{1}{2}}{n \cdot n} - \frac{\frac{1}{2}}{n}}{x}, \frac{e^{-\frac{\log x}{-n}}}{n}\right)}{x} \]
    6. Applied rewrites68.9%

      \[\leadsto \frac{\mathsf{fma}\left(1, \frac{\frac{0.5}{n \cdot n} - \frac{0.5}{n}}{x}, \frac{e^{-\frac{\log x}{-n}}}{n}\right)}{x} \]
    7. Taylor expanded in n around inf

      \[\leadsto \frac{\mathsf{fma}\left(1, \frac{\frac{\frac{1}{2}}{n \cdot n} - \frac{\frac{1}{2}}{n}}{x}, \frac{1}{n}\right)}{x} \]
    8. Applied rewrites67.1%

      \[\leadsto \frac{\mathsf{fma}\left(1, \frac{\frac{0.5}{n \cdot n} - \frac{0.5}{n}}{x}, \frac{1}{n}\right)}{x} \]

    if 5.70000000000000016e82 < x

    1. Initial program 82.3%

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

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

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

      \[\leadsto 1 - \color{blue}{1} \]
    6. Applied rewrites82.3%

      \[\leadsto 1 - \color{blue}{1} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 9: 49.9% accurate, 3.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 6.2 \cdot 10^{+82}:\\ \;\;\;\;\frac{-\frac{\left(-\frac{\frac{0.3333333333333333}{x} - 0.5}{x}\right) - 1}{x}}{n}\\ \mathbf{else}:\\ \;\;\;\;1 - 1\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= x 6.2e+82)
   (/ (- (/ (- (- (/ (- (/ 0.3333333333333333 x) 0.5) x)) 1.0) x)) n)
   (- 1.0 1.0)))
double code(double x, double n) {
	double tmp;
	if (x <= 6.2e+82) {
		tmp = -((-(((0.3333333333333333 / x) - 0.5) / x) - 1.0) / x) / n;
	} else {
		tmp = 1.0 - 1.0;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, n)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    real(8) :: tmp
    if (x <= 6.2d+82) then
        tmp = -((-(((0.3333333333333333d0 / x) - 0.5d0) / x) - 1.0d0) / x) / n
    else
        tmp = 1.0d0 - 1.0d0
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double tmp;
	if (x <= 6.2e+82) {
		tmp = -((-(((0.3333333333333333 / x) - 0.5) / x) - 1.0) / x) / n;
	} else {
		tmp = 1.0 - 1.0;
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if x <= 6.2e+82:
		tmp = -((-(((0.3333333333333333 / x) - 0.5) / x) - 1.0) / x) / n
	else:
		tmp = 1.0 - 1.0
	return tmp
function code(x, n)
	tmp = 0.0
	if (x <= 6.2e+82)
		tmp = Float64(Float64(-Float64(Float64(Float64(-Float64(Float64(Float64(0.3333333333333333 / x) - 0.5) / x)) - 1.0) / x)) / n);
	else
		tmp = Float64(1.0 - 1.0);
	end
	return tmp
end
function tmp_2 = code(x, n)
	tmp = 0.0;
	if (x <= 6.2e+82)
		tmp = -((-(((0.3333333333333333 / x) - 0.5) / x) - 1.0) / x) / n;
	else
		tmp = 1.0 - 1.0;
	end
	tmp_2 = tmp;
end
code[x_, n_] := If[LessEqual[x, 6.2e+82], N[((-N[(N[((-N[(N[(N[(0.3333333333333333 / x), $MachinePrecision] - 0.5), $MachinePrecision] / x), $MachinePrecision]) - 1.0), $MachinePrecision] / x), $MachinePrecision]) / n), $MachinePrecision], N[(1.0 - 1.0), $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 38.8%

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

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

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

      \[\leadsto \frac{-1 \cdot \frac{-1 \cdot \frac{\frac{1}{3} \cdot \frac{1}{x} - \frac{1}{2}}{x} - 1}{x}}{n} \]
    6. Applied rewrites38.7%

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

    if 6.20000000000000065e82 < x

    1. Initial program 82.3%

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

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

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

      \[\leadsto 1 - \color{blue}{1} \]
    6. Applied rewrites82.3%

      \[\leadsto 1 - \color{blue}{1} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 10: 49.5% accurate, 4.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 6.2 \cdot 10^{+82}:\\ \;\;\;\;\frac{-\frac{\left(-\frac{\frac{0.3333333333333333}{x}}{x}\right) - 1}{x}}{n}\\ \mathbf{else}:\\ \;\;\;\;1 - 1\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= x 6.2e+82)
   (/ (- (/ (- (- (/ (/ 0.3333333333333333 x) x)) 1.0) x)) n)
   (- 1.0 1.0)))
double code(double x, double n) {
	double tmp;
	if (x <= 6.2e+82) {
		tmp = -((-((0.3333333333333333 / x) / x) - 1.0) / x) / n;
	} else {
		tmp = 1.0 - 1.0;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, n)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    real(8) :: tmp
    if (x <= 6.2d+82) then
        tmp = -((-((0.3333333333333333d0 / x) / x) - 1.0d0) / x) / n
    else
        tmp = 1.0d0 - 1.0d0
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double tmp;
	if (x <= 6.2e+82) {
		tmp = -((-((0.3333333333333333 / x) / x) - 1.0) / x) / n;
	} else {
		tmp = 1.0 - 1.0;
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if x <= 6.2e+82:
		tmp = -((-((0.3333333333333333 / x) / x) - 1.0) / x) / n
	else:
		tmp = 1.0 - 1.0
	return tmp
function code(x, n)
	tmp = 0.0
	if (x <= 6.2e+82)
		tmp = Float64(Float64(-Float64(Float64(Float64(-Float64(Float64(0.3333333333333333 / x) / x)) - 1.0) / x)) / n);
	else
		tmp = Float64(1.0 - 1.0);
	end
	return tmp
end
function tmp_2 = code(x, n)
	tmp = 0.0;
	if (x <= 6.2e+82)
		tmp = -((-((0.3333333333333333 / x) / x) - 1.0) / x) / n;
	else
		tmp = 1.0 - 1.0;
	end
	tmp_2 = tmp;
end
code[x_, n_] := If[LessEqual[x, 6.2e+82], N[((-N[(N[((-N[(N[(0.3333333333333333 / x), $MachinePrecision] / x), $MachinePrecision]) - 1.0), $MachinePrecision] / x), $MachinePrecision]) / n), $MachinePrecision], N[(1.0 - 1.0), $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 38.8%

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

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

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

      \[\leadsto \frac{-1 \cdot \frac{-1 \cdot \frac{\frac{1}{3} \cdot \frac{1}{x} - \frac{1}{2}}{x} - 1}{x}}{n} \]
    6. Applied rewrites38.7%

      \[\leadsto \frac{-\frac{\left(-\frac{\frac{0.3333333333333333}{x} - 0.5}{x}\right) - 1}{x}}{n} \]
    7. Taylor expanded in x around 0

      \[\leadsto \frac{-\frac{\left(-\frac{\frac{\frac{1}{3}}{x}}{x}\right) - 1}{x}}{n} \]
    8. Applied rewrites38.7%

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

    if 6.20000000000000065e82 < x

    1. Initial program 82.3%

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

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

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

      \[\leadsto 1 - \color{blue}{1} \]
    6. Applied rewrites82.3%

      \[\leadsto 1 - \color{blue}{1} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 11: 46.4% accurate, 6.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq -5:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \mathbf{elif}\;n \leq -9 \cdot 10^{-197}:\\ \;\;\;\;1 - 1\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{1}{x}}{n}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= n -5.0)
   (/ (/ 1.0 n) x)
   (if (<= n -9e-197) (- 1.0 1.0) (/ (/ 1.0 x) n))))
double code(double x, double n) {
	double tmp;
	if (n <= -5.0) {
		tmp = (1.0 / n) / x;
	} else if (n <= -9e-197) {
		tmp = 1.0 - 1.0;
	} else {
		tmp = (1.0 / x) / n;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, n)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    real(8) :: tmp
    if (n <= (-5.0d0)) then
        tmp = (1.0d0 / n) / x
    else if (n <= (-9d-197)) then
        tmp = 1.0d0 - 1.0d0
    else
        tmp = (1.0d0 / x) / n
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double tmp;
	if (n <= -5.0) {
		tmp = (1.0 / n) / x;
	} else if (n <= -9e-197) {
		tmp = 1.0 - 1.0;
	} else {
		tmp = (1.0 / x) / n;
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if n <= -5.0:
		tmp = (1.0 / n) / x
	elif n <= -9e-197:
		tmp = 1.0 - 1.0
	else:
		tmp = (1.0 / x) / n
	return tmp
function code(x, n)
	tmp = 0.0
	if (n <= -5.0)
		tmp = Float64(Float64(1.0 / n) / x);
	elseif (n <= -9e-197)
		tmp = Float64(1.0 - 1.0);
	else
		tmp = Float64(Float64(1.0 / x) / n);
	end
	return tmp
end
function tmp_2 = code(x, n)
	tmp = 0.0;
	if (n <= -5.0)
		tmp = (1.0 / n) / x;
	elseif (n <= -9e-197)
		tmp = 1.0 - 1.0;
	else
		tmp = (1.0 / x) / n;
	end
	tmp_2 = tmp;
end
code[x_, n_] := If[LessEqual[n, -5.0], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[n, -9e-197], N[(1.0 - 1.0), $MachinePrecision], N[(N[(1.0 / x), $MachinePrecision] / n), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;n \leq -9 \cdot 10^{-197}:\\
\;\;\;\;1 - 1\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{1}{x}}{n}\\


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

    1. Initial program 26.5%

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

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

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

      \[\leadsto \frac{1}{\color{blue}{n \cdot x}} \]
    6. Applied rewrites43.7%

      \[\leadsto \frac{1}{\color{blue}{x \cdot n}} \]
    7. Applied rewrites44.9%

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

    if -5 < n < -9.0000000000000002e-197

    1. Initial program 100.0%

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

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

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

      \[\leadsto 1 - \color{blue}{1} \]
    6. Applied rewrites54.3%

      \[\leadsto 1 - \color{blue}{1} \]

    if -9.0000000000000002e-197 < n

    1. Initial program 46.6%

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

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

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

      \[\leadsto \frac{\frac{1}{x}}{n} \]
    6. Applied rewrites47.6%

      \[\leadsto \frac{\frac{1}{x}}{n} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 12: 46.2% accurate, 8.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq -5:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \mathbf{elif}\;n \leq -9 \cdot 10^{-197}:\\ \;\;\;\;1 - 1\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{x \cdot n}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (<= n -5.0)
   (/ (/ 1.0 n) x)
   (if (<= n -9e-197) (- 1.0 1.0) (/ 1.0 (* x n)))))
double code(double x, double n) {
	double tmp;
	if (n <= -5.0) {
		tmp = (1.0 / n) / x;
	} else if (n <= -9e-197) {
		tmp = 1.0 - 1.0;
	} else {
		tmp = 1.0 / (x * n);
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, n)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    real(8) :: tmp
    if (n <= (-5.0d0)) then
        tmp = (1.0d0 / n) / x
    else if (n <= (-9d-197)) then
        tmp = 1.0d0 - 1.0d0
    else
        tmp = 1.0d0 / (x * n)
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double tmp;
	if (n <= -5.0) {
		tmp = (1.0 / n) / x;
	} else if (n <= -9e-197) {
		tmp = 1.0 - 1.0;
	} else {
		tmp = 1.0 / (x * n);
	}
	return tmp;
}
def code(x, n):
	tmp = 0
	if n <= -5.0:
		tmp = (1.0 / n) / x
	elif n <= -9e-197:
		tmp = 1.0 - 1.0
	else:
		tmp = 1.0 / (x * n)
	return tmp
function code(x, n)
	tmp = 0.0
	if (n <= -5.0)
		tmp = Float64(Float64(1.0 / n) / x);
	elseif (n <= -9e-197)
		tmp = Float64(1.0 - 1.0);
	else
		tmp = Float64(1.0 / Float64(x * n));
	end
	return tmp
end
function tmp_2 = code(x, n)
	tmp = 0.0;
	if (n <= -5.0)
		tmp = (1.0 / n) / x;
	elseif (n <= -9e-197)
		tmp = 1.0 - 1.0;
	else
		tmp = 1.0 / (x * n);
	end
	tmp_2 = tmp;
end
code[x_, n_] := If[LessEqual[n, -5.0], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], If[LessEqual[n, -9e-197], N[(1.0 - 1.0), $MachinePrecision], N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{elif}\;n \leq -9 \cdot 10^{-197}:\\
\;\;\;\;1 - 1\\

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


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

    1. Initial program 26.5%

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

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

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

      \[\leadsto \frac{1}{\color{blue}{n \cdot x}} \]
    6. Applied rewrites43.7%

      \[\leadsto \frac{1}{\color{blue}{x \cdot n}} \]
    7. Applied rewrites44.9%

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

    if -5 < n < -9.0000000000000002e-197

    1. Initial program 100.0%

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

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

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

      \[\leadsto 1 - \color{blue}{1} \]
    6. Applied rewrites54.3%

      \[\leadsto 1 - \color{blue}{1} \]

    if -9.0000000000000002e-197 < n

    1. Initial program 46.6%

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

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

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

      \[\leadsto \frac{1}{\color{blue}{n \cdot x}} \]
    6. Applied rewrites47.5%

      \[\leadsto \frac{1}{\color{blue}{x \cdot n}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 13: 45.9% accurate, 8.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{1}{x \cdot n}\\ \mathbf{if}\;n \leq -5:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;n \leq -9 \cdot 10^{-197}:\\ \;\;\;\;1 - 1\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (/ 1.0 (* x n))))
   (if (<= n -5.0) t_0 (if (<= n -9e-197) (- 1.0 1.0) t_0))))
double code(double x, double n) {
	double t_0 = 1.0 / (x * n);
	double tmp;
	if (n <= -5.0) {
		tmp = t_0;
	} else if (n <= -9e-197) {
		tmp = 1.0 - 1.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, n)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: n
    real(8) :: t_0
    real(8) :: tmp
    t_0 = 1.0d0 / (x * n)
    if (n <= (-5.0d0)) then
        tmp = t_0
    else if (n <= (-9d-197)) then
        tmp = 1.0d0 - 1.0d0
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double n) {
	double t_0 = 1.0 / (x * n);
	double tmp;
	if (n <= -5.0) {
		tmp = t_0;
	} else if (n <= -9e-197) {
		tmp = 1.0 - 1.0;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, n):
	t_0 = 1.0 / (x * n)
	tmp = 0
	if n <= -5.0:
		tmp = t_0
	elif n <= -9e-197:
		tmp = 1.0 - 1.0
	else:
		tmp = t_0
	return tmp
function code(x, n)
	t_0 = Float64(1.0 / Float64(x * n))
	tmp = 0.0
	if (n <= -5.0)
		tmp = t_0;
	elseif (n <= -9e-197)
		tmp = Float64(1.0 - 1.0);
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, n)
	t_0 = 1.0 / (x * n);
	tmp = 0.0;
	if (n <= -5.0)
		tmp = t_0;
	elseif (n <= -9e-197)
		tmp = 1.0 - 1.0;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, n_] := Block[{t$95$0 = N[(1.0 / N[(x * n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[n, -5.0], t$95$0, If[LessEqual[n, -9e-197], N[(1.0 - 1.0), $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{1}{x \cdot n}\\
\mathbf{if}\;n \leq -5:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;n \leq -9 \cdot 10^{-197}:\\
\;\;\;\;1 - 1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if n < -5 or -9.0000000000000002e-197 < n

    1. Initial program 38.4%

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

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

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

      \[\leadsto \frac{1}{\color{blue}{n \cdot x}} \]
    6. Applied rewrites45.9%

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

    if -5 < n < -9.0000000000000002e-197

    1. Initial program 100.0%

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

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

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

      \[\leadsto 1 - \color{blue}{1} \]
    6. Applied rewrites54.3%

      \[\leadsto 1 - \color{blue}{1} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 14: 31.6% accurate, 57.8× speedup?

\[\begin{array}{l} \\ 1 - 1 \end{array} \]
(FPCore (x n) :precision binary64 (- 1.0 1.0))
double code(double x, double n) {
	return 1.0 - 1.0;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

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

\\
1 - 1
\end{array}
Derivation
  1. Initial program 51.9%

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

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

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

    \[\leadsto 1 - \color{blue}{1} \]
  6. Applied rewrites30.7%

    \[\leadsto 1 - \color{blue}{1} \]
  7. Add Preprocessing

Reproduce

?
herbie shell --seed 2025036 -o generate:simplify -o generate:proofs
(FPCore (x n)
  :name "2nthrt (problem 3.4.6)"
  :precision binary64
  (- (pow (+ x 1.0) (/ 1.0 n)) (pow x (/ 1.0 n))))