ENA, Section 1.4, Exercise 4b, n=5

Percentage Accurate: 88.3% → 97.2%
Time: 10.4s
Alternatives: 12
Speedup: 1.5×

Specification

?
\[\left(-1000000000 \leq x \land x \leq 1000000000\right) \land \left(-1 \leq \varepsilon \land \varepsilon \leq 1\right)\]
\[\begin{array}{l} \\ {\left(x + \varepsilon\right)}^{5} - {x}^{5} \end{array} \]
(FPCore (x eps) :precision binary64 (- (pow (+ x eps) 5.0) (pow x 5.0)))
double code(double x, double eps) {
	return pow((x + eps), 5.0) - pow(x, 5.0);
}
real(8) function code(x, eps)
    real(8), intent (in) :: x
    real(8), intent (in) :: eps
    code = ((x + eps) ** 5.0d0) - (x ** 5.0d0)
end function
public static double code(double x, double eps) {
	return Math.pow((x + eps), 5.0) - Math.pow(x, 5.0);
}
def code(x, eps):
	return math.pow((x + eps), 5.0) - math.pow(x, 5.0)
function code(x, eps)
	return Float64((Float64(x + eps) ^ 5.0) - (x ^ 5.0))
end
function tmp = code(x, eps)
	tmp = ((x + eps) ^ 5.0) - (x ^ 5.0);
end
code[x_, eps_] := N[(N[Power[N[(x + eps), $MachinePrecision], 5.0], $MachinePrecision] - N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
{\left(x + \varepsilon\right)}^{5} - {x}^{5}
\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 12 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: 88.3% accurate, 1.0× speedup?

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

\\
{\left(x + \varepsilon\right)}^{5} - {x}^{5}
\end{array}

Alternative 1: 97.2% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(x + \varepsilon\right)}^{5}\\ t_1 := t\_0 - {x}^{5}\\ \mathbf{if}\;t\_1 \leq -2 \cdot 10^{-318}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_1 \leq 0:\\ \;\;\;\;\varepsilon \cdot \left(5 \cdot {x}^{4}\right)\\ \mathbf{elif}\;t\_1 \leq 10^{-262}:\\ \;\;\;\;{x}^{3} \cdot \left(5 \cdot \left(x \cdot \varepsilon\right) + 10 \cdot {\varepsilon}^{2}\right)\\ \mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-193}:\\ \;\;\;\;{\varepsilon}^{4} \cdot \left(x \cdot \left(5 + \frac{\varepsilon}{x}\right)\right)\\ \mathbf{elif}\;t\_1 \leq 10^{-145}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-108}:\\ \;\;\;\;\frac{{\left(x + \varepsilon\right)}^{10} - {x}^{10}}{t\_0 + {x}^{5}}\\ \mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-19}:\\ \;\;\;\;{\varepsilon}^{4} \cdot \left(\varepsilon + x \cdot 5\right)\\ \mathbf{else}:\\ \;\;\;\;{x}^{4} \cdot \left(\varepsilon \cdot \left(5 + 10 \cdot \frac{\varepsilon}{x}\right)\right)\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (let* ((t_0 (pow (+ x eps) 5.0)) (t_1 (- t_0 (pow x 5.0))))
   (if (<= t_1 -2e-318)
     t_1
     (if (<= t_1 0.0)
       (* eps (* 5.0 (pow x 4.0)))
       (if (<= t_1 1e-262)
         (* (pow x 3.0) (+ (* 5.0 (* x eps)) (* 10.0 (pow eps 2.0))))
         (if (<= t_1 5e-193)
           (* (pow eps 4.0) (* x (+ 5.0 (/ eps x))))
           (if (<= t_1 1e-145)
             t_1
             (if (<= t_1 5e-108)
               (/ (- (pow (+ x eps) 10.0) (pow x 10.0)) (+ t_0 (pow x 5.0)))
               (if (<= t_1 5e-19)
                 (* (pow eps 4.0) (+ eps (* x 5.0)))
                 (* (pow x 4.0) (* eps (+ 5.0 (* 10.0 (/ eps x))))))))))))))
double code(double x, double eps) {
	double t_0 = pow((x + eps), 5.0);
	double t_1 = t_0 - pow(x, 5.0);
	double tmp;
	if (t_1 <= -2e-318) {
		tmp = t_1;
	} else if (t_1 <= 0.0) {
		tmp = eps * (5.0 * pow(x, 4.0));
	} else if (t_1 <= 1e-262) {
		tmp = pow(x, 3.0) * ((5.0 * (x * eps)) + (10.0 * pow(eps, 2.0)));
	} else if (t_1 <= 5e-193) {
		tmp = pow(eps, 4.0) * (x * (5.0 + (eps / x)));
	} else if (t_1 <= 1e-145) {
		tmp = t_1;
	} else if (t_1 <= 5e-108) {
		tmp = (pow((x + eps), 10.0) - pow(x, 10.0)) / (t_0 + pow(x, 5.0));
	} else if (t_1 <= 5e-19) {
		tmp = pow(eps, 4.0) * (eps + (x * 5.0));
	} else {
		tmp = pow(x, 4.0) * (eps * (5.0 + (10.0 * (eps / x))));
	}
	return tmp;
}
real(8) function code(x, eps)
    real(8), intent (in) :: x
    real(8), intent (in) :: eps
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (x + eps) ** 5.0d0
    t_1 = t_0 - (x ** 5.0d0)
    if (t_1 <= (-2d-318)) then
        tmp = t_1
    else if (t_1 <= 0.0d0) then
        tmp = eps * (5.0d0 * (x ** 4.0d0))
    else if (t_1 <= 1d-262) then
        tmp = (x ** 3.0d0) * ((5.0d0 * (x * eps)) + (10.0d0 * (eps ** 2.0d0)))
    else if (t_1 <= 5d-193) then
        tmp = (eps ** 4.0d0) * (x * (5.0d0 + (eps / x)))
    else if (t_1 <= 1d-145) then
        tmp = t_1
    else if (t_1 <= 5d-108) then
        tmp = (((x + eps) ** 10.0d0) - (x ** 10.0d0)) / (t_0 + (x ** 5.0d0))
    else if (t_1 <= 5d-19) then
        tmp = (eps ** 4.0d0) * (eps + (x * 5.0d0))
    else
        tmp = (x ** 4.0d0) * (eps * (5.0d0 + (10.0d0 * (eps / x))))
    end if
    code = tmp
end function
public static double code(double x, double eps) {
	double t_0 = Math.pow((x + eps), 5.0);
	double t_1 = t_0 - Math.pow(x, 5.0);
	double tmp;
	if (t_1 <= -2e-318) {
		tmp = t_1;
	} else if (t_1 <= 0.0) {
		tmp = eps * (5.0 * Math.pow(x, 4.0));
	} else if (t_1 <= 1e-262) {
		tmp = Math.pow(x, 3.0) * ((5.0 * (x * eps)) + (10.0 * Math.pow(eps, 2.0)));
	} else if (t_1 <= 5e-193) {
		tmp = Math.pow(eps, 4.0) * (x * (5.0 + (eps / x)));
	} else if (t_1 <= 1e-145) {
		tmp = t_1;
	} else if (t_1 <= 5e-108) {
		tmp = (Math.pow((x + eps), 10.0) - Math.pow(x, 10.0)) / (t_0 + Math.pow(x, 5.0));
	} else if (t_1 <= 5e-19) {
		tmp = Math.pow(eps, 4.0) * (eps + (x * 5.0));
	} else {
		tmp = Math.pow(x, 4.0) * (eps * (5.0 + (10.0 * (eps / x))));
	}
	return tmp;
}
def code(x, eps):
	t_0 = math.pow((x + eps), 5.0)
	t_1 = t_0 - math.pow(x, 5.0)
	tmp = 0
	if t_1 <= -2e-318:
		tmp = t_1
	elif t_1 <= 0.0:
		tmp = eps * (5.0 * math.pow(x, 4.0))
	elif t_1 <= 1e-262:
		tmp = math.pow(x, 3.0) * ((5.0 * (x * eps)) + (10.0 * math.pow(eps, 2.0)))
	elif t_1 <= 5e-193:
		tmp = math.pow(eps, 4.0) * (x * (5.0 + (eps / x)))
	elif t_1 <= 1e-145:
		tmp = t_1
	elif t_1 <= 5e-108:
		tmp = (math.pow((x + eps), 10.0) - math.pow(x, 10.0)) / (t_0 + math.pow(x, 5.0))
	elif t_1 <= 5e-19:
		tmp = math.pow(eps, 4.0) * (eps + (x * 5.0))
	else:
		tmp = math.pow(x, 4.0) * (eps * (5.0 + (10.0 * (eps / x))))
	return tmp
function code(x, eps)
	t_0 = Float64(x + eps) ^ 5.0
	t_1 = Float64(t_0 - (x ^ 5.0))
	tmp = 0.0
	if (t_1 <= -2e-318)
		tmp = t_1;
	elseif (t_1 <= 0.0)
		tmp = Float64(eps * Float64(5.0 * (x ^ 4.0)));
	elseif (t_1 <= 1e-262)
		tmp = Float64((x ^ 3.0) * Float64(Float64(5.0 * Float64(x * eps)) + Float64(10.0 * (eps ^ 2.0))));
	elseif (t_1 <= 5e-193)
		tmp = Float64((eps ^ 4.0) * Float64(x * Float64(5.0 + Float64(eps / x))));
	elseif (t_1 <= 1e-145)
		tmp = t_1;
	elseif (t_1 <= 5e-108)
		tmp = Float64(Float64((Float64(x + eps) ^ 10.0) - (x ^ 10.0)) / Float64(t_0 + (x ^ 5.0)));
	elseif (t_1 <= 5e-19)
		tmp = Float64((eps ^ 4.0) * Float64(eps + Float64(x * 5.0)));
	else
		tmp = Float64((x ^ 4.0) * Float64(eps * Float64(5.0 + Float64(10.0 * Float64(eps / x)))));
	end
	return tmp
end
function tmp_2 = code(x, eps)
	t_0 = (x + eps) ^ 5.0;
	t_1 = t_0 - (x ^ 5.0);
	tmp = 0.0;
	if (t_1 <= -2e-318)
		tmp = t_1;
	elseif (t_1 <= 0.0)
		tmp = eps * (5.0 * (x ^ 4.0));
	elseif (t_1 <= 1e-262)
		tmp = (x ^ 3.0) * ((5.0 * (x * eps)) + (10.0 * (eps ^ 2.0)));
	elseif (t_1 <= 5e-193)
		tmp = (eps ^ 4.0) * (x * (5.0 + (eps / x)));
	elseif (t_1 <= 1e-145)
		tmp = t_1;
	elseif (t_1 <= 5e-108)
		tmp = (((x + eps) ^ 10.0) - (x ^ 10.0)) / (t_0 + (x ^ 5.0));
	elseif (t_1 <= 5e-19)
		tmp = (eps ^ 4.0) * (eps + (x * 5.0));
	else
		tmp = (x ^ 4.0) * (eps * (5.0 + (10.0 * (eps / x))));
	end
	tmp_2 = tmp;
end
code[x_, eps_] := Block[{t$95$0 = N[Power[N[(x + eps), $MachinePrecision], 5.0], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 - N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, -2e-318], t$95$1, If[LessEqual[t$95$1, 0.0], N[(eps * N[(5.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e-262], N[(N[Power[x, 3.0], $MachinePrecision] * N[(N[(5.0 * N[(x * eps), $MachinePrecision]), $MachinePrecision] + N[(10.0 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e-193], N[(N[Power[eps, 4.0], $MachinePrecision] * N[(x * N[(5.0 + N[(eps / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 1e-145], t$95$1, If[LessEqual[t$95$1, 5e-108], N[(N[(N[Power[N[(x + eps), $MachinePrecision], 10.0], $MachinePrecision] - N[Power[x, 10.0], $MachinePrecision]), $MachinePrecision] / N[(t$95$0 + N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e-19], N[(N[Power[eps, 4.0], $MachinePrecision] * N[(eps + N[(x * 5.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, 4.0], $MachinePrecision] * N[(eps * N[(5.0 + N[(10.0 * N[(eps / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\left(x + \varepsilon\right)}^{5}\\
t_1 := t\_0 - {x}^{5}\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{-318}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_1 \leq 0:\\
\;\;\;\;\varepsilon \cdot \left(5 \cdot {x}^{4}\right)\\

\mathbf{elif}\;t\_1 \leq 10^{-262}:\\
\;\;\;\;{x}^{3} \cdot \left(5 \cdot \left(x \cdot \varepsilon\right) + 10 \cdot {\varepsilon}^{2}\right)\\

\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-193}:\\
\;\;\;\;{\varepsilon}^{4} \cdot \left(x \cdot \left(5 + \frac{\varepsilon}{x}\right)\right)\\

\mathbf{elif}\;t\_1 \leq 10^{-145}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-108}:\\
\;\;\;\;\frac{{\left(x + \varepsilon\right)}^{10} - {x}^{10}}{t\_0 + {x}^{5}}\\

\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{-19}:\\
\;\;\;\;{\varepsilon}^{4} \cdot \left(\varepsilon + x \cdot 5\right)\\

\mathbf{else}:\\
\;\;\;\;{x}^{4} \cdot \left(\varepsilon \cdot \left(5 + 10 \cdot \frac{\varepsilon}{x}\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 7 regimes
  2. if (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < -2.0000024e-318 or 5.0000000000000005e-193 < (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < 9.99999999999999915e-146

    1. Initial program 99.8%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing

    if -2.0000024e-318 < (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < 0.0

    1. Initial program 88.7%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 99.9%

      \[\leadsto \color{blue}{{x}^{4} \cdot \left(\varepsilon + 4 \cdot \varepsilon\right)} \]
    4. Step-by-step derivation
      1. *-commutative99.9%

        \[\leadsto \color{blue}{\left(\varepsilon + 4 \cdot \varepsilon\right) \cdot {x}^{4}} \]
      2. distribute-rgt1-in99.9%

        \[\leadsto \color{blue}{\left(\left(4 + 1\right) \cdot \varepsilon\right)} \cdot {x}^{4} \]
      3. metadata-eval99.9%

        \[\leadsto \left(\color{blue}{5} \cdot \varepsilon\right) \cdot {x}^{4} \]
      4. *-commutative99.9%

        \[\leadsto \color{blue}{\left(\varepsilon \cdot 5\right)} \cdot {x}^{4} \]
      5. associate-*r*99.9%

        \[\leadsto \color{blue}{\varepsilon \cdot \left(5 \cdot {x}^{4}\right)} \]
    5. Simplified99.9%

      \[\leadsto \color{blue}{\varepsilon \cdot \left(5 \cdot {x}^{4}\right)} \]

    if 0.0 < (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < 1.00000000000000001e-262

    1. Initial program 43.9%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around -inf 98.4%

      \[\leadsto \color{blue}{{x}^{4} \cdot \left(\varepsilon + \left(-1 \cdot \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x} + 4 \cdot \varepsilon\right)\right)} \]
    4. Step-by-step derivation
      1. +-commutative98.4%

        \[\leadsto {x}^{4} \cdot \left(\varepsilon + \color{blue}{\left(4 \cdot \varepsilon + -1 \cdot \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right)}\right) \]
      2. associate-+r+98.4%

        \[\leadsto {x}^{4} \cdot \color{blue}{\left(\left(\varepsilon + 4 \cdot \varepsilon\right) + -1 \cdot \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right)} \]
      3. mul-1-neg98.4%

        \[\leadsto {x}^{4} \cdot \left(\left(\varepsilon + 4 \cdot \varepsilon\right) + \color{blue}{\left(-\frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right)}\right) \]
      4. unsub-neg98.4%

        \[\leadsto {x}^{4} \cdot \color{blue}{\left(\left(\varepsilon + 4 \cdot \varepsilon\right) - \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right)} \]
      5. distribute-rgt1-in98.4%

        \[\leadsto {x}^{4} \cdot \left(\color{blue}{\left(4 + 1\right) \cdot \varepsilon} - \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right) \]
      6. metadata-eval98.4%

        \[\leadsto {x}^{4} \cdot \left(\color{blue}{5} \cdot \varepsilon - \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right) \]
      7. *-commutative98.4%

        \[\leadsto {x}^{4} \cdot \left(\color{blue}{\varepsilon \cdot 5} - \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right) \]
    5. Simplified98.4%

      \[\leadsto \color{blue}{{x}^{4} \cdot \left(\varepsilon \cdot 5 - \frac{{\varepsilon}^{2} \cdot -10}{x}\right)} \]
    6. Taylor expanded in x around 0 100.0%

      \[\leadsto \color{blue}{{x}^{3} \cdot \left(5 \cdot \left(\varepsilon \cdot x\right) + 10 \cdot {\varepsilon}^{2}\right)} \]

    if 1.00000000000000001e-262 < (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < 5.0000000000000005e-193

    1. Initial program 99.2%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 100.0%

      \[\leadsto \color{blue}{x \cdot \left(4 \cdot {\varepsilon}^{4} + {\varepsilon}^{4}\right) + {\varepsilon}^{5}} \]
    4. Step-by-step derivation
      1. fma-define100.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, 4 \cdot {\varepsilon}^{4} + {\varepsilon}^{4}, {\varepsilon}^{5}\right)} \]
      2. distribute-lft1-in100.0%

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{\left(4 + 1\right) \cdot {\varepsilon}^{4}}, {\varepsilon}^{5}\right) \]
      3. metadata-eval100.0%

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{5} \cdot {\varepsilon}^{4}, {\varepsilon}^{5}\right) \]
    5. Simplified100.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, 5 \cdot {\varepsilon}^{4}, {\varepsilon}^{5}\right)} \]
    6. Taylor expanded in eps around 0 99.2%

      \[\leadsto \color{blue}{{\varepsilon}^{4} \cdot \left(\varepsilon + 5 \cdot x\right)} \]
    7. Taylor expanded in x around inf 100.0%

      \[\leadsto {\varepsilon}^{4} \cdot \color{blue}{\left(x \cdot \left(5 + \frac{\varepsilon}{x}\right)\right)} \]

    if 9.99999999999999915e-146 < (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < 5e-108

    1. Initial program 99.2%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. flip--100.0%

        \[\leadsto \color{blue}{\frac{{\left(x + \varepsilon\right)}^{5} \cdot {\left(x + \varepsilon\right)}^{5} - {x}^{5} \cdot {x}^{5}}{{\left(x + \varepsilon\right)}^{5} + {x}^{5}}} \]
      2. pow-prod-up100.0%

        \[\leadsto \frac{\color{blue}{{\left(x + \varepsilon\right)}^{\left(5 + 5\right)}} - {x}^{5} \cdot {x}^{5}}{{\left(x + \varepsilon\right)}^{5} + {x}^{5}} \]
      3. metadata-eval100.0%

        \[\leadsto \frac{{\left(x + \varepsilon\right)}^{\color{blue}{10}} - {x}^{5} \cdot {x}^{5}}{{\left(x + \varepsilon\right)}^{5} + {x}^{5}} \]
      4. pow-prod-up100.0%

        \[\leadsto \frac{{\left(x + \varepsilon\right)}^{10} - \color{blue}{{x}^{\left(5 + 5\right)}}}{{\left(x + \varepsilon\right)}^{5} + {x}^{5}} \]
      5. metadata-eval100.0%

        \[\leadsto \frac{{\left(x + \varepsilon\right)}^{10} - {x}^{\color{blue}{10}}}{{\left(x + \varepsilon\right)}^{5} + {x}^{5}} \]
    4. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\frac{{\left(x + \varepsilon\right)}^{10} - {x}^{10}}{{\left(x + \varepsilon\right)}^{5} + {x}^{5}}} \]

    if 5e-108 < (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < 5.0000000000000004e-19

    1. Initial program 99.8%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 100.0%

      \[\leadsto \color{blue}{x \cdot \left(4 \cdot {\varepsilon}^{4} + {\varepsilon}^{4}\right) + {\varepsilon}^{5}} \]
    4. Step-by-step derivation
      1. fma-define100.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, 4 \cdot {\varepsilon}^{4} + {\varepsilon}^{4}, {\varepsilon}^{5}\right)} \]
      2. distribute-lft1-in100.0%

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{\left(4 + 1\right) \cdot {\varepsilon}^{4}}, {\varepsilon}^{5}\right) \]
      3. metadata-eval100.0%

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{5} \cdot {\varepsilon}^{4}, {\varepsilon}^{5}\right) \]
    5. Simplified100.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, 5 \cdot {\varepsilon}^{4}, {\varepsilon}^{5}\right)} \]
    6. Taylor expanded in eps around 0 100.0%

      \[\leadsto \color{blue}{{\varepsilon}^{4} \cdot \left(\varepsilon + 5 \cdot x\right)} \]

    if 5.0000000000000004e-19 < (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64)))

    1. Initial program 42.3%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around -inf 100.0%

      \[\leadsto \color{blue}{{x}^{4} \cdot \left(\varepsilon + \left(-1 \cdot \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x} + 4 \cdot \varepsilon\right)\right)} \]
    4. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto {x}^{4} \cdot \left(\varepsilon + \color{blue}{\left(4 \cdot \varepsilon + -1 \cdot \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right)}\right) \]
      2. associate-+r+100.0%

        \[\leadsto {x}^{4} \cdot \color{blue}{\left(\left(\varepsilon + 4 \cdot \varepsilon\right) + -1 \cdot \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right)} \]
      3. mul-1-neg100.0%

        \[\leadsto {x}^{4} \cdot \left(\left(\varepsilon + 4 \cdot \varepsilon\right) + \color{blue}{\left(-\frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right)}\right) \]
      4. unsub-neg100.0%

        \[\leadsto {x}^{4} \cdot \color{blue}{\left(\left(\varepsilon + 4 \cdot \varepsilon\right) - \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right)} \]
      5. distribute-rgt1-in100.0%

        \[\leadsto {x}^{4} \cdot \left(\color{blue}{\left(4 + 1\right) \cdot \varepsilon} - \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right) \]
      6. metadata-eval100.0%

        \[\leadsto {x}^{4} \cdot \left(\color{blue}{5} \cdot \varepsilon - \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right) \]
      7. *-commutative100.0%

        \[\leadsto {x}^{4} \cdot \left(\color{blue}{\varepsilon \cdot 5} - \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right) \]
    5. Simplified100.0%

      \[\leadsto \color{blue}{{x}^{4} \cdot \left(\varepsilon \cdot 5 - \frac{{\varepsilon}^{2} \cdot -10}{x}\right)} \]
    6. Taylor expanded in eps around 0 100.0%

      \[\leadsto {x}^{4} \cdot \color{blue}{\left(\varepsilon \cdot \left(5 + 10 \cdot \frac{\varepsilon}{x}\right)\right)} \]
    7. Step-by-step derivation
      1. *-commutative100.0%

        \[\leadsto {x}^{4} \cdot \left(\varepsilon \cdot \left(5 + \color{blue}{\frac{\varepsilon}{x} \cdot 10}\right)\right) \]
    8. Simplified100.0%

      \[\leadsto {x}^{4} \cdot \color{blue}{\left(\varepsilon \cdot \left(5 + \frac{\varepsilon}{x} \cdot 10\right)\right)} \]
  3. Recombined 7 regimes into one program.
  4. Final simplification99.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;{\left(x + \varepsilon\right)}^{5} - {x}^{5} \leq -2 \cdot 10^{-318}:\\ \;\;\;\;{\left(x + \varepsilon\right)}^{5} - {x}^{5}\\ \mathbf{elif}\;{\left(x + \varepsilon\right)}^{5} - {x}^{5} \leq 0:\\ \;\;\;\;\varepsilon \cdot \left(5 \cdot {x}^{4}\right)\\ \mathbf{elif}\;{\left(x + \varepsilon\right)}^{5} - {x}^{5} \leq 10^{-262}:\\ \;\;\;\;{x}^{3} \cdot \left(5 \cdot \left(x \cdot \varepsilon\right) + 10 \cdot {\varepsilon}^{2}\right)\\ \mathbf{elif}\;{\left(x + \varepsilon\right)}^{5} - {x}^{5} \leq 5 \cdot 10^{-193}:\\ \;\;\;\;{\varepsilon}^{4} \cdot \left(x \cdot \left(5 + \frac{\varepsilon}{x}\right)\right)\\ \mathbf{elif}\;{\left(x + \varepsilon\right)}^{5} - {x}^{5} \leq 10^{-145}:\\ \;\;\;\;{\left(x + \varepsilon\right)}^{5} - {x}^{5}\\ \mathbf{elif}\;{\left(x + \varepsilon\right)}^{5} - {x}^{5} \leq 5 \cdot 10^{-108}:\\ \;\;\;\;\frac{{\left(x + \varepsilon\right)}^{10} - {x}^{10}}{{\left(x + \varepsilon\right)}^{5} + {x}^{5}}\\ \mathbf{elif}\;{\left(x + \varepsilon\right)}^{5} - {x}^{5} \leq 5 \cdot 10^{-19}:\\ \;\;\;\;{\varepsilon}^{4} \cdot \left(\varepsilon + x \cdot 5\right)\\ \mathbf{else}:\\ \;\;\;\;{x}^{4} \cdot \left(\varepsilon \cdot \left(5 + 10 \cdot \frac{\varepsilon}{x}\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 97.2% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(x + \varepsilon\right)}^{5} - {x}^{5}\\ \mathbf{if}\;t\_0 \leq -2 \cdot 10^{-318}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;t\_0 \leq 0:\\ \;\;\;\;\varepsilon \cdot \left(5 \cdot {x}^{4}\right)\\ \mathbf{elif}\;t\_0 \leq 10^{-262}:\\ \;\;\;\;{x}^{3} \cdot \left(5 \cdot \left(x \cdot \varepsilon\right) + 10 \cdot {\varepsilon}^{2}\right)\\ \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-193}:\\ \;\;\;\;{\varepsilon}^{4} \cdot \left(x \cdot \left(5 + \frac{\varepsilon}{x}\right)\right)\\ \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-108}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-19}:\\ \;\;\;\;{\varepsilon}^{4} \cdot \left(\varepsilon + x \cdot 5\right)\\ \mathbf{else}:\\ \;\;\;\;{x}^{4} \cdot \left(\varepsilon \cdot \left(5 + 10 \cdot \frac{\varepsilon}{x}\right)\right)\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (let* ((t_0 (- (pow (+ x eps) 5.0) (pow x 5.0))))
   (if (<= t_0 -2e-318)
     t_0
     (if (<= t_0 0.0)
       (* eps (* 5.0 (pow x 4.0)))
       (if (<= t_0 1e-262)
         (* (pow x 3.0) (+ (* 5.0 (* x eps)) (* 10.0 (pow eps 2.0))))
         (if (<= t_0 5e-193)
           (* (pow eps 4.0) (* x (+ 5.0 (/ eps x))))
           (if (<= t_0 5e-108)
             t_0
             (if (<= t_0 5e-19)
               (* (pow eps 4.0) (+ eps (* x 5.0)))
               (* (pow x 4.0) (* eps (+ 5.0 (* 10.0 (/ eps x)))))))))))))
double code(double x, double eps) {
	double t_0 = pow((x + eps), 5.0) - pow(x, 5.0);
	double tmp;
	if (t_0 <= -2e-318) {
		tmp = t_0;
	} else if (t_0 <= 0.0) {
		tmp = eps * (5.0 * pow(x, 4.0));
	} else if (t_0 <= 1e-262) {
		tmp = pow(x, 3.0) * ((5.0 * (x * eps)) + (10.0 * pow(eps, 2.0)));
	} else if (t_0 <= 5e-193) {
		tmp = pow(eps, 4.0) * (x * (5.0 + (eps / x)));
	} else if (t_0 <= 5e-108) {
		tmp = t_0;
	} else if (t_0 <= 5e-19) {
		tmp = pow(eps, 4.0) * (eps + (x * 5.0));
	} else {
		tmp = pow(x, 4.0) * (eps * (5.0 + (10.0 * (eps / x))));
	}
	return tmp;
}
real(8) function code(x, eps)
    real(8), intent (in) :: x
    real(8), intent (in) :: eps
    real(8) :: t_0
    real(8) :: tmp
    t_0 = ((x + eps) ** 5.0d0) - (x ** 5.0d0)
    if (t_0 <= (-2d-318)) then
        tmp = t_0
    else if (t_0 <= 0.0d0) then
        tmp = eps * (5.0d0 * (x ** 4.0d0))
    else if (t_0 <= 1d-262) then
        tmp = (x ** 3.0d0) * ((5.0d0 * (x * eps)) + (10.0d0 * (eps ** 2.0d0)))
    else if (t_0 <= 5d-193) then
        tmp = (eps ** 4.0d0) * (x * (5.0d0 + (eps / x)))
    else if (t_0 <= 5d-108) then
        tmp = t_0
    else if (t_0 <= 5d-19) then
        tmp = (eps ** 4.0d0) * (eps + (x * 5.0d0))
    else
        tmp = (x ** 4.0d0) * (eps * (5.0d0 + (10.0d0 * (eps / x))))
    end if
    code = tmp
end function
public static double code(double x, double eps) {
	double t_0 = Math.pow((x + eps), 5.0) - Math.pow(x, 5.0);
	double tmp;
	if (t_0 <= -2e-318) {
		tmp = t_0;
	} else if (t_0 <= 0.0) {
		tmp = eps * (5.0 * Math.pow(x, 4.0));
	} else if (t_0 <= 1e-262) {
		tmp = Math.pow(x, 3.0) * ((5.0 * (x * eps)) + (10.0 * Math.pow(eps, 2.0)));
	} else if (t_0 <= 5e-193) {
		tmp = Math.pow(eps, 4.0) * (x * (5.0 + (eps / x)));
	} else if (t_0 <= 5e-108) {
		tmp = t_0;
	} else if (t_0 <= 5e-19) {
		tmp = Math.pow(eps, 4.0) * (eps + (x * 5.0));
	} else {
		tmp = Math.pow(x, 4.0) * (eps * (5.0 + (10.0 * (eps / x))));
	}
	return tmp;
}
def code(x, eps):
	t_0 = math.pow((x + eps), 5.0) - math.pow(x, 5.0)
	tmp = 0
	if t_0 <= -2e-318:
		tmp = t_0
	elif t_0 <= 0.0:
		tmp = eps * (5.0 * math.pow(x, 4.0))
	elif t_0 <= 1e-262:
		tmp = math.pow(x, 3.0) * ((5.0 * (x * eps)) + (10.0 * math.pow(eps, 2.0)))
	elif t_0 <= 5e-193:
		tmp = math.pow(eps, 4.0) * (x * (5.0 + (eps / x)))
	elif t_0 <= 5e-108:
		tmp = t_0
	elif t_0 <= 5e-19:
		tmp = math.pow(eps, 4.0) * (eps + (x * 5.0))
	else:
		tmp = math.pow(x, 4.0) * (eps * (5.0 + (10.0 * (eps / x))))
	return tmp
function code(x, eps)
	t_0 = Float64((Float64(x + eps) ^ 5.0) - (x ^ 5.0))
	tmp = 0.0
	if (t_0 <= -2e-318)
		tmp = t_0;
	elseif (t_0 <= 0.0)
		tmp = Float64(eps * Float64(5.0 * (x ^ 4.0)));
	elseif (t_0 <= 1e-262)
		tmp = Float64((x ^ 3.0) * Float64(Float64(5.0 * Float64(x * eps)) + Float64(10.0 * (eps ^ 2.0))));
	elseif (t_0 <= 5e-193)
		tmp = Float64((eps ^ 4.0) * Float64(x * Float64(5.0 + Float64(eps / x))));
	elseif (t_0 <= 5e-108)
		tmp = t_0;
	elseif (t_0 <= 5e-19)
		tmp = Float64((eps ^ 4.0) * Float64(eps + Float64(x * 5.0)));
	else
		tmp = Float64((x ^ 4.0) * Float64(eps * Float64(5.0 + Float64(10.0 * Float64(eps / x)))));
	end
	return tmp
end
function tmp_2 = code(x, eps)
	t_0 = ((x + eps) ^ 5.0) - (x ^ 5.0);
	tmp = 0.0;
	if (t_0 <= -2e-318)
		tmp = t_0;
	elseif (t_0 <= 0.0)
		tmp = eps * (5.0 * (x ^ 4.0));
	elseif (t_0 <= 1e-262)
		tmp = (x ^ 3.0) * ((5.0 * (x * eps)) + (10.0 * (eps ^ 2.0)));
	elseif (t_0 <= 5e-193)
		tmp = (eps ^ 4.0) * (x * (5.0 + (eps / x)));
	elseif (t_0 <= 5e-108)
		tmp = t_0;
	elseif (t_0 <= 5e-19)
		tmp = (eps ^ 4.0) * (eps + (x * 5.0));
	else
		tmp = (x ^ 4.0) * (eps * (5.0 + (10.0 * (eps / x))));
	end
	tmp_2 = tmp;
end
code[x_, eps_] := Block[{t$95$0 = N[(N[Power[N[(x + eps), $MachinePrecision], 5.0], $MachinePrecision] - N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2e-318], t$95$0, If[LessEqual[t$95$0, 0.0], N[(eps * N[(5.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e-262], N[(N[Power[x, 3.0], $MachinePrecision] * N[(N[(5.0 * N[(x * eps), $MachinePrecision]), $MachinePrecision] + N[(10.0 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e-193], N[(N[Power[eps, 4.0], $MachinePrecision] * N[(x * N[(5.0 + N[(eps / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e-108], t$95$0, If[LessEqual[t$95$0, 5e-19], N[(N[Power[eps, 4.0], $MachinePrecision] * N[(eps + N[(x * 5.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, 4.0], $MachinePrecision] * N[(eps * N[(5.0 + N[(10.0 * N[(eps / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\left(x + \varepsilon\right)}^{5} - {x}^{5}\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{-318}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;\varepsilon \cdot \left(5 \cdot {x}^{4}\right)\\

\mathbf{elif}\;t\_0 \leq 10^{-262}:\\
\;\;\;\;{x}^{3} \cdot \left(5 \cdot \left(x \cdot \varepsilon\right) + 10 \cdot {\varepsilon}^{2}\right)\\

\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-193}:\\
\;\;\;\;{\varepsilon}^{4} \cdot \left(x \cdot \left(5 + \frac{\varepsilon}{x}\right)\right)\\

\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-108}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-19}:\\
\;\;\;\;{\varepsilon}^{4} \cdot \left(\varepsilon + x \cdot 5\right)\\

\mathbf{else}:\\
\;\;\;\;{x}^{4} \cdot \left(\varepsilon \cdot \left(5 + 10 \cdot \frac{\varepsilon}{x}\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 6 regimes
  2. if (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < -2.0000024e-318 or 5.0000000000000005e-193 < (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < 5e-108

    1. Initial program 99.8%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing

    if -2.0000024e-318 < (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < 0.0

    1. Initial program 88.7%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 99.9%

      \[\leadsto \color{blue}{{x}^{4} \cdot \left(\varepsilon + 4 \cdot \varepsilon\right)} \]
    4. Step-by-step derivation
      1. *-commutative99.9%

        \[\leadsto \color{blue}{\left(\varepsilon + 4 \cdot \varepsilon\right) \cdot {x}^{4}} \]
      2. distribute-rgt1-in99.9%

        \[\leadsto \color{blue}{\left(\left(4 + 1\right) \cdot \varepsilon\right)} \cdot {x}^{4} \]
      3. metadata-eval99.9%

        \[\leadsto \left(\color{blue}{5} \cdot \varepsilon\right) \cdot {x}^{4} \]
      4. *-commutative99.9%

        \[\leadsto \color{blue}{\left(\varepsilon \cdot 5\right)} \cdot {x}^{4} \]
      5. associate-*r*99.9%

        \[\leadsto \color{blue}{\varepsilon \cdot \left(5 \cdot {x}^{4}\right)} \]
    5. Simplified99.9%

      \[\leadsto \color{blue}{\varepsilon \cdot \left(5 \cdot {x}^{4}\right)} \]

    if 0.0 < (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < 1.00000000000000001e-262

    1. Initial program 43.9%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around -inf 98.4%

      \[\leadsto \color{blue}{{x}^{4} \cdot \left(\varepsilon + \left(-1 \cdot \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x} + 4 \cdot \varepsilon\right)\right)} \]
    4. Step-by-step derivation
      1. +-commutative98.4%

        \[\leadsto {x}^{4} \cdot \left(\varepsilon + \color{blue}{\left(4 \cdot \varepsilon + -1 \cdot \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right)}\right) \]
      2. associate-+r+98.4%

        \[\leadsto {x}^{4} \cdot \color{blue}{\left(\left(\varepsilon + 4 \cdot \varepsilon\right) + -1 \cdot \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right)} \]
      3. mul-1-neg98.4%

        \[\leadsto {x}^{4} \cdot \left(\left(\varepsilon + 4 \cdot \varepsilon\right) + \color{blue}{\left(-\frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right)}\right) \]
      4. unsub-neg98.4%

        \[\leadsto {x}^{4} \cdot \color{blue}{\left(\left(\varepsilon + 4 \cdot \varepsilon\right) - \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right)} \]
      5. distribute-rgt1-in98.4%

        \[\leadsto {x}^{4} \cdot \left(\color{blue}{\left(4 + 1\right) \cdot \varepsilon} - \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right) \]
      6. metadata-eval98.4%

        \[\leadsto {x}^{4} \cdot \left(\color{blue}{5} \cdot \varepsilon - \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right) \]
      7. *-commutative98.4%

        \[\leadsto {x}^{4} \cdot \left(\color{blue}{\varepsilon \cdot 5} - \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right) \]
    5. Simplified98.4%

      \[\leadsto \color{blue}{{x}^{4} \cdot \left(\varepsilon \cdot 5 - \frac{{\varepsilon}^{2} \cdot -10}{x}\right)} \]
    6. Taylor expanded in x around 0 100.0%

      \[\leadsto \color{blue}{{x}^{3} \cdot \left(5 \cdot \left(\varepsilon \cdot x\right) + 10 \cdot {\varepsilon}^{2}\right)} \]

    if 1.00000000000000001e-262 < (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < 5.0000000000000005e-193

    1. Initial program 99.2%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 100.0%

      \[\leadsto \color{blue}{x \cdot \left(4 \cdot {\varepsilon}^{4} + {\varepsilon}^{4}\right) + {\varepsilon}^{5}} \]
    4. Step-by-step derivation
      1. fma-define100.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, 4 \cdot {\varepsilon}^{4} + {\varepsilon}^{4}, {\varepsilon}^{5}\right)} \]
      2. distribute-lft1-in100.0%

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{\left(4 + 1\right) \cdot {\varepsilon}^{4}}, {\varepsilon}^{5}\right) \]
      3. metadata-eval100.0%

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{5} \cdot {\varepsilon}^{4}, {\varepsilon}^{5}\right) \]
    5. Simplified100.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, 5 \cdot {\varepsilon}^{4}, {\varepsilon}^{5}\right)} \]
    6. Taylor expanded in eps around 0 99.2%

      \[\leadsto \color{blue}{{\varepsilon}^{4} \cdot \left(\varepsilon + 5 \cdot x\right)} \]
    7. Taylor expanded in x around inf 100.0%

      \[\leadsto {\varepsilon}^{4} \cdot \color{blue}{\left(x \cdot \left(5 + \frac{\varepsilon}{x}\right)\right)} \]

    if 5e-108 < (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < 5.0000000000000004e-19

    1. Initial program 99.8%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 100.0%

      \[\leadsto \color{blue}{x \cdot \left(4 \cdot {\varepsilon}^{4} + {\varepsilon}^{4}\right) + {\varepsilon}^{5}} \]
    4. Step-by-step derivation
      1. fma-define100.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, 4 \cdot {\varepsilon}^{4} + {\varepsilon}^{4}, {\varepsilon}^{5}\right)} \]
      2. distribute-lft1-in100.0%

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{\left(4 + 1\right) \cdot {\varepsilon}^{4}}, {\varepsilon}^{5}\right) \]
      3. metadata-eval100.0%

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{5} \cdot {\varepsilon}^{4}, {\varepsilon}^{5}\right) \]
    5. Simplified100.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, 5 \cdot {\varepsilon}^{4}, {\varepsilon}^{5}\right)} \]
    6. Taylor expanded in eps around 0 100.0%

      \[\leadsto \color{blue}{{\varepsilon}^{4} \cdot \left(\varepsilon + 5 \cdot x\right)} \]

    if 5.0000000000000004e-19 < (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64)))

    1. Initial program 42.3%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around -inf 100.0%

      \[\leadsto \color{blue}{{x}^{4} \cdot \left(\varepsilon + \left(-1 \cdot \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x} + 4 \cdot \varepsilon\right)\right)} \]
    4. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto {x}^{4} \cdot \left(\varepsilon + \color{blue}{\left(4 \cdot \varepsilon + -1 \cdot \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right)}\right) \]
      2. associate-+r+100.0%

        \[\leadsto {x}^{4} \cdot \color{blue}{\left(\left(\varepsilon + 4 \cdot \varepsilon\right) + -1 \cdot \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right)} \]
      3. mul-1-neg100.0%

        \[\leadsto {x}^{4} \cdot \left(\left(\varepsilon + 4 \cdot \varepsilon\right) + \color{blue}{\left(-\frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right)}\right) \]
      4. unsub-neg100.0%

        \[\leadsto {x}^{4} \cdot \color{blue}{\left(\left(\varepsilon + 4 \cdot \varepsilon\right) - \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right)} \]
      5. distribute-rgt1-in100.0%

        \[\leadsto {x}^{4} \cdot \left(\color{blue}{\left(4 + 1\right) \cdot \varepsilon} - \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right) \]
      6. metadata-eval100.0%

        \[\leadsto {x}^{4} \cdot \left(\color{blue}{5} \cdot \varepsilon - \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right) \]
      7. *-commutative100.0%

        \[\leadsto {x}^{4} \cdot \left(\color{blue}{\varepsilon \cdot 5} - \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right) \]
    5. Simplified100.0%

      \[\leadsto \color{blue}{{x}^{4} \cdot \left(\varepsilon \cdot 5 - \frac{{\varepsilon}^{2} \cdot -10}{x}\right)} \]
    6. Taylor expanded in eps around 0 100.0%

      \[\leadsto {x}^{4} \cdot \color{blue}{\left(\varepsilon \cdot \left(5 + 10 \cdot \frac{\varepsilon}{x}\right)\right)} \]
    7. Step-by-step derivation
      1. *-commutative100.0%

        \[\leadsto {x}^{4} \cdot \left(\varepsilon \cdot \left(5 + \color{blue}{\frac{\varepsilon}{x} \cdot 10}\right)\right) \]
    8. Simplified100.0%

      \[\leadsto {x}^{4} \cdot \color{blue}{\left(\varepsilon \cdot \left(5 + \frac{\varepsilon}{x} \cdot 10\right)\right)} \]
  3. Recombined 6 regimes into one program.
  4. Final simplification99.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;{\left(x + \varepsilon\right)}^{5} - {x}^{5} \leq -2 \cdot 10^{-318}:\\ \;\;\;\;{\left(x + \varepsilon\right)}^{5} - {x}^{5}\\ \mathbf{elif}\;{\left(x + \varepsilon\right)}^{5} - {x}^{5} \leq 0:\\ \;\;\;\;\varepsilon \cdot \left(5 \cdot {x}^{4}\right)\\ \mathbf{elif}\;{\left(x + \varepsilon\right)}^{5} - {x}^{5} \leq 10^{-262}:\\ \;\;\;\;{x}^{3} \cdot \left(5 \cdot \left(x \cdot \varepsilon\right) + 10 \cdot {\varepsilon}^{2}\right)\\ \mathbf{elif}\;{\left(x + \varepsilon\right)}^{5} - {x}^{5} \leq 5 \cdot 10^{-193}:\\ \;\;\;\;{\varepsilon}^{4} \cdot \left(x \cdot \left(5 + \frac{\varepsilon}{x}\right)\right)\\ \mathbf{elif}\;{\left(x + \varepsilon\right)}^{5} - {x}^{5} \leq 5 \cdot 10^{-108}:\\ \;\;\;\;{\left(x + \varepsilon\right)}^{5} - {x}^{5}\\ \mathbf{elif}\;{\left(x + \varepsilon\right)}^{5} - {x}^{5} \leq 5 \cdot 10^{-19}:\\ \;\;\;\;{\varepsilon}^{4} \cdot \left(\varepsilon + x \cdot 5\right)\\ \mathbf{else}:\\ \;\;\;\;{x}^{4} \cdot \left(\varepsilon \cdot \left(5 + 10 \cdot \frac{\varepsilon}{x}\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 97.2% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(x + \varepsilon\right)}^{5} - {x}^{5}\\ t_1 := {x}^{4} \cdot \left(\varepsilon \cdot \left(5 + 10 \cdot \frac{\varepsilon}{x}\right)\right)\\ \mathbf{if}\;t\_0 \leq -2 \cdot 10^{-318}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;t\_0 \leq 10^{-262}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-193}:\\ \;\;\;\;{\varepsilon}^{4} \cdot \left(x \cdot \left(5 + \frac{\varepsilon}{x}\right)\right)\\ \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-108}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-19}:\\ \;\;\;\;{\varepsilon}^{4} \cdot \left(\varepsilon + x \cdot 5\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (let* ((t_0 (- (pow (+ x eps) 5.0) (pow x 5.0)))
        (t_1 (* (pow x 4.0) (* eps (+ 5.0 (* 10.0 (/ eps x)))))))
   (if (<= t_0 -2e-318)
     t_0
     (if (<= t_0 1e-262)
       t_1
       (if (<= t_0 5e-193)
         (* (pow eps 4.0) (* x (+ 5.0 (/ eps x))))
         (if (<= t_0 5e-108)
           t_0
           (if (<= t_0 5e-19) (* (pow eps 4.0) (+ eps (* x 5.0))) t_1)))))))
double code(double x, double eps) {
	double t_0 = pow((x + eps), 5.0) - pow(x, 5.0);
	double t_1 = pow(x, 4.0) * (eps * (5.0 + (10.0 * (eps / x))));
	double tmp;
	if (t_0 <= -2e-318) {
		tmp = t_0;
	} else if (t_0 <= 1e-262) {
		tmp = t_1;
	} else if (t_0 <= 5e-193) {
		tmp = pow(eps, 4.0) * (x * (5.0 + (eps / x)));
	} else if (t_0 <= 5e-108) {
		tmp = t_0;
	} else if (t_0 <= 5e-19) {
		tmp = pow(eps, 4.0) * (eps + (x * 5.0));
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(x, eps)
    real(8), intent (in) :: x
    real(8), intent (in) :: eps
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = ((x + eps) ** 5.0d0) - (x ** 5.0d0)
    t_1 = (x ** 4.0d0) * (eps * (5.0d0 + (10.0d0 * (eps / x))))
    if (t_0 <= (-2d-318)) then
        tmp = t_0
    else if (t_0 <= 1d-262) then
        tmp = t_1
    else if (t_0 <= 5d-193) then
        tmp = (eps ** 4.0d0) * (x * (5.0d0 + (eps / x)))
    else if (t_0 <= 5d-108) then
        tmp = t_0
    else if (t_0 <= 5d-19) then
        tmp = (eps ** 4.0d0) * (eps + (x * 5.0d0))
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double eps) {
	double t_0 = Math.pow((x + eps), 5.0) - Math.pow(x, 5.0);
	double t_1 = Math.pow(x, 4.0) * (eps * (5.0 + (10.0 * (eps / x))));
	double tmp;
	if (t_0 <= -2e-318) {
		tmp = t_0;
	} else if (t_0 <= 1e-262) {
		tmp = t_1;
	} else if (t_0 <= 5e-193) {
		tmp = Math.pow(eps, 4.0) * (x * (5.0 + (eps / x)));
	} else if (t_0 <= 5e-108) {
		tmp = t_0;
	} else if (t_0 <= 5e-19) {
		tmp = Math.pow(eps, 4.0) * (eps + (x * 5.0));
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, eps):
	t_0 = math.pow((x + eps), 5.0) - math.pow(x, 5.0)
	t_1 = math.pow(x, 4.0) * (eps * (5.0 + (10.0 * (eps / x))))
	tmp = 0
	if t_0 <= -2e-318:
		tmp = t_0
	elif t_0 <= 1e-262:
		tmp = t_1
	elif t_0 <= 5e-193:
		tmp = math.pow(eps, 4.0) * (x * (5.0 + (eps / x)))
	elif t_0 <= 5e-108:
		tmp = t_0
	elif t_0 <= 5e-19:
		tmp = math.pow(eps, 4.0) * (eps + (x * 5.0))
	else:
		tmp = t_1
	return tmp
function code(x, eps)
	t_0 = Float64((Float64(x + eps) ^ 5.0) - (x ^ 5.0))
	t_1 = Float64((x ^ 4.0) * Float64(eps * Float64(5.0 + Float64(10.0 * Float64(eps / x)))))
	tmp = 0.0
	if (t_0 <= -2e-318)
		tmp = t_0;
	elseif (t_0 <= 1e-262)
		tmp = t_1;
	elseif (t_0 <= 5e-193)
		tmp = Float64((eps ^ 4.0) * Float64(x * Float64(5.0 + Float64(eps / x))));
	elseif (t_0 <= 5e-108)
		tmp = t_0;
	elseif (t_0 <= 5e-19)
		tmp = Float64((eps ^ 4.0) * Float64(eps + Float64(x * 5.0)));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, eps)
	t_0 = ((x + eps) ^ 5.0) - (x ^ 5.0);
	t_1 = (x ^ 4.0) * (eps * (5.0 + (10.0 * (eps / x))));
	tmp = 0.0;
	if (t_0 <= -2e-318)
		tmp = t_0;
	elseif (t_0 <= 1e-262)
		tmp = t_1;
	elseif (t_0 <= 5e-193)
		tmp = (eps ^ 4.0) * (x * (5.0 + (eps / x)));
	elseif (t_0 <= 5e-108)
		tmp = t_0;
	elseif (t_0 <= 5e-19)
		tmp = (eps ^ 4.0) * (eps + (x * 5.0));
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, eps_] := Block[{t$95$0 = N[(N[Power[N[(x + eps), $MachinePrecision], 5.0], $MachinePrecision] - N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[x, 4.0], $MachinePrecision] * N[(eps * N[(5.0 + N[(10.0 * N[(eps / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -2e-318], t$95$0, If[LessEqual[t$95$0, 1e-262], t$95$1, If[LessEqual[t$95$0, 5e-193], N[(N[Power[eps, 4.0], $MachinePrecision] * N[(x * N[(5.0 + N[(eps / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e-108], t$95$0, If[LessEqual[t$95$0, 5e-19], N[(N[Power[eps, 4.0], $MachinePrecision] * N[(eps + N[(x * 5.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\left(x + \varepsilon\right)}^{5} - {x}^{5}\\
t_1 := {x}^{4} \cdot \left(\varepsilon \cdot \left(5 + 10 \cdot \frac{\varepsilon}{x}\right)\right)\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{-318}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;t\_0 \leq 10^{-262}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-193}:\\
\;\;\;\;{\varepsilon}^{4} \cdot \left(x \cdot \left(5 + \frac{\varepsilon}{x}\right)\right)\\

\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-108}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{-19}:\\
\;\;\;\;{\varepsilon}^{4} \cdot \left(\varepsilon + x \cdot 5\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < -2.0000024e-318 or 5.0000000000000005e-193 < (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < 5e-108

    1. Initial program 99.8%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing

    if -2.0000024e-318 < (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < 1.00000000000000001e-262 or 5.0000000000000004e-19 < (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64)))

    1. Initial program 88.3%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around -inf 99.9%

      \[\leadsto \color{blue}{{x}^{4} \cdot \left(\varepsilon + \left(-1 \cdot \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x} + 4 \cdot \varepsilon\right)\right)} \]
    4. Step-by-step derivation
      1. +-commutative99.9%

        \[\leadsto {x}^{4} \cdot \left(\varepsilon + \color{blue}{\left(4 \cdot \varepsilon + -1 \cdot \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right)}\right) \]
      2. associate-+r+99.9%

        \[\leadsto {x}^{4} \cdot \color{blue}{\left(\left(\varepsilon + 4 \cdot \varepsilon\right) + -1 \cdot \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right)} \]
      3. mul-1-neg99.9%

        \[\leadsto {x}^{4} \cdot \left(\left(\varepsilon + 4 \cdot \varepsilon\right) + \color{blue}{\left(-\frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right)}\right) \]
      4. unsub-neg99.9%

        \[\leadsto {x}^{4} \cdot \color{blue}{\left(\left(\varepsilon + 4 \cdot \varepsilon\right) - \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right)} \]
      5. distribute-rgt1-in99.9%

        \[\leadsto {x}^{4} \cdot \left(\color{blue}{\left(4 + 1\right) \cdot \varepsilon} - \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right) \]
      6. metadata-eval99.9%

        \[\leadsto {x}^{4} \cdot \left(\color{blue}{5} \cdot \varepsilon - \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right) \]
      7. *-commutative99.9%

        \[\leadsto {x}^{4} \cdot \left(\color{blue}{\varepsilon \cdot 5} - \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right) \]
    5. Simplified99.9%

      \[\leadsto \color{blue}{{x}^{4} \cdot \left(\varepsilon \cdot 5 - \frac{{\varepsilon}^{2} \cdot -10}{x}\right)} \]
    6. Taylor expanded in eps around 0 99.9%

      \[\leadsto {x}^{4} \cdot \color{blue}{\left(\varepsilon \cdot \left(5 + 10 \cdot \frac{\varepsilon}{x}\right)\right)} \]
    7. Step-by-step derivation
      1. *-commutative99.9%

        \[\leadsto {x}^{4} \cdot \left(\varepsilon \cdot \left(5 + \color{blue}{\frac{\varepsilon}{x} \cdot 10}\right)\right) \]
    8. Simplified99.9%

      \[\leadsto {x}^{4} \cdot \color{blue}{\left(\varepsilon \cdot \left(5 + \frac{\varepsilon}{x} \cdot 10\right)\right)} \]

    if 1.00000000000000001e-262 < (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < 5.0000000000000005e-193

    1. Initial program 99.2%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 100.0%

      \[\leadsto \color{blue}{x \cdot \left(4 \cdot {\varepsilon}^{4} + {\varepsilon}^{4}\right) + {\varepsilon}^{5}} \]
    4. Step-by-step derivation
      1. fma-define100.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, 4 \cdot {\varepsilon}^{4} + {\varepsilon}^{4}, {\varepsilon}^{5}\right)} \]
      2. distribute-lft1-in100.0%

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{\left(4 + 1\right) \cdot {\varepsilon}^{4}}, {\varepsilon}^{5}\right) \]
      3. metadata-eval100.0%

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{5} \cdot {\varepsilon}^{4}, {\varepsilon}^{5}\right) \]
    5. Simplified100.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, 5 \cdot {\varepsilon}^{4}, {\varepsilon}^{5}\right)} \]
    6. Taylor expanded in eps around 0 99.2%

      \[\leadsto \color{blue}{{\varepsilon}^{4} \cdot \left(\varepsilon + 5 \cdot x\right)} \]
    7. Taylor expanded in x around inf 100.0%

      \[\leadsto {\varepsilon}^{4} \cdot \color{blue}{\left(x \cdot \left(5 + \frac{\varepsilon}{x}\right)\right)} \]

    if 5e-108 < (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < 5.0000000000000004e-19

    1. Initial program 99.8%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 100.0%

      \[\leadsto \color{blue}{x \cdot \left(4 \cdot {\varepsilon}^{4} + {\varepsilon}^{4}\right) + {\varepsilon}^{5}} \]
    4. Step-by-step derivation
      1. fma-define100.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, 4 \cdot {\varepsilon}^{4} + {\varepsilon}^{4}, {\varepsilon}^{5}\right)} \]
      2. distribute-lft1-in100.0%

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{\left(4 + 1\right) \cdot {\varepsilon}^{4}}, {\varepsilon}^{5}\right) \]
      3. metadata-eval100.0%

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{5} \cdot {\varepsilon}^{4}, {\varepsilon}^{5}\right) \]
    5. Simplified100.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, 5 \cdot {\varepsilon}^{4}, {\varepsilon}^{5}\right)} \]
    6. Taylor expanded in eps around 0 100.0%

      \[\leadsto \color{blue}{{\varepsilon}^{4} \cdot \left(\varepsilon + 5 \cdot x\right)} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification99.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;{\left(x + \varepsilon\right)}^{5} - {x}^{5} \leq -2 \cdot 10^{-318}:\\ \;\;\;\;{\left(x + \varepsilon\right)}^{5} - {x}^{5}\\ \mathbf{elif}\;{\left(x + \varepsilon\right)}^{5} - {x}^{5} \leq 10^{-262}:\\ \;\;\;\;{x}^{4} \cdot \left(\varepsilon \cdot \left(5 + 10 \cdot \frac{\varepsilon}{x}\right)\right)\\ \mathbf{elif}\;{\left(x + \varepsilon\right)}^{5} - {x}^{5} \leq 5 \cdot 10^{-193}:\\ \;\;\;\;{\varepsilon}^{4} \cdot \left(x \cdot \left(5 + \frac{\varepsilon}{x}\right)\right)\\ \mathbf{elif}\;{\left(x + \varepsilon\right)}^{5} - {x}^{5} \leq 5 \cdot 10^{-108}:\\ \;\;\;\;{\left(x + \varepsilon\right)}^{5} - {x}^{5}\\ \mathbf{elif}\;{\left(x + \varepsilon\right)}^{5} - {x}^{5} \leq 5 \cdot 10^{-19}:\\ \;\;\;\;{\varepsilon}^{4} \cdot \left(\varepsilon + x \cdot 5\right)\\ \mathbf{else}:\\ \;\;\;\;{x}^{4} \cdot \left(\varepsilon \cdot \left(5 + 10 \cdot \frac{\varepsilon}{x}\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 97.3% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\varepsilon}^{4} \cdot \left(\varepsilon + x \cdot 5\right)\\ t_1 := 5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\ t_2 := \varepsilon \cdot \left(5 \cdot {x}^{4}\right)\\ t_3 := {\varepsilon}^{4} \cdot \left(x \cdot \left(5 + \frac{\varepsilon}{x}\right)\right)\\ \mathbf{if}\;x \leq -4.8 \cdot 10^{-52}:\\ \;\;\;\;{x}^{4} \cdot \left(\varepsilon \cdot \left(5 + 10 \cdot \frac{\varepsilon}{x}\right)\right)\\ \mathbf{elif}\;x \leq -4 \cdot 10^{-78}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 10^{-270}:\\ \;\;\;\;{\varepsilon}^{5}\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{-55}:\\ \;\;\;\;t\_3\\ \mathbf{elif}\;x \leq 3 \cdot 10^{-45}:\\ \;\;\;\;{\varepsilon}^{5} \cdot \left(1 + 5 \cdot \frac{x}{\varepsilon}\right)\\ \mathbf{elif}\;x \leq 1.22 \cdot 10^{-26}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;x \leq 1.45 \cdot 10^{-23}:\\ \;\;\;\;t\_3\\ \mathbf{elif}\;x \leq 1.15 \cdot 10^{-18}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 1.16 \cdot 10^{-18}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 5 \cdot 10^{-7}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;x \leq 12000000:\\ \;\;\;\;\varepsilon \cdot \sqrt[3]{125 \cdot {x}^{12}}\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (let* ((t_0 (* (pow eps 4.0) (+ eps (* x 5.0))))
        (t_1 (* 5.0 (* eps (pow x 4.0))))
        (t_2 (* eps (* 5.0 (pow x 4.0))))
        (t_3 (* (pow eps 4.0) (* x (+ 5.0 (/ eps x))))))
   (if (<= x -4.8e-52)
     (* (pow x 4.0) (* eps (+ 5.0 (* 10.0 (/ eps x)))))
     (if (<= x -4e-78)
       t_0
       (if (<= x 1e-270)
         (pow eps 5.0)
         (if (<= x 1.5e-55)
           t_3
           (if (<= x 3e-45)
             (* (pow eps 5.0) (+ 1.0 (* 5.0 (/ x eps))))
             (if (<= x 1.22e-26)
               t_2
               (if (<= x 1.45e-23)
                 t_3
                 (if (<= x 1.15e-18)
                   t_1
                   (if (<= x 1.16e-18)
                     t_0
                     (if (<= x 5e-7)
                       t_2
                       (if (<= x 12000000.0)
                         (* eps (cbrt (* 125.0 (pow x 12.0))))
                         t_1)))))))))))))
double code(double x, double eps) {
	double t_0 = pow(eps, 4.0) * (eps + (x * 5.0));
	double t_1 = 5.0 * (eps * pow(x, 4.0));
	double t_2 = eps * (5.0 * pow(x, 4.0));
	double t_3 = pow(eps, 4.0) * (x * (5.0 + (eps / x)));
	double tmp;
	if (x <= -4.8e-52) {
		tmp = pow(x, 4.0) * (eps * (5.0 + (10.0 * (eps / x))));
	} else if (x <= -4e-78) {
		tmp = t_0;
	} else if (x <= 1e-270) {
		tmp = pow(eps, 5.0);
	} else if (x <= 1.5e-55) {
		tmp = t_3;
	} else if (x <= 3e-45) {
		tmp = pow(eps, 5.0) * (1.0 + (5.0 * (x / eps)));
	} else if (x <= 1.22e-26) {
		tmp = t_2;
	} else if (x <= 1.45e-23) {
		tmp = t_3;
	} else if (x <= 1.15e-18) {
		tmp = t_1;
	} else if (x <= 1.16e-18) {
		tmp = t_0;
	} else if (x <= 5e-7) {
		tmp = t_2;
	} else if (x <= 12000000.0) {
		tmp = eps * cbrt((125.0 * pow(x, 12.0)));
	} else {
		tmp = t_1;
	}
	return tmp;
}
public static double code(double x, double eps) {
	double t_0 = Math.pow(eps, 4.0) * (eps + (x * 5.0));
	double t_1 = 5.0 * (eps * Math.pow(x, 4.0));
	double t_2 = eps * (5.0 * Math.pow(x, 4.0));
	double t_3 = Math.pow(eps, 4.0) * (x * (5.0 + (eps / x)));
	double tmp;
	if (x <= -4.8e-52) {
		tmp = Math.pow(x, 4.0) * (eps * (5.0 + (10.0 * (eps / x))));
	} else if (x <= -4e-78) {
		tmp = t_0;
	} else if (x <= 1e-270) {
		tmp = Math.pow(eps, 5.0);
	} else if (x <= 1.5e-55) {
		tmp = t_3;
	} else if (x <= 3e-45) {
		tmp = Math.pow(eps, 5.0) * (1.0 + (5.0 * (x / eps)));
	} else if (x <= 1.22e-26) {
		tmp = t_2;
	} else if (x <= 1.45e-23) {
		tmp = t_3;
	} else if (x <= 1.15e-18) {
		tmp = t_1;
	} else if (x <= 1.16e-18) {
		tmp = t_0;
	} else if (x <= 5e-7) {
		tmp = t_2;
	} else if (x <= 12000000.0) {
		tmp = eps * Math.cbrt((125.0 * Math.pow(x, 12.0)));
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, eps)
	t_0 = Float64((eps ^ 4.0) * Float64(eps + Float64(x * 5.0)))
	t_1 = Float64(5.0 * Float64(eps * (x ^ 4.0)))
	t_2 = Float64(eps * Float64(5.0 * (x ^ 4.0)))
	t_3 = Float64((eps ^ 4.0) * Float64(x * Float64(5.0 + Float64(eps / x))))
	tmp = 0.0
	if (x <= -4.8e-52)
		tmp = Float64((x ^ 4.0) * Float64(eps * Float64(5.0 + Float64(10.0 * Float64(eps / x)))));
	elseif (x <= -4e-78)
		tmp = t_0;
	elseif (x <= 1e-270)
		tmp = eps ^ 5.0;
	elseif (x <= 1.5e-55)
		tmp = t_3;
	elseif (x <= 3e-45)
		tmp = Float64((eps ^ 5.0) * Float64(1.0 + Float64(5.0 * Float64(x / eps))));
	elseif (x <= 1.22e-26)
		tmp = t_2;
	elseif (x <= 1.45e-23)
		tmp = t_3;
	elseif (x <= 1.15e-18)
		tmp = t_1;
	elseif (x <= 1.16e-18)
		tmp = t_0;
	elseif (x <= 5e-7)
		tmp = t_2;
	elseif (x <= 12000000.0)
		tmp = Float64(eps * cbrt(Float64(125.0 * (x ^ 12.0))));
	else
		tmp = t_1;
	end
	return tmp
end
code[x_, eps_] := Block[{t$95$0 = N[(N[Power[eps, 4.0], $MachinePrecision] * N[(eps + N[(x * 5.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(5.0 * N[(eps * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(eps * N[(5.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Power[eps, 4.0], $MachinePrecision] * N[(x * N[(5.0 + N[(eps / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -4.8e-52], N[(N[Power[x, 4.0], $MachinePrecision] * N[(eps * N[(5.0 + N[(10.0 * N[(eps / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -4e-78], t$95$0, If[LessEqual[x, 1e-270], N[Power[eps, 5.0], $MachinePrecision], If[LessEqual[x, 1.5e-55], t$95$3, If[LessEqual[x, 3e-45], N[(N[Power[eps, 5.0], $MachinePrecision] * N[(1.0 + N[(5.0 * N[(x / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.22e-26], t$95$2, If[LessEqual[x, 1.45e-23], t$95$3, If[LessEqual[x, 1.15e-18], t$95$1, If[LessEqual[x, 1.16e-18], t$95$0, If[LessEqual[x, 5e-7], t$95$2, If[LessEqual[x, 12000000.0], N[(eps * N[Power[N[(125.0 * N[Power[x, 12.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\varepsilon}^{4} \cdot \left(\varepsilon + x \cdot 5\right)\\
t_1 := 5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\
t_2 := \varepsilon \cdot \left(5 \cdot {x}^{4}\right)\\
t_3 := {\varepsilon}^{4} \cdot \left(x \cdot \left(5 + \frac{\varepsilon}{x}\right)\right)\\
\mathbf{if}\;x \leq -4.8 \cdot 10^{-52}:\\
\;\;\;\;{x}^{4} \cdot \left(\varepsilon \cdot \left(5 + 10 \cdot \frac{\varepsilon}{x}\right)\right)\\

\mathbf{elif}\;x \leq -4 \cdot 10^{-78}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 10^{-270}:\\
\;\;\;\;{\varepsilon}^{5}\\

\mathbf{elif}\;x \leq 1.5 \cdot 10^{-55}:\\
\;\;\;\;t\_3\\

\mathbf{elif}\;x \leq 3 \cdot 10^{-45}:\\
\;\;\;\;{\varepsilon}^{5} \cdot \left(1 + 5 \cdot \frac{x}{\varepsilon}\right)\\

\mathbf{elif}\;x \leq 1.22 \cdot 10^{-26}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;x \leq 1.45 \cdot 10^{-23}:\\
\;\;\;\;t\_3\\

\mathbf{elif}\;x \leq 1.15 \cdot 10^{-18}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 1.16 \cdot 10^{-18}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 5 \cdot 10^{-7}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;x \leq 12000000:\\
\;\;\;\;\varepsilon \cdot \sqrt[3]{125 \cdot {x}^{12}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 8 regimes
  2. if x < -4.8000000000000003e-52

    1. Initial program 46.2%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around -inf 95.1%

      \[\leadsto \color{blue}{{x}^{4} \cdot \left(\varepsilon + \left(-1 \cdot \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x} + 4 \cdot \varepsilon\right)\right)} \]
    4. Step-by-step derivation
      1. +-commutative95.1%

        \[\leadsto {x}^{4} \cdot \left(\varepsilon + \color{blue}{\left(4 \cdot \varepsilon + -1 \cdot \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right)}\right) \]
      2. associate-+r+95.1%

        \[\leadsto {x}^{4} \cdot \color{blue}{\left(\left(\varepsilon + 4 \cdot \varepsilon\right) + -1 \cdot \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right)} \]
      3. mul-1-neg95.1%

        \[\leadsto {x}^{4} \cdot \left(\left(\varepsilon + 4 \cdot \varepsilon\right) + \color{blue}{\left(-\frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right)}\right) \]
      4. unsub-neg95.1%

        \[\leadsto {x}^{4} \cdot \color{blue}{\left(\left(\varepsilon + 4 \cdot \varepsilon\right) - \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right)} \]
      5. distribute-rgt1-in95.1%

        \[\leadsto {x}^{4} \cdot \left(\color{blue}{\left(4 + 1\right) \cdot \varepsilon} - \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right) \]
      6. metadata-eval95.1%

        \[\leadsto {x}^{4} \cdot \left(\color{blue}{5} \cdot \varepsilon - \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right) \]
      7. *-commutative95.1%

        \[\leadsto {x}^{4} \cdot \left(\color{blue}{\varepsilon \cdot 5} - \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right) \]
    5. Simplified95.1%

      \[\leadsto \color{blue}{{x}^{4} \cdot \left(\varepsilon \cdot 5 - \frac{{\varepsilon}^{2} \cdot -10}{x}\right)} \]
    6. Taylor expanded in eps around 0 95.1%

      \[\leadsto {x}^{4} \cdot \color{blue}{\left(\varepsilon \cdot \left(5 + 10 \cdot \frac{\varepsilon}{x}\right)\right)} \]
    7. Step-by-step derivation
      1. *-commutative95.1%

        \[\leadsto {x}^{4} \cdot \left(\varepsilon \cdot \left(5 + \color{blue}{\frac{\varepsilon}{x} \cdot 10}\right)\right) \]
    8. Simplified95.1%

      \[\leadsto {x}^{4} \cdot \color{blue}{\left(\varepsilon \cdot \left(5 + \frac{\varepsilon}{x} \cdot 10\right)\right)} \]

    if -4.8000000000000003e-52 < x < -4e-78 or 1.15e-18 < x < 1.16e-18

    1. Initial program 99.8%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 97.2%

      \[\leadsto \color{blue}{x \cdot \left(4 \cdot {\varepsilon}^{4} + {\varepsilon}^{4}\right) + {\varepsilon}^{5}} \]
    4. Step-by-step derivation
      1. fma-define97.2%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, 4 \cdot {\varepsilon}^{4} + {\varepsilon}^{4}, {\varepsilon}^{5}\right)} \]
      2. distribute-lft1-in97.2%

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{\left(4 + 1\right) \cdot {\varepsilon}^{4}}, {\varepsilon}^{5}\right) \]
      3. metadata-eval97.2%

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{5} \cdot {\varepsilon}^{4}, {\varepsilon}^{5}\right) \]
    5. Simplified97.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, 5 \cdot {\varepsilon}^{4}, {\varepsilon}^{5}\right)} \]
    6. Taylor expanded in eps around 0 97.2%

      \[\leadsto \color{blue}{{\varepsilon}^{4} \cdot \left(\varepsilon + 5 \cdot x\right)} \]

    if -4e-78 < x < 1e-270

    1. Initial program 100.0%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 100.0%

      \[\leadsto \color{blue}{{\varepsilon}^{5}} \]

    if 1e-270 < x < 1.50000000000000008e-55 or 1.22e-26 < x < 1.4500000000000001e-23

    1. Initial program 100.0%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 99.2%

      \[\leadsto \color{blue}{x \cdot \left(4 \cdot {\varepsilon}^{4} + {\varepsilon}^{4}\right) + {\varepsilon}^{5}} \]
    4. Step-by-step derivation
      1. fma-define99.2%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, 4 \cdot {\varepsilon}^{4} + {\varepsilon}^{4}, {\varepsilon}^{5}\right)} \]
      2. distribute-lft1-in99.2%

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{\left(4 + 1\right) \cdot {\varepsilon}^{4}}, {\varepsilon}^{5}\right) \]
      3. metadata-eval99.2%

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{5} \cdot {\varepsilon}^{4}, {\varepsilon}^{5}\right) \]
    5. Simplified99.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, 5 \cdot {\varepsilon}^{4}, {\varepsilon}^{5}\right)} \]
    6. Taylor expanded in eps around 0 99.2%

      \[\leadsto \color{blue}{{\varepsilon}^{4} \cdot \left(\varepsilon + 5 \cdot x\right)} \]
    7. Taylor expanded in x around inf 99.2%

      \[\leadsto {\varepsilon}^{4} \cdot \color{blue}{\left(x \cdot \left(5 + \frac{\varepsilon}{x}\right)\right)} \]

    if 1.50000000000000008e-55 < x < 3.00000000000000011e-45

    1. Initial program 99.6%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in eps around inf 100.0%

      \[\leadsto \color{blue}{{\varepsilon}^{5} \cdot \left(1 + \left(4 \cdot \frac{x}{\varepsilon} + \frac{x}{\varepsilon}\right)\right)} \]
    4. Step-by-step derivation
      1. distribute-lft1-in100.0%

        \[\leadsto {\varepsilon}^{5} \cdot \left(1 + \color{blue}{\left(4 + 1\right) \cdot \frac{x}{\varepsilon}}\right) \]
      2. metadata-eval100.0%

        \[\leadsto {\varepsilon}^{5} \cdot \left(1 + \color{blue}{5} \cdot \frac{x}{\varepsilon}\right) \]
    5. Simplified100.0%

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

    if 3.00000000000000011e-45 < x < 1.22e-26 or 1.16e-18 < x < 4.99999999999999977e-7

    1. Initial program 35.9%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 99.6%

      \[\leadsto \color{blue}{{x}^{4} \cdot \left(\varepsilon + 4 \cdot \varepsilon\right)} \]
    4. Step-by-step derivation
      1. *-commutative99.6%

        \[\leadsto \color{blue}{\left(\varepsilon + 4 \cdot \varepsilon\right) \cdot {x}^{4}} \]
      2. distribute-rgt1-in99.6%

        \[\leadsto \color{blue}{\left(\left(4 + 1\right) \cdot \varepsilon\right)} \cdot {x}^{4} \]
      3. metadata-eval99.6%

        \[\leadsto \left(\color{blue}{5} \cdot \varepsilon\right) \cdot {x}^{4} \]
      4. *-commutative99.6%

        \[\leadsto \color{blue}{\left(\varepsilon \cdot 5\right)} \cdot {x}^{4} \]
      5. associate-*r*100.0%

        \[\leadsto \color{blue}{\varepsilon \cdot \left(5 \cdot {x}^{4}\right)} \]
    5. Simplified100.0%

      \[\leadsto \color{blue}{\varepsilon \cdot \left(5 \cdot {x}^{4}\right)} \]

    if 1.4500000000000001e-23 < x < 1.15e-18 or 1.2e7 < x

    1. Initial program 20.4%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 99.7%

      \[\leadsto \color{blue}{{x}^{4} \cdot \left(\varepsilon + 4 \cdot \varepsilon\right)} \]
    4. Step-by-step derivation
      1. *-commutative99.7%

        \[\leadsto \color{blue}{\left(\varepsilon + 4 \cdot \varepsilon\right) \cdot {x}^{4}} \]
      2. distribute-rgt1-in99.7%

        \[\leadsto \color{blue}{\left(\left(4 + 1\right) \cdot \varepsilon\right)} \cdot {x}^{4} \]
      3. metadata-eval99.7%

        \[\leadsto \left(\color{blue}{5} \cdot \varepsilon\right) \cdot {x}^{4} \]
      4. *-commutative99.7%

        \[\leadsto \color{blue}{\left(\varepsilon \cdot 5\right)} \cdot {x}^{4} \]
      5. associate-*r*99.7%

        \[\leadsto \color{blue}{\varepsilon \cdot \left(5 \cdot {x}^{4}\right)} \]
    5. Simplified99.7%

      \[\leadsto \color{blue}{\varepsilon \cdot \left(5 \cdot {x}^{4}\right)} \]
    6. Taylor expanded in eps around 0 100.0%

      \[\leadsto \color{blue}{5 \cdot \left(\varepsilon \cdot {x}^{4}\right)} \]

    if 4.99999999999999977e-7 < x < 1.2e7

    1. Initial program 6.0%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 99.2%

      \[\leadsto \color{blue}{{x}^{4} \cdot \left(\varepsilon + 4 \cdot \varepsilon\right)} \]
    4. Step-by-step derivation
      1. *-commutative99.2%

        \[\leadsto \color{blue}{\left(\varepsilon + 4 \cdot \varepsilon\right) \cdot {x}^{4}} \]
      2. distribute-rgt1-in99.2%

        \[\leadsto \color{blue}{\left(\left(4 + 1\right) \cdot \varepsilon\right)} \cdot {x}^{4} \]
      3. metadata-eval99.2%

        \[\leadsto \left(\color{blue}{5} \cdot \varepsilon\right) \cdot {x}^{4} \]
      4. *-commutative99.2%

        \[\leadsto \color{blue}{\left(\varepsilon \cdot 5\right)} \cdot {x}^{4} \]
      5. associate-*r*98.8%

        \[\leadsto \color{blue}{\varepsilon \cdot \left(5 \cdot {x}^{4}\right)} \]
    5. Simplified98.8%

      \[\leadsto \color{blue}{\varepsilon \cdot \left(5 \cdot {x}^{4}\right)} \]
    6. Step-by-step derivation
      1. add-sqr-sqrt99.0%

        \[\leadsto \varepsilon \cdot \color{blue}{\left(\sqrt{5 \cdot {x}^{4}} \cdot \sqrt{5 \cdot {x}^{4}}\right)} \]
      2. sqrt-unprod98.8%

        \[\leadsto \varepsilon \cdot \color{blue}{\sqrt{\left(5 \cdot {x}^{4}\right) \cdot \left(5 \cdot {x}^{4}\right)}} \]
      3. *-commutative98.8%

        \[\leadsto \varepsilon \cdot \sqrt{\color{blue}{\left({x}^{4} \cdot 5\right)} \cdot \left(5 \cdot {x}^{4}\right)} \]
      4. *-commutative98.8%

        \[\leadsto \varepsilon \cdot \sqrt{\left({x}^{4} \cdot 5\right) \cdot \color{blue}{\left({x}^{4} \cdot 5\right)}} \]
      5. swap-sqr98.8%

        \[\leadsto \varepsilon \cdot \sqrt{\color{blue}{\left({x}^{4} \cdot {x}^{4}\right) \cdot \left(5 \cdot 5\right)}} \]
      6. pow-prod-up99.6%

        \[\leadsto \varepsilon \cdot \sqrt{\color{blue}{{x}^{\left(4 + 4\right)}} \cdot \left(5 \cdot 5\right)} \]
      7. metadata-eval99.6%

        \[\leadsto \varepsilon \cdot \sqrt{{x}^{\color{blue}{8}} \cdot \left(5 \cdot 5\right)} \]
      8. metadata-eval99.6%

        \[\leadsto \varepsilon \cdot \sqrt{{x}^{8} \cdot \color{blue}{25}} \]
    7. Applied egg-rr99.6%

      \[\leadsto \varepsilon \cdot \color{blue}{\sqrt{{x}^{8} \cdot 25}} \]
    8. Step-by-step derivation
      1. add-cbrt-cube99.6%

        \[\leadsto \varepsilon \cdot \color{blue}{\sqrt[3]{\left(\sqrt{{x}^{8} \cdot 25} \cdot \sqrt{{x}^{8} \cdot 25}\right) \cdot \sqrt{{x}^{8} \cdot 25}}} \]
      2. add-sqr-sqrt99.2%

        \[\leadsto \varepsilon \cdot \sqrt[3]{\color{blue}{\left({x}^{8} \cdot 25\right)} \cdot \sqrt{{x}^{8} \cdot 25}} \]
      3. pow199.2%

        \[\leadsto \varepsilon \cdot \sqrt[3]{\color{blue}{{\left({x}^{8} \cdot 25\right)}^{1}} \cdot \sqrt{{x}^{8} \cdot 25}} \]
      4. pow1/299.2%

        \[\leadsto \varepsilon \cdot \sqrt[3]{{\left({x}^{8} \cdot 25\right)}^{1} \cdot \color{blue}{{\left({x}^{8} \cdot 25\right)}^{0.5}}} \]
      5. pow-prod-up99.2%

        \[\leadsto \varepsilon \cdot \sqrt[3]{\color{blue}{{\left({x}^{8} \cdot 25\right)}^{\left(1 + 0.5\right)}}} \]
      6. metadata-eval99.2%

        \[\leadsto \varepsilon \cdot \sqrt[3]{{\left({x}^{8} \cdot 25\right)}^{\color{blue}{1.5}}} \]
    9. Applied egg-rr99.2%

      \[\leadsto \varepsilon \cdot \color{blue}{\sqrt[3]{{\left({x}^{8} \cdot 25\right)}^{1.5}}} \]
    10. Taylor expanded in x around 0 100.0%

      \[\leadsto \varepsilon \cdot \sqrt[3]{\color{blue}{125 \cdot {x}^{12}}} \]
  3. Recombined 8 regimes into one program.
  4. Final simplification99.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4.8 \cdot 10^{-52}:\\ \;\;\;\;{x}^{4} \cdot \left(\varepsilon \cdot \left(5 + 10 \cdot \frac{\varepsilon}{x}\right)\right)\\ \mathbf{elif}\;x \leq -4 \cdot 10^{-78}:\\ \;\;\;\;{\varepsilon}^{4} \cdot \left(\varepsilon + x \cdot 5\right)\\ \mathbf{elif}\;x \leq 10^{-270}:\\ \;\;\;\;{\varepsilon}^{5}\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{-55}:\\ \;\;\;\;{\varepsilon}^{4} \cdot \left(x \cdot \left(5 + \frac{\varepsilon}{x}\right)\right)\\ \mathbf{elif}\;x \leq 3 \cdot 10^{-45}:\\ \;\;\;\;{\varepsilon}^{5} \cdot \left(1 + 5 \cdot \frac{x}{\varepsilon}\right)\\ \mathbf{elif}\;x \leq 1.22 \cdot 10^{-26}:\\ \;\;\;\;\varepsilon \cdot \left(5 \cdot {x}^{4}\right)\\ \mathbf{elif}\;x \leq 1.45 \cdot 10^{-23}:\\ \;\;\;\;{\varepsilon}^{4} \cdot \left(x \cdot \left(5 + \frac{\varepsilon}{x}\right)\right)\\ \mathbf{elif}\;x \leq 1.15 \cdot 10^{-18}:\\ \;\;\;\;5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\ \mathbf{elif}\;x \leq 1.16 \cdot 10^{-18}:\\ \;\;\;\;{\varepsilon}^{4} \cdot \left(\varepsilon + x \cdot 5\right)\\ \mathbf{elif}\;x \leq 5 \cdot 10^{-7}:\\ \;\;\;\;\varepsilon \cdot \left(5 \cdot {x}^{4}\right)\\ \mathbf{elif}\;x \leq 12000000:\\ \;\;\;\;\varepsilon \cdot \sqrt[3]{125 \cdot {x}^{12}}\\ \mathbf{else}:\\ \;\;\;\;5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 97.3% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\varepsilon}^{4} \cdot \left(\varepsilon + x \cdot 5\right)\\ t_1 := \varepsilon \cdot \left(5 \cdot {x}^{4}\right)\\ t_2 := {\varepsilon}^{4} \cdot \left(x \cdot \left(5 + \frac{\varepsilon}{x}\right)\right)\\ \mathbf{if}\;x \leq -1.12 \cdot 10^{-51}:\\ \;\;\;\;{x}^{4} \cdot \left(\varepsilon \cdot \left(5 + 10 \cdot \frac{\varepsilon}{x}\right)\right)\\ \mathbf{elif}\;x \leq -4 \cdot 10^{-78}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 4 \cdot 10^{-268}:\\ \;\;\;\;{\varepsilon}^{5}\\ \mathbf{elif}\;x \leq 10^{-55}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;x \leq 2.15 \cdot 10^{-45}:\\ \;\;\;\;{\varepsilon}^{5} \cdot \left(1 + 5 \cdot \frac{x}{\varepsilon}\right)\\ \mathbf{elif}\;x \leq 1.22 \cdot 10^{-26}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 1.45 \cdot 10^{-23}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;x \leq 1.15 \cdot 10^{-18}:\\ \;\;\;\;5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\ \mathbf{elif}\;x \leq 1.16 \cdot 10^{-18}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 8 \cdot 10^{-8}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;{x}^{4} \cdot \left(\varepsilon \cdot 5\right)\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (let* ((t_0 (* (pow eps 4.0) (+ eps (* x 5.0))))
        (t_1 (* eps (* 5.0 (pow x 4.0))))
        (t_2 (* (pow eps 4.0) (* x (+ 5.0 (/ eps x))))))
   (if (<= x -1.12e-51)
     (* (pow x 4.0) (* eps (+ 5.0 (* 10.0 (/ eps x)))))
     (if (<= x -4e-78)
       t_0
       (if (<= x 4e-268)
         (pow eps 5.0)
         (if (<= x 1e-55)
           t_2
           (if (<= x 2.15e-45)
             (* (pow eps 5.0) (+ 1.0 (* 5.0 (/ x eps))))
             (if (<= x 1.22e-26)
               t_1
               (if (<= x 1.45e-23)
                 t_2
                 (if (<= x 1.15e-18)
                   (* 5.0 (* eps (pow x 4.0)))
                   (if (<= x 1.16e-18)
                     t_0
                     (if (<= x 8e-8)
                       t_1
                       (* (pow x 4.0) (* eps 5.0))))))))))))))
double code(double x, double eps) {
	double t_0 = pow(eps, 4.0) * (eps + (x * 5.0));
	double t_1 = eps * (5.0 * pow(x, 4.0));
	double t_2 = pow(eps, 4.0) * (x * (5.0 + (eps / x)));
	double tmp;
	if (x <= -1.12e-51) {
		tmp = pow(x, 4.0) * (eps * (5.0 + (10.0 * (eps / x))));
	} else if (x <= -4e-78) {
		tmp = t_0;
	} else if (x <= 4e-268) {
		tmp = pow(eps, 5.0);
	} else if (x <= 1e-55) {
		tmp = t_2;
	} else if (x <= 2.15e-45) {
		tmp = pow(eps, 5.0) * (1.0 + (5.0 * (x / eps)));
	} else if (x <= 1.22e-26) {
		tmp = t_1;
	} else if (x <= 1.45e-23) {
		tmp = t_2;
	} else if (x <= 1.15e-18) {
		tmp = 5.0 * (eps * pow(x, 4.0));
	} else if (x <= 1.16e-18) {
		tmp = t_0;
	} else if (x <= 8e-8) {
		tmp = t_1;
	} else {
		tmp = pow(x, 4.0) * (eps * 5.0);
	}
	return tmp;
}
real(8) function code(x, eps)
    real(8), intent (in) :: x
    real(8), intent (in) :: eps
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_0 = (eps ** 4.0d0) * (eps + (x * 5.0d0))
    t_1 = eps * (5.0d0 * (x ** 4.0d0))
    t_2 = (eps ** 4.0d0) * (x * (5.0d0 + (eps / x)))
    if (x <= (-1.12d-51)) then
        tmp = (x ** 4.0d0) * (eps * (5.0d0 + (10.0d0 * (eps / x))))
    else if (x <= (-4d-78)) then
        tmp = t_0
    else if (x <= 4d-268) then
        tmp = eps ** 5.0d0
    else if (x <= 1d-55) then
        tmp = t_2
    else if (x <= 2.15d-45) then
        tmp = (eps ** 5.0d0) * (1.0d0 + (5.0d0 * (x / eps)))
    else if (x <= 1.22d-26) then
        tmp = t_1
    else if (x <= 1.45d-23) then
        tmp = t_2
    else if (x <= 1.15d-18) then
        tmp = 5.0d0 * (eps * (x ** 4.0d0))
    else if (x <= 1.16d-18) then
        tmp = t_0
    else if (x <= 8d-8) then
        tmp = t_1
    else
        tmp = (x ** 4.0d0) * (eps * 5.0d0)
    end if
    code = tmp
end function
public static double code(double x, double eps) {
	double t_0 = Math.pow(eps, 4.0) * (eps + (x * 5.0));
	double t_1 = eps * (5.0 * Math.pow(x, 4.0));
	double t_2 = Math.pow(eps, 4.0) * (x * (5.0 + (eps / x)));
	double tmp;
	if (x <= -1.12e-51) {
		tmp = Math.pow(x, 4.0) * (eps * (5.0 + (10.0 * (eps / x))));
	} else if (x <= -4e-78) {
		tmp = t_0;
	} else if (x <= 4e-268) {
		tmp = Math.pow(eps, 5.0);
	} else if (x <= 1e-55) {
		tmp = t_2;
	} else if (x <= 2.15e-45) {
		tmp = Math.pow(eps, 5.0) * (1.0 + (5.0 * (x / eps)));
	} else if (x <= 1.22e-26) {
		tmp = t_1;
	} else if (x <= 1.45e-23) {
		tmp = t_2;
	} else if (x <= 1.15e-18) {
		tmp = 5.0 * (eps * Math.pow(x, 4.0));
	} else if (x <= 1.16e-18) {
		tmp = t_0;
	} else if (x <= 8e-8) {
		tmp = t_1;
	} else {
		tmp = Math.pow(x, 4.0) * (eps * 5.0);
	}
	return tmp;
}
def code(x, eps):
	t_0 = math.pow(eps, 4.0) * (eps + (x * 5.0))
	t_1 = eps * (5.0 * math.pow(x, 4.0))
	t_2 = math.pow(eps, 4.0) * (x * (5.0 + (eps / x)))
	tmp = 0
	if x <= -1.12e-51:
		tmp = math.pow(x, 4.0) * (eps * (5.0 + (10.0 * (eps / x))))
	elif x <= -4e-78:
		tmp = t_0
	elif x <= 4e-268:
		tmp = math.pow(eps, 5.0)
	elif x <= 1e-55:
		tmp = t_2
	elif x <= 2.15e-45:
		tmp = math.pow(eps, 5.0) * (1.0 + (5.0 * (x / eps)))
	elif x <= 1.22e-26:
		tmp = t_1
	elif x <= 1.45e-23:
		tmp = t_2
	elif x <= 1.15e-18:
		tmp = 5.0 * (eps * math.pow(x, 4.0))
	elif x <= 1.16e-18:
		tmp = t_0
	elif x <= 8e-8:
		tmp = t_1
	else:
		tmp = math.pow(x, 4.0) * (eps * 5.0)
	return tmp
function code(x, eps)
	t_0 = Float64((eps ^ 4.0) * Float64(eps + Float64(x * 5.0)))
	t_1 = Float64(eps * Float64(5.0 * (x ^ 4.0)))
	t_2 = Float64((eps ^ 4.0) * Float64(x * Float64(5.0 + Float64(eps / x))))
	tmp = 0.0
	if (x <= -1.12e-51)
		tmp = Float64((x ^ 4.0) * Float64(eps * Float64(5.0 + Float64(10.0 * Float64(eps / x)))));
	elseif (x <= -4e-78)
		tmp = t_0;
	elseif (x <= 4e-268)
		tmp = eps ^ 5.0;
	elseif (x <= 1e-55)
		tmp = t_2;
	elseif (x <= 2.15e-45)
		tmp = Float64((eps ^ 5.0) * Float64(1.0 + Float64(5.0 * Float64(x / eps))));
	elseif (x <= 1.22e-26)
		tmp = t_1;
	elseif (x <= 1.45e-23)
		tmp = t_2;
	elseif (x <= 1.15e-18)
		tmp = Float64(5.0 * Float64(eps * (x ^ 4.0)));
	elseif (x <= 1.16e-18)
		tmp = t_0;
	elseif (x <= 8e-8)
		tmp = t_1;
	else
		tmp = Float64((x ^ 4.0) * Float64(eps * 5.0));
	end
	return tmp
end
function tmp_2 = code(x, eps)
	t_0 = (eps ^ 4.0) * (eps + (x * 5.0));
	t_1 = eps * (5.0 * (x ^ 4.0));
	t_2 = (eps ^ 4.0) * (x * (5.0 + (eps / x)));
	tmp = 0.0;
	if (x <= -1.12e-51)
		tmp = (x ^ 4.0) * (eps * (5.0 + (10.0 * (eps / x))));
	elseif (x <= -4e-78)
		tmp = t_0;
	elseif (x <= 4e-268)
		tmp = eps ^ 5.0;
	elseif (x <= 1e-55)
		tmp = t_2;
	elseif (x <= 2.15e-45)
		tmp = (eps ^ 5.0) * (1.0 + (5.0 * (x / eps)));
	elseif (x <= 1.22e-26)
		tmp = t_1;
	elseif (x <= 1.45e-23)
		tmp = t_2;
	elseif (x <= 1.15e-18)
		tmp = 5.0 * (eps * (x ^ 4.0));
	elseif (x <= 1.16e-18)
		tmp = t_0;
	elseif (x <= 8e-8)
		tmp = t_1;
	else
		tmp = (x ^ 4.0) * (eps * 5.0);
	end
	tmp_2 = tmp;
end
code[x_, eps_] := Block[{t$95$0 = N[(N[Power[eps, 4.0], $MachinePrecision] * N[(eps + N[(x * 5.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(eps * N[(5.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Power[eps, 4.0], $MachinePrecision] * N[(x * N[(5.0 + N[(eps / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.12e-51], N[(N[Power[x, 4.0], $MachinePrecision] * N[(eps * N[(5.0 + N[(10.0 * N[(eps / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, -4e-78], t$95$0, If[LessEqual[x, 4e-268], N[Power[eps, 5.0], $MachinePrecision], If[LessEqual[x, 1e-55], t$95$2, If[LessEqual[x, 2.15e-45], N[(N[Power[eps, 5.0], $MachinePrecision] * N[(1.0 + N[(5.0 * N[(x / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.22e-26], t$95$1, If[LessEqual[x, 1.45e-23], t$95$2, If[LessEqual[x, 1.15e-18], N[(5.0 * N[(eps * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.16e-18], t$95$0, If[LessEqual[x, 8e-8], t$95$1, N[(N[Power[x, 4.0], $MachinePrecision] * N[(eps * 5.0), $MachinePrecision]), $MachinePrecision]]]]]]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\varepsilon}^{4} \cdot \left(\varepsilon + x \cdot 5\right)\\
t_1 := \varepsilon \cdot \left(5 \cdot {x}^{4}\right)\\
t_2 := {\varepsilon}^{4} \cdot \left(x \cdot \left(5 + \frac{\varepsilon}{x}\right)\right)\\
\mathbf{if}\;x \leq -1.12 \cdot 10^{-51}:\\
\;\;\;\;{x}^{4} \cdot \left(\varepsilon \cdot \left(5 + 10 \cdot \frac{\varepsilon}{x}\right)\right)\\

\mathbf{elif}\;x \leq -4 \cdot 10^{-78}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 4 \cdot 10^{-268}:\\
\;\;\;\;{\varepsilon}^{5}\\

\mathbf{elif}\;x \leq 10^{-55}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;x \leq 2.15 \cdot 10^{-45}:\\
\;\;\;\;{\varepsilon}^{5} \cdot \left(1 + 5 \cdot \frac{x}{\varepsilon}\right)\\

\mathbf{elif}\;x \leq 1.22 \cdot 10^{-26}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 1.45 \cdot 10^{-23}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;x \leq 1.15 \cdot 10^{-18}:\\
\;\;\;\;5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\

\mathbf{elif}\;x \leq 1.16 \cdot 10^{-18}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 8 \cdot 10^{-8}:\\
\;\;\;\;t\_1\\

\mathbf{else}:\\
\;\;\;\;{x}^{4} \cdot \left(\varepsilon \cdot 5\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 8 regimes
  2. if x < -1.11999999999999998e-51

    1. Initial program 46.2%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around -inf 95.1%

      \[\leadsto \color{blue}{{x}^{4} \cdot \left(\varepsilon + \left(-1 \cdot \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x} + 4 \cdot \varepsilon\right)\right)} \]
    4. Step-by-step derivation
      1. +-commutative95.1%

        \[\leadsto {x}^{4} \cdot \left(\varepsilon + \color{blue}{\left(4 \cdot \varepsilon + -1 \cdot \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right)}\right) \]
      2. associate-+r+95.1%

        \[\leadsto {x}^{4} \cdot \color{blue}{\left(\left(\varepsilon + 4 \cdot \varepsilon\right) + -1 \cdot \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right)} \]
      3. mul-1-neg95.1%

        \[\leadsto {x}^{4} \cdot \left(\left(\varepsilon + 4 \cdot \varepsilon\right) + \color{blue}{\left(-\frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right)}\right) \]
      4. unsub-neg95.1%

        \[\leadsto {x}^{4} \cdot \color{blue}{\left(\left(\varepsilon + 4 \cdot \varepsilon\right) - \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right)} \]
      5. distribute-rgt1-in95.1%

        \[\leadsto {x}^{4} \cdot \left(\color{blue}{\left(4 + 1\right) \cdot \varepsilon} - \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right) \]
      6. metadata-eval95.1%

        \[\leadsto {x}^{4} \cdot \left(\color{blue}{5} \cdot \varepsilon - \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right) \]
      7. *-commutative95.1%

        \[\leadsto {x}^{4} \cdot \left(\color{blue}{\varepsilon \cdot 5} - \frac{-4 \cdot {\varepsilon}^{2} + -1 \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)}{x}\right) \]
    5. Simplified95.1%

      \[\leadsto \color{blue}{{x}^{4} \cdot \left(\varepsilon \cdot 5 - \frac{{\varepsilon}^{2} \cdot -10}{x}\right)} \]
    6. Taylor expanded in eps around 0 95.1%

      \[\leadsto {x}^{4} \cdot \color{blue}{\left(\varepsilon \cdot \left(5 + 10 \cdot \frac{\varepsilon}{x}\right)\right)} \]
    7. Step-by-step derivation
      1. *-commutative95.1%

        \[\leadsto {x}^{4} \cdot \left(\varepsilon \cdot \left(5 + \color{blue}{\frac{\varepsilon}{x} \cdot 10}\right)\right) \]
    8. Simplified95.1%

      \[\leadsto {x}^{4} \cdot \color{blue}{\left(\varepsilon \cdot \left(5 + \frac{\varepsilon}{x} \cdot 10\right)\right)} \]

    if -1.11999999999999998e-51 < x < -4e-78 or 1.15e-18 < x < 1.16e-18

    1. Initial program 99.8%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 97.2%

      \[\leadsto \color{blue}{x \cdot \left(4 \cdot {\varepsilon}^{4} + {\varepsilon}^{4}\right) + {\varepsilon}^{5}} \]
    4. Step-by-step derivation
      1. fma-define97.2%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, 4 \cdot {\varepsilon}^{4} + {\varepsilon}^{4}, {\varepsilon}^{5}\right)} \]
      2. distribute-lft1-in97.2%

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{\left(4 + 1\right) \cdot {\varepsilon}^{4}}, {\varepsilon}^{5}\right) \]
      3. metadata-eval97.2%

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{5} \cdot {\varepsilon}^{4}, {\varepsilon}^{5}\right) \]
    5. Simplified97.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, 5 \cdot {\varepsilon}^{4}, {\varepsilon}^{5}\right)} \]
    6. Taylor expanded in eps around 0 97.2%

      \[\leadsto \color{blue}{{\varepsilon}^{4} \cdot \left(\varepsilon + 5 \cdot x\right)} \]

    if -4e-78 < x < 3.99999999999999983e-268

    1. Initial program 100.0%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 100.0%

      \[\leadsto \color{blue}{{\varepsilon}^{5}} \]

    if 3.99999999999999983e-268 < x < 9.99999999999999995e-56 or 1.22e-26 < x < 1.4500000000000001e-23

    1. Initial program 100.0%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 99.2%

      \[\leadsto \color{blue}{x \cdot \left(4 \cdot {\varepsilon}^{4} + {\varepsilon}^{4}\right) + {\varepsilon}^{5}} \]
    4. Step-by-step derivation
      1. fma-define99.2%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, 4 \cdot {\varepsilon}^{4} + {\varepsilon}^{4}, {\varepsilon}^{5}\right)} \]
      2. distribute-lft1-in99.2%

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{\left(4 + 1\right) \cdot {\varepsilon}^{4}}, {\varepsilon}^{5}\right) \]
      3. metadata-eval99.2%

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{5} \cdot {\varepsilon}^{4}, {\varepsilon}^{5}\right) \]
    5. Simplified99.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, 5 \cdot {\varepsilon}^{4}, {\varepsilon}^{5}\right)} \]
    6. Taylor expanded in eps around 0 99.2%

      \[\leadsto \color{blue}{{\varepsilon}^{4} \cdot \left(\varepsilon + 5 \cdot x\right)} \]
    7. Taylor expanded in x around inf 99.2%

      \[\leadsto {\varepsilon}^{4} \cdot \color{blue}{\left(x \cdot \left(5 + \frac{\varepsilon}{x}\right)\right)} \]

    if 9.99999999999999995e-56 < x < 2.1499999999999999e-45

    1. Initial program 99.6%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in eps around inf 100.0%

      \[\leadsto \color{blue}{{\varepsilon}^{5} \cdot \left(1 + \left(4 \cdot \frac{x}{\varepsilon} + \frac{x}{\varepsilon}\right)\right)} \]
    4. Step-by-step derivation
      1. distribute-lft1-in100.0%

        \[\leadsto {\varepsilon}^{5} \cdot \left(1 + \color{blue}{\left(4 + 1\right) \cdot \frac{x}{\varepsilon}}\right) \]
      2. metadata-eval100.0%

        \[\leadsto {\varepsilon}^{5} \cdot \left(1 + \color{blue}{5} \cdot \frac{x}{\varepsilon}\right) \]
    5. Simplified100.0%

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

    if 2.1499999999999999e-45 < x < 1.22e-26 or 1.16e-18 < x < 8.0000000000000002e-8

    1. Initial program 35.9%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 99.6%

      \[\leadsto \color{blue}{{x}^{4} \cdot \left(\varepsilon + 4 \cdot \varepsilon\right)} \]
    4. Step-by-step derivation
      1. *-commutative99.6%

        \[\leadsto \color{blue}{\left(\varepsilon + 4 \cdot \varepsilon\right) \cdot {x}^{4}} \]
      2. distribute-rgt1-in99.6%

        \[\leadsto \color{blue}{\left(\left(4 + 1\right) \cdot \varepsilon\right)} \cdot {x}^{4} \]
      3. metadata-eval99.6%

        \[\leadsto \left(\color{blue}{5} \cdot \varepsilon\right) \cdot {x}^{4} \]
      4. *-commutative99.6%

        \[\leadsto \color{blue}{\left(\varepsilon \cdot 5\right)} \cdot {x}^{4} \]
      5. associate-*r*100.0%

        \[\leadsto \color{blue}{\varepsilon \cdot \left(5 \cdot {x}^{4}\right)} \]
    5. Simplified100.0%

      \[\leadsto \color{blue}{\varepsilon \cdot \left(5 \cdot {x}^{4}\right)} \]

    if 1.4500000000000001e-23 < x < 1.15e-18

    1. Initial program 28.5%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 99.6%

      \[\leadsto \color{blue}{{x}^{4} \cdot \left(\varepsilon + 4 \cdot \varepsilon\right)} \]
    4. Step-by-step derivation
      1. *-commutative99.6%

        \[\leadsto \color{blue}{\left(\varepsilon + 4 \cdot \varepsilon\right) \cdot {x}^{4}} \]
      2. distribute-rgt1-in99.6%

        \[\leadsto \color{blue}{\left(\left(4 + 1\right) \cdot \varepsilon\right)} \cdot {x}^{4} \]
      3. metadata-eval99.6%

        \[\leadsto \left(\color{blue}{5} \cdot \varepsilon\right) \cdot {x}^{4} \]
      4. *-commutative99.6%

        \[\leadsto \color{blue}{\left(\varepsilon \cdot 5\right)} \cdot {x}^{4} \]
      5. associate-*r*100.0%

        \[\leadsto \color{blue}{\varepsilon \cdot \left(5 \cdot {x}^{4}\right)} \]
    5. Simplified100.0%

      \[\leadsto \color{blue}{\varepsilon \cdot \left(5 \cdot {x}^{4}\right)} \]
    6. Taylor expanded in eps around 0 100.0%

      \[\leadsto \color{blue}{5 \cdot \left(\varepsilon \cdot {x}^{4}\right)} \]

    if 8.0000000000000002e-8 < x

    1. Initial program 5.4%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 99.5%

      \[\leadsto \color{blue}{{x}^{4} \cdot \left(\varepsilon + 4 \cdot \varepsilon\right)} \]
    4. Step-by-step derivation
      1. distribute-rgt1-in99.5%

        \[\leadsto {x}^{4} \cdot \color{blue}{\left(\left(4 + 1\right) \cdot \varepsilon\right)} \]
      2. metadata-eval99.5%

        \[\leadsto {x}^{4} \cdot \left(\color{blue}{5} \cdot \varepsilon\right) \]
    5. Simplified99.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.12 \cdot 10^{-51}:\\ \;\;\;\;{x}^{4} \cdot \left(\varepsilon \cdot \left(5 + 10 \cdot \frac{\varepsilon}{x}\right)\right)\\ \mathbf{elif}\;x \leq -4 \cdot 10^{-78}:\\ \;\;\;\;{\varepsilon}^{4} \cdot \left(\varepsilon + x \cdot 5\right)\\ \mathbf{elif}\;x \leq 4 \cdot 10^{-268}:\\ \;\;\;\;{\varepsilon}^{5}\\ \mathbf{elif}\;x \leq 10^{-55}:\\ \;\;\;\;{\varepsilon}^{4} \cdot \left(x \cdot \left(5 + \frac{\varepsilon}{x}\right)\right)\\ \mathbf{elif}\;x \leq 2.15 \cdot 10^{-45}:\\ \;\;\;\;{\varepsilon}^{5} \cdot \left(1 + 5 \cdot \frac{x}{\varepsilon}\right)\\ \mathbf{elif}\;x \leq 1.22 \cdot 10^{-26}:\\ \;\;\;\;\varepsilon \cdot \left(5 \cdot {x}^{4}\right)\\ \mathbf{elif}\;x \leq 1.45 \cdot 10^{-23}:\\ \;\;\;\;{\varepsilon}^{4} \cdot \left(x \cdot \left(5 + \frac{\varepsilon}{x}\right)\right)\\ \mathbf{elif}\;x \leq 1.15 \cdot 10^{-18}:\\ \;\;\;\;5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\ \mathbf{elif}\;x \leq 1.16 \cdot 10^{-18}:\\ \;\;\;\;{\varepsilon}^{4} \cdot \left(\varepsilon + x \cdot 5\right)\\ \mathbf{elif}\;x \leq 8 \cdot 10^{-8}:\\ \;\;\;\;\varepsilon \cdot \left(5 \cdot {x}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;{x}^{4} \cdot \left(\varepsilon \cdot 5\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 97.2% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {x}^{4} \cdot \left(\varepsilon \cdot 5\right)\\ t_1 := \varepsilon \cdot \left(5 \cdot {x}^{4}\right)\\ t_2 := {\varepsilon}^{4} \cdot \left(x \cdot \left(5 + \frac{\varepsilon}{x}\right)\right)\\ t_3 := {\varepsilon}^{4} \cdot \left(\varepsilon + x \cdot 5\right)\\ \mathbf{if}\;x \leq -1.5 \cdot 10^{-52}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq -4 \cdot 10^{-78}:\\ \;\;\;\;t\_3\\ \mathbf{elif}\;x \leq 10^{-270}:\\ \;\;\;\;{\varepsilon}^{5}\\ \mathbf{elif}\;x \leq 10^{-55}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;x \leq 1.35 \cdot 10^{-45}:\\ \;\;\;\;{\varepsilon}^{5} \cdot \left(1 + 5 \cdot \frac{x}{\varepsilon}\right)\\ \mathbf{elif}\;x \leq 1.22 \cdot 10^{-26}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 1.45 \cdot 10^{-23}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;x \leq 1.15 \cdot 10^{-18}:\\ \;\;\;\;5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\ \mathbf{elif}\;x \leq 1.16 \cdot 10^{-18}:\\ \;\;\;\;t\_3\\ \mathbf{elif}\;x \leq 3 \cdot 10^{-9}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (let* ((t_0 (* (pow x 4.0) (* eps 5.0)))
        (t_1 (* eps (* 5.0 (pow x 4.0))))
        (t_2 (* (pow eps 4.0) (* x (+ 5.0 (/ eps x)))))
        (t_3 (* (pow eps 4.0) (+ eps (* x 5.0)))))
   (if (<= x -1.5e-52)
     t_0
     (if (<= x -4e-78)
       t_3
       (if (<= x 1e-270)
         (pow eps 5.0)
         (if (<= x 1e-55)
           t_2
           (if (<= x 1.35e-45)
             (* (pow eps 5.0) (+ 1.0 (* 5.0 (/ x eps))))
             (if (<= x 1.22e-26)
               t_1
               (if (<= x 1.45e-23)
                 t_2
                 (if (<= x 1.15e-18)
                   (* 5.0 (* eps (pow x 4.0)))
                   (if (<= x 1.16e-18) t_3 (if (<= x 3e-9) t_1 t_0))))))))))))
double code(double x, double eps) {
	double t_0 = pow(x, 4.0) * (eps * 5.0);
	double t_1 = eps * (5.0 * pow(x, 4.0));
	double t_2 = pow(eps, 4.0) * (x * (5.0 + (eps / x)));
	double t_3 = pow(eps, 4.0) * (eps + (x * 5.0));
	double tmp;
	if (x <= -1.5e-52) {
		tmp = t_0;
	} else if (x <= -4e-78) {
		tmp = t_3;
	} else if (x <= 1e-270) {
		tmp = pow(eps, 5.0);
	} else if (x <= 1e-55) {
		tmp = t_2;
	} else if (x <= 1.35e-45) {
		tmp = pow(eps, 5.0) * (1.0 + (5.0 * (x / eps)));
	} else if (x <= 1.22e-26) {
		tmp = t_1;
	} else if (x <= 1.45e-23) {
		tmp = t_2;
	} else if (x <= 1.15e-18) {
		tmp = 5.0 * (eps * pow(x, 4.0));
	} else if (x <= 1.16e-18) {
		tmp = t_3;
	} else if (x <= 3e-9) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, eps)
    real(8), intent (in) :: x
    real(8), intent (in) :: eps
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: t_3
    real(8) :: tmp
    t_0 = (x ** 4.0d0) * (eps * 5.0d0)
    t_1 = eps * (5.0d0 * (x ** 4.0d0))
    t_2 = (eps ** 4.0d0) * (x * (5.0d0 + (eps / x)))
    t_3 = (eps ** 4.0d0) * (eps + (x * 5.0d0))
    if (x <= (-1.5d-52)) then
        tmp = t_0
    else if (x <= (-4d-78)) then
        tmp = t_3
    else if (x <= 1d-270) then
        tmp = eps ** 5.0d0
    else if (x <= 1d-55) then
        tmp = t_2
    else if (x <= 1.35d-45) then
        tmp = (eps ** 5.0d0) * (1.0d0 + (5.0d0 * (x / eps)))
    else if (x <= 1.22d-26) then
        tmp = t_1
    else if (x <= 1.45d-23) then
        tmp = t_2
    else if (x <= 1.15d-18) then
        tmp = 5.0d0 * (eps * (x ** 4.0d0))
    else if (x <= 1.16d-18) then
        tmp = t_3
    else if (x <= 3d-9) then
        tmp = t_1
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double eps) {
	double t_0 = Math.pow(x, 4.0) * (eps * 5.0);
	double t_1 = eps * (5.0 * Math.pow(x, 4.0));
	double t_2 = Math.pow(eps, 4.0) * (x * (5.0 + (eps / x)));
	double t_3 = Math.pow(eps, 4.0) * (eps + (x * 5.0));
	double tmp;
	if (x <= -1.5e-52) {
		tmp = t_0;
	} else if (x <= -4e-78) {
		tmp = t_3;
	} else if (x <= 1e-270) {
		tmp = Math.pow(eps, 5.0);
	} else if (x <= 1e-55) {
		tmp = t_2;
	} else if (x <= 1.35e-45) {
		tmp = Math.pow(eps, 5.0) * (1.0 + (5.0 * (x / eps)));
	} else if (x <= 1.22e-26) {
		tmp = t_1;
	} else if (x <= 1.45e-23) {
		tmp = t_2;
	} else if (x <= 1.15e-18) {
		tmp = 5.0 * (eps * Math.pow(x, 4.0));
	} else if (x <= 1.16e-18) {
		tmp = t_3;
	} else if (x <= 3e-9) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, eps):
	t_0 = math.pow(x, 4.0) * (eps * 5.0)
	t_1 = eps * (5.0 * math.pow(x, 4.0))
	t_2 = math.pow(eps, 4.0) * (x * (5.0 + (eps / x)))
	t_3 = math.pow(eps, 4.0) * (eps + (x * 5.0))
	tmp = 0
	if x <= -1.5e-52:
		tmp = t_0
	elif x <= -4e-78:
		tmp = t_3
	elif x <= 1e-270:
		tmp = math.pow(eps, 5.0)
	elif x <= 1e-55:
		tmp = t_2
	elif x <= 1.35e-45:
		tmp = math.pow(eps, 5.0) * (1.0 + (5.0 * (x / eps)))
	elif x <= 1.22e-26:
		tmp = t_1
	elif x <= 1.45e-23:
		tmp = t_2
	elif x <= 1.15e-18:
		tmp = 5.0 * (eps * math.pow(x, 4.0))
	elif x <= 1.16e-18:
		tmp = t_3
	elif x <= 3e-9:
		tmp = t_1
	else:
		tmp = t_0
	return tmp
function code(x, eps)
	t_0 = Float64((x ^ 4.0) * Float64(eps * 5.0))
	t_1 = Float64(eps * Float64(5.0 * (x ^ 4.0)))
	t_2 = Float64((eps ^ 4.0) * Float64(x * Float64(5.0 + Float64(eps / x))))
	t_3 = Float64((eps ^ 4.0) * Float64(eps + Float64(x * 5.0)))
	tmp = 0.0
	if (x <= -1.5e-52)
		tmp = t_0;
	elseif (x <= -4e-78)
		tmp = t_3;
	elseif (x <= 1e-270)
		tmp = eps ^ 5.0;
	elseif (x <= 1e-55)
		tmp = t_2;
	elseif (x <= 1.35e-45)
		tmp = Float64((eps ^ 5.0) * Float64(1.0 + Float64(5.0 * Float64(x / eps))));
	elseif (x <= 1.22e-26)
		tmp = t_1;
	elseif (x <= 1.45e-23)
		tmp = t_2;
	elseif (x <= 1.15e-18)
		tmp = Float64(5.0 * Float64(eps * (x ^ 4.0)));
	elseif (x <= 1.16e-18)
		tmp = t_3;
	elseif (x <= 3e-9)
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, eps)
	t_0 = (x ^ 4.0) * (eps * 5.0);
	t_1 = eps * (5.0 * (x ^ 4.0));
	t_2 = (eps ^ 4.0) * (x * (5.0 + (eps / x)));
	t_3 = (eps ^ 4.0) * (eps + (x * 5.0));
	tmp = 0.0;
	if (x <= -1.5e-52)
		tmp = t_0;
	elseif (x <= -4e-78)
		tmp = t_3;
	elseif (x <= 1e-270)
		tmp = eps ^ 5.0;
	elseif (x <= 1e-55)
		tmp = t_2;
	elseif (x <= 1.35e-45)
		tmp = (eps ^ 5.0) * (1.0 + (5.0 * (x / eps)));
	elseif (x <= 1.22e-26)
		tmp = t_1;
	elseif (x <= 1.45e-23)
		tmp = t_2;
	elseif (x <= 1.15e-18)
		tmp = 5.0 * (eps * (x ^ 4.0));
	elseif (x <= 1.16e-18)
		tmp = t_3;
	elseif (x <= 3e-9)
		tmp = t_1;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, eps_] := Block[{t$95$0 = N[(N[Power[x, 4.0], $MachinePrecision] * N[(eps * 5.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(eps * N[(5.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Power[eps, 4.0], $MachinePrecision] * N[(x * N[(5.0 + N[(eps / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Power[eps, 4.0], $MachinePrecision] * N[(eps + N[(x * 5.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.5e-52], t$95$0, If[LessEqual[x, -4e-78], t$95$3, If[LessEqual[x, 1e-270], N[Power[eps, 5.0], $MachinePrecision], If[LessEqual[x, 1e-55], t$95$2, If[LessEqual[x, 1.35e-45], N[(N[Power[eps, 5.0], $MachinePrecision] * N[(1.0 + N[(5.0 * N[(x / eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.22e-26], t$95$1, If[LessEqual[x, 1.45e-23], t$95$2, If[LessEqual[x, 1.15e-18], N[(5.0 * N[(eps * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.16e-18], t$95$3, If[LessEqual[x, 3e-9], t$95$1, t$95$0]]]]]]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {x}^{4} \cdot \left(\varepsilon \cdot 5\right)\\
t_1 := \varepsilon \cdot \left(5 \cdot {x}^{4}\right)\\
t_2 := {\varepsilon}^{4} \cdot \left(x \cdot \left(5 + \frac{\varepsilon}{x}\right)\right)\\
t_3 := {\varepsilon}^{4} \cdot \left(\varepsilon + x \cdot 5\right)\\
\mathbf{if}\;x \leq -1.5 \cdot 10^{-52}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq -4 \cdot 10^{-78}:\\
\;\;\;\;t\_3\\

\mathbf{elif}\;x \leq 10^{-270}:\\
\;\;\;\;{\varepsilon}^{5}\\

\mathbf{elif}\;x \leq 10^{-55}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;x \leq 1.35 \cdot 10^{-45}:\\
\;\;\;\;{\varepsilon}^{5} \cdot \left(1 + 5 \cdot \frac{x}{\varepsilon}\right)\\

\mathbf{elif}\;x \leq 1.22 \cdot 10^{-26}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 1.45 \cdot 10^{-23}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;x \leq 1.15 \cdot 10^{-18}:\\
\;\;\;\;5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\

\mathbf{elif}\;x \leq 1.16 \cdot 10^{-18}:\\
\;\;\;\;t\_3\\

\mathbf{elif}\;x \leq 3 \cdot 10^{-9}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 7 regimes
  2. if x < -1.5e-52 or 2.99999999999999998e-9 < x

    1. Initial program 37.1%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 94.8%

      \[\leadsto \color{blue}{{x}^{4} \cdot \left(\varepsilon + 4 \cdot \varepsilon\right)} \]
    4. Step-by-step derivation
      1. distribute-rgt1-in94.8%

        \[\leadsto {x}^{4} \cdot \color{blue}{\left(\left(4 + 1\right) \cdot \varepsilon\right)} \]
      2. metadata-eval94.8%

        \[\leadsto {x}^{4} \cdot \left(\color{blue}{5} \cdot \varepsilon\right) \]
    5. Simplified94.8%

      \[\leadsto \color{blue}{{x}^{4} \cdot \left(5 \cdot \varepsilon\right)} \]

    if -1.5e-52 < x < -4e-78 or 1.15e-18 < x < 1.16e-18

    1. Initial program 99.8%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 97.2%

      \[\leadsto \color{blue}{x \cdot \left(4 \cdot {\varepsilon}^{4} + {\varepsilon}^{4}\right) + {\varepsilon}^{5}} \]
    4. Step-by-step derivation
      1. fma-define97.2%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, 4 \cdot {\varepsilon}^{4} + {\varepsilon}^{4}, {\varepsilon}^{5}\right)} \]
      2. distribute-lft1-in97.2%

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{\left(4 + 1\right) \cdot {\varepsilon}^{4}}, {\varepsilon}^{5}\right) \]
      3. metadata-eval97.2%

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{5} \cdot {\varepsilon}^{4}, {\varepsilon}^{5}\right) \]
    5. Simplified97.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, 5 \cdot {\varepsilon}^{4}, {\varepsilon}^{5}\right)} \]
    6. Taylor expanded in eps around 0 97.2%

      \[\leadsto \color{blue}{{\varepsilon}^{4} \cdot \left(\varepsilon + 5 \cdot x\right)} \]

    if -4e-78 < x < 1e-270

    1. Initial program 100.0%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 100.0%

      \[\leadsto \color{blue}{{\varepsilon}^{5}} \]

    if 1e-270 < x < 9.99999999999999995e-56 or 1.22e-26 < x < 1.4500000000000001e-23

    1. Initial program 100.0%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 99.2%

      \[\leadsto \color{blue}{x \cdot \left(4 \cdot {\varepsilon}^{4} + {\varepsilon}^{4}\right) + {\varepsilon}^{5}} \]
    4. Step-by-step derivation
      1. fma-define99.2%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, 4 \cdot {\varepsilon}^{4} + {\varepsilon}^{4}, {\varepsilon}^{5}\right)} \]
      2. distribute-lft1-in99.2%

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{\left(4 + 1\right) \cdot {\varepsilon}^{4}}, {\varepsilon}^{5}\right) \]
      3. metadata-eval99.2%

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{5} \cdot {\varepsilon}^{4}, {\varepsilon}^{5}\right) \]
    5. Simplified99.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, 5 \cdot {\varepsilon}^{4}, {\varepsilon}^{5}\right)} \]
    6. Taylor expanded in eps around 0 99.2%

      \[\leadsto \color{blue}{{\varepsilon}^{4} \cdot \left(\varepsilon + 5 \cdot x\right)} \]
    7. Taylor expanded in x around inf 99.2%

      \[\leadsto {\varepsilon}^{4} \cdot \color{blue}{\left(x \cdot \left(5 + \frac{\varepsilon}{x}\right)\right)} \]

    if 9.99999999999999995e-56 < x < 1.34999999999999992e-45

    1. Initial program 99.6%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in eps around inf 100.0%

      \[\leadsto \color{blue}{{\varepsilon}^{5} \cdot \left(1 + \left(4 \cdot \frac{x}{\varepsilon} + \frac{x}{\varepsilon}\right)\right)} \]
    4. Step-by-step derivation
      1. distribute-lft1-in100.0%

        \[\leadsto {\varepsilon}^{5} \cdot \left(1 + \color{blue}{\left(4 + 1\right) \cdot \frac{x}{\varepsilon}}\right) \]
      2. metadata-eval100.0%

        \[\leadsto {\varepsilon}^{5} \cdot \left(1 + \color{blue}{5} \cdot \frac{x}{\varepsilon}\right) \]
    5. Simplified100.0%

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

    if 1.34999999999999992e-45 < x < 1.22e-26 or 1.16e-18 < x < 2.99999999999999998e-9

    1. Initial program 35.9%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 99.6%

      \[\leadsto \color{blue}{{x}^{4} \cdot \left(\varepsilon + 4 \cdot \varepsilon\right)} \]
    4. Step-by-step derivation
      1. *-commutative99.6%

        \[\leadsto \color{blue}{\left(\varepsilon + 4 \cdot \varepsilon\right) \cdot {x}^{4}} \]
      2. distribute-rgt1-in99.6%

        \[\leadsto \color{blue}{\left(\left(4 + 1\right) \cdot \varepsilon\right)} \cdot {x}^{4} \]
      3. metadata-eval99.6%

        \[\leadsto \left(\color{blue}{5} \cdot \varepsilon\right) \cdot {x}^{4} \]
      4. *-commutative99.6%

        \[\leadsto \color{blue}{\left(\varepsilon \cdot 5\right)} \cdot {x}^{4} \]
      5. associate-*r*100.0%

        \[\leadsto \color{blue}{\varepsilon \cdot \left(5 \cdot {x}^{4}\right)} \]
    5. Simplified100.0%

      \[\leadsto \color{blue}{\varepsilon \cdot \left(5 \cdot {x}^{4}\right)} \]

    if 1.4500000000000001e-23 < x < 1.15e-18

    1. Initial program 28.5%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 99.6%

      \[\leadsto \color{blue}{{x}^{4} \cdot \left(\varepsilon + 4 \cdot \varepsilon\right)} \]
    4. Step-by-step derivation
      1. *-commutative99.6%

        \[\leadsto \color{blue}{\left(\varepsilon + 4 \cdot \varepsilon\right) \cdot {x}^{4}} \]
      2. distribute-rgt1-in99.6%

        \[\leadsto \color{blue}{\left(\left(4 + 1\right) \cdot \varepsilon\right)} \cdot {x}^{4} \]
      3. metadata-eval99.6%

        \[\leadsto \left(\color{blue}{5} \cdot \varepsilon\right) \cdot {x}^{4} \]
      4. *-commutative99.6%

        \[\leadsto \color{blue}{\left(\varepsilon \cdot 5\right)} \cdot {x}^{4} \]
      5. associate-*r*100.0%

        \[\leadsto \color{blue}{\varepsilon \cdot \left(5 \cdot {x}^{4}\right)} \]
    5. Simplified100.0%

      \[\leadsto \color{blue}{\varepsilon \cdot \left(5 \cdot {x}^{4}\right)} \]
    6. Taylor expanded in eps around 0 100.0%

      \[\leadsto \color{blue}{5 \cdot \left(\varepsilon \cdot {x}^{4}\right)} \]
  3. Recombined 7 regimes into one program.
  4. Final simplification99.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.5 \cdot 10^{-52}:\\ \;\;\;\;{x}^{4} \cdot \left(\varepsilon \cdot 5\right)\\ \mathbf{elif}\;x \leq -4 \cdot 10^{-78}:\\ \;\;\;\;{\varepsilon}^{4} \cdot \left(\varepsilon + x \cdot 5\right)\\ \mathbf{elif}\;x \leq 10^{-270}:\\ \;\;\;\;{\varepsilon}^{5}\\ \mathbf{elif}\;x \leq 10^{-55}:\\ \;\;\;\;{\varepsilon}^{4} \cdot \left(x \cdot \left(5 + \frac{\varepsilon}{x}\right)\right)\\ \mathbf{elif}\;x \leq 1.35 \cdot 10^{-45}:\\ \;\;\;\;{\varepsilon}^{5} \cdot \left(1 + 5 \cdot \frac{x}{\varepsilon}\right)\\ \mathbf{elif}\;x \leq 1.22 \cdot 10^{-26}:\\ \;\;\;\;\varepsilon \cdot \left(5 \cdot {x}^{4}\right)\\ \mathbf{elif}\;x \leq 1.45 \cdot 10^{-23}:\\ \;\;\;\;{\varepsilon}^{4} \cdot \left(x \cdot \left(5 + \frac{\varepsilon}{x}\right)\right)\\ \mathbf{elif}\;x \leq 1.15 \cdot 10^{-18}:\\ \;\;\;\;5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\ \mathbf{elif}\;x \leq 1.16 \cdot 10^{-18}:\\ \;\;\;\;{\varepsilon}^{4} \cdot \left(\varepsilon + x \cdot 5\right)\\ \mathbf{elif}\;x \leq 3 \cdot 10^{-9}:\\ \;\;\;\;\varepsilon \cdot \left(5 \cdot {x}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;{x}^{4} \cdot \left(\varepsilon \cdot 5\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 97.2% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \varepsilon \cdot \left(5 \cdot {x}^{4}\right)\\ t_1 := {x}^{4} \cdot \left(\varepsilon \cdot 5\right)\\ t_2 := {\varepsilon}^{4} \cdot \left(x \cdot \left(5 + \frac{\varepsilon}{x}\right)\right)\\ t_3 := {\varepsilon}^{4} \cdot \left(\varepsilon + x \cdot 5\right)\\ \mathbf{if}\;x \leq -1.6 \cdot 10^{-52}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq -4 \cdot 10^{-78}:\\ \;\;\;\;t\_3\\ \mathbf{elif}\;x \leq 4 \cdot 10^{-268}:\\ \;\;\;\;{\varepsilon}^{5}\\ \mathbf{elif}\;x \leq 10^{-55}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;x \leq 6.8 \cdot 10^{-45}:\\ \;\;\;\;t\_3\\ \mathbf{elif}\;x \leq 1.22 \cdot 10^{-26}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 1.45 \cdot 10^{-23}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;x \leq 1.15 \cdot 10^{-18}:\\ \;\;\;\;5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\ \mathbf{elif}\;x \leq 1.16 \cdot 10^{-18}:\\ \;\;\;\;t\_3\\ \mathbf{elif}\;x \leq 3.05 \cdot 10^{-9}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (let* ((t_0 (* eps (* 5.0 (pow x 4.0))))
        (t_1 (* (pow x 4.0) (* eps 5.0)))
        (t_2 (* (pow eps 4.0) (* x (+ 5.0 (/ eps x)))))
        (t_3 (* (pow eps 4.0) (+ eps (* x 5.0)))))
   (if (<= x -1.6e-52)
     t_1
     (if (<= x -4e-78)
       t_3
       (if (<= x 4e-268)
         (pow eps 5.0)
         (if (<= x 1e-55)
           t_2
           (if (<= x 6.8e-45)
             t_3
             (if (<= x 1.22e-26)
               t_0
               (if (<= x 1.45e-23)
                 t_2
                 (if (<= x 1.15e-18)
                   (* 5.0 (* eps (pow x 4.0)))
                   (if (<= x 1.16e-18)
                     t_3
                     (if (<= x 3.05e-9) t_0 t_1))))))))))))
double code(double x, double eps) {
	double t_0 = eps * (5.0 * pow(x, 4.0));
	double t_1 = pow(x, 4.0) * (eps * 5.0);
	double t_2 = pow(eps, 4.0) * (x * (5.0 + (eps / x)));
	double t_3 = pow(eps, 4.0) * (eps + (x * 5.0));
	double tmp;
	if (x <= -1.6e-52) {
		tmp = t_1;
	} else if (x <= -4e-78) {
		tmp = t_3;
	} else if (x <= 4e-268) {
		tmp = pow(eps, 5.0);
	} else if (x <= 1e-55) {
		tmp = t_2;
	} else if (x <= 6.8e-45) {
		tmp = t_3;
	} else if (x <= 1.22e-26) {
		tmp = t_0;
	} else if (x <= 1.45e-23) {
		tmp = t_2;
	} else if (x <= 1.15e-18) {
		tmp = 5.0 * (eps * pow(x, 4.0));
	} else if (x <= 1.16e-18) {
		tmp = t_3;
	} else if (x <= 3.05e-9) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(x, eps)
    real(8), intent (in) :: x
    real(8), intent (in) :: eps
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: t_3
    real(8) :: tmp
    t_0 = eps * (5.0d0 * (x ** 4.0d0))
    t_1 = (x ** 4.0d0) * (eps * 5.0d0)
    t_2 = (eps ** 4.0d0) * (x * (5.0d0 + (eps / x)))
    t_3 = (eps ** 4.0d0) * (eps + (x * 5.0d0))
    if (x <= (-1.6d-52)) then
        tmp = t_1
    else if (x <= (-4d-78)) then
        tmp = t_3
    else if (x <= 4d-268) then
        tmp = eps ** 5.0d0
    else if (x <= 1d-55) then
        tmp = t_2
    else if (x <= 6.8d-45) then
        tmp = t_3
    else if (x <= 1.22d-26) then
        tmp = t_0
    else if (x <= 1.45d-23) then
        tmp = t_2
    else if (x <= 1.15d-18) then
        tmp = 5.0d0 * (eps * (x ** 4.0d0))
    else if (x <= 1.16d-18) then
        tmp = t_3
    else if (x <= 3.05d-9) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double eps) {
	double t_0 = eps * (5.0 * Math.pow(x, 4.0));
	double t_1 = Math.pow(x, 4.0) * (eps * 5.0);
	double t_2 = Math.pow(eps, 4.0) * (x * (5.0 + (eps / x)));
	double t_3 = Math.pow(eps, 4.0) * (eps + (x * 5.0));
	double tmp;
	if (x <= -1.6e-52) {
		tmp = t_1;
	} else if (x <= -4e-78) {
		tmp = t_3;
	} else if (x <= 4e-268) {
		tmp = Math.pow(eps, 5.0);
	} else if (x <= 1e-55) {
		tmp = t_2;
	} else if (x <= 6.8e-45) {
		tmp = t_3;
	} else if (x <= 1.22e-26) {
		tmp = t_0;
	} else if (x <= 1.45e-23) {
		tmp = t_2;
	} else if (x <= 1.15e-18) {
		tmp = 5.0 * (eps * Math.pow(x, 4.0));
	} else if (x <= 1.16e-18) {
		tmp = t_3;
	} else if (x <= 3.05e-9) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, eps):
	t_0 = eps * (5.0 * math.pow(x, 4.0))
	t_1 = math.pow(x, 4.0) * (eps * 5.0)
	t_2 = math.pow(eps, 4.0) * (x * (5.0 + (eps / x)))
	t_3 = math.pow(eps, 4.0) * (eps + (x * 5.0))
	tmp = 0
	if x <= -1.6e-52:
		tmp = t_1
	elif x <= -4e-78:
		tmp = t_3
	elif x <= 4e-268:
		tmp = math.pow(eps, 5.0)
	elif x <= 1e-55:
		tmp = t_2
	elif x <= 6.8e-45:
		tmp = t_3
	elif x <= 1.22e-26:
		tmp = t_0
	elif x <= 1.45e-23:
		tmp = t_2
	elif x <= 1.15e-18:
		tmp = 5.0 * (eps * math.pow(x, 4.0))
	elif x <= 1.16e-18:
		tmp = t_3
	elif x <= 3.05e-9:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(x, eps)
	t_0 = Float64(eps * Float64(5.0 * (x ^ 4.0)))
	t_1 = Float64((x ^ 4.0) * Float64(eps * 5.0))
	t_2 = Float64((eps ^ 4.0) * Float64(x * Float64(5.0 + Float64(eps / x))))
	t_3 = Float64((eps ^ 4.0) * Float64(eps + Float64(x * 5.0)))
	tmp = 0.0
	if (x <= -1.6e-52)
		tmp = t_1;
	elseif (x <= -4e-78)
		tmp = t_3;
	elseif (x <= 4e-268)
		tmp = eps ^ 5.0;
	elseif (x <= 1e-55)
		tmp = t_2;
	elseif (x <= 6.8e-45)
		tmp = t_3;
	elseif (x <= 1.22e-26)
		tmp = t_0;
	elseif (x <= 1.45e-23)
		tmp = t_2;
	elseif (x <= 1.15e-18)
		tmp = Float64(5.0 * Float64(eps * (x ^ 4.0)));
	elseif (x <= 1.16e-18)
		tmp = t_3;
	elseif (x <= 3.05e-9)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, eps)
	t_0 = eps * (5.0 * (x ^ 4.0));
	t_1 = (x ^ 4.0) * (eps * 5.0);
	t_2 = (eps ^ 4.0) * (x * (5.0 + (eps / x)));
	t_3 = (eps ^ 4.0) * (eps + (x * 5.0));
	tmp = 0.0;
	if (x <= -1.6e-52)
		tmp = t_1;
	elseif (x <= -4e-78)
		tmp = t_3;
	elseif (x <= 4e-268)
		tmp = eps ^ 5.0;
	elseif (x <= 1e-55)
		tmp = t_2;
	elseif (x <= 6.8e-45)
		tmp = t_3;
	elseif (x <= 1.22e-26)
		tmp = t_0;
	elseif (x <= 1.45e-23)
		tmp = t_2;
	elseif (x <= 1.15e-18)
		tmp = 5.0 * (eps * (x ^ 4.0));
	elseif (x <= 1.16e-18)
		tmp = t_3;
	elseif (x <= 3.05e-9)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, eps_] := Block[{t$95$0 = N[(eps * N[(5.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[x, 4.0], $MachinePrecision] * N[(eps * 5.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Power[eps, 4.0], $MachinePrecision] * N[(x * N[(5.0 + N[(eps / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Power[eps, 4.0], $MachinePrecision] * N[(eps + N[(x * 5.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.6e-52], t$95$1, If[LessEqual[x, -4e-78], t$95$3, If[LessEqual[x, 4e-268], N[Power[eps, 5.0], $MachinePrecision], If[LessEqual[x, 1e-55], t$95$2, If[LessEqual[x, 6.8e-45], t$95$3, If[LessEqual[x, 1.22e-26], t$95$0, If[LessEqual[x, 1.45e-23], t$95$2, If[LessEqual[x, 1.15e-18], N[(5.0 * N[(eps * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.16e-18], t$95$3, If[LessEqual[x, 3.05e-9], t$95$0, t$95$1]]]]]]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \varepsilon \cdot \left(5 \cdot {x}^{4}\right)\\
t_1 := {x}^{4} \cdot \left(\varepsilon \cdot 5\right)\\
t_2 := {\varepsilon}^{4} \cdot \left(x \cdot \left(5 + \frac{\varepsilon}{x}\right)\right)\\
t_3 := {\varepsilon}^{4} \cdot \left(\varepsilon + x \cdot 5\right)\\
\mathbf{if}\;x \leq -1.6 \cdot 10^{-52}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq -4 \cdot 10^{-78}:\\
\;\;\;\;t\_3\\

\mathbf{elif}\;x \leq 4 \cdot 10^{-268}:\\
\;\;\;\;{\varepsilon}^{5}\\

\mathbf{elif}\;x \leq 10^{-55}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;x \leq 6.8 \cdot 10^{-45}:\\
\;\;\;\;t\_3\\

\mathbf{elif}\;x \leq 1.22 \cdot 10^{-26}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 1.45 \cdot 10^{-23}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;x \leq 1.15 \cdot 10^{-18}:\\
\;\;\;\;5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\

\mathbf{elif}\;x \leq 1.16 \cdot 10^{-18}:\\
\;\;\;\;t\_3\\

\mathbf{elif}\;x \leq 3.05 \cdot 10^{-9}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 6 regimes
  2. if x < -1.60000000000000005e-52 or 3.05e-9 < x

    1. Initial program 37.1%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 94.8%

      \[\leadsto \color{blue}{{x}^{4} \cdot \left(\varepsilon + 4 \cdot \varepsilon\right)} \]
    4. Step-by-step derivation
      1. distribute-rgt1-in94.8%

        \[\leadsto {x}^{4} \cdot \color{blue}{\left(\left(4 + 1\right) \cdot \varepsilon\right)} \]
      2. metadata-eval94.8%

        \[\leadsto {x}^{4} \cdot \left(\color{blue}{5} \cdot \varepsilon\right) \]
    5. Simplified94.8%

      \[\leadsto \color{blue}{{x}^{4} \cdot \left(5 \cdot \varepsilon\right)} \]

    if -1.60000000000000005e-52 < x < -4e-78 or 9.99999999999999995e-56 < x < 6.80000000000000008e-45 or 1.15e-18 < x < 1.16e-18

    1. Initial program 99.8%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 97.8%

      \[\leadsto \color{blue}{x \cdot \left(4 \cdot {\varepsilon}^{4} + {\varepsilon}^{4}\right) + {\varepsilon}^{5}} \]
    4. Step-by-step derivation
      1. fma-define97.8%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, 4 \cdot {\varepsilon}^{4} + {\varepsilon}^{4}, {\varepsilon}^{5}\right)} \]
      2. distribute-lft1-in97.8%

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{\left(4 + 1\right) \cdot {\varepsilon}^{4}}, {\varepsilon}^{5}\right) \]
      3. metadata-eval97.8%

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{5} \cdot {\varepsilon}^{4}, {\varepsilon}^{5}\right) \]
    5. Simplified97.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, 5 \cdot {\varepsilon}^{4}, {\varepsilon}^{5}\right)} \]
    6. Taylor expanded in eps around 0 97.8%

      \[\leadsto \color{blue}{{\varepsilon}^{4} \cdot \left(\varepsilon + 5 \cdot x\right)} \]

    if -4e-78 < x < 3.99999999999999983e-268

    1. Initial program 100.0%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 100.0%

      \[\leadsto \color{blue}{{\varepsilon}^{5}} \]

    if 3.99999999999999983e-268 < x < 9.99999999999999995e-56 or 1.22e-26 < x < 1.4500000000000001e-23

    1. Initial program 100.0%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 99.2%

      \[\leadsto \color{blue}{x \cdot \left(4 \cdot {\varepsilon}^{4} + {\varepsilon}^{4}\right) + {\varepsilon}^{5}} \]
    4. Step-by-step derivation
      1. fma-define99.2%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, 4 \cdot {\varepsilon}^{4} + {\varepsilon}^{4}, {\varepsilon}^{5}\right)} \]
      2. distribute-lft1-in99.2%

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{\left(4 + 1\right) \cdot {\varepsilon}^{4}}, {\varepsilon}^{5}\right) \]
      3. metadata-eval99.2%

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{5} \cdot {\varepsilon}^{4}, {\varepsilon}^{5}\right) \]
    5. Simplified99.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, 5 \cdot {\varepsilon}^{4}, {\varepsilon}^{5}\right)} \]
    6. Taylor expanded in eps around 0 99.2%

      \[\leadsto \color{blue}{{\varepsilon}^{4} \cdot \left(\varepsilon + 5 \cdot x\right)} \]
    7. Taylor expanded in x around inf 99.2%

      \[\leadsto {\varepsilon}^{4} \cdot \color{blue}{\left(x \cdot \left(5 + \frac{\varepsilon}{x}\right)\right)} \]

    if 6.80000000000000008e-45 < x < 1.22e-26 or 1.16e-18 < x < 3.05e-9

    1. Initial program 35.9%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 99.6%

      \[\leadsto \color{blue}{{x}^{4} \cdot \left(\varepsilon + 4 \cdot \varepsilon\right)} \]
    4. Step-by-step derivation
      1. *-commutative99.6%

        \[\leadsto \color{blue}{\left(\varepsilon + 4 \cdot \varepsilon\right) \cdot {x}^{4}} \]
      2. distribute-rgt1-in99.6%

        \[\leadsto \color{blue}{\left(\left(4 + 1\right) \cdot \varepsilon\right)} \cdot {x}^{4} \]
      3. metadata-eval99.6%

        \[\leadsto \left(\color{blue}{5} \cdot \varepsilon\right) \cdot {x}^{4} \]
      4. *-commutative99.6%

        \[\leadsto \color{blue}{\left(\varepsilon \cdot 5\right)} \cdot {x}^{4} \]
      5. associate-*r*100.0%

        \[\leadsto \color{blue}{\varepsilon \cdot \left(5 \cdot {x}^{4}\right)} \]
    5. Simplified100.0%

      \[\leadsto \color{blue}{\varepsilon \cdot \left(5 \cdot {x}^{4}\right)} \]

    if 1.4500000000000001e-23 < x < 1.15e-18

    1. Initial program 28.5%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 99.6%

      \[\leadsto \color{blue}{{x}^{4} \cdot \left(\varepsilon + 4 \cdot \varepsilon\right)} \]
    4. Step-by-step derivation
      1. *-commutative99.6%

        \[\leadsto \color{blue}{\left(\varepsilon + 4 \cdot \varepsilon\right) \cdot {x}^{4}} \]
      2. distribute-rgt1-in99.6%

        \[\leadsto \color{blue}{\left(\left(4 + 1\right) \cdot \varepsilon\right)} \cdot {x}^{4} \]
      3. metadata-eval99.6%

        \[\leadsto \left(\color{blue}{5} \cdot \varepsilon\right) \cdot {x}^{4} \]
      4. *-commutative99.6%

        \[\leadsto \color{blue}{\left(\varepsilon \cdot 5\right)} \cdot {x}^{4} \]
      5. associate-*r*100.0%

        \[\leadsto \color{blue}{\varepsilon \cdot \left(5 \cdot {x}^{4}\right)} \]
    5. Simplified100.0%

      \[\leadsto \color{blue}{\varepsilon \cdot \left(5 \cdot {x}^{4}\right)} \]
    6. Taylor expanded in eps around 0 100.0%

      \[\leadsto \color{blue}{5 \cdot \left(\varepsilon \cdot {x}^{4}\right)} \]
  3. Recombined 6 regimes into one program.
  4. Final simplification99.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.6 \cdot 10^{-52}:\\ \;\;\;\;{x}^{4} \cdot \left(\varepsilon \cdot 5\right)\\ \mathbf{elif}\;x \leq -4 \cdot 10^{-78}:\\ \;\;\;\;{\varepsilon}^{4} \cdot \left(\varepsilon + x \cdot 5\right)\\ \mathbf{elif}\;x \leq 4 \cdot 10^{-268}:\\ \;\;\;\;{\varepsilon}^{5}\\ \mathbf{elif}\;x \leq 10^{-55}:\\ \;\;\;\;{\varepsilon}^{4} \cdot \left(x \cdot \left(5 + \frac{\varepsilon}{x}\right)\right)\\ \mathbf{elif}\;x \leq 6.8 \cdot 10^{-45}:\\ \;\;\;\;{\varepsilon}^{4} \cdot \left(\varepsilon + x \cdot 5\right)\\ \mathbf{elif}\;x \leq 1.22 \cdot 10^{-26}:\\ \;\;\;\;\varepsilon \cdot \left(5 \cdot {x}^{4}\right)\\ \mathbf{elif}\;x \leq 1.45 \cdot 10^{-23}:\\ \;\;\;\;{\varepsilon}^{4} \cdot \left(x \cdot \left(5 + \frac{\varepsilon}{x}\right)\right)\\ \mathbf{elif}\;x \leq 1.15 \cdot 10^{-18}:\\ \;\;\;\;5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\ \mathbf{elif}\;x \leq 1.16 \cdot 10^{-18}:\\ \;\;\;\;{\varepsilon}^{4} \cdot \left(\varepsilon + x \cdot 5\right)\\ \mathbf{elif}\;x \leq 3.05 \cdot 10^{-9}:\\ \;\;\;\;\varepsilon \cdot \left(5 \cdot {x}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;{x}^{4} \cdot \left(\varepsilon \cdot 5\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 97.2% accurate, 1.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {x}^{4} \cdot \left(\varepsilon \cdot 5\right)\\ t_1 := \varepsilon \cdot \left(5 \cdot {x}^{4}\right)\\ t_2 := {\varepsilon}^{4} \cdot \left(\varepsilon + x \cdot 5\right)\\ \mathbf{if}\;x \leq -1.2 \cdot 10^{-51}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq -4 \cdot 10^{-78}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;x \leq 10^{-270}:\\ \;\;\;\;{\varepsilon}^{5}\\ \mathbf{elif}\;x \leq 1.65 \cdot 10^{-45}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;x \leq 1.22 \cdot 10^{-26}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 1.45 \cdot 10^{-23}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;x \leq 1.15 \cdot 10^{-18}:\\ \;\;\;\;5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\ \mathbf{elif}\;x \leq 1.16 \cdot 10^{-18}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;x \leq 1.05 \cdot 10^{-7}:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (let* ((t_0 (* (pow x 4.0) (* eps 5.0)))
        (t_1 (* eps (* 5.0 (pow x 4.0))))
        (t_2 (* (pow eps 4.0) (+ eps (* x 5.0)))))
   (if (<= x -1.2e-51)
     t_0
     (if (<= x -4e-78)
       t_2
       (if (<= x 1e-270)
         (pow eps 5.0)
         (if (<= x 1.65e-45)
           t_2
           (if (<= x 1.22e-26)
             t_1
             (if (<= x 1.45e-23)
               t_2
               (if (<= x 1.15e-18)
                 (* 5.0 (* eps (pow x 4.0)))
                 (if (<= x 1.16e-18) t_2 (if (<= x 1.05e-7) t_1 t_0)))))))))))
double code(double x, double eps) {
	double t_0 = pow(x, 4.0) * (eps * 5.0);
	double t_1 = eps * (5.0 * pow(x, 4.0));
	double t_2 = pow(eps, 4.0) * (eps + (x * 5.0));
	double tmp;
	if (x <= -1.2e-51) {
		tmp = t_0;
	} else if (x <= -4e-78) {
		tmp = t_2;
	} else if (x <= 1e-270) {
		tmp = pow(eps, 5.0);
	} else if (x <= 1.65e-45) {
		tmp = t_2;
	} else if (x <= 1.22e-26) {
		tmp = t_1;
	} else if (x <= 1.45e-23) {
		tmp = t_2;
	} else if (x <= 1.15e-18) {
		tmp = 5.0 * (eps * pow(x, 4.0));
	} else if (x <= 1.16e-18) {
		tmp = t_2;
	} else if (x <= 1.05e-7) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x, eps)
    real(8), intent (in) :: x
    real(8), intent (in) :: eps
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: t_2
    real(8) :: tmp
    t_0 = (x ** 4.0d0) * (eps * 5.0d0)
    t_1 = eps * (5.0d0 * (x ** 4.0d0))
    t_2 = (eps ** 4.0d0) * (eps + (x * 5.0d0))
    if (x <= (-1.2d-51)) then
        tmp = t_0
    else if (x <= (-4d-78)) then
        tmp = t_2
    else if (x <= 1d-270) then
        tmp = eps ** 5.0d0
    else if (x <= 1.65d-45) then
        tmp = t_2
    else if (x <= 1.22d-26) then
        tmp = t_1
    else if (x <= 1.45d-23) then
        tmp = t_2
    else if (x <= 1.15d-18) then
        tmp = 5.0d0 * (eps * (x ** 4.0d0))
    else if (x <= 1.16d-18) then
        tmp = t_2
    else if (x <= 1.05d-7) then
        tmp = t_1
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x, double eps) {
	double t_0 = Math.pow(x, 4.0) * (eps * 5.0);
	double t_1 = eps * (5.0 * Math.pow(x, 4.0));
	double t_2 = Math.pow(eps, 4.0) * (eps + (x * 5.0));
	double tmp;
	if (x <= -1.2e-51) {
		tmp = t_0;
	} else if (x <= -4e-78) {
		tmp = t_2;
	} else if (x <= 1e-270) {
		tmp = Math.pow(eps, 5.0);
	} else if (x <= 1.65e-45) {
		tmp = t_2;
	} else if (x <= 1.22e-26) {
		tmp = t_1;
	} else if (x <= 1.45e-23) {
		tmp = t_2;
	} else if (x <= 1.15e-18) {
		tmp = 5.0 * (eps * Math.pow(x, 4.0));
	} else if (x <= 1.16e-18) {
		tmp = t_2;
	} else if (x <= 1.05e-7) {
		tmp = t_1;
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, eps):
	t_0 = math.pow(x, 4.0) * (eps * 5.0)
	t_1 = eps * (5.0 * math.pow(x, 4.0))
	t_2 = math.pow(eps, 4.0) * (eps + (x * 5.0))
	tmp = 0
	if x <= -1.2e-51:
		tmp = t_0
	elif x <= -4e-78:
		tmp = t_2
	elif x <= 1e-270:
		tmp = math.pow(eps, 5.0)
	elif x <= 1.65e-45:
		tmp = t_2
	elif x <= 1.22e-26:
		tmp = t_1
	elif x <= 1.45e-23:
		tmp = t_2
	elif x <= 1.15e-18:
		tmp = 5.0 * (eps * math.pow(x, 4.0))
	elif x <= 1.16e-18:
		tmp = t_2
	elif x <= 1.05e-7:
		tmp = t_1
	else:
		tmp = t_0
	return tmp
function code(x, eps)
	t_0 = Float64((x ^ 4.0) * Float64(eps * 5.0))
	t_1 = Float64(eps * Float64(5.0 * (x ^ 4.0)))
	t_2 = Float64((eps ^ 4.0) * Float64(eps + Float64(x * 5.0)))
	tmp = 0.0
	if (x <= -1.2e-51)
		tmp = t_0;
	elseif (x <= -4e-78)
		tmp = t_2;
	elseif (x <= 1e-270)
		tmp = eps ^ 5.0;
	elseif (x <= 1.65e-45)
		tmp = t_2;
	elseif (x <= 1.22e-26)
		tmp = t_1;
	elseif (x <= 1.45e-23)
		tmp = t_2;
	elseif (x <= 1.15e-18)
		tmp = Float64(5.0 * Float64(eps * (x ^ 4.0)));
	elseif (x <= 1.16e-18)
		tmp = t_2;
	elseif (x <= 1.05e-7)
		tmp = t_1;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x, eps)
	t_0 = (x ^ 4.0) * (eps * 5.0);
	t_1 = eps * (5.0 * (x ^ 4.0));
	t_2 = (eps ^ 4.0) * (eps + (x * 5.0));
	tmp = 0.0;
	if (x <= -1.2e-51)
		tmp = t_0;
	elseif (x <= -4e-78)
		tmp = t_2;
	elseif (x <= 1e-270)
		tmp = eps ^ 5.0;
	elseif (x <= 1.65e-45)
		tmp = t_2;
	elseif (x <= 1.22e-26)
		tmp = t_1;
	elseif (x <= 1.45e-23)
		tmp = t_2;
	elseif (x <= 1.15e-18)
		tmp = 5.0 * (eps * (x ^ 4.0));
	elseif (x <= 1.16e-18)
		tmp = t_2;
	elseif (x <= 1.05e-7)
		tmp = t_1;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_, eps_] := Block[{t$95$0 = N[(N[Power[x, 4.0], $MachinePrecision] * N[(eps * 5.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(eps * N[(5.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Power[eps, 4.0], $MachinePrecision] * N[(eps + N[(x * 5.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.2e-51], t$95$0, If[LessEqual[x, -4e-78], t$95$2, If[LessEqual[x, 1e-270], N[Power[eps, 5.0], $MachinePrecision], If[LessEqual[x, 1.65e-45], t$95$2, If[LessEqual[x, 1.22e-26], t$95$1, If[LessEqual[x, 1.45e-23], t$95$2, If[LessEqual[x, 1.15e-18], N[(5.0 * N[(eps * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.16e-18], t$95$2, If[LessEqual[x, 1.05e-7], t$95$1, t$95$0]]]]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {x}^{4} \cdot \left(\varepsilon \cdot 5\right)\\
t_1 := \varepsilon \cdot \left(5 \cdot {x}^{4}\right)\\
t_2 := {\varepsilon}^{4} \cdot \left(\varepsilon + x \cdot 5\right)\\
\mathbf{if}\;x \leq -1.2 \cdot 10^{-51}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq -4 \cdot 10^{-78}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;x \leq 10^{-270}:\\
\;\;\;\;{\varepsilon}^{5}\\

\mathbf{elif}\;x \leq 1.65 \cdot 10^{-45}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;x \leq 1.22 \cdot 10^{-26}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 1.45 \cdot 10^{-23}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;x \leq 1.15 \cdot 10^{-18}:\\
\;\;\;\;5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\

\mathbf{elif}\;x \leq 1.16 \cdot 10^{-18}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;x \leq 1.05 \cdot 10^{-7}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 5 regimes
  2. if x < -1.2e-51 or 1.05e-7 < x

    1. Initial program 37.1%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 94.8%

      \[\leadsto \color{blue}{{x}^{4} \cdot \left(\varepsilon + 4 \cdot \varepsilon\right)} \]
    4. Step-by-step derivation
      1. distribute-rgt1-in94.8%

        \[\leadsto {x}^{4} \cdot \color{blue}{\left(\left(4 + 1\right) \cdot \varepsilon\right)} \]
      2. metadata-eval94.8%

        \[\leadsto {x}^{4} \cdot \left(\color{blue}{5} \cdot \varepsilon\right) \]
    5. Simplified94.8%

      \[\leadsto \color{blue}{{x}^{4} \cdot \left(5 \cdot \varepsilon\right)} \]

    if -1.2e-51 < x < -4e-78 or 1e-270 < x < 1.65e-45 or 1.22e-26 < x < 1.4500000000000001e-23 or 1.15e-18 < x < 1.16e-18

    1. Initial program 99.9%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 99.0%

      \[\leadsto \color{blue}{x \cdot \left(4 \cdot {\varepsilon}^{4} + {\varepsilon}^{4}\right) + {\varepsilon}^{5}} \]
    4. Step-by-step derivation
      1. fma-define99.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, 4 \cdot {\varepsilon}^{4} + {\varepsilon}^{4}, {\varepsilon}^{5}\right)} \]
      2. distribute-lft1-in99.0%

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{\left(4 + 1\right) \cdot {\varepsilon}^{4}}, {\varepsilon}^{5}\right) \]
      3. metadata-eval99.0%

        \[\leadsto \mathsf{fma}\left(x, \color{blue}{5} \cdot {\varepsilon}^{4}, {\varepsilon}^{5}\right) \]
    5. Simplified99.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, 5 \cdot {\varepsilon}^{4}, {\varepsilon}^{5}\right)} \]
    6. Taylor expanded in eps around 0 99.0%

      \[\leadsto \color{blue}{{\varepsilon}^{4} \cdot \left(\varepsilon + 5 \cdot x\right)} \]

    if -4e-78 < x < 1e-270

    1. Initial program 100.0%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 100.0%

      \[\leadsto \color{blue}{{\varepsilon}^{5}} \]

    if 1.65e-45 < x < 1.22e-26 or 1.16e-18 < x < 1.05e-7

    1. Initial program 35.9%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 99.6%

      \[\leadsto \color{blue}{{x}^{4} \cdot \left(\varepsilon + 4 \cdot \varepsilon\right)} \]
    4. Step-by-step derivation
      1. *-commutative99.6%

        \[\leadsto \color{blue}{\left(\varepsilon + 4 \cdot \varepsilon\right) \cdot {x}^{4}} \]
      2. distribute-rgt1-in99.6%

        \[\leadsto \color{blue}{\left(\left(4 + 1\right) \cdot \varepsilon\right)} \cdot {x}^{4} \]
      3. metadata-eval99.6%

        \[\leadsto \left(\color{blue}{5} \cdot \varepsilon\right) \cdot {x}^{4} \]
      4. *-commutative99.6%

        \[\leadsto \color{blue}{\left(\varepsilon \cdot 5\right)} \cdot {x}^{4} \]
      5. associate-*r*100.0%

        \[\leadsto \color{blue}{\varepsilon \cdot \left(5 \cdot {x}^{4}\right)} \]
    5. Simplified100.0%

      \[\leadsto \color{blue}{\varepsilon \cdot \left(5 \cdot {x}^{4}\right)} \]

    if 1.4500000000000001e-23 < x < 1.15e-18

    1. Initial program 28.5%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 99.6%

      \[\leadsto \color{blue}{{x}^{4} \cdot \left(\varepsilon + 4 \cdot \varepsilon\right)} \]
    4. Step-by-step derivation
      1. *-commutative99.6%

        \[\leadsto \color{blue}{\left(\varepsilon + 4 \cdot \varepsilon\right) \cdot {x}^{4}} \]
      2. distribute-rgt1-in99.6%

        \[\leadsto \color{blue}{\left(\left(4 + 1\right) \cdot \varepsilon\right)} \cdot {x}^{4} \]
      3. metadata-eval99.6%

        \[\leadsto \left(\color{blue}{5} \cdot \varepsilon\right) \cdot {x}^{4} \]
      4. *-commutative99.6%

        \[\leadsto \color{blue}{\left(\varepsilon \cdot 5\right)} \cdot {x}^{4} \]
      5. associate-*r*100.0%

        \[\leadsto \color{blue}{\varepsilon \cdot \left(5 \cdot {x}^{4}\right)} \]
    5. Simplified100.0%

      \[\leadsto \color{blue}{\varepsilon \cdot \left(5 \cdot {x}^{4}\right)} \]
    6. Taylor expanded in eps around 0 100.0%

      \[\leadsto \color{blue}{5 \cdot \left(\varepsilon \cdot {x}^{4}\right)} \]
  3. Recombined 5 regimes into one program.
  4. Final simplification99.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.2 \cdot 10^{-51}:\\ \;\;\;\;{x}^{4} \cdot \left(\varepsilon \cdot 5\right)\\ \mathbf{elif}\;x \leq -4 \cdot 10^{-78}:\\ \;\;\;\;{\varepsilon}^{4} \cdot \left(\varepsilon + x \cdot 5\right)\\ \mathbf{elif}\;x \leq 10^{-270}:\\ \;\;\;\;{\varepsilon}^{5}\\ \mathbf{elif}\;x \leq 1.65 \cdot 10^{-45}:\\ \;\;\;\;{\varepsilon}^{4} \cdot \left(\varepsilon + x \cdot 5\right)\\ \mathbf{elif}\;x \leq 1.22 \cdot 10^{-26}:\\ \;\;\;\;\varepsilon \cdot \left(5 \cdot {x}^{4}\right)\\ \mathbf{elif}\;x \leq 1.45 \cdot 10^{-23}:\\ \;\;\;\;{\varepsilon}^{4} \cdot \left(\varepsilon + x \cdot 5\right)\\ \mathbf{elif}\;x \leq 1.15 \cdot 10^{-18}:\\ \;\;\;\;5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\ \mathbf{elif}\;x \leq 1.16 \cdot 10^{-18}:\\ \;\;\;\;{\varepsilon}^{4} \cdot \left(\varepsilon + x \cdot 5\right)\\ \mathbf{elif}\;x \leq 1.05 \cdot 10^{-7}:\\ \;\;\;\;\varepsilon \cdot \left(5 \cdot {x}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;{x}^{4} \cdot \left(\varepsilon \cdot 5\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 97.1% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \varepsilon \cdot \left(5 \cdot {x}^{4}\right)\\ t_1 := {x}^{4} \cdot \left(\varepsilon \cdot 5\right)\\ \mathbf{if}\;x \leq -9 \cdot 10^{-53}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 6.8 \cdot 10^{-45}:\\ \;\;\;\;{\varepsilon}^{5}\\ \mathbf{elif}\;x \leq 1.22 \cdot 10^{-26}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 1.45 \cdot 10^{-23}:\\ \;\;\;\;{\varepsilon}^{5}\\ \mathbf{elif}\;x \leq 1.15 \cdot 10^{-18}:\\ \;\;\;\;5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\ \mathbf{elif}\;x \leq 1.16 \cdot 10^{-18}:\\ \;\;\;\;{\varepsilon}^{5}\\ \mathbf{elif}\;x \leq 5 \cdot 10^{-10}:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (let* ((t_0 (* eps (* 5.0 (pow x 4.0)))) (t_1 (* (pow x 4.0) (* eps 5.0))))
   (if (<= x -9e-53)
     t_1
     (if (<= x 6.8e-45)
       (pow eps 5.0)
       (if (<= x 1.22e-26)
         t_0
         (if (<= x 1.45e-23)
           (pow eps 5.0)
           (if (<= x 1.15e-18)
             (* 5.0 (* eps (pow x 4.0)))
             (if (<= x 1.16e-18)
               (pow eps 5.0)
               (if (<= x 5e-10) t_0 t_1)))))))))
double code(double x, double eps) {
	double t_0 = eps * (5.0 * pow(x, 4.0));
	double t_1 = pow(x, 4.0) * (eps * 5.0);
	double tmp;
	if (x <= -9e-53) {
		tmp = t_1;
	} else if (x <= 6.8e-45) {
		tmp = pow(eps, 5.0);
	} else if (x <= 1.22e-26) {
		tmp = t_0;
	} else if (x <= 1.45e-23) {
		tmp = pow(eps, 5.0);
	} else if (x <= 1.15e-18) {
		tmp = 5.0 * (eps * pow(x, 4.0));
	} else if (x <= 1.16e-18) {
		tmp = pow(eps, 5.0);
	} else if (x <= 5e-10) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(x, eps)
    real(8), intent (in) :: x
    real(8), intent (in) :: eps
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = eps * (5.0d0 * (x ** 4.0d0))
    t_1 = (x ** 4.0d0) * (eps * 5.0d0)
    if (x <= (-9d-53)) then
        tmp = t_1
    else if (x <= 6.8d-45) then
        tmp = eps ** 5.0d0
    else if (x <= 1.22d-26) then
        tmp = t_0
    else if (x <= 1.45d-23) then
        tmp = eps ** 5.0d0
    else if (x <= 1.15d-18) then
        tmp = 5.0d0 * (eps * (x ** 4.0d0))
    else if (x <= 1.16d-18) then
        tmp = eps ** 5.0d0
    else if (x <= 5d-10) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double eps) {
	double t_0 = eps * (5.0 * Math.pow(x, 4.0));
	double t_1 = Math.pow(x, 4.0) * (eps * 5.0);
	double tmp;
	if (x <= -9e-53) {
		tmp = t_1;
	} else if (x <= 6.8e-45) {
		tmp = Math.pow(eps, 5.0);
	} else if (x <= 1.22e-26) {
		tmp = t_0;
	} else if (x <= 1.45e-23) {
		tmp = Math.pow(eps, 5.0);
	} else if (x <= 1.15e-18) {
		tmp = 5.0 * (eps * Math.pow(x, 4.0));
	} else if (x <= 1.16e-18) {
		tmp = Math.pow(eps, 5.0);
	} else if (x <= 5e-10) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, eps):
	t_0 = eps * (5.0 * math.pow(x, 4.0))
	t_1 = math.pow(x, 4.0) * (eps * 5.0)
	tmp = 0
	if x <= -9e-53:
		tmp = t_1
	elif x <= 6.8e-45:
		tmp = math.pow(eps, 5.0)
	elif x <= 1.22e-26:
		tmp = t_0
	elif x <= 1.45e-23:
		tmp = math.pow(eps, 5.0)
	elif x <= 1.15e-18:
		tmp = 5.0 * (eps * math.pow(x, 4.0))
	elif x <= 1.16e-18:
		tmp = math.pow(eps, 5.0)
	elif x <= 5e-10:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(x, eps)
	t_0 = Float64(eps * Float64(5.0 * (x ^ 4.0)))
	t_1 = Float64((x ^ 4.0) * Float64(eps * 5.0))
	tmp = 0.0
	if (x <= -9e-53)
		tmp = t_1;
	elseif (x <= 6.8e-45)
		tmp = eps ^ 5.0;
	elseif (x <= 1.22e-26)
		tmp = t_0;
	elseif (x <= 1.45e-23)
		tmp = eps ^ 5.0;
	elseif (x <= 1.15e-18)
		tmp = Float64(5.0 * Float64(eps * (x ^ 4.0)));
	elseif (x <= 1.16e-18)
		tmp = eps ^ 5.0;
	elseif (x <= 5e-10)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, eps)
	t_0 = eps * (5.0 * (x ^ 4.0));
	t_1 = (x ^ 4.0) * (eps * 5.0);
	tmp = 0.0;
	if (x <= -9e-53)
		tmp = t_1;
	elseif (x <= 6.8e-45)
		tmp = eps ^ 5.0;
	elseif (x <= 1.22e-26)
		tmp = t_0;
	elseif (x <= 1.45e-23)
		tmp = eps ^ 5.0;
	elseif (x <= 1.15e-18)
		tmp = 5.0 * (eps * (x ^ 4.0));
	elseif (x <= 1.16e-18)
		tmp = eps ^ 5.0;
	elseif (x <= 5e-10)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, eps_] := Block[{t$95$0 = N[(eps * N[(5.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[x, 4.0], $MachinePrecision] * N[(eps * 5.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -9e-53], t$95$1, If[LessEqual[x, 6.8e-45], N[Power[eps, 5.0], $MachinePrecision], If[LessEqual[x, 1.22e-26], t$95$0, If[LessEqual[x, 1.45e-23], N[Power[eps, 5.0], $MachinePrecision], If[LessEqual[x, 1.15e-18], N[(5.0 * N[(eps * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.16e-18], N[Power[eps, 5.0], $MachinePrecision], If[LessEqual[x, 5e-10], t$95$0, t$95$1]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \varepsilon \cdot \left(5 \cdot {x}^{4}\right)\\
t_1 := {x}^{4} \cdot \left(\varepsilon \cdot 5\right)\\
\mathbf{if}\;x \leq -9 \cdot 10^{-53}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 6.8 \cdot 10^{-45}:\\
\;\;\;\;{\varepsilon}^{5}\\

\mathbf{elif}\;x \leq 1.22 \cdot 10^{-26}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 1.45 \cdot 10^{-23}:\\
\;\;\;\;{\varepsilon}^{5}\\

\mathbf{elif}\;x \leq 1.15 \cdot 10^{-18}:\\
\;\;\;\;5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\

\mathbf{elif}\;x \leq 1.16 \cdot 10^{-18}:\\
\;\;\;\;{\varepsilon}^{5}\\

\mathbf{elif}\;x \leq 5 \cdot 10^{-10}:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if x < -8.9999999999999997e-53 or 5.00000000000000031e-10 < x

    1. Initial program 37.1%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 94.8%

      \[\leadsto \color{blue}{{x}^{4} \cdot \left(\varepsilon + 4 \cdot \varepsilon\right)} \]
    4. Step-by-step derivation
      1. distribute-rgt1-in94.8%

        \[\leadsto {x}^{4} \cdot \color{blue}{\left(\left(4 + 1\right) \cdot \varepsilon\right)} \]
      2. metadata-eval94.8%

        \[\leadsto {x}^{4} \cdot \left(\color{blue}{5} \cdot \varepsilon\right) \]
    5. Simplified94.8%

      \[\leadsto \color{blue}{{x}^{4} \cdot \left(5 \cdot \varepsilon\right)} \]

    if -8.9999999999999997e-53 < x < 6.80000000000000008e-45 or 1.22e-26 < x < 1.4500000000000001e-23 or 1.15e-18 < x < 1.16e-18

    1. Initial program 100.0%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 99.0%

      \[\leadsto \color{blue}{{\varepsilon}^{5}} \]

    if 6.80000000000000008e-45 < x < 1.22e-26 or 1.16e-18 < x < 5.00000000000000031e-10

    1. Initial program 35.9%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 99.6%

      \[\leadsto \color{blue}{{x}^{4} \cdot \left(\varepsilon + 4 \cdot \varepsilon\right)} \]
    4. Step-by-step derivation
      1. *-commutative99.6%

        \[\leadsto \color{blue}{\left(\varepsilon + 4 \cdot \varepsilon\right) \cdot {x}^{4}} \]
      2. distribute-rgt1-in99.6%

        \[\leadsto \color{blue}{\left(\left(4 + 1\right) \cdot \varepsilon\right)} \cdot {x}^{4} \]
      3. metadata-eval99.6%

        \[\leadsto \left(\color{blue}{5} \cdot \varepsilon\right) \cdot {x}^{4} \]
      4. *-commutative99.6%

        \[\leadsto \color{blue}{\left(\varepsilon \cdot 5\right)} \cdot {x}^{4} \]
      5. associate-*r*100.0%

        \[\leadsto \color{blue}{\varepsilon \cdot \left(5 \cdot {x}^{4}\right)} \]
    5. Simplified100.0%

      \[\leadsto \color{blue}{\varepsilon \cdot \left(5 \cdot {x}^{4}\right)} \]

    if 1.4500000000000001e-23 < x < 1.15e-18

    1. Initial program 28.5%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 99.6%

      \[\leadsto \color{blue}{{x}^{4} \cdot \left(\varepsilon + 4 \cdot \varepsilon\right)} \]
    4. Step-by-step derivation
      1. *-commutative99.6%

        \[\leadsto \color{blue}{\left(\varepsilon + 4 \cdot \varepsilon\right) \cdot {x}^{4}} \]
      2. distribute-rgt1-in99.6%

        \[\leadsto \color{blue}{\left(\left(4 + 1\right) \cdot \varepsilon\right)} \cdot {x}^{4} \]
      3. metadata-eval99.6%

        \[\leadsto \left(\color{blue}{5} \cdot \varepsilon\right) \cdot {x}^{4} \]
      4. *-commutative99.6%

        \[\leadsto \color{blue}{\left(\varepsilon \cdot 5\right)} \cdot {x}^{4} \]
      5. associate-*r*100.0%

        \[\leadsto \color{blue}{\varepsilon \cdot \left(5 \cdot {x}^{4}\right)} \]
    5. Simplified100.0%

      \[\leadsto \color{blue}{\varepsilon \cdot \left(5 \cdot {x}^{4}\right)} \]
    6. Taylor expanded in eps around 0 100.0%

      \[\leadsto \color{blue}{5 \cdot \left(\varepsilon \cdot {x}^{4}\right)} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification98.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -9 \cdot 10^{-53}:\\ \;\;\;\;{x}^{4} \cdot \left(\varepsilon \cdot 5\right)\\ \mathbf{elif}\;x \leq 6.8 \cdot 10^{-45}:\\ \;\;\;\;{\varepsilon}^{5}\\ \mathbf{elif}\;x \leq 1.22 \cdot 10^{-26}:\\ \;\;\;\;\varepsilon \cdot \left(5 \cdot {x}^{4}\right)\\ \mathbf{elif}\;x \leq 1.45 \cdot 10^{-23}:\\ \;\;\;\;{\varepsilon}^{5}\\ \mathbf{elif}\;x \leq 1.15 \cdot 10^{-18}:\\ \;\;\;\;5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\ \mathbf{elif}\;x \leq 1.16 \cdot 10^{-18}:\\ \;\;\;\;{\varepsilon}^{5}\\ \mathbf{elif}\;x \leq 5 \cdot 10^{-10}:\\ \;\;\;\;\varepsilon \cdot \left(5 \cdot {x}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;{x}^{4} \cdot \left(\varepsilon \cdot 5\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 97.1% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \varepsilon \cdot \left(5 \cdot {x}^{4}\right)\\ t_1 := 5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\ \mathbf{if}\;x \leq -6.8 \cdot 10^{-53}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{-45}:\\ \;\;\;\;{\varepsilon}^{5}\\ \mathbf{elif}\;x \leq 1.22 \cdot 10^{-26}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;x \leq 1.45 \cdot 10^{-23}:\\ \;\;\;\;{\varepsilon}^{5}\\ \mathbf{elif}\;x \leq 1.15 \cdot 10^{-18}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \leq 1.16 \cdot 10^{-18}:\\ \;\;\;\;{\varepsilon}^{5}\\ \mathbf{elif}\;x \leq 14000000:\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (let* ((t_0 (* eps (* 5.0 (pow x 4.0)))) (t_1 (* 5.0 (* eps (pow x 4.0)))))
   (if (<= x -6.8e-53)
     t_0
     (if (<= x 1.4e-45)
       (pow eps 5.0)
       (if (<= x 1.22e-26)
         t_0
         (if (<= x 1.45e-23)
           (pow eps 5.0)
           (if (<= x 1.15e-18)
             t_1
             (if (<= x 1.16e-18)
               (pow eps 5.0)
               (if (<= x 14000000.0) t_0 t_1)))))))))
double code(double x, double eps) {
	double t_0 = eps * (5.0 * pow(x, 4.0));
	double t_1 = 5.0 * (eps * pow(x, 4.0));
	double tmp;
	if (x <= -6.8e-53) {
		tmp = t_0;
	} else if (x <= 1.4e-45) {
		tmp = pow(eps, 5.0);
	} else if (x <= 1.22e-26) {
		tmp = t_0;
	} else if (x <= 1.45e-23) {
		tmp = pow(eps, 5.0);
	} else if (x <= 1.15e-18) {
		tmp = t_1;
	} else if (x <= 1.16e-18) {
		tmp = pow(eps, 5.0);
	} else if (x <= 14000000.0) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
real(8) function code(x, eps)
    real(8), intent (in) :: x
    real(8), intent (in) :: eps
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = eps * (5.0d0 * (x ** 4.0d0))
    t_1 = 5.0d0 * (eps * (x ** 4.0d0))
    if (x <= (-6.8d-53)) then
        tmp = t_0
    else if (x <= 1.4d-45) then
        tmp = eps ** 5.0d0
    else if (x <= 1.22d-26) then
        tmp = t_0
    else if (x <= 1.45d-23) then
        tmp = eps ** 5.0d0
    else if (x <= 1.15d-18) then
        tmp = t_1
    else if (x <= 1.16d-18) then
        tmp = eps ** 5.0d0
    else if (x <= 14000000.0d0) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double eps) {
	double t_0 = eps * (5.0 * Math.pow(x, 4.0));
	double t_1 = 5.0 * (eps * Math.pow(x, 4.0));
	double tmp;
	if (x <= -6.8e-53) {
		tmp = t_0;
	} else if (x <= 1.4e-45) {
		tmp = Math.pow(eps, 5.0);
	} else if (x <= 1.22e-26) {
		tmp = t_0;
	} else if (x <= 1.45e-23) {
		tmp = Math.pow(eps, 5.0);
	} else if (x <= 1.15e-18) {
		tmp = t_1;
	} else if (x <= 1.16e-18) {
		tmp = Math.pow(eps, 5.0);
	} else if (x <= 14000000.0) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, eps):
	t_0 = eps * (5.0 * math.pow(x, 4.0))
	t_1 = 5.0 * (eps * math.pow(x, 4.0))
	tmp = 0
	if x <= -6.8e-53:
		tmp = t_0
	elif x <= 1.4e-45:
		tmp = math.pow(eps, 5.0)
	elif x <= 1.22e-26:
		tmp = t_0
	elif x <= 1.45e-23:
		tmp = math.pow(eps, 5.0)
	elif x <= 1.15e-18:
		tmp = t_1
	elif x <= 1.16e-18:
		tmp = math.pow(eps, 5.0)
	elif x <= 14000000.0:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
function code(x, eps)
	t_0 = Float64(eps * Float64(5.0 * (x ^ 4.0)))
	t_1 = Float64(5.0 * Float64(eps * (x ^ 4.0)))
	tmp = 0.0
	if (x <= -6.8e-53)
		tmp = t_0;
	elseif (x <= 1.4e-45)
		tmp = eps ^ 5.0;
	elseif (x <= 1.22e-26)
		tmp = t_0;
	elseif (x <= 1.45e-23)
		tmp = eps ^ 5.0;
	elseif (x <= 1.15e-18)
		tmp = t_1;
	elseif (x <= 1.16e-18)
		tmp = eps ^ 5.0;
	elseif (x <= 14000000.0)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, eps)
	t_0 = eps * (5.0 * (x ^ 4.0));
	t_1 = 5.0 * (eps * (x ^ 4.0));
	tmp = 0.0;
	if (x <= -6.8e-53)
		tmp = t_0;
	elseif (x <= 1.4e-45)
		tmp = eps ^ 5.0;
	elseif (x <= 1.22e-26)
		tmp = t_0;
	elseif (x <= 1.45e-23)
		tmp = eps ^ 5.0;
	elseif (x <= 1.15e-18)
		tmp = t_1;
	elseif (x <= 1.16e-18)
		tmp = eps ^ 5.0;
	elseif (x <= 14000000.0)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, eps_] := Block[{t$95$0 = N[(eps * N[(5.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(5.0 * N[(eps * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -6.8e-53], t$95$0, If[LessEqual[x, 1.4e-45], N[Power[eps, 5.0], $MachinePrecision], If[LessEqual[x, 1.22e-26], t$95$0, If[LessEqual[x, 1.45e-23], N[Power[eps, 5.0], $MachinePrecision], If[LessEqual[x, 1.15e-18], t$95$1, If[LessEqual[x, 1.16e-18], N[Power[eps, 5.0], $MachinePrecision], If[LessEqual[x, 14000000.0], t$95$0, t$95$1]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \varepsilon \cdot \left(5 \cdot {x}^{4}\right)\\
t_1 := 5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\
\mathbf{if}\;x \leq -6.8 \cdot 10^{-53}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 1.4 \cdot 10^{-45}:\\
\;\;\;\;{\varepsilon}^{5}\\

\mathbf{elif}\;x \leq 1.22 \cdot 10^{-26}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;x \leq 1.45 \cdot 10^{-23}:\\
\;\;\;\;{\varepsilon}^{5}\\

\mathbf{elif}\;x \leq 1.15 \cdot 10^{-18}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \leq 1.16 \cdot 10^{-18}:\\
\;\;\;\;{\varepsilon}^{5}\\

\mathbf{elif}\;x \leq 14000000:\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -6.8e-53 or 1.4000000000000001e-45 < x < 1.22e-26 or 1.16e-18 < x < 1.4e7

    1. Initial program 38.9%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 95.5%

      \[\leadsto \color{blue}{{x}^{4} \cdot \left(\varepsilon + 4 \cdot \varepsilon\right)} \]
    4. Step-by-step derivation
      1. *-commutative95.5%

        \[\leadsto \color{blue}{\left(\varepsilon + 4 \cdot \varepsilon\right) \cdot {x}^{4}} \]
      2. distribute-rgt1-in95.5%

        \[\leadsto \color{blue}{\left(\left(4 + 1\right) \cdot \varepsilon\right)} \cdot {x}^{4} \]
      3. metadata-eval95.5%

        \[\leadsto \left(\color{blue}{5} \cdot \varepsilon\right) \cdot {x}^{4} \]
      4. *-commutative95.5%

        \[\leadsto \color{blue}{\left(\varepsilon \cdot 5\right)} \cdot {x}^{4} \]
      5. associate-*r*95.5%

        \[\leadsto \color{blue}{\varepsilon \cdot \left(5 \cdot {x}^{4}\right)} \]
    5. Simplified95.5%

      \[\leadsto \color{blue}{\varepsilon \cdot \left(5 \cdot {x}^{4}\right)} \]

    if -6.8e-53 < x < 1.4000000000000001e-45 or 1.22e-26 < x < 1.4500000000000001e-23 or 1.15e-18 < x < 1.16e-18

    1. Initial program 100.0%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 99.0%

      \[\leadsto \color{blue}{{\varepsilon}^{5}} \]

    if 1.4500000000000001e-23 < x < 1.15e-18 or 1.4e7 < x

    1. Initial program 20.4%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 99.7%

      \[\leadsto \color{blue}{{x}^{4} \cdot \left(\varepsilon + 4 \cdot \varepsilon\right)} \]
    4. Step-by-step derivation
      1. *-commutative99.7%

        \[\leadsto \color{blue}{\left(\varepsilon + 4 \cdot \varepsilon\right) \cdot {x}^{4}} \]
      2. distribute-rgt1-in99.7%

        \[\leadsto \color{blue}{\left(\left(4 + 1\right) \cdot \varepsilon\right)} \cdot {x}^{4} \]
      3. metadata-eval99.7%

        \[\leadsto \left(\color{blue}{5} \cdot \varepsilon\right) \cdot {x}^{4} \]
      4. *-commutative99.7%

        \[\leadsto \color{blue}{\left(\varepsilon \cdot 5\right)} \cdot {x}^{4} \]
      5. associate-*r*99.7%

        \[\leadsto \color{blue}{\varepsilon \cdot \left(5 \cdot {x}^{4}\right)} \]
    5. Simplified99.7%

      \[\leadsto \color{blue}{\varepsilon \cdot \left(5 \cdot {x}^{4}\right)} \]
    6. Taylor expanded in eps around 0 100.0%

      \[\leadsto \color{blue}{5 \cdot \left(\varepsilon \cdot {x}^{4}\right)} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 11: 97.1% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -5.7 \cdot 10^{-52} \lor \neg \left(x \leq 1.32 \cdot 10^{-45}\right) \land \left(x \leq 1.22 \cdot 10^{-26} \lor \neg \left(x \leq 1.45 \cdot 10^{-23}\right) \land \left(x \leq 1.15 \cdot 10^{-18} \lor \neg \left(x \leq 1.16 \cdot 10^{-18}\right)\right)\right):\\ \;\;\;\;5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;{\varepsilon}^{5}\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (if (or (<= x -5.7e-52)
         (and (not (<= x 1.32e-45))
              (or (<= x 1.22e-26)
                  (and (not (<= x 1.45e-23))
                       (or (<= x 1.15e-18) (not (<= x 1.16e-18)))))))
   (* 5.0 (* eps (pow x 4.0)))
   (pow eps 5.0)))
double code(double x, double eps) {
	double tmp;
	if ((x <= -5.7e-52) || (!(x <= 1.32e-45) && ((x <= 1.22e-26) || (!(x <= 1.45e-23) && ((x <= 1.15e-18) || !(x <= 1.16e-18)))))) {
		tmp = 5.0 * (eps * pow(x, 4.0));
	} else {
		tmp = pow(eps, 5.0);
	}
	return tmp;
}
real(8) function code(x, eps)
    real(8), intent (in) :: x
    real(8), intent (in) :: eps
    real(8) :: tmp
    if ((x <= (-5.7d-52)) .or. (.not. (x <= 1.32d-45)) .and. (x <= 1.22d-26) .or. (.not. (x <= 1.45d-23)) .and. (x <= 1.15d-18) .or. (.not. (x <= 1.16d-18))) then
        tmp = 5.0d0 * (eps * (x ** 4.0d0))
    else
        tmp = eps ** 5.0d0
    end if
    code = tmp
end function
public static double code(double x, double eps) {
	double tmp;
	if ((x <= -5.7e-52) || (!(x <= 1.32e-45) && ((x <= 1.22e-26) || (!(x <= 1.45e-23) && ((x <= 1.15e-18) || !(x <= 1.16e-18)))))) {
		tmp = 5.0 * (eps * Math.pow(x, 4.0));
	} else {
		tmp = Math.pow(eps, 5.0);
	}
	return tmp;
}
def code(x, eps):
	tmp = 0
	if (x <= -5.7e-52) or (not (x <= 1.32e-45) and ((x <= 1.22e-26) or (not (x <= 1.45e-23) and ((x <= 1.15e-18) or not (x <= 1.16e-18))))):
		tmp = 5.0 * (eps * math.pow(x, 4.0))
	else:
		tmp = math.pow(eps, 5.0)
	return tmp
function code(x, eps)
	tmp = 0.0
	if ((x <= -5.7e-52) || (!(x <= 1.32e-45) && ((x <= 1.22e-26) || (!(x <= 1.45e-23) && ((x <= 1.15e-18) || !(x <= 1.16e-18))))))
		tmp = Float64(5.0 * Float64(eps * (x ^ 4.0)));
	else
		tmp = eps ^ 5.0;
	end
	return tmp
end
function tmp_2 = code(x, eps)
	tmp = 0.0;
	if ((x <= -5.7e-52) || (~((x <= 1.32e-45)) && ((x <= 1.22e-26) || (~((x <= 1.45e-23)) && ((x <= 1.15e-18) || ~((x <= 1.16e-18)))))))
		tmp = 5.0 * (eps * (x ^ 4.0));
	else
		tmp = eps ^ 5.0;
	end
	tmp_2 = tmp;
end
code[x_, eps_] := If[Or[LessEqual[x, -5.7e-52], And[N[Not[LessEqual[x, 1.32e-45]], $MachinePrecision], Or[LessEqual[x, 1.22e-26], And[N[Not[LessEqual[x, 1.45e-23]], $MachinePrecision], Or[LessEqual[x, 1.15e-18], N[Not[LessEqual[x, 1.16e-18]], $MachinePrecision]]]]]], N[(5.0 * N[(eps * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[eps, 5.0], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.7 \cdot 10^{-52} \lor \neg \left(x \leq 1.32 \cdot 10^{-45}\right) \land \left(x \leq 1.22 \cdot 10^{-26} \lor \neg \left(x \leq 1.45 \cdot 10^{-23}\right) \land \left(x \leq 1.15 \cdot 10^{-18} \lor \neg \left(x \leq 1.16 \cdot 10^{-18}\right)\right)\right):\\
\;\;\;\;5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\

\mathbf{else}:\\
\;\;\;\;{\varepsilon}^{5}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -5.6999999999999997e-52 or 1.32000000000000005e-45 < x < 1.22e-26 or 1.4500000000000001e-23 < x < 1.15e-18 or 1.16e-18 < x

    1. Initial program 36.0%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 96.2%

      \[\leadsto \color{blue}{{x}^{4} \cdot \left(\varepsilon + 4 \cdot \varepsilon\right)} \]
    4. Step-by-step derivation
      1. *-commutative96.2%

        \[\leadsto \color{blue}{\left(\varepsilon + 4 \cdot \varepsilon\right) \cdot {x}^{4}} \]
      2. distribute-rgt1-in96.2%

        \[\leadsto \color{blue}{\left(\left(4 + 1\right) \cdot \varepsilon\right)} \cdot {x}^{4} \]
      3. metadata-eval96.2%

        \[\leadsto \left(\color{blue}{5} \cdot \varepsilon\right) \cdot {x}^{4} \]
      4. *-commutative96.2%

        \[\leadsto \color{blue}{\left(\varepsilon \cdot 5\right)} \cdot {x}^{4} \]
      5. associate-*r*96.2%

        \[\leadsto \color{blue}{\varepsilon \cdot \left(5 \cdot {x}^{4}\right)} \]
    5. Simplified96.2%

      \[\leadsto \color{blue}{\varepsilon \cdot \left(5 \cdot {x}^{4}\right)} \]
    6. Taylor expanded in eps around 0 96.0%

      \[\leadsto \color{blue}{5 \cdot \left(\varepsilon \cdot {x}^{4}\right)} \]

    if -5.6999999999999997e-52 < x < 1.32000000000000005e-45 or 1.22e-26 < x < 1.4500000000000001e-23 or 1.15e-18 < x < 1.16e-18

    1. Initial program 100.0%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 99.0%

      \[\leadsto \color{blue}{{\varepsilon}^{5}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5.7 \cdot 10^{-52} \lor \neg \left(x \leq 1.32 \cdot 10^{-45}\right) \land \left(x \leq 1.22 \cdot 10^{-26} \lor \neg \left(x \leq 1.45 \cdot 10^{-23}\right) \land \left(x \leq 1.15 \cdot 10^{-18} \lor \neg \left(x \leq 1.16 \cdot 10^{-18}\right)\right)\right):\\ \;\;\;\;5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;{\varepsilon}^{5}\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 87.1% accurate, 2.0× speedup?

\[\begin{array}{l} \\ {\varepsilon}^{5} \end{array} \]
(FPCore (x eps) :precision binary64 (pow eps 5.0))
double code(double x, double eps) {
	return pow(eps, 5.0);
}
real(8) function code(x, eps)
    real(8), intent (in) :: x
    real(8), intent (in) :: eps
    code = eps ** 5.0d0
end function
public static double code(double x, double eps) {
	return Math.pow(eps, 5.0);
}
def code(x, eps):
	return math.pow(eps, 5.0)
function code(x, eps)
	return eps ^ 5.0
end
function tmp = code(x, eps)
	tmp = eps ^ 5.0;
end
code[x_, eps_] := N[Power[eps, 5.0], $MachinePrecision]
\begin{array}{l}

\\
{\varepsilon}^{5}
\end{array}
Derivation
  1. Initial program 90.5%

    \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
  2. Add Preprocessing
  3. Taylor expanded in x around 0 89.1%

    \[\leadsto \color{blue}{{\varepsilon}^{5}} \]
  4. Add Preprocessing

Reproduce

?
herbie shell --seed 2024096 
(FPCore (x eps)
  :name "ENA, Section 1.4, Exercise 4b, n=5"
  :precision binary64
  :pre (and (and (<= -1000000000.0 x) (<= x 1000000000.0)) (and (<= -1.0 eps) (<= eps 1.0)))
  (- (pow (+ x eps) 5.0) (pow x 5.0)))