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

Percentage Accurate: 88.3% → 98.1%
Time: 12.6s
Alternatives: 8
Speedup: 1.9×

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 8 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: 98.1% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -4.2 \cdot 10^{-60} \lor \neg \left(x \leq 9.5 \cdot 10^{-52}\right):\\ \;\;\;\;{x}^{2} \cdot \left(4 \cdot {\varepsilon}^{3} + \varepsilon \cdot \left(\varepsilon \cdot \left(\varepsilon \cdot 6\right)\right)\right) + \left({x}^{3} \cdot \left(\varepsilon \cdot \left(\varepsilon \cdot 10\right)\right) + {x}^{4} \cdot \left(\varepsilon + 4 \cdot \varepsilon\right)\right)\\ \mathbf{else}:\\ \;\;\;\;{\varepsilon}^{5}\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (if (or (<= x -4.2e-60) (not (<= x 9.5e-52)))
   (+
    (* (pow x 2.0) (+ (* 4.0 (pow eps 3.0)) (* eps (* eps (* eps 6.0)))))
    (+
     (* (pow x 3.0) (* eps (* eps 10.0)))
     (* (pow x 4.0) (+ eps (* 4.0 eps)))))
   (pow eps 5.0)))
double code(double x, double eps) {
	double tmp;
	if ((x <= -4.2e-60) || !(x <= 9.5e-52)) {
		tmp = (pow(x, 2.0) * ((4.0 * pow(eps, 3.0)) + (eps * (eps * (eps * 6.0))))) + ((pow(x, 3.0) * (eps * (eps * 10.0))) + (pow(x, 4.0) * (eps + (4.0 * eps))));
	} 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 <= (-4.2d-60)) .or. (.not. (x <= 9.5d-52))) then
        tmp = ((x ** 2.0d0) * ((4.0d0 * (eps ** 3.0d0)) + (eps * (eps * (eps * 6.0d0))))) + (((x ** 3.0d0) * (eps * (eps * 10.0d0))) + ((x ** 4.0d0) * (eps + (4.0d0 * eps))))
    else
        tmp = eps ** 5.0d0
    end if
    code = tmp
end function
public static double code(double x, double eps) {
	double tmp;
	if ((x <= -4.2e-60) || !(x <= 9.5e-52)) {
		tmp = (Math.pow(x, 2.0) * ((4.0 * Math.pow(eps, 3.0)) + (eps * (eps * (eps * 6.0))))) + ((Math.pow(x, 3.0) * (eps * (eps * 10.0))) + (Math.pow(x, 4.0) * (eps + (4.0 * eps))));
	} else {
		tmp = Math.pow(eps, 5.0);
	}
	return tmp;
}
def code(x, eps):
	tmp = 0
	if (x <= -4.2e-60) or not (x <= 9.5e-52):
		tmp = (math.pow(x, 2.0) * ((4.0 * math.pow(eps, 3.0)) + (eps * (eps * (eps * 6.0))))) + ((math.pow(x, 3.0) * (eps * (eps * 10.0))) + (math.pow(x, 4.0) * (eps + (4.0 * eps))))
	else:
		tmp = math.pow(eps, 5.0)
	return tmp
function code(x, eps)
	tmp = 0.0
	if ((x <= -4.2e-60) || !(x <= 9.5e-52))
		tmp = Float64(Float64((x ^ 2.0) * Float64(Float64(4.0 * (eps ^ 3.0)) + Float64(eps * Float64(eps * Float64(eps * 6.0))))) + Float64(Float64((x ^ 3.0) * Float64(eps * Float64(eps * 10.0))) + Float64((x ^ 4.0) * Float64(eps + Float64(4.0 * eps)))));
	else
		tmp = eps ^ 5.0;
	end
	return tmp
end
function tmp_2 = code(x, eps)
	tmp = 0.0;
	if ((x <= -4.2e-60) || ~((x <= 9.5e-52)))
		tmp = ((x ^ 2.0) * ((4.0 * (eps ^ 3.0)) + (eps * (eps * (eps * 6.0))))) + (((x ^ 3.0) * (eps * (eps * 10.0))) + ((x ^ 4.0) * (eps + (4.0 * eps))));
	else
		tmp = eps ^ 5.0;
	end
	tmp_2 = tmp;
end
code[x_, eps_] := If[Or[LessEqual[x, -4.2e-60], N[Not[LessEqual[x, 9.5e-52]], $MachinePrecision]], N[(N[(N[Power[x, 2.0], $MachinePrecision] * N[(N[(4.0 * N[Power[eps, 3.0], $MachinePrecision]), $MachinePrecision] + N[(eps * N[(eps * N[(eps * 6.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(N[Power[x, 3.0], $MachinePrecision] * N[(eps * N[(eps * 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Power[x, 4.0], $MachinePrecision] * N[(eps + N[(4.0 * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[eps, 5.0], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.2 \cdot 10^{-60} \lor \neg \left(x \leq 9.5 \cdot 10^{-52}\right):\\
\;\;\;\;{x}^{2} \cdot \left(4 \cdot {\varepsilon}^{3} + \varepsilon \cdot \left(\varepsilon \cdot \left(\varepsilon \cdot 6\right)\right)\right) + \left({x}^{3} \cdot \left(\varepsilon \cdot \left(\varepsilon \cdot 10\right)\right) + {x}^{4} \cdot \left(\varepsilon + 4 \cdot \varepsilon\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -4.19999999999999982e-60 or 9.50000000000000007e-52 < x

    1. Initial program 41.3%

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

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

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

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

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

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

        \[\leadsto {x}^{2} \cdot \left(4 \cdot {\varepsilon}^{3} + \varepsilon \cdot \left(2 \cdot {\varepsilon}^{2} + 4 \cdot {\varepsilon}^{2}\right)\right) + \left({x}^{3} \cdot \color{blue}{\left(\left(10 \cdot \varepsilon\right) \cdot \varepsilon\right)} + {x}^{4} \cdot \left(\varepsilon + 4 \cdot \varepsilon\right)\right) \]
    4. Applied egg-rr98.5%

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

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

        \[\leadsto {x}^{2} \cdot \left(4 \cdot {\varepsilon}^{3} + \varepsilon \cdot \left(\color{blue}{\left(\varepsilon \cdot \varepsilon\right)} \cdot \left(2 + 4\right)\right)\right) + \left({x}^{3} \cdot \left(\left(10 \cdot \varepsilon\right) \cdot \varepsilon\right) + {x}^{4} \cdot \left(\varepsilon + 4 \cdot \varepsilon\right)\right) \]
      3. associate-*l*98.5%

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

        \[\leadsto {x}^{2} \cdot \left(4 \cdot {\varepsilon}^{3} + \varepsilon \cdot \left(\varepsilon \cdot \left(\varepsilon \cdot \color{blue}{6}\right)\right)\right) + \left({x}^{3} \cdot \left(\left(10 \cdot \varepsilon\right) \cdot \varepsilon\right) + {x}^{4} \cdot \left(\varepsilon + 4 \cdot \varepsilon\right)\right) \]
    6. Applied egg-rr98.5%

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

    if -4.19999999999999982e-60 < x < 9.50000000000000007e-52

    1. Initial program 100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -4.2 \cdot 10^{-60} \lor \neg \left(x \leq 9.5 \cdot 10^{-52}\right):\\ \;\;\;\;{x}^{2} \cdot \left(4 \cdot {\varepsilon}^{3} + \varepsilon \cdot \left(\varepsilon \cdot \left(\varepsilon \cdot 6\right)\right)\right) + \left({x}^{3} \cdot \left(\varepsilon \cdot \left(\varepsilon \cdot 10\right)\right) + {x}^{4} \cdot \left(\varepsilon + 4 \cdot \varepsilon\right)\right)\\ \mathbf{else}:\\ \;\;\;\;{\varepsilon}^{5}\\ \end{array} \]

Alternative 2: 97.7% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(x + \varepsilon\right)}^{5} - {x}^{5}\\ \mathbf{if}\;t_0 \leq -5 \cdot 10^{-256}:\\ \;\;\;\;{\varepsilon}^{5}\\ \mathbf{elif}\;t_0 \leq 0:\\ \;\;\;\;5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (let* ((t_0 (- (pow (+ x eps) 5.0) (pow x 5.0))))
   (if (<= t_0 -5e-256)
     (pow eps 5.0)
     (if (<= t_0 0.0) (* 5.0 (* eps (pow x 4.0))) t_0))))
double code(double x, double eps) {
	double t_0 = pow((x + eps), 5.0) - pow(x, 5.0);
	double tmp;
	if (t_0 <= -5e-256) {
		tmp = pow(eps, 5.0);
	} else if (t_0 <= 0.0) {
		tmp = 5.0 * (eps * pow(x, 4.0));
	} 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) :: tmp
    t_0 = ((x + eps) ** 5.0d0) - (x ** 5.0d0)
    if (t_0 <= (-5d-256)) then
        tmp = eps ** 5.0d0
    else if (t_0 <= 0.0d0) then
        tmp = 5.0d0 * (eps * (x ** 4.0d0))
    else
        tmp = t_0
    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 <= -5e-256) {
		tmp = Math.pow(eps, 5.0);
	} else if (t_0 <= 0.0) {
		tmp = 5.0 * (eps * Math.pow(x, 4.0));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x, eps):
	t_0 = math.pow((x + eps), 5.0) - math.pow(x, 5.0)
	tmp = 0
	if t_0 <= -5e-256:
		tmp = math.pow(eps, 5.0)
	elif t_0 <= 0.0:
		tmp = 5.0 * (eps * math.pow(x, 4.0))
	else:
		tmp = t_0
	return tmp
function code(x, eps)
	t_0 = Float64((Float64(x + eps) ^ 5.0) - (x ^ 5.0))
	tmp = 0.0
	if (t_0 <= -5e-256)
		tmp = eps ^ 5.0;
	elseif (t_0 <= 0.0)
		tmp = Float64(5.0 * Float64(eps * (x ^ 4.0)));
	else
		tmp = t_0;
	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 <= -5e-256)
		tmp = eps ^ 5.0;
	elseif (t_0 <= 0.0)
		tmp = 5.0 * (eps * (x ^ 4.0));
	else
		tmp = t_0;
	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, -5e-256], N[Power[eps, 5.0], $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[(5.0 * N[(eps * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}

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

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

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (-.f64 (pow.f64 (+.f64 x eps) 5) (pow.f64 x 5)) < -5e-256

    1. Initial program 100.0%

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

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

    if -5e-256 < (-.f64 (pow.f64 (+.f64 x eps) 5) (pow.f64 x 5)) < 0.0

    1. Initial program 84.9%

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

      \[\leadsto \color{blue}{{x}^{4} \cdot \left(\varepsilon + 4 \cdot \varepsilon\right)} \]
    3. 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)} \]
    4. Simplified99.9%

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

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

    if 0.0 < (-.f64 (pow.f64 (+.f64 x eps) 5) (pow.f64 x 5))

    1. Initial program 92.6%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification99.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;{\left(x + \varepsilon\right)}^{5} - {x}^{5} \leq -5 \cdot 10^{-256}:\\ \;\;\;\;{\varepsilon}^{5}\\ \mathbf{elif}\;{\left(x + \varepsilon\right)}^{5} - {x}^{5} \leq 0:\\ \;\;\;\;5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;{\left(x + \varepsilon\right)}^{5} - {x}^{5}\\ \end{array} \]

Alternative 3: 98.1% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \varepsilon \cdot {x}^{4}\\ \mathbf{if}\;x \leq -2.7 \cdot 10^{-58}:\\ \;\;\;\;{x}^{3} \cdot \left(10 \cdot {\varepsilon}^{2}\right) + 5 \cdot t_0\\ \mathbf{elif}\;x \leq 1.15 \cdot 10^{-51}:\\ \;\;\;\;{\varepsilon}^{5}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(5, t_0, 10 \cdot \left({x}^{3} \cdot {\varepsilon}^{2}\right)\right)\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (let* ((t_0 (* eps (pow x 4.0))))
   (if (<= x -2.7e-58)
     (+ (* (pow x 3.0) (* 10.0 (pow eps 2.0))) (* 5.0 t_0))
     (if (<= x 1.15e-51)
       (pow eps 5.0)
       (fma 5.0 t_0 (* 10.0 (* (pow x 3.0) (pow eps 2.0))))))))
double code(double x, double eps) {
	double t_0 = eps * pow(x, 4.0);
	double tmp;
	if (x <= -2.7e-58) {
		tmp = (pow(x, 3.0) * (10.0 * pow(eps, 2.0))) + (5.0 * t_0);
	} else if (x <= 1.15e-51) {
		tmp = pow(eps, 5.0);
	} else {
		tmp = fma(5.0, t_0, (10.0 * (pow(x, 3.0) * pow(eps, 2.0))));
	}
	return tmp;
}
function code(x, eps)
	t_0 = Float64(eps * (x ^ 4.0))
	tmp = 0.0
	if (x <= -2.7e-58)
		tmp = Float64(Float64((x ^ 3.0) * Float64(10.0 * (eps ^ 2.0))) + Float64(5.0 * t_0));
	elseif (x <= 1.15e-51)
		tmp = eps ^ 5.0;
	else
		tmp = fma(5.0, t_0, Float64(10.0 * Float64((x ^ 3.0) * (eps ^ 2.0))));
	end
	return tmp
end
code[x_, eps_] := Block[{t$95$0 = N[(eps * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.7e-58], N[(N[(N[Power[x, 3.0], $MachinePrecision] * N[(10.0 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(5.0 * t$95$0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.15e-51], N[Power[eps, 5.0], $MachinePrecision], N[(5.0 * t$95$0 + N[(10.0 * N[(N[Power[x, 3.0], $MachinePrecision] * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \varepsilon \cdot {x}^{4}\\
\mathbf{if}\;x \leq -2.7 \cdot 10^{-58}:\\
\;\;\;\;{x}^{3} \cdot \left(10 \cdot {\varepsilon}^{2}\right) + 5 \cdot t_0\\

\mathbf{elif}\;x \leq 1.15 \cdot 10^{-51}:\\
\;\;\;\;{\varepsilon}^{5}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(5, t_0, 10 \cdot \left({x}^{3} \cdot {\varepsilon}^{2}\right)\right)\\


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

    1. Initial program 44.1%

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

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

        \[\leadsto \color{blue}{{x}^{4} \cdot \left(\varepsilon + 4 \cdot \varepsilon\right) + {x}^{3} \cdot \left(2 \cdot {\varepsilon}^{2} + 8 \cdot {\varepsilon}^{2}\right)} \]
      2. fma-def99.3%

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

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

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

        \[\leadsto \mathsf{fma}\left({x}^{4}, \color{blue}{\varepsilon \cdot 5}, {x}^{3} \cdot \left(2 \cdot {\varepsilon}^{2} + 8 \cdot {\varepsilon}^{2}\right)\right) \]
      6. *-commutative99.3%

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

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

        \[\leadsto \mathsf{fma}\left({x}^{4}, \varepsilon \cdot 5, \left({\varepsilon}^{2} \cdot \color{blue}{10}\right) \cdot {x}^{3}\right) \]
      9. associate-*l*99.3%

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

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

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

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

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

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

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

        \[\leadsto {x}^{3} \cdot \left(10 \cdot {\varepsilon}^{2}\right) + \color{blue}{\left(\varepsilon \cdot 5\right) \cdot {x}^{4}} \]
      7. associate-*r*99.3%

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

        \[\leadsto {x}^{3} \cdot \left(10 \cdot {\varepsilon}^{2}\right) + \color{blue}{\left(5 \cdot {x}^{4}\right) \cdot \varepsilon} \]
      9. associate-*l*99.3%

        \[\leadsto {x}^{3} \cdot \left(10 \cdot {\varepsilon}^{2}\right) + \color{blue}{5 \cdot \left({x}^{4} \cdot \varepsilon\right)} \]
    6. Applied egg-rr99.3%

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

    if -2.6999999999999999e-58 < x < 1.15000000000000001e-51

    1. Initial program 100.0%

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

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

    if 1.15000000000000001e-51 < x

    1. Initial program 38.9%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Step-by-step derivation
      1. add-cbrt-cube12.0%

        \[\leadsto \color{blue}{\sqrt[3]{\left({\left(x + \varepsilon\right)}^{5} \cdot {\left(x + \varepsilon\right)}^{5}\right) \cdot {\left(x + \varepsilon\right)}^{5}}} - {x}^{5} \]
      2. unpow38.7%

        \[\leadsto \sqrt[3]{\color{blue}{{\left({\left(x + \varepsilon\right)}^{5}\right)}^{3}}} - {x}^{5} \]
      3. pow-pow12.0%

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

        \[\leadsto \sqrt[3]{{\left(x + \varepsilon\right)}^{\color{blue}{15}}} - {x}^{5} \]
    3. Applied egg-rr12.0%

      \[\leadsto \color{blue}{\sqrt[3]{{\left(x + \varepsilon\right)}^{15}}} - {x}^{5} \]
    4. Taylor expanded in x around inf 97.2%

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

        \[\leadsto \color{blue}{{x}^{4} \cdot \left(\varepsilon + 4 \cdot \varepsilon\right) + {x}^{3} \cdot \left(2 \cdot {\varepsilon}^{2} + 8 \cdot {\varepsilon}^{2}\right)} \]
      2. distribute-rgt-out97.2%

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

        \[\leadsto {x}^{4} \cdot \left(\varepsilon + 4 \cdot \varepsilon\right) + {x}^{3} \cdot \left({\varepsilon}^{2} \cdot \color{blue}{10}\right) \]
      4. *-commutative97.2%

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

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

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

        \[\leadsto \left(\color{blue}{5} \cdot \varepsilon\right) \cdot {x}^{4} + {x}^{3} \cdot \left(10 \cdot {\varepsilon}^{2}\right) \]
      8. associate-*r*97.3%

        \[\leadsto \color{blue}{5 \cdot \left(\varepsilon \cdot {x}^{4}\right)} + {x}^{3} \cdot \left(10 \cdot {\varepsilon}^{2}\right) \]
      9. fma-def97.3%

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

        \[\leadsto \mathsf{fma}\left(5, \varepsilon \cdot {x}^{4}, \color{blue}{\left(10 \cdot {\varepsilon}^{2}\right) \cdot {x}^{3}}\right) \]
      11. associate-*r*97.3%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.7 \cdot 10^{-58}:\\ \;\;\;\;{x}^{3} \cdot \left(10 \cdot {\varepsilon}^{2}\right) + 5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\ \mathbf{elif}\;x \leq 1.15 \cdot 10^{-51}:\\ \;\;\;\;{\varepsilon}^{5}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(5, \varepsilon \cdot {x}^{4}, 10 \cdot \left({x}^{3} \cdot {\varepsilon}^{2}\right)\right)\\ \end{array} \]

Alternative 4: 98.1% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2.7 \cdot 10^{-58} \lor \neg \left(x \leq 10^{-51}\right):\\ \;\;\;\;{\varepsilon}^{2} \cdot \left({x}^{3} \cdot 10\right) + \varepsilon \cdot \left({x}^{4} \cdot 5\right)\\ \mathbf{else}:\\ \;\;\;\;{\varepsilon}^{5}\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (if (or (<= x -2.7e-58) (not (<= x 1e-51)))
   (+ (* (pow eps 2.0) (* (pow x 3.0) 10.0)) (* eps (* (pow x 4.0) 5.0)))
   (pow eps 5.0)))
double code(double x, double eps) {
	double tmp;
	if ((x <= -2.7e-58) || !(x <= 1e-51)) {
		tmp = (pow(eps, 2.0) * (pow(x, 3.0) * 10.0)) + (eps * (pow(x, 4.0) * 5.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 <= (-2.7d-58)) .or. (.not. (x <= 1d-51))) then
        tmp = ((eps ** 2.0d0) * ((x ** 3.0d0) * 10.0d0)) + (eps * ((x ** 4.0d0) * 5.0d0))
    else
        tmp = eps ** 5.0d0
    end if
    code = tmp
end function
public static double code(double x, double eps) {
	double tmp;
	if ((x <= -2.7e-58) || !(x <= 1e-51)) {
		tmp = (Math.pow(eps, 2.0) * (Math.pow(x, 3.0) * 10.0)) + (eps * (Math.pow(x, 4.0) * 5.0));
	} else {
		tmp = Math.pow(eps, 5.0);
	}
	return tmp;
}
def code(x, eps):
	tmp = 0
	if (x <= -2.7e-58) or not (x <= 1e-51):
		tmp = (math.pow(eps, 2.0) * (math.pow(x, 3.0) * 10.0)) + (eps * (math.pow(x, 4.0) * 5.0))
	else:
		tmp = math.pow(eps, 5.0)
	return tmp
function code(x, eps)
	tmp = 0.0
	if ((x <= -2.7e-58) || !(x <= 1e-51))
		tmp = Float64(Float64((eps ^ 2.0) * Float64((x ^ 3.0) * 10.0)) + Float64(eps * Float64((x ^ 4.0) * 5.0)));
	else
		tmp = eps ^ 5.0;
	end
	return tmp
end
function tmp_2 = code(x, eps)
	tmp = 0.0;
	if ((x <= -2.7e-58) || ~((x <= 1e-51)))
		tmp = ((eps ^ 2.0) * ((x ^ 3.0) * 10.0)) + (eps * ((x ^ 4.0) * 5.0));
	else
		tmp = eps ^ 5.0;
	end
	tmp_2 = tmp;
end
code[x_, eps_] := If[Or[LessEqual[x, -2.7e-58], N[Not[LessEqual[x, 1e-51]], $MachinePrecision]], N[(N[(N[Power[eps, 2.0], $MachinePrecision] * N[(N[Power[x, 3.0], $MachinePrecision] * 10.0), $MachinePrecision]), $MachinePrecision] + N[(eps * N[(N[Power[x, 4.0], $MachinePrecision] * 5.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[eps, 5.0], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.7 \cdot 10^{-58} \lor \neg \left(x \leq 10^{-51}\right):\\
\;\;\;\;{\varepsilon}^{2} \cdot \left({x}^{3} \cdot 10\right) + \varepsilon \cdot \left({x}^{4} \cdot 5\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -2.6999999999999999e-58 or 1e-51 < x

    1. Initial program 41.3%

      \[{\left(x + \varepsilon\right)}^{5} - {x}^{5} \]
    2. Step-by-step derivation
      1. add-cbrt-cube13.0%

        \[\leadsto \color{blue}{\sqrt[3]{\left({\left(x + \varepsilon\right)}^{5} \cdot {\left(x + \varepsilon\right)}^{5}\right) \cdot {\left(x + \varepsilon\right)}^{5}}} - {x}^{5} \]
      2. unpow311.2%

        \[\leadsto \sqrt[3]{\color{blue}{{\left({\left(x + \varepsilon\right)}^{5}\right)}^{3}}} - {x}^{5} \]
      3. pow-pow13.0%

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

        \[\leadsto \sqrt[3]{{\left(x + \varepsilon\right)}^{\color{blue}{15}}} - {x}^{5} \]
    3. Applied egg-rr13.0%

      \[\leadsto \color{blue}{\sqrt[3]{{\left(x + \varepsilon\right)}^{15}}} - {x}^{5} \]
    4. Taylor expanded in x around inf 98.2%

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

        \[\leadsto \color{blue}{{x}^{4} \cdot \left(\varepsilon + 4 \cdot \varepsilon\right) + {x}^{3} \cdot \left(2 \cdot {\varepsilon}^{2} + 8 \cdot {\varepsilon}^{2}\right)} \]
      2. distribute-rgt-out98.2%

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

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

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

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

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

        \[\leadsto \left(\color{blue}{5} \cdot \varepsilon\right) \cdot {x}^{4} + {x}^{3} \cdot \left(10 \cdot {\varepsilon}^{2}\right) \]
      8. associate-*r*98.2%

        \[\leadsto \color{blue}{5 \cdot \left(\varepsilon \cdot {x}^{4}\right)} + {x}^{3} \cdot \left(10 \cdot {\varepsilon}^{2}\right) \]
      9. fma-def98.2%

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

        \[\leadsto \mathsf{fma}\left(5, \varepsilon \cdot {x}^{4}, \color{blue}{\left(10 \cdot {\varepsilon}^{2}\right) \cdot {x}^{3}}\right) \]
      11. associate-*r*98.2%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(5, \varepsilon \cdot {x}^{4}, 10 \cdot \left({\varepsilon}^{2} \cdot {x}^{3}\right)\right)} \]
    7. Step-by-step derivation
      1. fma-udef98.2%

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

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

        \[\leadsto \color{blue}{\left({\varepsilon}^{2} \cdot {x}^{3}\right) \cdot 10} + 5 \cdot \left(\varepsilon \cdot {x}^{4}\right) \]
      4. associate-*l*98.2%

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

        \[\leadsto {\varepsilon}^{2} \cdot \left({x}^{3} \cdot 10\right) + 5 \cdot \color{blue}{\left({x}^{4} \cdot \varepsilon\right)} \]
      6. associate-*r*98.2%

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

        \[\leadsto {\varepsilon}^{2} \cdot \left({x}^{3} \cdot 10\right) + \color{blue}{\varepsilon \cdot \left(5 \cdot {x}^{4}\right)} \]
    8. Applied egg-rr98.2%

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

    if -2.6999999999999999e-58 < x < 1e-51

    1. Initial program 100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.7 \cdot 10^{-58} \lor \neg \left(x \leq 10^{-51}\right):\\ \;\;\;\;{\varepsilon}^{2} \cdot \left({x}^{3} \cdot 10\right) + \varepsilon \cdot \left({x}^{4} \cdot 5\right)\\ \mathbf{else}:\\ \;\;\;\;{\varepsilon}^{5}\\ \end{array} \]

Alternative 5: 98.0% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2.1 \cdot 10^{-58} \lor \neg \left(x \leq 1.1 \cdot 10^{-51}\right):\\ \;\;\;\;{x}^{3} \cdot \left(10 \cdot {\varepsilon}^{2}\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 -2.1e-58) (not (<= x 1.1e-51)))
   (+ (* (pow x 3.0) (* 10.0 (pow eps 2.0))) (* 5.0 (* eps (pow x 4.0))))
   (pow eps 5.0)))
double code(double x, double eps) {
	double tmp;
	if ((x <= -2.1e-58) || !(x <= 1.1e-51)) {
		tmp = (pow(x, 3.0) * (10.0 * pow(eps, 2.0))) + (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 <= (-2.1d-58)) .or. (.not. (x <= 1.1d-51))) then
        tmp = ((x ** 3.0d0) * (10.0d0 * (eps ** 2.0d0))) + (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 <= -2.1e-58) || !(x <= 1.1e-51)) {
		tmp = (Math.pow(x, 3.0) * (10.0 * Math.pow(eps, 2.0))) + (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 <= -2.1e-58) or not (x <= 1.1e-51):
		tmp = (math.pow(x, 3.0) * (10.0 * math.pow(eps, 2.0))) + (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 <= -2.1e-58) || !(x <= 1.1e-51))
		tmp = Float64(Float64((x ^ 3.0) * Float64(10.0 * (eps ^ 2.0))) + 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 <= -2.1e-58) || ~((x <= 1.1e-51)))
		tmp = ((x ^ 3.0) * (10.0 * (eps ^ 2.0))) + (5.0 * (eps * (x ^ 4.0)));
	else
		tmp = eps ^ 5.0;
	end
	tmp_2 = tmp;
end
code[x_, eps_] := If[Or[LessEqual[x, -2.1e-58], N[Not[LessEqual[x, 1.1e-51]], $MachinePrecision]], N[(N[(N[Power[x, 3.0], $MachinePrecision] * N[(10.0 * N[Power[eps, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(5.0 * N[(eps * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[eps, 5.0], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.1 \cdot 10^{-58} \lor \neg \left(x \leq 1.1 \cdot 10^{-51}\right):\\
\;\;\;\;{x}^{3} \cdot \left(10 \cdot {\varepsilon}^{2}\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 < -2.09999999999999988e-58 or 1.1e-51 < x

    1. Initial program 41.3%

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

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

        \[\leadsto \color{blue}{{x}^{4} \cdot \left(\varepsilon + 4 \cdot \varepsilon\right) + {x}^{3} \cdot \left(2 \cdot {\varepsilon}^{2} + 8 \cdot {\varepsilon}^{2}\right)} \]
      2. fma-def98.2%

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

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

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

        \[\leadsto \mathsf{fma}\left({x}^{4}, \color{blue}{\varepsilon \cdot 5}, {x}^{3} \cdot \left(2 \cdot {\varepsilon}^{2} + 8 \cdot {\varepsilon}^{2}\right)\right) \]
      6. *-commutative98.2%

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

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

        \[\leadsto \mathsf{fma}\left({x}^{4}, \varepsilon \cdot 5, \left({\varepsilon}^{2} \cdot \color{blue}{10}\right) \cdot {x}^{3}\right) \]
      9. associate-*l*98.2%

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

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

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

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

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

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

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

        \[\leadsto {x}^{3} \cdot \left(10 \cdot {\varepsilon}^{2}\right) + \color{blue}{\left(\varepsilon \cdot 5\right) \cdot {x}^{4}} \]
      7. associate-*r*98.2%

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

        \[\leadsto {x}^{3} \cdot \left(10 \cdot {\varepsilon}^{2}\right) + \color{blue}{\left(5 \cdot {x}^{4}\right) \cdot \varepsilon} \]
      9. associate-*l*98.2%

        \[\leadsto {x}^{3} \cdot \left(10 \cdot {\varepsilon}^{2}\right) + \color{blue}{5 \cdot \left({x}^{4} \cdot \varepsilon\right)} \]
    6. Applied egg-rr98.2%

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

    if -2.09999999999999988e-58 < x < 1.1e-51

    1. Initial program 100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.1 \cdot 10^{-58} \lor \neg \left(x \leq 1.1 \cdot 10^{-51}\right):\\ \;\;\;\;{x}^{3} \cdot \left(10 \cdot {\varepsilon}^{2}\right) + 5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;{\varepsilon}^{5}\\ \end{array} \]

Alternative 6: 97.9% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2.7 \cdot 10^{-58} \lor \neg \left(x \leq 1.2 \cdot 10^{-51}\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 -2.7e-58) (not (<= x 1.2e-51)))
   (* 5.0 (* eps (pow x 4.0)))
   (pow eps 5.0)))
double code(double x, double eps) {
	double tmp;
	if ((x <= -2.7e-58) || !(x <= 1.2e-51)) {
		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 <= (-2.7d-58)) .or. (.not. (x <= 1.2d-51))) 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 <= -2.7e-58) || !(x <= 1.2e-51)) {
		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 <= -2.7e-58) or not (x <= 1.2e-51):
		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 <= -2.7e-58) || !(x <= 1.2e-51))
		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 <= -2.7e-58) || ~((x <= 1.2e-51)))
		tmp = 5.0 * (eps * (x ^ 4.0));
	else
		tmp = eps ^ 5.0;
	end
	tmp_2 = tmp;
end
code[x_, eps_] := If[Or[LessEqual[x, -2.7e-58], N[Not[LessEqual[x, 1.2e-51]], $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 -2.7 \cdot 10^{-58} \lor \neg \left(x \leq 1.2 \cdot 10^{-51}\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 < -2.6999999999999999e-58 or 1.2e-51 < x

    1. Initial program 41.3%

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

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

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

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

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

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

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

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

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

    if -2.6999999999999999e-58 < x < 1.2e-51

    1. Initial program 100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.7 \cdot 10^{-58} \lor \neg \left(x \leq 1.2 \cdot 10^{-51}\right):\\ \;\;\;\;5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;{\varepsilon}^{5}\\ \end{array} \]

Alternative 7: 97.9% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2.7 \cdot 10^{-58}:\\ \;\;\;\;5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\ \mathbf{elif}\;x \leq 1.02 \cdot 10^{-51}:\\ \;\;\;\;{\varepsilon}^{5}\\ \mathbf{else}:\\ \;\;\;\;\varepsilon \cdot \left({x}^{4} \cdot 5\right)\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (if (<= x -2.7e-58)
   (* 5.0 (* eps (pow x 4.0)))
   (if (<= x 1.02e-51) (pow eps 5.0) (* eps (* (pow x 4.0) 5.0)))))
double code(double x, double eps) {
	double tmp;
	if (x <= -2.7e-58) {
		tmp = 5.0 * (eps * pow(x, 4.0));
	} else if (x <= 1.02e-51) {
		tmp = pow(eps, 5.0);
	} else {
		tmp = eps * (pow(x, 4.0) * 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 <= (-2.7d-58)) then
        tmp = 5.0d0 * (eps * (x ** 4.0d0))
    else if (x <= 1.02d-51) then
        tmp = eps ** 5.0d0
    else
        tmp = eps * ((x ** 4.0d0) * 5.0d0)
    end if
    code = tmp
end function
public static double code(double x, double eps) {
	double tmp;
	if (x <= -2.7e-58) {
		tmp = 5.0 * (eps * Math.pow(x, 4.0));
	} else if (x <= 1.02e-51) {
		tmp = Math.pow(eps, 5.0);
	} else {
		tmp = eps * (Math.pow(x, 4.0) * 5.0);
	}
	return tmp;
}
def code(x, eps):
	tmp = 0
	if x <= -2.7e-58:
		tmp = 5.0 * (eps * math.pow(x, 4.0))
	elif x <= 1.02e-51:
		tmp = math.pow(eps, 5.0)
	else:
		tmp = eps * (math.pow(x, 4.0) * 5.0)
	return tmp
function code(x, eps)
	tmp = 0.0
	if (x <= -2.7e-58)
		tmp = Float64(5.0 * Float64(eps * (x ^ 4.0)));
	elseif (x <= 1.02e-51)
		tmp = eps ^ 5.0;
	else
		tmp = Float64(eps * Float64((x ^ 4.0) * 5.0));
	end
	return tmp
end
function tmp_2 = code(x, eps)
	tmp = 0.0;
	if (x <= -2.7e-58)
		tmp = 5.0 * (eps * (x ^ 4.0));
	elseif (x <= 1.02e-51)
		tmp = eps ^ 5.0;
	else
		tmp = eps * ((x ^ 4.0) * 5.0);
	end
	tmp_2 = tmp;
end
code[x_, eps_] := If[LessEqual[x, -2.7e-58], N[(5.0 * N[(eps * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.02e-51], N[Power[eps, 5.0], $MachinePrecision], N[(eps * N[(N[Power[x, 4.0], $MachinePrecision] * 5.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.7 \cdot 10^{-58}:\\
\;\;\;\;5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\

\mathbf{elif}\;x \leq 1.02 \cdot 10^{-51}:\\
\;\;\;\;{\varepsilon}^{5}\\

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


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

    1. Initial program 44.1%

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

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

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

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

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

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

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

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

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

    if -2.6999999999999999e-58 < x < 1.01999999999999998e-51

    1. Initial program 100.0%

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

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

    if 1.01999999999999998e-51 < x

    1. Initial program 38.9%

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.7 \cdot 10^{-58}:\\ \;\;\;\;5 \cdot \left(\varepsilon \cdot {x}^{4}\right)\\ \mathbf{elif}\;x \leq 1.02 \cdot 10^{-51}:\\ \;\;\;\;{\varepsilon}^{5}\\ \mathbf{else}:\\ \;\;\;\;\varepsilon \cdot \left({x}^{4} \cdot 5\right)\\ \end{array} \]

Alternative 8: 87.2% 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 87.8%

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

    \[\leadsto \color{blue}{{\varepsilon}^{5}} \]
  3. Final simplification86.9%

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

Reproduce

?
herbie shell --seed 2023301 
(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)))