2nthrt (problem 3.4.6)

Percentage Accurate: 53.7% → 86.5%
Time: 27.6s
Alternatives: 5
Speedup: N/A×

Specification

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

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

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 5 alternatives:

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

Initial Program: 53.7% accurate, 1.0× speedup?

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

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

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

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

Alternative 1: 86.5% accurate, N/A× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq -110000 \lor \neg \left(n \leq 122000\right):\\ \;\;\;\;\frac{\mathsf{fma}\left(-1, \mathsf{log1p}\left(x\right), \frac{\mathsf{fma}\left(-1, \frac{\mathsf{fma}\left(-1, \frac{0.041666666666666664 \cdot {\left(\mathsf{log1p}\left(x\right)\right)}^{4}}{n} - \frac{0.041666666666666664 \cdot {\log x}^{4}}{n}, -0.16666666666666666 \cdot {\left(\mathsf{log1p}\left(x\right)\right)}^{3}\right) - -0.16666666666666666 \cdot {\log x}^{3}}{n}, 0.5 \cdot {\left(\mathsf{log1p}\left(x\right)\right)}^{2}\right) - 0.5 \cdot {\log x}^{2}}{-1 \cdot n}\right)}{-1 \cdot n} - -1 \cdot \frac{-1 \cdot \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;e^{\mathsf{log1p}\left(x\right) \cdot {n}^{-1}} - {x}^{\left(\frac{1}{n}\right)}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (if (or (<= n -110000.0) (not (<= n 122000.0)))
   (-
    (/
     (fma
      -1.0
      (log1p x)
      (/
       (-
        (fma
         -1.0
         (/
          (-
           (fma
            -1.0
            (-
             (/ (* 0.041666666666666664 (pow (log1p x) 4.0)) n)
             (/ (* 0.041666666666666664 (pow (log x) 4.0)) n))
            (* -0.16666666666666666 (pow (log1p x) 3.0)))
           (* -0.16666666666666666 (pow (log x) 3.0)))
          n)
         (* 0.5 (pow (log1p x) 2.0)))
        (* 0.5 (pow (log x) 2.0)))
       (* -1.0 n)))
     (* -1.0 n))
    (* -1.0 (/ (* -1.0 (log x)) n)))
   (- (exp (* (log1p x) (pow n -1.0))) (pow x (/ 1.0 n)))))
double code(double x, double n) {
	double tmp;
	if ((n <= -110000.0) || !(n <= 122000.0)) {
		tmp = (fma(-1.0, log1p(x), ((fma(-1.0, ((fma(-1.0, (((0.041666666666666664 * pow(log1p(x), 4.0)) / n) - ((0.041666666666666664 * pow(log(x), 4.0)) / n)), (-0.16666666666666666 * pow(log1p(x), 3.0))) - (-0.16666666666666666 * pow(log(x), 3.0))) / n), (0.5 * pow(log1p(x), 2.0))) - (0.5 * pow(log(x), 2.0))) / (-1.0 * n))) / (-1.0 * n)) - (-1.0 * ((-1.0 * log(x)) / n));
	} else {
		tmp = exp((log1p(x) * pow(n, -1.0))) - pow(x, (1.0 / n));
	}
	return tmp;
}
function code(x, n)
	tmp = 0.0
	if ((n <= -110000.0) || !(n <= 122000.0))
		tmp = Float64(Float64(fma(-1.0, log1p(x), Float64(Float64(fma(-1.0, Float64(Float64(fma(-1.0, Float64(Float64(Float64(0.041666666666666664 * (log1p(x) ^ 4.0)) / n) - Float64(Float64(0.041666666666666664 * (log(x) ^ 4.0)) / n)), Float64(-0.16666666666666666 * (log1p(x) ^ 3.0))) - Float64(-0.16666666666666666 * (log(x) ^ 3.0))) / n), Float64(0.5 * (log1p(x) ^ 2.0))) - Float64(0.5 * (log(x) ^ 2.0))) / Float64(-1.0 * n))) / Float64(-1.0 * n)) - Float64(-1.0 * Float64(Float64(-1.0 * log(x)) / n)));
	else
		tmp = Float64(exp(Float64(log1p(x) * (n ^ -1.0))) - (x ^ Float64(1.0 / n)));
	end
	return tmp
end
code[x_, n_] := If[Or[LessEqual[n, -110000.0], N[Not[LessEqual[n, 122000.0]], $MachinePrecision]], N[(N[(N[(-1.0 * N[Log[1 + x], $MachinePrecision] + N[(N[(N[(-1.0 * N[(N[(N[(-1.0 * N[(N[(N[(0.041666666666666664 * N[Power[N[Log[1 + x], $MachinePrecision], 4.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] - N[(N[(0.041666666666666664 * N[Power[N[Log[x], $MachinePrecision], 4.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] + N[(-0.16666666666666666 * N[Power[N[Log[1 + x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(-0.16666666666666666 * N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] + N[(0.5 * N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.5 * N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(-1.0 * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(-1.0 * n), $MachinePrecision]), $MachinePrecision] - N[(-1.0 * N[(N[(-1.0 * N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Exp[N[(N[Log[1 + x], $MachinePrecision] * N[Power[n, -1.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - N[Power[x, N[(1.0 / n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;n \leq -110000 \lor \neg \left(n \leq 122000\right):\\
\;\;\;\;\frac{\mathsf{fma}\left(-1, \mathsf{log1p}\left(x\right), \frac{\mathsf{fma}\left(-1, \frac{\mathsf{fma}\left(-1, \frac{0.041666666666666664 \cdot {\left(\mathsf{log1p}\left(x\right)\right)}^{4}}{n} - \frac{0.041666666666666664 \cdot {\log x}^{4}}{n}, -0.16666666666666666 \cdot {\left(\mathsf{log1p}\left(x\right)\right)}^{3}\right) - -0.16666666666666666 \cdot {\log x}^{3}}{n}, 0.5 \cdot {\left(\mathsf{log1p}\left(x\right)\right)}^{2}\right) - 0.5 \cdot {\log x}^{2}}{-1 \cdot n}\right)}{-1 \cdot n} - -1 \cdot \frac{-1 \cdot \log x}{n}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if n < -1.1e5 or 122000 < n

    1. Initial program 33.5%

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{\mathsf{fma}\left(-1, \mathsf{log1p}\left(x\right), -1 \cdot \frac{\mathsf{fma}\left(-1, \frac{\mathsf{fma}\left(-1, \frac{0.041666666666666664 \cdot {\left(\mathsf{log1p}\left(x\right)\right)}^{4}}{n} - \frac{0.041666666666666664 \cdot {\log x}^{4}}{n}, -0.16666666666666666 \cdot {\left(\mathsf{log1p}\left(x\right)\right)}^{3}\right) - -0.16666666666666666 \cdot {\log x}^{3}}{n}, 0.5 \cdot {\left(\mathsf{log1p}\left(x\right)\right)}^{2}\right) - 0.5 \cdot {\log x}^{2}}{n}\right) - -1 \cdot \log x}{n}} \]
    7. Applied rewrites77.7%

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

    if -1.1e5 < n < 122000

    1. Initial program 74.5%

      \[{\left(x + 1\right)}^{\left(\frac{1}{n}\right)} - {x}^{\left(\frac{1}{n}\right)} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-+.f64N/A

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

        \[\leadsto {\left(x + 1\right)}^{\color{blue}{\left(\frac{1}{n}\right)}} - {x}^{\left(\frac{1}{n}\right)} \]
      3. lift-pow.f64N/A

        \[\leadsto \color{blue}{{\left(x + 1\right)}^{\left(\frac{1}{n}\right)}} - {x}^{\left(\frac{1}{n}\right)} \]
      4. pow-to-expN/A

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

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

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

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

        \[\leadsto e^{\color{blue}{\mathsf{log1p}\left(x\right)} \cdot \frac{1}{n}} - {x}^{\left(\frac{1}{n}\right)} \]
      9. inv-powN/A

        \[\leadsto e^{\mathsf{log1p}\left(x\right) \cdot \color{blue}{{n}^{-1}}} - {x}^{\left(\frac{1}{n}\right)} \]
      10. lower-pow.f6498.2

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -110000 \lor \neg \left(n \leq 122000\right):\\ \;\;\;\;\frac{\mathsf{fma}\left(-1, \mathsf{log1p}\left(x\right), \frac{\mathsf{fma}\left(-1, \frac{\mathsf{fma}\left(-1, \frac{0.041666666666666664 \cdot {\left(\mathsf{log1p}\left(x\right)\right)}^{4}}{n} - \frac{0.041666666666666664 \cdot {\log x}^{4}}{n}, -0.16666666666666666 \cdot {\left(\mathsf{log1p}\left(x\right)\right)}^{3}\right) - -0.16666666666666666 \cdot {\log x}^{3}}{n}, 0.5 \cdot {\left(\mathsf{log1p}\left(x\right)\right)}^{2}\right) - 0.5 \cdot {\log x}^{2}}{-1 \cdot n}\right)}{-1 \cdot n} - -1 \cdot \frac{-1 \cdot \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;e^{\mathsf{log1p}\left(x\right) \cdot {n}^{-1}} - {x}^{\left(\frac{1}{n}\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 78.0% accurate, N/A× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\log x}^{2}\\ t_1 := \frac{-1 \cdot \log x}{n}\\ \mathbf{if}\;\frac{1}{n} \leq -100000000:\\ \;\;\;\;\frac{{\left(e^{-1}\right)}^{t\_1}}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-33}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-1, \mathsf{log1p}\left(x\right), \frac{\mathsf{fma}\left(-1, \frac{\mathsf{fma}\left(-1, \frac{0.041666666666666664 \cdot {\left(\mathsf{log1p}\left(x\right)\right)}^{4}}{n} - \frac{0.041666666666666664 \cdot {\log x}^{4}}{n}, -0.16666666666666666 \cdot {\left(\mathsf{log1p}\left(x\right)\right)}^{3}\right) - -0.16666666666666666 \cdot {\log x}^{3}}{n}, 0.5 \cdot {\left(\mathsf{log1p}\left(x\right)\right)}^{2}\right) - 0.5 \cdot t\_0}{-1 \cdot n}\right)}{-1 \cdot n} - -1 \cdot t\_1\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(0.5, \frac{t\_0}{n \cdot x}, \frac{\log x}{x}\right)}{-1 \cdot n} - {x}^{-1}}{-1 \cdot n}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (pow (log x) 2.0)) (t_1 (/ (* -1.0 (log x)) n)))
   (if (<= (/ 1.0 n) -100000000.0)
     (/ (pow (exp -1.0) t_1) (* n x))
     (if (<= (/ 1.0 n) 2e-33)
       (-
        (/
         (fma
          -1.0
          (log1p x)
          (/
           (-
            (fma
             -1.0
             (/
              (-
               (fma
                -1.0
                (-
                 (/ (* 0.041666666666666664 (pow (log1p x) 4.0)) n)
                 (/ (* 0.041666666666666664 (pow (log x) 4.0)) n))
                (* -0.16666666666666666 (pow (log1p x) 3.0)))
               (* -0.16666666666666666 (pow (log x) 3.0)))
              n)
             (* 0.5 (pow (log1p x) 2.0)))
            (* 0.5 t_0))
           (* -1.0 n)))
         (* -1.0 n))
        (* -1.0 t_1))
       (/
        (- (/ (fma 0.5 (/ t_0 (* n x)) (/ (log x) x)) (* -1.0 n)) (pow x -1.0))
        (* -1.0 n))))))
double code(double x, double n) {
	double t_0 = pow(log(x), 2.0);
	double t_1 = (-1.0 * log(x)) / n;
	double tmp;
	if ((1.0 / n) <= -100000000.0) {
		tmp = pow(exp(-1.0), t_1) / (n * x);
	} else if ((1.0 / n) <= 2e-33) {
		tmp = (fma(-1.0, log1p(x), ((fma(-1.0, ((fma(-1.0, (((0.041666666666666664 * pow(log1p(x), 4.0)) / n) - ((0.041666666666666664 * pow(log(x), 4.0)) / n)), (-0.16666666666666666 * pow(log1p(x), 3.0))) - (-0.16666666666666666 * pow(log(x), 3.0))) / n), (0.5 * pow(log1p(x), 2.0))) - (0.5 * t_0)) / (-1.0 * n))) / (-1.0 * n)) - (-1.0 * t_1);
	} else {
		tmp = ((fma(0.5, (t_0 / (n * x)), (log(x) / x)) / (-1.0 * n)) - pow(x, -1.0)) / (-1.0 * n);
	}
	return tmp;
}
function code(x, n)
	t_0 = log(x) ^ 2.0
	t_1 = Float64(Float64(-1.0 * log(x)) / n)
	tmp = 0.0
	if (Float64(1.0 / n) <= -100000000.0)
		tmp = Float64((exp(-1.0) ^ t_1) / Float64(n * x));
	elseif (Float64(1.0 / n) <= 2e-33)
		tmp = Float64(Float64(fma(-1.0, log1p(x), Float64(Float64(fma(-1.0, Float64(Float64(fma(-1.0, Float64(Float64(Float64(0.041666666666666664 * (log1p(x) ^ 4.0)) / n) - Float64(Float64(0.041666666666666664 * (log(x) ^ 4.0)) / n)), Float64(-0.16666666666666666 * (log1p(x) ^ 3.0))) - Float64(-0.16666666666666666 * (log(x) ^ 3.0))) / n), Float64(0.5 * (log1p(x) ^ 2.0))) - Float64(0.5 * t_0)) / Float64(-1.0 * n))) / Float64(-1.0 * n)) - Float64(-1.0 * t_1));
	else
		tmp = Float64(Float64(Float64(fma(0.5, Float64(t_0 / Float64(n * x)), Float64(log(x) / x)) / Float64(-1.0 * n)) - (x ^ -1.0)) / Float64(-1.0 * n));
	end
	return tmp
end
code[x_, n_] := Block[{t$95$0 = N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[(-1.0 * N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], -100000000.0], N[(N[Power[N[Exp[-1.0], $MachinePrecision], t$95$1], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-33], N[(N[(N[(-1.0 * N[Log[1 + x], $MachinePrecision] + N[(N[(N[(-1.0 * N[(N[(N[(-1.0 * N[(N[(N[(0.041666666666666664 * N[Power[N[Log[1 + x], $MachinePrecision], 4.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] - N[(N[(0.041666666666666664 * N[Power[N[Log[x], $MachinePrecision], 4.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] + N[(-0.16666666666666666 * N[Power[N[Log[1 + x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(-0.16666666666666666 * N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] + N[(0.5 * N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.5 * t$95$0), $MachinePrecision]), $MachinePrecision] / N[(-1.0 * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(-1.0 * n), $MachinePrecision]), $MachinePrecision] - N[(-1.0 * t$95$1), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(0.5 * N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision] + N[(N[Log[x], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(-1.0 * n), $MachinePrecision]), $MachinePrecision] - N[Power[x, -1.0], $MachinePrecision]), $MachinePrecision] / N[(-1.0 * n), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\log x}^{2}\\
t_1 := \frac{-1 \cdot \log x}{n}\\
\mathbf{if}\;\frac{1}{n} \leq -100000000:\\
\;\;\;\;\frac{{\left(e^{-1}\right)}^{t\_1}}{n \cdot x}\\

\mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-33}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-1, \mathsf{log1p}\left(x\right), \frac{\mathsf{fma}\left(-1, \frac{\mathsf{fma}\left(-1, \frac{0.041666666666666664 \cdot {\left(\mathsf{log1p}\left(x\right)\right)}^{4}}{n} - \frac{0.041666666666666664 \cdot {\log x}^{4}}{n}, -0.16666666666666666 \cdot {\left(\mathsf{log1p}\left(x\right)\right)}^{3}\right) - -0.16666666666666666 \cdot {\log x}^{3}}{n}, 0.5 \cdot {\left(\mathsf{log1p}\left(x\right)\right)}^{2}\right) - 0.5 \cdot t\_0}{-1 \cdot n}\right)}{-1 \cdot n} - -1 \cdot t\_1\\

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


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

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\frac{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}}}{n \cdot x}} \]
    4. 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. exp-prodN/A

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

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

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

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

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

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

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

        \[\leadsto \frac{{\left(e^{-1}\right)}^{\left(\frac{-1 \cdot \log x}{n}\right)}}{n \cdot x} \]
      10. lower-*.f64100.0

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

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

    if -1e8 < (/.f64 #s(literal 1 binary64) n) < 2.0000000000000001e-33

    1. Initial program 34.2%

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{\mathsf{fma}\left(-1, \mathsf{log1p}\left(x\right), -1 \cdot \frac{\mathsf{fma}\left(-1, \frac{\mathsf{fma}\left(-1, \frac{0.041666666666666664 \cdot {\left(\mathsf{log1p}\left(x\right)\right)}^{4}}{n} - \frac{0.041666666666666664 \cdot {\log x}^{4}}{n}, -0.16666666666666666 \cdot {\left(\mathsf{log1p}\left(x\right)\right)}^{3}\right) - -0.16666666666666666 \cdot {\log x}^{3}}{n}, 0.5 \cdot {\left(\mathsf{log1p}\left(x\right)\right)}^{2}\right) - 0.5 \cdot {\log x}^{2}}{n}\right) - -1 \cdot \log x}{n}} \]
    7. Applied rewrites80.1%

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

    if 2.0000000000000001e-33 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 42.7%

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

      \[\leadsto \color{blue}{\frac{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}}}{n \cdot x}} \]
    4. 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. exp-prodN/A

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

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

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

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

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

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

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

        \[\leadsto \frac{{\left(e^{-1}\right)}^{\left(\frac{-1 \cdot \log x}{n}\right)}}{n \cdot x} \]
      10. lower-*.f6412.5

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

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

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

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

        \[\leadsto -1 \cdot \frac{-1 \cdot \frac{\frac{1}{2} \cdot \frac{{\log x}^{2}}{n \cdot x} + \frac{\log x}{x}}{n} - \frac{1}{x}}{n} \]
    8. Applied rewrites52.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq -100000000:\\ \;\;\;\;\frac{{\left(e^{-1}\right)}^{\left(\frac{-1 \cdot \log x}{n}\right)}}{n \cdot x}\\ \mathbf{elif}\;\frac{1}{n} \leq 2 \cdot 10^{-33}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-1, \mathsf{log1p}\left(x\right), \frac{\mathsf{fma}\left(-1, \frac{\mathsf{fma}\left(-1, \frac{0.041666666666666664 \cdot {\left(\mathsf{log1p}\left(x\right)\right)}^{4}}{n} - \frac{0.041666666666666664 \cdot {\log x}^{4}}{n}, -0.16666666666666666 \cdot {\left(\mathsf{log1p}\left(x\right)\right)}^{3}\right) - -0.16666666666666666 \cdot {\log x}^{3}}{n}, 0.5 \cdot {\left(\mathsf{log1p}\left(x\right)\right)}^{2}\right) - 0.5 \cdot {\log x}^{2}}{-1 \cdot n}\right)}{-1 \cdot n} - -1 \cdot \frac{-1 \cdot \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{n \cdot x}, \frac{\log x}{x}\right)}{-1 \cdot n} - {x}^{-1}}{-1 \cdot n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 73.8% accurate, N/A× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\log x}^{2}\\ \mathbf{if}\;\frac{1}{n} \leq 2 \cdot 10^{-33}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-1, \mathsf{log1p}\left(x\right), \frac{\mathsf{fma}\left(-1, \frac{\mathsf{fma}\left(-1, \frac{0.041666666666666664 \cdot {\left(\mathsf{log1p}\left(x\right)\right)}^{4}}{n} - \frac{0.041666666666666664 \cdot {\log x}^{4}}{n}, -0.16666666666666666 \cdot {\left(\mathsf{log1p}\left(x\right)\right)}^{3}\right) - -0.16666666666666666 \cdot {\log x}^{3}}{n}, 0.5 \cdot {\left(\mathsf{log1p}\left(x\right)\right)}^{2}\right) - 0.5 \cdot t\_0}{-1 \cdot n}\right)}{-1 \cdot n} - -1 \cdot \frac{-1 \cdot \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(0.5, \frac{t\_0}{n \cdot x}, \frac{\log x}{x}\right)}{-1 \cdot n} - {x}^{-1}}{-1 \cdot n}\\ \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (pow (log x) 2.0)))
   (if (<= (/ 1.0 n) 2e-33)
     (-
      (/
       (fma
        -1.0
        (log1p x)
        (/
         (-
          (fma
           -1.0
           (/
            (-
             (fma
              -1.0
              (-
               (/ (* 0.041666666666666664 (pow (log1p x) 4.0)) n)
               (/ (* 0.041666666666666664 (pow (log x) 4.0)) n))
              (* -0.16666666666666666 (pow (log1p x) 3.0)))
             (* -0.16666666666666666 (pow (log x) 3.0)))
            n)
           (* 0.5 (pow (log1p x) 2.0)))
          (* 0.5 t_0))
         (* -1.0 n)))
       (* -1.0 n))
      (* -1.0 (/ (* -1.0 (log x)) n)))
     (/
      (- (/ (fma 0.5 (/ t_0 (* n x)) (/ (log x) x)) (* -1.0 n)) (pow x -1.0))
      (* -1.0 n)))))
double code(double x, double n) {
	double t_0 = pow(log(x), 2.0);
	double tmp;
	if ((1.0 / n) <= 2e-33) {
		tmp = (fma(-1.0, log1p(x), ((fma(-1.0, ((fma(-1.0, (((0.041666666666666664 * pow(log1p(x), 4.0)) / n) - ((0.041666666666666664 * pow(log(x), 4.0)) / n)), (-0.16666666666666666 * pow(log1p(x), 3.0))) - (-0.16666666666666666 * pow(log(x), 3.0))) / n), (0.5 * pow(log1p(x), 2.0))) - (0.5 * t_0)) / (-1.0 * n))) / (-1.0 * n)) - (-1.0 * ((-1.0 * log(x)) / n));
	} else {
		tmp = ((fma(0.5, (t_0 / (n * x)), (log(x) / x)) / (-1.0 * n)) - pow(x, -1.0)) / (-1.0 * n);
	}
	return tmp;
}
function code(x, n)
	t_0 = log(x) ^ 2.0
	tmp = 0.0
	if (Float64(1.0 / n) <= 2e-33)
		tmp = Float64(Float64(fma(-1.0, log1p(x), Float64(Float64(fma(-1.0, Float64(Float64(fma(-1.0, Float64(Float64(Float64(0.041666666666666664 * (log1p(x) ^ 4.0)) / n) - Float64(Float64(0.041666666666666664 * (log(x) ^ 4.0)) / n)), Float64(-0.16666666666666666 * (log1p(x) ^ 3.0))) - Float64(-0.16666666666666666 * (log(x) ^ 3.0))) / n), Float64(0.5 * (log1p(x) ^ 2.0))) - Float64(0.5 * t_0)) / Float64(-1.0 * n))) / Float64(-1.0 * n)) - Float64(-1.0 * Float64(Float64(-1.0 * log(x)) / n)));
	else
		tmp = Float64(Float64(Float64(fma(0.5, Float64(t_0 / Float64(n * x)), Float64(log(x) / x)) / Float64(-1.0 * n)) - (x ^ -1.0)) / Float64(-1.0 * n));
	end
	return tmp
end
code[x_, n_] := Block[{t$95$0 = N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[N[(1.0 / n), $MachinePrecision], 2e-33], N[(N[(N[(-1.0 * N[Log[1 + x], $MachinePrecision] + N[(N[(N[(-1.0 * N[(N[(N[(-1.0 * N[(N[(N[(0.041666666666666664 * N[Power[N[Log[1 + x], $MachinePrecision], 4.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] - N[(N[(0.041666666666666664 * N[Power[N[Log[x], $MachinePrecision], 4.0], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision] + N[(-0.16666666666666666 * N[Power[N[Log[1 + x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(-0.16666666666666666 * N[Power[N[Log[x], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] + N[(0.5 * N[Power[N[Log[1 + x], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.5 * t$95$0), $MachinePrecision]), $MachinePrecision] / N[(-1.0 * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(-1.0 * n), $MachinePrecision]), $MachinePrecision] - N[(-1.0 * N[(N[(-1.0 * N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(0.5 * N[(t$95$0 / N[(n * x), $MachinePrecision]), $MachinePrecision] + N[(N[Log[x], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(-1.0 * n), $MachinePrecision]), $MachinePrecision] - N[Power[x, -1.0], $MachinePrecision]), $MachinePrecision] / N[(-1.0 * n), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\log x}^{2}\\
\mathbf{if}\;\frac{1}{n} \leq 2 \cdot 10^{-33}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-1, \mathsf{log1p}\left(x\right), \frac{\mathsf{fma}\left(-1, \frac{\mathsf{fma}\left(-1, \frac{0.041666666666666664 \cdot {\left(\mathsf{log1p}\left(x\right)\right)}^{4}}{n} - \frac{0.041666666666666664 \cdot {\log x}^{4}}{n}, -0.16666666666666666 \cdot {\left(\mathsf{log1p}\left(x\right)\right)}^{3}\right) - -0.16666666666666666 \cdot {\log x}^{3}}{n}, 0.5 \cdot {\left(\mathsf{log1p}\left(x\right)\right)}^{2}\right) - 0.5 \cdot t\_0}{-1 \cdot n}\right)}{-1 \cdot n} - -1 \cdot \frac{-1 \cdot \log x}{n}\\

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


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

    1. Initial program 54.8%

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

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

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{\mathsf{fma}\left(-1, \mathsf{log1p}\left(x\right), -1 \cdot \frac{\mathsf{fma}\left(-1, \frac{\mathsf{fma}\left(-1, \frac{0.041666666666666664 \cdot {\left(\mathsf{log1p}\left(x\right)\right)}^{4}}{n} - \frac{0.041666666666666664 \cdot {\log x}^{4}}{n}, -0.16666666666666666 \cdot {\left(\mathsf{log1p}\left(x\right)\right)}^{3}\right) - -0.16666666666666666 \cdot {\log x}^{3}}{n}, 0.5 \cdot {\left(\mathsf{log1p}\left(x\right)\right)}^{2}\right) - 0.5 \cdot {\log x}^{2}}{n}\right) - -1 \cdot \log x}{n}} \]
    7. Applied rewrites79.9%

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

    if 2.0000000000000001e-33 < (/.f64 #s(literal 1 binary64) n)

    1. Initial program 42.7%

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

      \[\leadsto \color{blue}{\frac{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}}}{n \cdot x}} \]
    4. 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. exp-prodN/A

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

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

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

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

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

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

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

        \[\leadsto \frac{{\left(e^{-1}\right)}^{\left(\frac{-1 \cdot \log x}{n}\right)}}{n \cdot x} \]
      10. lower-*.f6412.5

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

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

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

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

        \[\leadsto -1 \cdot \frac{-1 \cdot \frac{\frac{1}{2} \cdot \frac{{\log x}^{2}}{n \cdot x} + \frac{\log x}{x}}{n} - \frac{1}{x}}{n} \]
    8. Applied rewrites52.1%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{1}{n} \leq 2 \cdot 10^{-33}:\\ \;\;\;\;\frac{\mathsf{fma}\left(-1, \mathsf{log1p}\left(x\right), \frac{\mathsf{fma}\left(-1, \frac{\mathsf{fma}\left(-1, \frac{0.041666666666666664 \cdot {\left(\mathsf{log1p}\left(x\right)\right)}^{4}}{n} - \frac{0.041666666666666664 \cdot {\log x}^{4}}{n}, -0.16666666666666666 \cdot {\left(\mathsf{log1p}\left(x\right)\right)}^{3}\right) - -0.16666666666666666 \cdot {\log x}^{3}}{n}, 0.5 \cdot {\left(\mathsf{log1p}\left(x\right)\right)}^{2}\right) - 0.5 \cdot {\log x}^{2}}{-1 \cdot n}\right)}{-1 \cdot n} - -1 \cdot \frac{-1 \cdot \log x}{n}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{n \cdot x}, \frac{\log x}{x}\right)}{-1 \cdot n} - {x}^{-1}}{-1 \cdot n}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 48.6% accurate, N/A× speedup?

\[\begin{array}{l} \\ \frac{\frac{\mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{n \cdot x}, \frac{\log x}{x}\right)}{-1 \cdot n} - {x}^{-1}}{-1 \cdot n} \end{array} \]
(FPCore (x n)
 :precision binary64
 (/
  (-
   (/ (fma 0.5 (/ (pow (log x) 2.0) (* n x)) (/ (log x) x)) (* -1.0 n))
   (pow x -1.0))
  (* -1.0 n)))
double code(double x, double n) {
	return ((fma(0.5, (pow(log(x), 2.0) / (n * x)), (log(x) / x)) / (-1.0 * n)) - pow(x, -1.0)) / (-1.0 * n);
}
function code(x, n)
	return Float64(Float64(Float64(fma(0.5, Float64((log(x) ^ 2.0) / Float64(n * x)), Float64(log(x) / x)) / Float64(-1.0 * n)) - (x ^ -1.0)) / Float64(-1.0 * n))
end
code[x_, n_] := N[(N[(N[(N[(0.5 * N[(N[Power[N[Log[x], $MachinePrecision], 2.0], $MachinePrecision] / N[(n * x), $MachinePrecision]), $MachinePrecision] + N[(N[Log[x], $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] / N[(-1.0 * n), $MachinePrecision]), $MachinePrecision] - N[Power[x, -1.0], $MachinePrecision]), $MachinePrecision] / N[(-1.0 * n), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\frac{\mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{n \cdot x}, \frac{\log x}{x}\right)}{-1 \cdot n} - {x}^{-1}}{-1 \cdot n}
\end{array}
Derivation
  1. Initial program 51.9%

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

    \[\leadsto \color{blue}{\frac{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}}}{n \cdot x}} \]
  4. 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. exp-prodN/A

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

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

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

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

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

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

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

      \[\leadsto \frac{{\left(e^{-1}\right)}^{\left(\frac{-1 \cdot \log x}{n}\right)}}{n \cdot x} \]
    10. lower-*.f6454.5

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

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

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

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

      \[\leadsto -1 \cdot \frac{-1 \cdot \frac{\frac{1}{2} \cdot \frac{{\log x}^{2}}{n \cdot x} + \frac{\log x}{x}}{n} - \frac{1}{x}}{n} \]
  8. Applied rewrites52.0%

    \[\leadsto -1 \cdot \color{blue}{\frac{-1 \cdot \frac{\mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{n \cdot x}, \frac{\log x}{x}\right)}{n} - {x}^{-1}}{n}} \]
  9. Final simplification52.0%

    \[\leadsto \frac{\frac{\mathsf{fma}\left(0.5, \frac{{\log x}^{2}}{n \cdot x}, \frac{\log x}{x}\right)}{-1 \cdot n} - {x}^{-1}}{-1 \cdot n} \]
  10. Add Preprocessing

Alternative 5: 14.2% accurate, N/A× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{-1 \cdot \log x}{n}\\ t_1 := {\left(e^{-1}\right)}^{t\_0}\\ t_2 := n \cdot t\_1\\ t_3 := e^{-1 \cdot t\_0}\\ t_4 := \frac{t\_3}{{x}^{4}}\\ t_5 := \left(x \cdot x\right) \cdot x\\ t_6 := \frac{t\_3}{t\_5}\\ \frac{\mathsf{fma}\left(0.041666666666666664, t\_4, n \cdot \mathsf{fma}\left(-0.25, t\_4, \mathsf{fma}\left(0.16666666666666666, t\_6, n \cdot \mathsf{fma}\left(-1, \frac{\left(-1 \cdot n\right) \cdot t\_1 + \mathsf{fma}\left(-0.3333333333333333, \frac{t\_2}{x \cdot x}, \mathsf{fma}\left(0.25, \frac{t\_2}{t\_5}, 0.5 \cdot \frac{t\_2}{x}\right)\right)}{x}, \mathsf{fma}\left(-0.5, t\_6, \mathsf{fma}\left(0.4583333333333333, t\_4, 0.5 \cdot \frac{t\_3}{x \cdot x}\right)\right)\right)\right)\right)\right)}{{n}^{4}} \end{array} \end{array} \]
(FPCore (x n)
 :precision binary64
 (let* ((t_0 (/ (* -1.0 (log x)) n))
        (t_1 (pow (exp -1.0) t_0))
        (t_2 (* n t_1))
        (t_3 (exp (* -1.0 t_0)))
        (t_4 (/ t_3 (pow x 4.0)))
        (t_5 (* (* x x) x))
        (t_6 (/ t_3 t_5)))
   (/
    (fma
     0.041666666666666664
     t_4
     (*
      n
      (fma
       -0.25
       t_4
       (fma
        0.16666666666666666
        t_6
        (*
         n
         (fma
          -1.0
          (/
           (+
            (* (* -1.0 n) t_1)
            (fma
             -0.3333333333333333
             (/ t_2 (* x x))
             (fma 0.25 (/ t_2 t_5) (* 0.5 (/ t_2 x)))))
           x)
          (fma
           -0.5
           t_6
           (fma 0.4583333333333333 t_4 (* 0.5 (/ t_3 (* x x)))))))))))
    (pow n 4.0))))
double code(double x, double n) {
	double t_0 = (-1.0 * log(x)) / n;
	double t_1 = pow(exp(-1.0), t_0);
	double t_2 = n * t_1;
	double t_3 = exp((-1.0 * t_0));
	double t_4 = t_3 / pow(x, 4.0);
	double t_5 = (x * x) * x;
	double t_6 = t_3 / t_5;
	return fma(0.041666666666666664, t_4, (n * fma(-0.25, t_4, fma(0.16666666666666666, t_6, (n * fma(-1.0, ((((-1.0 * n) * t_1) + fma(-0.3333333333333333, (t_2 / (x * x)), fma(0.25, (t_2 / t_5), (0.5 * (t_2 / x))))) / x), fma(-0.5, t_6, fma(0.4583333333333333, t_4, (0.5 * (t_3 / (x * x))))))))))) / pow(n, 4.0);
}
function code(x, n)
	t_0 = Float64(Float64(-1.0 * log(x)) / n)
	t_1 = exp(-1.0) ^ t_0
	t_2 = Float64(n * t_1)
	t_3 = exp(Float64(-1.0 * t_0))
	t_4 = Float64(t_3 / (x ^ 4.0))
	t_5 = Float64(Float64(x * x) * x)
	t_6 = Float64(t_3 / t_5)
	return Float64(fma(0.041666666666666664, t_4, Float64(n * fma(-0.25, t_4, fma(0.16666666666666666, t_6, Float64(n * fma(-1.0, Float64(Float64(Float64(Float64(-1.0 * n) * t_1) + fma(-0.3333333333333333, Float64(t_2 / Float64(x * x)), fma(0.25, Float64(t_2 / t_5), Float64(0.5 * Float64(t_2 / x))))) / x), fma(-0.5, t_6, fma(0.4583333333333333, t_4, Float64(0.5 * Float64(t_3 / Float64(x * x))))))))))) / (n ^ 4.0))
end
code[x_, n_] := Block[{t$95$0 = N[(N[(-1.0 * N[Log[x], $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Exp[-1.0], $MachinePrecision], t$95$0], $MachinePrecision]}, Block[{t$95$2 = N[(n * t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[Exp[N[(-1.0 * t$95$0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 / N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision]}, Block[{t$95$6 = N[(t$95$3 / t$95$5), $MachinePrecision]}, N[(N[(0.041666666666666664 * t$95$4 + N[(n * N[(-0.25 * t$95$4 + N[(0.16666666666666666 * t$95$6 + N[(n * N[(-1.0 * N[(N[(N[(N[(-1.0 * n), $MachinePrecision] * t$95$1), $MachinePrecision] + N[(-0.3333333333333333 * N[(t$95$2 / N[(x * x), $MachinePrecision]), $MachinePrecision] + N[(0.25 * N[(t$95$2 / t$95$5), $MachinePrecision] + N[(0.5 * N[(t$95$2 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] + N[(-0.5 * t$95$6 + N[(0.4583333333333333 * t$95$4 + N[(0.5 * N[(t$95$3 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[n, 4.0], $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{-1 \cdot \log x}{n}\\
t_1 := {\left(e^{-1}\right)}^{t\_0}\\
t_2 := n \cdot t\_1\\
t_3 := e^{-1 \cdot t\_0}\\
t_4 := \frac{t\_3}{{x}^{4}}\\
t_5 := \left(x \cdot x\right) \cdot x\\
t_6 := \frac{t\_3}{t\_5}\\
\frac{\mathsf{fma}\left(0.041666666666666664, t\_4, n \cdot \mathsf{fma}\left(-0.25, t\_4, \mathsf{fma}\left(0.16666666666666666, t\_6, n \cdot \mathsf{fma}\left(-1, \frac{\left(-1 \cdot n\right) \cdot t\_1 + \mathsf{fma}\left(-0.3333333333333333, \frac{t\_2}{x \cdot x}, \mathsf{fma}\left(0.25, \frac{t\_2}{t\_5}, 0.5 \cdot \frac{t\_2}{x}\right)\right)}{x}, \mathsf{fma}\left(-0.5, t\_6, \mathsf{fma}\left(0.4583333333333333, t\_4, 0.5 \cdot \frac{t\_3}{x \cdot x}\right)\right)\right)\right)\right)\right)}{{n}^{4}}
\end{array}
\end{array}
Derivation
  1. Initial program 51.9%

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

    \[\leadsto \color{blue}{\frac{\frac{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}}}{n} + \left(\frac{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}} \cdot \left(\frac{1}{2} \cdot \frac{1}{{n}^{2}} - \frac{1}{2} \cdot \frac{1}{n}\right)}{x} + \left(\frac{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}} \cdot \left(\left(\frac{1}{24} \cdot \frac{1}{{n}^{4}} + \frac{11}{24} \cdot \frac{1}{{n}^{2}}\right) - \left(\frac{1}{4} \cdot \frac{1}{n} + \frac{1}{4} \cdot \frac{1}{{n}^{3}}\right)\right)}{{x}^{3}} + \frac{e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}} \cdot \left(\left(\frac{1}{6} \cdot \frac{1}{{n}^{3}} + \frac{1}{3} \cdot \frac{1}{n}\right) - \frac{1}{2} \cdot \frac{1}{{n}^{2}}\right)}{{x}^{2}}\right)\right)}{x}} \]
  4. Applied rewrites9.7%

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(-{\left(e^{-1}\right)}^{\left(\frac{-1 \cdot \log x}{n}\right)}, x, \left(-n \cdot x\right) \cdot \mathsf{fma}\left({\left(e^{-1}\right)}^{\left(\frac{-1 \cdot \log x}{n}\right)}, \frac{{\left(n \cdot n\right)}^{-1} \cdot 0.5}{x} - \frac{0.5 \cdot {n}^{-1}}{x}, \mathsf{fma}\left({\left(e^{-1}\right)}^{\left(\frac{-1 \cdot \log x}{n}\right)}, \frac{\mathsf{fma}\left(0.3333333333333333, {n}^{-1}, {\left(\left(n \cdot n\right) \cdot n\right)}^{-1} \cdot 0.16666666666666666\right) - {\left(n \cdot n\right)}^{-1} \cdot 0.5}{x \cdot x}, {\left(e^{-1}\right)}^{\left(\frac{-1 \cdot \log x}{n}\right)} \cdot \frac{\mathsf{fma}\left(0.4583333333333333, {\left(n \cdot n\right)}^{-1}, {\left({\left(n \cdot n\right)}^{2}\right)}^{-1} \cdot 0.041666666666666664\right) - \mathsf{fma}\left(0.25, {\left(\left(n \cdot n\right) \cdot n\right)}^{-1}, 0.25 \cdot {n}^{-1}\right)}{\left(x \cdot x\right) \cdot x}\right)\right)\right)}{\left(-n \cdot x\right) \cdot x}} \]
  5. Taylor expanded in n around 0

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

    \[\leadsto \frac{\mathsf{fma}\left(0.041666666666666664, \frac{e^{\frac{\log x}{n}}}{{x}^{4}}, n \cdot \mathsf{fma}\left(-0.25, \frac{e^{\frac{\log x}{n}}}{{x}^{4}}, \mathsf{fma}\left(0.16666666666666666, \frac{e^{\frac{\log x}{n}}}{\left(x \cdot x\right) \cdot x}, n \cdot \mathsf{fma}\left(-1, n \cdot \mathsf{fma}\left(-1, \frac{e^{\frac{\log x}{n}}}{x}, -1 \cdot \frac{\mathsf{fma}\left(-0.5, \frac{e^{\frac{\log x}{n}}}{x}, \mathsf{fma}\left(-0.25, \frac{e^{\frac{\log x}{n}}}{\left(x \cdot x\right) \cdot x}, 0.3333333333333333 \cdot \frac{e^{\frac{\log x}{n}}}{x \cdot x}\right)\right)}{x}\right), \mathsf{fma}\left(-0.5, \frac{e^{\frac{\log x}{n}}}{\left(x \cdot x\right) \cdot x}, \mathsf{fma}\left(0.4583333333333333, \frac{e^{\frac{\log x}{n}}}{{x}^{4}}, 0.5 \cdot \frac{e^{\frac{\log x}{n}}}{x \cdot x}\right)\right)\right)\right)\right)\right)}{\color{blue}{{n}^{4}}} \]
  7. Taylor expanded in x around inf

    \[\leadsto \frac{\mathsf{fma}\left(\frac{1}{24}, \frac{e^{\frac{\log x}{n}}}{{x}^{4}}, n \cdot \mathsf{fma}\left(\frac{-1}{4}, \frac{e^{\frac{\log x}{n}}}{{x}^{4}}, \mathsf{fma}\left(\frac{1}{6}, \frac{e^{\frac{\log x}{n}}}{\left(x \cdot x\right) \cdot x}, n \cdot \mathsf{fma}\left(-1, \frac{-1 \cdot \left(n \cdot e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}}\right) + \left(\frac{-1}{3} \cdot \frac{n \cdot e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}}}{{x}^{2}} + \left(\frac{1}{4} \cdot \frac{n \cdot e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}}}{{x}^{3}} + \frac{1}{2} \cdot \frac{n \cdot e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}}}{x}\right)\right)}{x}, \mathsf{fma}\left(\frac{-1}{2}, \frac{e^{\frac{\log x}{n}}}{\left(x \cdot x\right) \cdot x}, \mathsf{fma}\left(\frac{11}{24}, \frac{e^{\frac{\log x}{n}}}{{x}^{4}}, \frac{1}{2} \cdot \frac{e^{\frac{\log x}{n}}}{x \cdot x}\right)\right)\right)\right)\right)\right)}{{n}^{4}} \]
  8. Step-by-step derivation
    1. lower-/.f64N/A

      \[\leadsto \frac{\mathsf{fma}\left(\frac{1}{24}, \frac{e^{\frac{\log x}{n}}}{{x}^{4}}, n \cdot \mathsf{fma}\left(\frac{-1}{4}, \frac{e^{\frac{\log x}{n}}}{{x}^{4}}, \mathsf{fma}\left(\frac{1}{6}, \frac{e^{\frac{\log x}{n}}}{\left(x \cdot x\right) \cdot x}, n \cdot \mathsf{fma}\left(-1, \frac{-1 \cdot \left(n \cdot e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}}\right) + \left(\frac{-1}{3} \cdot \frac{n \cdot e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}}}{{x}^{2}} + \left(\frac{1}{4} \cdot \frac{n \cdot e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}}}{{x}^{3}} + \frac{1}{2} \cdot \frac{n \cdot e^{-1 \cdot \frac{\log \left(\frac{1}{x}\right)}{n}}}{x}\right)\right)}{x}, \mathsf{fma}\left(\frac{-1}{2}, \frac{e^{\frac{\log x}{n}}}{\left(x \cdot x\right) \cdot x}, \mathsf{fma}\left(\frac{11}{24}, \frac{e^{\frac{\log x}{n}}}{{x}^{4}}, \frac{1}{2} \cdot \frac{e^{\frac{\log x}{n}}}{x \cdot x}\right)\right)\right)\right)\right)\right)}{{n}^{4}} \]
  9. Applied rewrites12.8%

    \[\leadsto \frac{\mathsf{fma}\left(0.041666666666666664, \frac{e^{\frac{\log x}{n}}}{{x}^{4}}, n \cdot \mathsf{fma}\left(-0.25, \frac{e^{\frac{\log x}{n}}}{{x}^{4}}, \mathsf{fma}\left(0.16666666666666666, \frac{e^{\frac{\log x}{n}}}{\left(x \cdot x\right) \cdot x}, n \cdot \mathsf{fma}\left(-1, \frac{-1 \cdot \left(n \cdot {\left(e^{-1}\right)}^{\left(\frac{-1 \cdot \log x}{n}\right)}\right) + \mathsf{fma}\left(-0.3333333333333333, \frac{n \cdot {\left(e^{-1}\right)}^{\left(\frac{-1 \cdot \log x}{n}\right)}}{x \cdot x}, \mathsf{fma}\left(0.25, \frac{n \cdot {\left(e^{-1}\right)}^{\left(\frac{-1 \cdot \log x}{n}\right)}}{\left(x \cdot x\right) \cdot x}, 0.5 \cdot \frac{n \cdot {\left(e^{-1}\right)}^{\left(\frac{-1 \cdot \log x}{n}\right)}}{x}\right)\right)}{x}, \mathsf{fma}\left(-0.5, \frac{e^{\frac{\log x}{n}}}{\left(x \cdot x\right) \cdot x}, \mathsf{fma}\left(0.4583333333333333, \frac{e^{\frac{\log x}{n}}}{{x}^{4}}, 0.5 \cdot \frac{e^{\frac{\log x}{n}}}{x \cdot x}\right)\right)\right)\right)\right)\right)}{{n}^{4}} \]
  10. Final simplification12.8%

    \[\leadsto \frac{\mathsf{fma}\left(0.041666666666666664, \frac{e^{-1 \cdot \frac{-1 \cdot \log x}{n}}}{{x}^{4}}, n \cdot \mathsf{fma}\left(-0.25, \frac{e^{-1 \cdot \frac{-1 \cdot \log x}{n}}}{{x}^{4}}, \mathsf{fma}\left(0.16666666666666666, \frac{e^{-1 \cdot \frac{-1 \cdot \log x}{n}}}{\left(x \cdot x\right) \cdot x}, n \cdot \mathsf{fma}\left(-1, \frac{\left(-1 \cdot n\right) \cdot {\left(e^{-1}\right)}^{\left(\frac{-1 \cdot \log x}{n}\right)} + \mathsf{fma}\left(-0.3333333333333333, \frac{n \cdot {\left(e^{-1}\right)}^{\left(\frac{-1 \cdot \log x}{n}\right)}}{x \cdot x}, \mathsf{fma}\left(0.25, \frac{n \cdot {\left(e^{-1}\right)}^{\left(\frac{-1 \cdot \log x}{n}\right)}}{\left(x \cdot x\right) \cdot x}, 0.5 \cdot \frac{n \cdot {\left(e^{-1}\right)}^{\left(\frac{-1 \cdot \log x}{n}\right)}}{x}\right)\right)}{x}, \mathsf{fma}\left(-0.5, \frac{e^{-1 \cdot \frac{-1 \cdot \log x}{n}}}{\left(x \cdot x\right) \cdot x}, \mathsf{fma}\left(0.4583333333333333, \frac{e^{-1 \cdot \frac{-1 \cdot \log x}{n}}}{{x}^{4}}, 0.5 \cdot \frac{e^{-1 \cdot \frac{-1 \cdot \log x}{n}}}{x \cdot x}\right)\right)\right)\right)\right)\right)}{{n}^{4}} \]
  11. Add Preprocessing

Reproduce

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