2nthrt (problem 3.4.6)

Percentage Accurate: 54.6% → 91.2%
Time: 17.9s
Alternatives: 11
Speedup: 2.3×

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}

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: 54.6% 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: 91.2% accurate, 1.5× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{\log x}{n}\\
\mathbf{if}\;x \leq 0.71:\\
\;\;\;\;-\mathsf{expm1}\left(t\_0\right)\\

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


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

    1. Initial program 43.6%

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

      \[\leadsto \color{blue}{1 - e^{\frac{\log x}{n}}} \]
    3. Step-by-step derivation
      1. negate-sub2N/A

        \[\leadsto \mathsf{neg}\left(\left(e^{\frac{\log x}{n}} - 1\right)\right) \]
      2. lower-neg.f64N/A

        \[\leadsto -\left(e^{\frac{\log x}{n}} - 1\right) \]
      3. lower-expm1.f64N/A

        \[\leadsto -\mathsf{expm1}\left(\frac{\log x}{n}\right) \]
      4. lower-/.f64N/A

        \[\leadsto -\mathsf{expm1}\left(\frac{\log x}{n}\right) \]
      5. lower-log.f6486.6

        \[\leadsto -\mathsf{expm1}\left(\frac{\log x}{n}\right) \]
    4. Applied rewrites86.6%

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

    if 0.70999999999999996 < x

    1. Initial program 68.9%

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

      \[\leadsto \color{blue}{\frac{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}}}{n \cdot x}} \]
    3. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \frac{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}}}{\color{blue}{n \cdot x}} \]
      2. lower-exp.f64N/A

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

        \[\leadsto \frac{e^{\mathsf{neg}\left(\frac{\log \left(\frac{1}{x}\right)}{n}\right)}}{n \cdot x} \]
      4. log-recN/A

        \[\leadsto \frac{e^{\mathsf{neg}\left(\frac{\mathsf{neg}\left(\log x\right)}{n}\right)}}{n \cdot x} \]
      5. mul-1-negN/A

        \[\leadsto \frac{e^{\mathsf{neg}\left(\frac{-1 \cdot \log x}{n}\right)}}{n \cdot x} \]
      6. lower-neg.f64N/A

        \[\leadsto \frac{e^{-\frac{-1 \cdot \log x}{n}}}{n \cdot x} \]
      7. lower-/.f64N/A

        \[\leadsto \frac{e^{-\frac{-1 \cdot \log x}{n}}}{n \cdot x} \]
      8. mul-1-negN/A

        \[\leadsto \frac{e^{-\frac{\mathsf{neg}\left(\log x\right)}{n}}}{n \cdot x} \]
      9. lower-neg.f64N/A

        \[\leadsto \frac{e^{-\frac{-\log x}{n}}}{n \cdot x} \]
      10. lower-log.f64N/A

        \[\leadsto \frac{e^{-\frac{-\log x}{n}}}{n \cdot x} \]
      11. lower-*.f6497.3

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

      \[\leadsto \color{blue}{\frac{e^{-\frac{-\log x}{n}}}{n \cdot x}} \]
    5. Step-by-step derivation
      1. lift-neg.f64N/A

        \[\leadsto \frac{e^{\mathsf{neg}\left(\frac{-\log x}{n}\right)}}{n \cdot x} \]
      2. lift-/.f64N/A

        \[\leadsto \frac{e^{\mathsf{neg}\left(\frac{-\log x}{n}\right)}}{n \cdot x} \]
      3. lift-log.f64N/A

        \[\leadsto \frac{e^{\mathsf{neg}\left(\frac{-\log x}{n}\right)}}{n \cdot x} \]
      4. lift-neg.f64N/A

        \[\leadsto \frac{e^{\mathsf{neg}\left(\frac{\mathsf{neg}\left(\log x\right)}{n}\right)}}{n \cdot x} \]
      5. distribute-neg-frac2N/A

        \[\leadsto \frac{e^{\frac{\mathsf{neg}\left(\log x\right)}{\mathsf{neg}\left(n\right)}}}{n \cdot x} \]
      6. frac-2negN/A

        \[\leadsto \frac{e^{\frac{\log x}{n}}}{n \cdot x} \]
      7. lower-/.f64N/A

        \[\leadsto \frac{e^{\frac{\log x}{n}}}{n \cdot x} \]
      8. lift-log.f6497.3

        \[\leadsto \frac{e^{\frac{\log x}{n}}}{n \cdot x} \]
    6. Applied rewrites97.3%

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

Alternative 2: 78.1% accurate, 1.2× speedup?

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

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

\mathbf{elif}\;x \leq 10^{+49}:\\
\;\;\;\;1 - 1\\

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

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


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

    1. Initial program 43.6%

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

      \[\leadsto \color{blue}{1 - e^{\frac{\log x}{n}}} \]
    3. Step-by-step derivation
      1. negate-sub2N/A

        \[\leadsto \mathsf{neg}\left(\left(e^{\frac{\log x}{n}} - 1\right)\right) \]
      2. lower-neg.f64N/A

        \[\leadsto -\left(e^{\frac{\log x}{n}} - 1\right) \]
      3. lower-expm1.f64N/A

        \[\leadsto -\mathsf{expm1}\left(\frac{\log x}{n}\right) \]
      4. lower-/.f64N/A

        \[\leadsto -\mathsf{expm1}\left(\frac{\log x}{n}\right) \]
      5. lower-log.f6486.5

        \[\leadsto -\mathsf{expm1}\left(\frac{\log x}{n}\right) \]
    4. Applied rewrites86.5%

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

    if 1 < x < 9.99999999999999946e48

    1. Initial program 42.3%

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

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

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

        \[\leadsto \color{blue}{1} - 1 \]
      3. Step-by-step derivation
        1. Applied rewrites42.2%

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

        if 9.99999999999999946e48 < x < 8.49999999999999971e245

        1. Initial program 68.5%

          \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
        2. 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}} \]
        3. Applied rewrites68.5%

          \[\leadsto \color{blue}{-\frac{\left(\left(-\frac{0.5 \cdot \left(\log \left(1 + x\right) \cdot \log \left(1 + x\right) - \log x \cdot \log x\right)}{n}\right) + \left(-\log \left(1 + x\right)\right)\right) + \log x}{n}} \]
        4. Taylor expanded in x around inf

          \[\leadsto \frac{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{{n}^{2}} + \frac{1}{n}}{\color{blue}{x}} \]
        5. Step-by-step derivation
          1. lower-/.f64N/A

            \[\leadsto \frac{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{{n}^{2}} + \frac{1}{n}}{x} \]
          2. lower-fma.f64N/A

            \[\leadsto \frac{\mathsf{fma}\left(-1, \frac{\log \left(\frac{1}{x}\right)}{{n}^{2}}, \frac{1}{n}\right)}{x} \]
          3. lower-/.f64N/A

            \[\leadsto \frac{\mathsf{fma}\left(-1, \frac{\log \left(\frac{1}{x}\right)}{{n}^{2}}, \frac{1}{n}\right)}{x} \]
          4. neg-logN/A

            \[\leadsto \frac{\mathsf{fma}\left(-1, \frac{\mathsf{neg}\left(\log x\right)}{{n}^{2}}, \frac{1}{n}\right)}{x} \]
          5. lift-neg.f64N/A

            \[\leadsto \frac{\mathsf{fma}\left(-1, \frac{-\log x}{{n}^{2}}, \frac{1}{n}\right)}{x} \]
          6. lift-log.f64N/A

            \[\leadsto \frac{\mathsf{fma}\left(-1, \frac{-\log x}{{n}^{2}}, \frac{1}{n}\right)}{x} \]
          7. pow2N/A

            \[\leadsto \frac{\mathsf{fma}\left(-1, \frac{-\log x}{n \cdot n}, \frac{1}{n}\right)}{x} \]
          8. lift-*.f64N/A

            \[\leadsto \frac{\mathsf{fma}\left(-1, \frac{-\log x}{n \cdot n}, \frac{1}{n}\right)}{x} \]
          9. lift-/.f6465.7

            \[\leadsto \frac{\mathsf{fma}\left(-1, \frac{-\log x}{n \cdot n}, \frac{1}{n}\right)}{x} \]
        6. Applied rewrites65.7%

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

        if 8.49999999999999971e245 < x

        1. Initial program 93.6%

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

          \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
        3. Step-by-step derivation
          1. lower-/.f64N/A

            \[\leadsto \frac{\log \left(1 + x\right) - \log x}{\color{blue}{n}} \]
          2. lower--.f64N/A

            \[\leadsto \frac{\log \left(1 + x\right) - \log x}{n} \]
          3. +-commutativeN/A

            \[\leadsto \frac{\log \left(x + 1\right) - \log x}{n} \]
          4. lower-log.f64N/A

            \[\leadsto \frac{\log \left(x + 1\right) - \log x}{n} \]
          5. +-commutativeN/A

            \[\leadsto \frac{\log \left(1 + x\right) - \log x}{n} \]
          6. lower-+.f64N/A

            \[\leadsto \frac{\log \left(1 + x\right) - \log x}{n} \]
          7. lower-log.f6493.6

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

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

      Alternative 3: 78.0% accurate, 1.5× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\log x}{n}\\ \mathbf{if}\;x \leq 1:\\ \;\;\;\;-\mathsf{expm1}\left(t\_0\right)\\ \mathbf{elif}\;x \leq 10^{+49}:\\ \;\;\;\;1 - 1\\ \mathbf{elif}\;x \leq 8.5 \cdot 10^{+245}:\\ \;\;\;\;\frac{t\_0 + 1}{n \cdot x}\\ \mathbf{else}:\\ \;\;\;\;1 - 1\\ \end{array} \end{array} \]
      (FPCore (x n)
       :precision binary64
       (let* ((t_0 (/ (log x) n)))
         (if (<= x 1.0)
           (- (expm1 t_0))
           (if (<= x 1e+49)
             (- 1.0 1.0)
             (if (<= x 8.5e+245) (/ (+ t_0 1.0) (* n x)) (- 1.0 1.0))))))
      double code(double x, double n) {
      	double t_0 = log(x) / n;
      	double tmp;
      	if (x <= 1.0) {
      		tmp = -expm1(t_0);
      	} else if (x <= 1e+49) {
      		tmp = 1.0 - 1.0;
      	} else if (x <= 8.5e+245) {
      		tmp = (t_0 + 1.0) / (n * x);
      	} else {
      		tmp = 1.0 - 1.0;
      	}
      	return tmp;
      }
      
      public static double code(double x, double n) {
      	double t_0 = Math.log(x) / n;
      	double tmp;
      	if (x <= 1.0) {
      		tmp = -Math.expm1(t_0);
      	} else if (x <= 1e+49) {
      		tmp = 1.0 - 1.0;
      	} else if (x <= 8.5e+245) {
      		tmp = (t_0 + 1.0) / (n * x);
      	} else {
      		tmp = 1.0 - 1.0;
      	}
      	return tmp;
      }
      
      def code(x, n):
      	t_0 = math.log(x) / n
      	tmp = 0
      	if x <= 1.0:
      		tmp = -math.expm1(t_0)
      	elif x <= 1e+49:
      		tmp = 1.0 - 1.0
      	elif x <= 8.5e+245:
      		tmp = (t_0 + 1.0) / (n * x)
      	else:
      		tmp = 1.0 - 1.0
      	return tmp
      
      function code(x, n)
      	t_0 = Float64(log(x) / n)
      	tmp = 0.0
      	if (x <= 1.0)
      		tmp = Float64(-expm1(t_0));
      	elseif (x <= 1e+49)
      		tmp = Float64(1.0 - 1.0);
      	elseif (x <= 8.5e+245)
      		tmp = Float64(Float64(t_0 + 1.0) / Float64(n * x));
      	else
      		tmp = Float64(1.0 - 1.0);
      	end
      	return tmp
      end
      
      code[x_, n_] := Block[{t$95$0 = N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[x, 1.0], (-N[(Exp[t$95$0] - 1), $MachinePrecision]), If[LessEqual[x, 1e+49], N[(1.0 - 1.0), $MachinePrecision], If[LessEqual[x, 8.5e+245], N[(N[(t$95$0 + 1.0), $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], N[(1.0 - 1.0), $MachinePrecision]]]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := \frac{\log x}{n}\\
      \mathbf{if}\;x \leq 1:\\
      \;\;\;\;-\mathsf{expm1}\left(t\_0\right)\\
      
      \mathbf{elif}\;x \leq 10^{+49}:\\
      \;\;\;\;1 - 1\\
      
      \mathbf{elif}\;x \leq 8.5 \cdot 10^{+245}:\\
      \;\;\;\;\frac{t\_0 + 1}{n \cdot x}\\
      
      \mathbf{else}:\\
      \;\;\;\;1 - 1\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if x < 1

        1. Initial program 43.6%

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

          \[\leadsto \color{blue}{1 - e^{\frac{\log x}{n}}} \]
        3. Step-by-step derivation
          1. negate-sub2N/A

            \[\leadsto \mathsf{neg}\left(\left(e^{\frac{\log x}{n}} - 1\right)\right) \]
          2. lower-neg.f64N/A

            \[\leadsto -\left(e^{\frac{\log x}{n}} - 1\right) \]
          3. lower-expm1.f64N/A

            \[\leadsto -\mathsf{expm1}\left(\frac{\log x}{n}\right) \]
          4. lower-/.f64N/A

            \[\leadsto -\mathsf{expm1}\left(\frac{\log x}{n}\right) \]
          5. lower-log.f6486.5

            \[\leadsto -\mathsf{expm1}\left(\frac{\log x}{n}\right) \]
        4. Applied rewrites86.5%

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

        if 1 < x < 9.99999999999999946e48 or 8.49999999999999971e245 < x

        1. Initial program 69.6%

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

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

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

            \[\leadsto \color{blue}{1} - 1 \]
          3. Step-by-step derivation
            1. Applied rewrites69.6%

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

            if 9.99999999999999946e48 < x < 8.49999999999999971e245

            1. Initial program 68.5%

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

              \[\leadsto \color{blue}{\frac{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}}}{n \cdot x}} \]
            3. Step-by-step derivation
              1. lower-/.f64N/A

                \[\leadsto \frac{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}}}{\color{blue}{n \cdot x}} \]
              2. lower-exp.f64N/A

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

                \[\leadsto \frac{e^{\mathsf{neg}\left(\frac{\log \left(\frac{1}{x}\right)}{n}\right)}}{n \cdot x} \]
              4. log-recN/A

                \[\leadsto \frac{e^{\mathsf{neg}\left(\frac{\mathsf{neg}\left(\log x\right)}{n}\right)}}{n \cdot x} \]
              5. mul-1-negN/A

                \[\leadsto \frac{e^{\mathsf{neg}\left(\frac{-1 \cdot \log x}{n}\right)}}{n \cdot x} \]
              6. lower-neg.f64N/A

                \[\leadsto \frac{e^{-\frac{-1 \cdot \log x}{n}}}{n \cdot x} \]
              7. lower-/.f64N/A

                \[\leadsto \frac{e^{-\frac{-1 \cdot \log x}{n}}}{n \cdot x} \]
              8. mul-1-negN/A

                \[\leadsto \frac{e^{-\frac{\mathsf{neg}\left(\log x\right)}{n}}}{n \cdot x} \]
              9. lower-neg.f64N/A

                \[\leadsto \frac{e^{-\frac{-\log x}{n}}}{n \cdot x} \]
              10. lower-log.f64N/A

                \[\leadsto \frac{e^{-\frac{-\log x}{n}}}{n \cdot x} \]
              11. lower-*.f6498.6

                \[\leadsto \frac{e^{-\frac{-\log x}{n}}}{n \cdot \color{blue}{x}} \]
            4. Applied rewrites98.6%

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

              \[\leadsto \frac{1 + \frac{\log x}{n}}{\color{blue}{n} \cdot x} \]
            6. Step-by-step derivation
              1. +-commutativeN/A

                \[\leadsto \frac{\frac{\log x}{n} + 1}{n \cdot x} \]
              2. lower-+.f64N/A

                \[\leadsto \frac{\frac{\log x}{n} + 1}{n \cdot x} \]
              3. lower-/.f64N/A

                \[\leadsto \frac{\frac{\log x}{n} + 1}{n \cdot x} \]
              4. lift-log.f6464.5

                \[\leadsto \frac{\frac{\log x}{n} + 1}{n \cdot x} \]
            7. Applied rewrites64.5%

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

          Alternative 4: 77.8% accurate, 1.4× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\log x}{n}\\ \mathbf{if}\;x \leq 1:\\ \;\;\;\;-\mathsf{expm1}\left(t\_0\right)\\ \mathbf{elif}\;x \leq 10^{+49}:\\ \;\;\;\;1 - 1\\ \mathbf{elif}\;x \leq 8.5 \cdot 10^{+245}:\\ \;\;\;\;\frac{t\_0 + 1}{n \cdot x}\\ \mathbf{else}:\\ \;\;\;\;\frac{\log \left(1 + x\right) - \log x}{n}\\ \end{array} \end{array} \]
          (FPCore (x n)
           :precision binary64
           (let* ((t_0 (/ (log x) n)))
             (if (<= x 1.0)
               (- (expm1 t_0))
               (if (<= x 1e+49)
                 (- 1.0 1.0)
                 (if (<= x 8.5e+245)
                   (/ (+ t_0 1.0) (* n x))
                   (/ (- (log (+ 1.0 x)) (log x)) n))))))
          double code(double x, double n) {
          	double t_0 = log(x) / n;
          	double tmp;
          	if (x <= 1.0) {
          		tmp = -expm1(t_0);
          	} else if (x <= 1e+49) {
          		tmp = 1.0 - 1.0;
          	} else if (x <= 8.5e+245) {
          		tmp = (t_0 + 1.0) / (n * x);
          	} else {
          		tmp = (log((1.0 + x)) - log(x)) / n;
          	}
          	return tmp;
          }
          
          public static double code(double x, double n) {
          	double t_0 = Math.log(x) / n;
          	double tmp;
          	if (x <= 1.0) {
          		tmp = -Math.expm1(t_0);
          	} else if (x <= 1e+49) {
          		tmp = 1.0 - 1.0;
          	} else if (x <= 8.5e+245) {
          		tmp = (t_0 + 1.0) / (n * x);
          	} else {
          		tmp = (Math.log((1.0 + x)) - Math.log(x)) / n;
          	}
          	return tmp;
          }
          
          def code(x, n):
          	t_0 = math.log(x) / n
          	tmp = 0
          	if x <= 1.0:
          		tmp = -math.expm1(t_0)
          	elif x <= 1e+49:
          		tmp = 1.0 - 1.0
          	elif x <= 8.5e+245:
          		tmp = (t_0 + 1.0) / (n * x)
          	else:
          		tmp = (math.log((1.0 + x)) - math.log(x)) / n
          	return tmp
          
          function code(x, n)
          	t_0 = Float64(log(x) / n)
          	tmp = 0.0
          	if (x <= 1.0)
          		tmp = Float64(-expm1(t_0));
          	elseif (x <= 1e+49)
          		tmp = Float64(1.0 - 1.0);
          	elseif (x <= 8.5e+245)
          		tmp = Float64(Float64(t_0 + 1.0) / Float64(n * x));
          	else
          		tmp = Float64(Float64(log(Float64(1.0 + x)) - log(x)) / n);
          	end
          	return tmp
          end
          
          code[x_, n_] := Block[{t$95$0 = N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[x, 1.0], (-N[(Exp[t$95$0] - 1), $MachinePrecision]), If[LessEqual[x, 1e+49], N[(1.0 - 1.0), $MachinePrecision], If[LessEqual[x, 8.5e+245], N[(N[(t$95$0 + 1.0), $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], N[(N[(N[Log[N[(1.0 + x), $MachinePrecision]], $MachinePrecision] - N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]]]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_0 := \frac{\log x}{n}\\
          \mathbf{if}\;x \leq 1:\\
          \;\;\;\;-\mathsf{expm1}\left(t\_0\right)\\
          
          \mathbf{elif}\;x \leq 10^{+49}:\\
          \;\;\;\;1 - 1\\
          
          \mathbf{elif}\;x \leq 8.5 \cdot 10^{+245}:\\
          \;\;\;\;\frac{t\_0 + 1}{n \cdot x}\\
          
          \mathbf{else}:\\
          \;\;\;\;\frac{\log \left(1 + x\right) - \log x}{n}\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 4 regimes
          2. if x < 1

            1. Initial program 43.6%

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

              \[\leadsto \color{blue}{1 - e^{\frac{\log x}{n}}} \]
            3. Step-by-step derivation
              1. negate-sub2N/A

                \[\leadsto \mathsf{neg}\left(\left(e^{\frac{\log x}{n}} - 1\right)\right) \]
              2. lower-neg.f64N/A

                \[\leadsto -\left(e^{\frac{\log x}{n}} - 1\right) \]
              3. lower-expm1.f64N/A

                \[\leadsto -\mathsf{expm1}\left(\frac{\log x}{n}\right) \]
              4. lower-/.f64N/A

                \[\leadsto -\mathsf{expm1}\left(\frac{\log x}{n}\right) \]
              5. lower-log.f6486.5

                \[\leadsto -\mathsf{expm1}\left(\frac{\log x}{n}\right) \]
            4. Applied rewrites86.5%

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

            if 1 < x < 9.99999999999999946e48

            1. Initial program 42.3%

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

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

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

                \[\leadsto \color{blue}{1} - 1 \]
              3. Step-by-step derivation
                1. Applied rewrites42.2%

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

                if 9.99999999999999946e48 < x < 8.49999999999999971e245

                1. Initial program 68.5%

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

                  \[\leadsto \color{blue}{\frac{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}}}{n \cdot x}} \]
                3. Step-by-step derivation
                  1. lower-/.f64N/A

                    \[\leadsto \frac{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}}}{\color{blue}{n \cdot x}} \]
                  2. lower-exp.f64N/A

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

                    \[\leadsto \frac{e^{\mathsf{neg}\left(\frac{\log \left(\frac{1}{x}\right)}{n}\right)}}{n \cdot x} \]
                  4. log-recN/A

                    \[\leadsto \frac{e^{\mathsf{neg}\left(\frac{\mathsf{neg}\left(\log x\right)}{n}\right)}}{n \cdot x} \]
                  5. mul-1-negN/A

                    \[\leadsto \frac{e^{\mathsf{neg}\left(\frac{-1 \cdot \log x}{n}\right)}}{n \cdot x} \]
                  6. lower-neg.f64N/A

                    \[\leadsto \frac{e^{-\frac{-1 \cdot \log x}{n}}}{n \cdot x} \]
                  7. lower-/.f64N/A

                    \[\leadsto \frac{e^{-\frac{-1 \cdot \log x}{n}}}{n \cdot x} \]
                  8. mul-1-negN/A

                    \[\leadsto \frac{e^{-\frac{\mathsf{neg}\left(\log x\right)}{n}}}{n \cdot x} \]
                  9. lower-neg.f64N/A

                    \[\leadsto \frac{e^{-\frac{-\log x}{n}}}{n \cdot x} \]
                  10. lower-log.f64N/A

                    \[\leadsto \frac{e^{-\frac{-\log x}{n}}}{n \cdot x} \]
                  11. lower-*.f6498.6

                    \[\leadsto \frac{e^{-\frac{-\log x}{n}}}{n \cdot \color{blue}{x}} \]
                4. Applied rewrites98.6%

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

                  \[\leadsto \frac{1 + \frac{\log x}{n}}{\color{blue}{n} \cdot x} \]
                6. Step-by-step derivation
                  1. +-commutativeN/A

                    \[\leadsto \frac{\frac{\log x}{n} + 1}{n \cdot x} \]
                  2. lower-+.f64N/A

                    \[\leadsto \frac{\frac{\log x}{n} + 1}{n \cdot x} \]
                  3. lower-/.f64N/A

                    \[\leadsto \frac{\frac{\log x}{n} + 1}{n \cdot x} \]
                  4. lift-log.f6464.5

                    \[\leadsto \frac{\frac{\log x}{n} + 1}{n \cdot x} \]
                7. Applied rewrites64.5%

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

                if 8.49999999999999971e245 < x

                1. Initial program 93.6%

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

                  \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
                3. Step-by-step derivation
                  1. lower-/.f64N/A

                    \[\leadsto \frac{\log \left(1 + x\right) - \log x}{\color{blue}{n}} \]
                  2. lower--.f64N/A

                    \[\leadsto \frac{\log \left(1 + x\right) - \log x}{n} \]
                  3. +-commutativeN/A

                    \[\leadsto \frac{\log \left(x + 1\right) - \log x}{n} \]
                  4. lower-log.f64N/A

                    \[\leadsto \frac{\log \left(x + 1\right) - \log x}{n} \]
                  5. +-commutativeN/A

                    \[\leadsto \frac{\log \left(1 + x\right) - \log x}{n} \]
                  6. lower-+.f64N/A

                    \[\leadsto \frac{\log \left(1 + x\right) - \log x}{n} \]
                  7. lower-log.f6493.6

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

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

              Alternative 5: 77.8% accurate, 2.1× speedup?

              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 1:\\ \;\;\;\;-\mathsf{expm1}\left(\frac{\log x}{n}\right)\\ \mathbf{elif}\;x \leq 10^{+49}:\\ \;\;\;\;1 - 1\\ \mathbf{elif}\;x \leq 8.5 \cdot 10^{+245}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \mathbf{else}:\\ \;\;\;\;1 - 1\\ \end{array} \end{array} \]
              (FPCore (x n)
               :precision binary64
               (if (<= x 1.0)
                 (- (expm1 (/ (log x) n)))
                 (if (<= x 1e+49)
                   (- 1.0 1.0)
                   (if (<= x 8.5e+245) (/ (/ 1.0 n) x) (- 1.0 1.0)))))
              double code(double x, double n) {
              	double tmp;
              	if (x <= 1.0) {
              		tmp = -expm1((log(x) / n));
              	} else if (x <= 1e+49) {
              		tmp = 1.0 - 1.0;
              	} else if (x <= 8.5e+245) {
              		tmp = (1.0 / n) / x;
              	} else {
              		tmp = 1.0 - 1.0;
              	}
              	return tmp;
              }
              
              public static double code(double x, double n) {
              	double tmp;
              	if (x <= 1.0) {
              		tmp = -Math.expm1((Math.log(x) / n));
              	} else if (x <= 1e+49) {
              		tmp = 1.0 - 1.0;
              	} else if (x <= 8.5e+245) {
              		tmp = (1.0 / n) / x;
              	} else {
              		tmp = 1.0 - 1.0;
              	}
              	return tmp;
              }
              
              def code(x, n):
              	tmp = 0
              	if x <= 1.0:
              		tmp = -math.expm1((math.log(x) / n))
              	elif x <= 1e+49:
              		tmp = 1.0 - 1.0
              	elif x <= 8.5e+245:
              		tmp = (1.0 / n) / x
              	else:
              		tmp = 1.0 - 1.0
              	return tmp
              
              function code(x, n)
              	tmp = 0.0
              	if (x <= 1.0)
              		tmp = Float64(-expm1(Float64(log(x) / n)));
              	elseif (x <= 1e+49)
              		tmp = Float64(1.0 - 1.0);
              	elseif (x <= 8.5e+245)
              		tmp = Float64(Float64(1.0 / n) / x);
              	else
              		tmp = Float64(1.0 - 1.0);
              	end
              	return tmp
              end
              
              code[x_, n_] := If[LessEqual[x, 1.0], (-N[(Exp[N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]] - 1), $MachinePrecision]), If[LessEqual[x, 1e+49], N[(1.0 - 1.0), $MachinePrecision], If[LessEqual[x, 8.5e+245], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], N[(1.0 - 1.0), $MachinePrecision]]]]
              
              \begin{array}{l}
              
              \\
              \begin{array}{l}
              \mathbf{if}\;x \leq 1:\\
              \;\;\;\;-\mathsf{expm1}\left(\frac{\log x}{n}\right)\\
              
              \mathbf{elif}\;x \leq 10^{+49}:\\
              \;\;\;\;1 - 1\\
              
              \mathbf{elif}\;x \leq 8.5 \cdot 10^{+245}:\\
              \;\;\;\;\frac{\frac{1}{n}}{x}\\
              
              \mathbf{else}:\\
              \;\;\;\;1 - 1\\
              
              
              \end{array}
              \end{array}
              
              Derivation
              1. Split input into 3 regimes
              2. if x < 1

                1. Initial program 43.6%

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

                  \[\leadsto \color{blue}{1 - e^{\frac{\log x}{n}}} \]
                3. Step-by-step derivation
                  1. negate-sub2N/A

                    \[\leadsto \mathsf{neg}\left(\left(e^{\frac{\log x}{n}} - 1\right)\right) \]
                  2. lower-neg.f64N/A

                    \[\leadsto -\left(e^{\frac{\log x}{n}} - 1\right) \]
                  3. lower-expm1.f64N/A

                    \[\leadsto -\mathsf{expm1}\left(\frac{\log x}{n}\right) \]
                  4. lower-/.f64N/A

                    \[\leadsto -\mathsf{expm1}\left(\frac{\log x}{n}\right) \]
                  5. lower-log.f6486.5

                    \[\leadsto -\mathsf{expm1}\left(\frac{\log x}{n}\right) \]
                4. Applied rewrites86.5%

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

                if 1 < x < 9.99999999999999946e48 or 8.49999999999999971e245 < x

                1. Initial program 69.6%

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

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

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

                    \[\leadsto \color{blue}{1} - 1 \]
                  3. Step-by-step derivation
                    1. Applied rewrites69.6%

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

                    if 9.99999999999999946e48 < x < 8.49999999999999971e245

                    1. Initial program 68.5%

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

                      \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
                    3. Step-by-step derivation
                      1. lower-/.f64N/A

                        \[\leadsto \frac{\log \left(1 + x\right) - \log x}{\color{blue}{n}} \]
                      2. lower--.f64N/A

                        \[\leadsto \frac{\log \left(1 + x\right) - \log x}{n} \]
                      3. +-commutativeN/A

                        \[\leadsto \frac{\log \left(x + 1\right) - \log x}{n} \]
                      4. lower-log.f64N/A

                        \[\leadsto \frac{\log \left(x + 1\right) - \log x}{n} \]
                      5. +-commutativeN/A

                        \[\leadsto \frac{\log \left(1 + x\right) - \log x}{n} \]
                      6. lower-+.f64N/A

                        \[\leadsto \frac{\log \left(1 + x\right) - \log x}{n} \]
                      7. lower-log.f6468.5

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

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

                      \[\leadsto \frac{1}{\color{blue}{n \cdot x}} \]
                    6. Step-by-step derivation
                      1. lower-/.f64N/A

                        \[\leadsto \frac{1}{n \cdot \color{blue}{x}} \]
                      2. lift-*.f6464.0

                        \[\leadsto \frac{1}{n \cdot x} \]
                    7. Applied rewrites64.0%

                      \[\leadsto \frac{1}{\color{blue}{n \cdot x}} \]
                    8. Step-by-step derivation
                      1. lift-*.f64N/A

                        \[\leadsto \frac{1}{n \cdot x} \]
                      2. lift-/.f64N/A

                        \[\leadsto \frac{1}{n \cdot \color{blue}{x}} \]
                      3. associate-/r*N/A

                        \[\leadsto \frac{\frac{1}{n}}{x} \]
                      4. lower-/.f64N/A

                        \[\leadsto \frac{\frac{1}{n}}{x} \]
                      5. lower-/.f6465.3

                        \[\leadsto \frac{\frac{1}{n}}{x} \]
                    9. Applied rewrites65.3%

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

                  Alternative 6: 58.0% accurate, 2.1× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 2.7:\\ \;\;\;\;\left(-\frac{\log x}{n}\right) + \frac{x}{n}\\ \mathbf{elif}\;x \leq 10^{+49}:\\ \;\;\;\;1 - 1\\ \mathbf{elif}\;x \leq 8.5 \cdot 10^{+245}:\\ \;\;\;\;\frac{\frac{1}{n}}{x}\\ \mathbf{else}:\\ \;\;\;\;1 - 1\\ \end{array} \end{array} \]
                  (FPCore (x n)
                   :precision binary64
                   (if (<= x 2.7)
                     (+ (- (/ (log x) n)) (/ x n))
                     (if (<= x 1e+49)
                       (- 1.0 1.0)
                       (if (<= x 8.5e+245) (/ (/ 1.0 n) x) (- 1.0 1.0)))))
                  double code(double x, double n) {
                  	double tmp;
                  	if (x <= 2.7) {
                  		tmp = -(log(x) / n) + (x / n);
                  	} else if (x <= 1e+49) {
                  		tmp = 1.0 - 1.0;
                  	} else if (x <= 8.5e+245) {
                  		tmp = (1.0 / n) / x;
                  	} 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 <= 2.7d0) then
                          tmp = -(log(x) / n) + (x / n)
                      else if (x <= 1d+49) then
                          tmp = 1.0d0 - 1.0d0
                      else if (x <= 8.5d+245) then
                          tmp = (1.0d0 / n) / x
                      else
                          tmp = 1.0d0 - 1.0d0
                      end if
                      code = tmp
                  end function
                  
                  public static double code(double x, double n) {
                  	double tmp;
                  	if (x <= 2.7) {
                  		tmp = -(Math.log(x) / n) + (x / n);
                  	} else if (x <= 1e+49) {
                  		tmp = 1.0 - 1.0;
                  	} else if (x <= 8.5e+245) {
                  		tmp = (1.0 / n) / x;
                  	} else {
                  		tmp = 1.0 - 1.0;
                  	}
                  	return tmp;
                  }
                  
                  def code(x, n):
                  	tmp = 0
                  	if x <= 2.7:
                  		tmp = -(math.log(x) / n) + (x / n)
                  	elif x <= 1e+49:
                  		tmp = 1.0 - 1.0
                  	elif x <= 8.5e+245:
                  		tmp = (1.0 / n) / x
                  	else:
                  		tmp = 1.0 - 1.0
                  	return tmp
                  
                  function code(x, n)
                  	tmp = 0.0
                  	if (x <= 2.7)
                  		tmp = Float64(Float64(-Float64(log(x) / n)) + Float64(x / n));
                  	elseif (x <= 1e+49)
                  		tmp = Float64(1.0 - 1.0);
                  	elseif (x <= 8.5e+245)
                  		tmp = Float64(Float64(1.0 / n) / x);
                  	else
                  		tmp = Float64(1.0 - 1.0);
                  	end
                  	return tmp
                  end
                  
                  function tmp_2 = code(x, n)
                  	tmp = 0.0;
                  	if (x <= 2.7)
                  		tmp = -(log(x) / n) + (x / n);
                  	elseif (x <= 1e+49)
                  		tmp = 1.0 - 1.0;
                  	elseif (x <= 8.5e+245)
                  		tmp = (1.0 / n) / x;
                  	else
                  		tmp = 1.0 - 1.0;
                  	end
                  	tmp_2 = tmp;
                  end
                  
                  code[x_, n_] := If[LessEqual[x, 2.7], N[((-N[(N[Log[x], $MachinePrecision] / n), $MachinePrecision]) + N[(x / n), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1e+49], N[(1.0 - 1.0), $MachinePrecision], If[LessEqual[x, 8.5e+245], N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision], N[(1.0 - 1.0), $MachinePrecision]]]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  \mathbf{if}\;x \leq 2.7:\\
                  \;\;\;\;\left(-\frac{\log x}{n}\right) + \frac{x}{n}\\
                  
                  \mathbf{elif}\;x \leq 10^{+49}:\\
                  \;\;\;\;1 - 1\\
                  
                  \mathbf{elif}\;x \leq 8.5 \cdot 10^{+245}:\\
                  \;\;\;\;\frac{\frac{1}{n}}{x}\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;1 - 1\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 3 regimes
                  2. if x < 2.7000000000000002

                    1. Initial program 43.5%

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

                      \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
                    3. Step-by-step derivation
                      1. lower-/.f64N/A

                        \[\leadsto \frac{\log \left(1 + x\right) - \log x}{\color{blue}{n}} \]
                      2. lower--.f64N/A

                        \[\leadsto \frac{\log \left(1 + x\right) - \log x}{n} \]
                      3. +-commutativeN/A

                        \[\leadsto \frac{\log \left(x + 1\right) - \log x}{n} \]
                      4. lower-log.f64N/A

                        \[\leadsto \frac{\log \left(x + 1\right) - \log x}{n} \]
                      5. +-commutativeN/A

                        \[\leadsto \frac{\log \left(1 + x\right) - \log x}{n} \]
                      6. lower-+.f64N/A

                        \[\leadsto \frac{\log \left(1 + x\right) - \log x}{n} \]
                      7. lower-log.f6451.8

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

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

                      \[\leadsto -1 \cdot \frac{\log x}{n} + \color{blue}{\frac{x}{n}} \]
                    6. Step-by-step derivation
                      1. lower-+.f64N/A

                        \[\leadsto -1 \cdot \frac{\log x}{n} + \frac{x}{\color{blue}{n}} \]
                      2. mul-1-negN/A

                        \[\leadsto \left(\mathsf{neg}\left(\frac{\log x}{n}\right)\right) + \frac{x}{n} \]
                      3. lower-neg.f64N/A

                        \[\leadsto \left(-\frac{\log x}{n}\right) + \frac{x}{n} \]
                      4. lower-/.f64N/A

                        \[\leadsto \left(-\frac{\log x}{n}\right) + \frac{x}{n} \]
                      5. lift-log.f64N/A

                        \[\leadsto \left(-\frac{\log x}{n}\right) + \frac{x}{n} \]
                      6. lower-/.f6451.2

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

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

                    if 2.7000000000000002 < x < 9.99999999999999946e48 or 8.49999999999999971e245 < x

                    1. Initial program 69.9%

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

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

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

                        \[\leadsto \color{blue}{1} - 1 \]
                      3. Step-by-step derivation
                        1. Applied rewrites69.9%

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

                        if 9.99999999999999946e48 < x < 8.49999999999999971e245

                        1. Initial program 68.5%

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

                          \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
                        3. Step-by-step derivation
                          1. lower-/.f64N/A

                            \[\leadsto \frac{\log \left(1 + x\right) - \log x}{\color{blue}{n}} \]
                          2. lower--.f64N/A

                            \[\leadsto \frac{\log \left(1 + x\right) - \log x}{n} \]
                          3. +-commutativeN/A

                            \[\leadsto \frac{\log \left(x + 1\right) - \log x}{n} \]
                          4. lower-log.f64N/A

                            \[\leadsto \frac{\log \left(x + 1\right) - \log x}{n} \]
                          5. +-commutativeN/A

                            \[\leadsto \frac{\log \left(1 + x\right) - \log x}{n} \]
                          6. lower-+.f64N/A

                            \[\leadsto \frac{\log \left(1 + x\right) - \log x}{n} \]
                          7. lower-log.f6468.5

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

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

                          \[\leadsto \frac{1}{\color{blue}{n \cdot x}} \]
                        6. Step-by-step derivation
                          1. lower-/.f64N/A

                            \[\leadsto \frac{1}{n \cdot \color{blue}{x}} \]
                          2. lift-*.f6464.0

                            \[\leadsto \frac{1}{n \cdot x} \]
                        7. Applied rewrites64.0%

                          \[\leadsto \frac{1}{\color{blue}{n \cdot x}} \]
                        8. Step-by-step derivation
                          1. lift-*.f64N/A

                            \[\leadsto \frac{1}{n \cdot x} \]
                          2. lift-/.f64N/A

                            \[\leadsto \frac{1}{n \cdot \color{blue}{x}} \]
                          3. associate-/r*N/A

                            \[\leadsto \frac{\frac{1}{n}}{x} \]
                          4. lower-/.f64N/A

                            \[\leadsto \frac{\frac{1}{n}}{x} \]
                          5. lower-/.f6465.3

                            \[\leadsto \frac{\frac{1}{n}}{x} \]
                        9. Applied rewrites65.3%

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

                      Alternative 7: 58.0% accurate, 2.3× speedup?

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

                        1. Initial program 43.5%

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

                          \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
                        3. Step-by-step derivation
                          1. lower-/.f64N/A

                            \[\leadsto \frac{\log \left(1 + x\right) - \log x}{\color{blue}{n}} \]
                          2. lower--.f64N/A

                            \[\leadsto \frac{\log \left(1 + x\right) - \log x}{n} \]
                          3. +-commutativeN/A

                            \[\leadsto \frac{\log \left(x + 1\right) - \log x}{n} \]
                          4. lower-log.f64N/A

                            \[\leadsto \frac{\log \left(x + 1\right) - \log x}{n} \]
                          5. +-commutativeN/A

                            \[\leadsto \frac{\log \left(1 + x\right) - \log x}{n} \]
                          6. lower-+.f64N/A

                            \[\leadsto \frac{\log \left(1 + x\right) - \log x}{n} \]
                          7. lower-log.f6451.8

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

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

                          \[\leadsto \frac{x - \log x}{n} \]
                        6. Step-by-step derivation
                          1. Applied rewrites51.2%

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

                          if 2.7000000000000002 < x < 9.99999999999999946e48 or 8.49999999999999971e245 < x

                          1. Initial program 69.9%

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

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

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

                              \[\leadsto \color{blue}{1} - 1 \]
                            3. Step-by-step derivation
                              1. Applied rewrites69.9%

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

                              if 9.99999999999999946e48 < x < 8.49999999999999971e245

                              1. Initial program 68.5%

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

                                \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
                              3. Step-by-step derivation
                                1. lower-/.f64N/A

                                  \[\leadsto \frac{\log \left(1 + x\right) - \log x}{\color{blue}{n}} \]
                                2. lower--.f64N/A

                                  \[\leadsto \frac{\log \left(1 + x\right) - \log x}{n} \]
                                3. +-commutativeN/A

                                  \[\leadsto \frac{\log \left(x + 1\right) - \log x}{n} \]
                                4. lower-log.f64N/A

                                  \[\leadsto \frac{\log \left(x + 1\right) - \log x}{n} \]
                                5. +-commutativeN/A

                                  \[\leadsto \frac{\log \left(1 + x\right) - \log x}{n} \]
                                6. lower-+.f64N/A

                                  \[\leadsto \frac{\log \left(1 + x\right) - \log x}{n} \]
                                7. lower-log.f6468.5

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

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

                                \[\leadsto \frac{1}{\color{blue}{n \cdot x}} \]
                              6. Step-by-step derivation
                                1. lower-/.f64N/A

                                  \[\leadsto \frac{1}{n \cdot \color{blue}{x}} \]
                                2. lift-*.f6464.0

                                  \[\leadsto \frac{1}{n \cdot x} \]
                              7. Applied rewrites64.0%

                                \[\leadsto \frac{1}{\color{blue}{n \cdot x}} \]
                              8. Step-by-step derivation
                                1. lift-*.f64N/A

                                  \[\leadsto \frac{1}{n \cdot x} \]
                                2. lift-/.f64N/A

                                  \[\leadsto \frac{1}{n \cdot \color{blue}{x}} \]
                                3. associate-/r*N/A

                                  \[\leadsto \frac{\frac{1}{n}}{x} \]
                                4. lower-/.f64N/A

                                  \[\leadsto \frac{\frac{1}{n}}{x} \]
                                5. lower-/.f6465.3

                                  \[\leadsto \frac{\frac{1}{n}}{x} \]
                              9. Applied rewrites65.3%

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

                            Alternative 8: 57.8% accurate, 2.3× speedup?

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

                              1. Initial program 43.6%

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

                                \[\leadsto \color{blue}{1 - e^{\frac{\log x}{n}}} \]
                              3. Step-by-step derivation
                                1. negate-sub2N/A

                                  \[\leadsto \mathsf{neg}\left(\left(e^{\frac{\log x}{n}} - 1\right)\right) \]
                                2. lower-neg.f64N/A

                                  \[\leadsto -\left(e^{\frac{\log x}{n}} - 1\right) \]
                                3. lower-expm1.f64N/A

                                  \[\leadsto -\mathsf{expm1}\left(\frac{\log x}{n}\right) \]
                                4. lower-/.f64N/A

                                  \[\leadsto -\mathsf{expm1}\left(\frac{\log x}{n}\right) \]
                                5. lower-log.f6486.5

                                  \[\leadsto -\mathsf{expm1}\left(\frac{\log x}{n}\right) \]
                              4. Applied rewrites86.5%

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

                                \[\leadsto -\frac{\log x}{n} \]
                              6. Step-by-step derivation
                                1. lift-log.f64N/A

                                  \[\leadsto -\frac{\log x}{n} \]
                                2. lift-/.f6450.8

                                  \[\leadsto -\frac{\log x}{n} \]
                              7. Applied rewrites50.8%

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

                              if 1 < x < 9.99999999999999946e48 or 8.49999999999999971e245 < x

                              1. Initial program 69.6%

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

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

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

                                  \[\leadsto \color{blue}{1} - 1 \]
                                3. Step-by-step derivation
                                  1. Applied rewrites69.6%

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

                                  if 9.99999999999999946e48 < x < 8.49999999999999971e245

                                  1. Initial program 68.5%

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

                                    \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
                                  3. Step-by-step derivation
                                    1. lower-/.f64N/A

                                      \[\leadsto \frac{\log \left(1 + x\right) - \log x}{\color{blue}{n}} \]
                                    2. lower--.f64N/A

                                      \[\leadsto \frac{\log \left(1 + x\right) - \log x}{n} \]
                                    3. +-commutativeN/A

                                      \[\leadsto \frac{\log \left(x + 1\right) - \log x}{n} \]
                                    4. lower-log.f64N/A

                                      \[\leadsto \frac{\log \left(x + 1\right) - \log x}{n} \]
                                    5. +-commutativeN/A

                                      \[\leadsto \frac{\log \left(1 + x\right) - \log x}{n} \]
                                    6. lower-+.f64N/A

                                      \[\leadsto \frac{\log \left(1 + x\right) - \log x}{n} \]
                                    7. lower-log.f6468.5

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

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

                                    \[\leadsto \frac{1}{\color{blue}{n \cdot x}} \]
                                  6. Step-by-step derivation
                                    1. lower-/.f64N/A

                                      \[\leadsto \frac{1}{n \cdot \color{blue}{x}} \]
                                    2. lift-*.f6464.0

                                      \[\leadsto \frac{1}{n \cdot x} \]
                                  7. Applied rewrites64.0%

                                    \[\leadsto \frac{1}{\color{blue}{n \cdot x}} \]
                                  8. Step-by-step derivation
                                    1. lift-*.f64N/A

                                      \[\leadsto \frac{1}{n \cdot x} \]
                                    2. lift-/.f64N/A

                                      \[\leadsto \frac{1}{n \cdot \color{blue}{x}} \]
                                    3. associate-/r*N/A

                                      \[\leadsto \frac{\frac{1}{n}}{x} \]
                                    4. lower-/.f64N/A

                                      \[\leadsto \frac{\frac{1}{n}}{x} \]
                                    5. lower-/.f6465.3

                                      \[\leadsto \frac{\frac{1}{n}}{x} \]
                                  9. Applied rewrites65.3%

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

                                Alternative 9: 43.9% accurate, 2.9× speedup?

                                \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\frac{1}{n}}{x}\\ \mathbf{if}\;n \leq -5.4 \cdot 10^{-33}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;n \leq -1.45 \cdot 10^{-131}:\\ \;\;\;\;1 - 1\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
                                (FPCore (x n)
                                 :precision binary64
                                 (let* ((t_0 (/ (/ 1.0 n) x)))
                                   (if (<= n -5.4e-33) t_0 (if (<= n -1.45e-131) (- 1.0 1.0) t_0))))
                                double code(double x, double n) {
                                	double t_0 = (1.0 / n) / x;
                                	double tmp;
                                	if (n <= -5.4e-33) {
                                		tmp = t_0;
                                	} else if (n <= -1.45e-131) {
                                		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 / n) / x
                                    if (n <= (-5.4d-33)) then
                                        tmp = t_0
                                    else if (n <= (-1.45d-131)) 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 / n) / x;
                                	double tmp;
                                	if (n <= -5.4e-33) {
                                		tmp = t_0;
                                	} else if (n <= -1.45e-131) {
                                		tmp = 1.0 - 1.0;
                                	} else {
                                		tmp = t_0;
                                	}
                                	return tmp;
                                }
                                
                                def code(x, n):
                                	t_0 = (1.0 / n) / x
                                	tmp = 0
                                	if n <= -5.4e-33:
                                		tmp = t_0
                                	elif n <= -1.45e-131:
                                		tmp = 1.0 - 1.0
                                	else:
                                		tmp = t_0
                                	return tmp
                                
                                function code(x, n)
                                	t_0 = Float64(Float64(1.0 / n) / x)
                                	tmp = 0.0
                                	if (n <= -5.4e-33)
                                		tmp = t_0;
                                	elseif (n <= -1.45e-131)
                                		tmp = Float64(1.0 - 1.0);
                                	else
                                		tmp = t_0;
                                	end
                                	return tmp
                                end
                                
                                function tmp_2 = code(x, n)
                                	t_0 = (1.0 / n) / x;
                                	tmp = 0.0;
                                	if (n <= -5.4e-33)
                                		tmp = t_0;
                                	elseif (n <= -1.45e-131)
                                		tmp = 1.0 - 1.0;
                                	else
                                		tmp = t_0;
                                	end
                                	tmp_2 = tmp;
                                end
                                
                                code[x_, n_] := Block[{t$95$0 = N[(N[(1.0 / n), $MachinePrecision] / x), $MachinePrecision]}, If[LessEqual[n, -5.4e-33], t$95$0, If[LessEqual[n, -1.45e-131], N[(1.0 - 1.0), $MachinePrecision], t$95$0]]]
                                
                                \begin{array}{l}
                                
                                \\
                                \begin{array}{l}
                                t_0 := \frac{\frac{1}{n}}{x}\\
                                \mathbf{if}\;n \leq -5.4 \cdot 10^{-33}:\\
                                \;\;\;\;t\_0\\
                                
                                \mathbf{elif}\;n \leq -1.45 \cdot 10^{-131}:\\
                                \;\;\;\;1 - 1\\
                                
                                \mathbf{else}:\\
                                \;\;\;\;t\_0\\
                                
                                
                                \end{array}
                                \end{array}
                                
                                Derivation
                                1. Split input into 2 regimes
                                2. if n < -5.4000000000000002e-33 or -1.4500000000000001e-131 < n

                                  1. Initial program 49.9%

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

                                    \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
                                  3. Step-by-step derivation
                                    1. lower-/.f64N/A

                                      \[\leadsto \frac{\log \left(1 + x\right) - \log x}{\color{blue}{n}} \]
                                    2. lower--.f64N/A

                                      \[\leadsto \frac{\log \left(1 + x\right) - \log x}{n} \]
                                    3. +-commutativeN/A

                                      \[\leadsto \frac{\log \left(x + 1\right) - \log x}{n} \]
                                    4. lower-log.f64N/A

                                      \[\leadsto \frac{\log \left(x + 1\right) - \log x}{n} \]
                                    5. +-commutativeN/A

                                      \[\leadsto \frac{\log \left(1 + x\right) - \log x}{n} \]
                                    6. lower-+.f64N/A

                                      \[\leadsto \frac{\log \left(1 + x\right) - \log x}{n} \]
                                    7. lower-log.f6460.0

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

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

                                    \[\leadsto \frac{1}{\color{blue}{n \cdot x}} \]
                                  6. Step-by-step derivation
                                    1. lower-/.f64N/A

                                      \[\leadsto \frac{1}{n \cdot \color{blue}{x}} \]
                                    2. lift-*.f6442.5

                                      \[\leadsto \frac{1}{n \cdot x} \]
                                  7. Applied rewrites42.5%

                                    \[\leadsto \frac{1}{\color{blue}{n \cdot x}} \]
                                  8. Step-by-step derivation
                                    1. lift-*.f64N/A

                                      \[\leadsto \frac{1}{n \cdot x} \]
                                    2. lift-/.f64N/A

                                      \[\leadsto \frac{1}{n \cdot \color{blue}{x}} \]
                                    3. associate-/r*N/A

                                      \[\leadsto \frac{\frac{1}{n}}{x} \]
                                    4. lower-/.f64N/A

                                      \[\leadsto \frac{\frac{1}{n}}{x} \]
                                    5. lower-/.f6443.1

                                      \[\leadsto \frac{\frac{1}{n}}{x} \]
                                  9. Applied rewrites43.1%

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

                                  if -5.4000000000000002e-33 < n < -1.4500000000000001e-131

                                  1. Initial program 100.0%

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

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

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

                                      \[\leadsto \color{blue}{1} - 1 \]
                                    3. Step-by-step derivation
                                      1. Applied rewrites52.6%

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

                                    Alternative 10: 43.4% accurate, 3.0× speedup?

                                    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{1}{n \cdot x}\\ \mathbf{if}\;n \leq -5.4 \cdot 10^{-33}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;n \leq -1.45 \cdot 10^{-131}:\\ \;\;\;\;1 - 1\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
                                    (FPCore (x n)
                                     :precision binary64
                                     (let* ((t_0 (/ 1.0 (* n x))))
                                       (if (<= n -5.4e-33) t_0 (if (<= n -1.45e-131) (- 1.0 1.0) t_0))))
                                    double code(double x, double n) {
                                    	double t_0 = 1.0 / (n * x);
                                    	double tmp;
                                    	if (n <= -5.4e-33) {
                                    		tmp = t_0;
                                    	} else if (n <= -1.45e-131) {
                                    		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 / (n * x)
                                        if (n <= (-5.4d-33)) then
                                            tmp = t_0
                                        else if (n <= (-1.45d-131)) 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 / (n * x);
                                    	double tmp;
                                    	if (n <= -5.4e-33) {
                                    		tmp = t_0;
                                    	} else if (n <= -1.45e-131) {
                                    		tmp = 1.0 - 1.0;
                                    	} else {
                                    		tmp = t_0;
                                    	}
                                    	return tmp;
                                    }
                                    
                                    def code(x, n):
                                    	t_0 = 1.0 / (n * x)
                                    	tmp = 0
                                    	if n <= -5.4e-33:
                                    		tmp = t_0
                                    	elif n <= -1.45e-131:
                                    		tmp = 1.0 - 1.0
                                    	else:
                                    		tmp = t_0
                                    	return tmp
                                    
                                    function code(x, n)
                                    	t_0 = Float64(1.0 / Float64(n * x))
                                    	tmp = 0.0
                                    	if (n <= -5.4e-33)
                                    		tmp = t_0;
                                    	elseif (n <= -1.45e-131)
                                    		tmp = Float64(1.0 - 1.0);
                                    	else
                                    		tmp = t_0;
                                    	end
                                    	return tmp
                                    end
                                    
                                    function tmp_2 = code(x, n)
                                    	t_0 = 1.0 / (n * x);
                                    	tmp = 0.0;
                                    	if (n <= -5.4e-33)
                                    		tmp = t_0;
                                    	elseif (n <= -1.45e-131)
                                    		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[(n * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[n, -5.4e-33], t$95$0, If[LessEqual[n, -1.45e-131], N[(1.0 - 1.0), $MachinePrecision], t$95$0]]]
                                    
                                    \begin{array}{l}
                                    
                                    \\
                                    \begin{array}{l}
                                    t_0 := \frac{1}{n \cdot x}\\
                                    \mathbf{if}\;n \leq -5.4 \cdot 10^{-33}:\\
                                    \;\;\;\;t\_0\\
                                    
                                    \mathbf{elif}\;n \leq -1.45 \cdot 10^{-131}:\\
                                    \;\;\;\;1 - 1\\
                                    
                                    \mathbf{else}:\\
                                    \;\;\;\;t\_0\\
                                    
                                    
                                    \end{array}
                                    \end{array}
                                    
                                    Derivation
                                    1. Split input into 2 regimes
                                    2. if n < -5.4000000000000002e-33 or -1.4500000000000001e-131 < n

                                      1. Initial program 49.9%

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

                                        \[\leadsto \color{blue}{\frac{\log \left(1 + x\right) - \log x}{n}} \]
                                      3. Step-by-step derivation
                                        1. lower-/.f64N/A

                                          \[\leadsto \frac{\log \left(1 + x\right) - \log x}{\color{blue}{n}} \]
                                        2. lower--.f64N/A

                                          \[\leadsto \frac{\log \left(1 + x\right) - \log x}{n} \]
                                        3. +-commutativeN/A

                                          \[\leadsto \frac{\log \left(x + 1\right) - \log x}{n} \]
                                        4. lower-log.f64N/A

                                          \[\leadsto \frac{\log \left(x + 1\right) - \log x}{n} \]
                                        5. +-commutativeN/A

                                          \[\leadsto \frac{\log \left(1 + x\right) - \log x}{n} \]
                                        6. lower-+.f64N/A

                                          \[\leadsto \frac{\log \left(1 + x\right) - \log x}{n} \]
                                        7. lower-log.f6460.0

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

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

                                        \[\leadsto \frac{1}{\color{blue}{n \cdot x}} \]
                                      6. Step-by-step derivation
                                        1. lower-/.f64N/A

                                          \[\leadsto \frac{1}{n \cdot \color{blue}{x}} \]
                                        2. lift-*.f6442.5

                                          \[\leadsto \frac{1}{n \cdot x} \]
                                      7. Applied rewrites42.5%

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

                                      if -5.4000000000000002e-33 < n < -1.4500000000000001e-131

                                      1. Initial program 100.0%

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

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

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

                                          \[\leadsto \color{blue}{1} - 1 \]
                                        3. Step-by-step derivation
                                          1. Applied rewrites52.6%

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

                                        Alternative 11: 32.0% accurate, 12.4× 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 54.6%

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

                                          \[\leadsto {\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - \color{blue}{1} \]
                                        3. Step-by-step derivation
                                          1. Applied rewrites18.2%

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

                                            \[\leadsto \color{blue}{1} - 1 \]
                                          3. Step-by-step derivation
                                            1. Applied rewrites32.0%

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

                                            Reproduce

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