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

Percentage Accurate: 88.7% → 99.2%
Time: 4.2s
Alternatives: 12
Speedup: 0.4×

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

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

real(8) function code(x, eps)
use fmin_fmax_functions
    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.7% 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);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, eps)
use fmin_fmax_functions
    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: 99.2% accurate, 0.3× 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 -4 \cdot 10^{-303}:\\ \;\;\;\;t\_0 - {\left(x \cdot x\right)}^{2.5}\\ \mathbf{elif}\;t\_1 \leq 0:\\ \;\;\;\;\left(5 \cdot {x}^{4}\right) \cdot \varepsilon\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \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 -4e-303)
     (- t_0 (pow (* x x) 2.5))
     (if (<= t_1 0.0) (* (* 5.0 (pow x 4.0)) eps) t_1))))
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 <= -4e-303) {
		tmp = t_0 - pow((x * x), 2.5);
	} else if (t_1 <= 0.0) {
		tmp = (5.0 * pow(x, 4.0)) * eps;
	} else {
		tmp = t_1;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, eps)
use fmin_fmax_functions
    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 <= (-4d-303)) then
        tmp = t_0 - ((x * x) ** 2.5d0)
    else if (t_1 <= 0.0d0) then
        tmp = (5.0d0 * (x ** 4.0d0)) * eps
    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);
	double t_1 = t_0 - Math.pow(x, 5.0);
	double tmp;
	if (t_1 <= -4e-303) {
		tmp = t_0 - Math.pow((x * x), 2.5);
	} else if (t_1 <= 0.0) {
		tmp = (5.0 * Math.pow(x, 4.0)) * eps;
	} else {
		tmp = t_1;
	}
	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 <= -4e-303:
		tmp = t_0 - math.pow((x * x), 2.5)
	elif t_1 <= 0.0:
		tmp = (5.0 * math.pow(x, 4.0)) * eps
	else:
		tmp = t_1
	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 <= -4e-303)
		tmp = Float64(t_0 - (Float64(x * x) ^ 2.5));
	elseif (t_1 <= 0.0)
		tmp = Float64(Float64(5.0 * (x ^ 4.0)) * eps);
	else
		tmp = t_1;
	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 <= -4e-303)
		tmp = t_0 - ((x * x) ^ 2.5);
	elseif (t_1 <= 0.0)
		tmp = (5.0 * (x ^ 4.0)) * eps;
	else
		tmp = t_1;
	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, -4e-303], N[(t$95$0 - N[Power[N[(x * x), $MachinePrecision], 2.5], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.0], N[(N[(5.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < -3.99999999999999972e-303

    1. Initial program 96.4%

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

        \[\leadsto {\left(x + \varepsilon\right)}^{5} - \color{blue}{{x}^{5}} \]
      2. sqr-powN/A

        \[\leadsto {\left(x + \varepsilon\right)}^{5} - \color{blue}{{x}^{\left(\frac{5}{2}\right)} \cdot {x}^{\left(\frac{5}{2}\right)}} \]
      3. pow-prod-downN/A

        \[\leadsto {\left(x + \varepsilon\right)}^{5} - \color{blue}{{\left(x \cdot x\right)}^{\left(\frac{5}{2}\right)}} \]
      4. unpow2N/A

        \[\leadsto {\left(x + \varepsilon\right)}^{5} - {\color{blue}{\left({x}^{2}\right)}}^{\left(\frac{5}{2}\right)} \]
      5. lower-pow.f64N/A

        \[\leadsto {\left(x + \varepsilon\right)}^{5} - \color{blue}{{\left({x}^{2}\right)}^{\left(\frac{5}{2}\right)}} \]
      6. unpow2N/A

        \[\leadsto {\left(x + \varepsilon\right)}^{5} - {\color{blue}{\left(x \cdot x\right)}}^{\left(\frac{5}{2}\right)} \]
      7. lower-*.f64N/A

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

        \[\leadsto {\left(x + \varepsilon\right)}^{5} - {\left(x \cdot x\right)}^{\color{blue}{2.5}} \]
    4. Applied rewrites96.4%

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

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

    1. Initial program 83.6%

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

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

        \[\leadsto \left(4 \cdot {x}^{4} + {x}^{4}\right) \cdot \color{blue}{\varepsilon} \]
      2. lower-*.f64N/A

        \[\leadsto \left(4 \cdot {x}^{4} + {x}^{4}\right) \cdot \color{blue}{\varepsilon} \]
      3. distribute-lft1-inN/A

        \[\leadsto \left(\left(4 + 1\right) \cdot {x}^{4}\right) \cdot \varepsilon \]
      4. metadata-evalN/A

        \[\leadsto \left(5 \cdot {x}^{4}\right) \cdot \varepsilon \]
      5. lower-*.f64N/A

        \[\leadsto \left(5 \cdot {x}^{4}\right) \cdot \varepsilon \]
      6. lower-pow.f6499.9

        \[\leadsto \left(5 \cdot {x}^{4}\right) \cdot \varepsilon \]
    5. Applied rewrites99.9%

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

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

    1. Initial program 96.1%

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

Alternative 2: 99.3% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(x + \varepsilon\right)}^{5} - {x}^{5}\\ \mathbf{if}\;t\_0 \leq -4 \cdot 10^{-303} \lor \neg \left(t\_0 \leq 0\right):\\ \;\;\;\;t\_0\\ \mathbf{else}:\\ \;\;\;\;\left(5 \cdot {x}^{4}\right) \cdot \varepsilon\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (let* ((t_0 (- (pow (+ x eps) 5.0) (pow x 5.0))))
   (if (or (<= t_0 -4e-303) (not (<= t_0 0.0)))
     t_0
     (* (* 5.0 (pow x 4.0)) eps))))
double code(double x, double eps) {
	double t_0 = pow((x + eps), 5.0) - pow(x, 5.0);
	double tmp;
	if ((t_0 <= -4e-303) || !(t_0 <= 0.0)) {
		tmp = t_0;
	} else {
		tmp = (5.0 * pow(x, 4.0)) * eps;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

real(8) function code(x, eps)
use fmin_fmax_functions
    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 <= (-4d-303)) .or. (.not. (t_0 <= 0.0d0))) then
        tmp = t_0
    else
        tmp = (5.0d0 * (x ** 4.0d0)) * eps
    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 <= -4e-303) || !(t_0 <= 0.0)) {
		tmp = t_0;
	} else {
		tmp = (5.0 * Math.pow(x, 4.0)) * eps;
	}
	return tmp;
}
def code(x, eps):
	t_0 = math.pow((x + eps), 5.0) - math.pow(x, 5.0)
	tmp = 0
	if (t_0 <= -4e-303) or not (t_0 <= 0.0):
		tmp = t_0
	else:
		tmp = (5.0 * math.pow(x, 4.0)) * eps
	return tmp
function code(x, eps)
	t_0 = Float64((Float64(x + eps) ^ 5.0) - (x ^ 5.0))
	tmp = 0.0
	if ((t_0 <= -4e-303) || !(t_0 <= 0.0))
		tmp = t_0;
	else
		tmp = Float64(Float64(5.0 * (x ^ 4.0)) * eps);
	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 <= -4e-303) || ~((t_0 <= 0.0)))
		tmp = t_0;
	else
		tmp = (5.0 * (x ^ 4.0)) * eps;
	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[Or[LessEqual[t$95$0, -4e-303], N[Not[LessEqual[t$95$0, 0.0]], $MachinePrecision]], t$95$0, N[(N[(5.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\left(x + \varepsilon\right)}^{5} - {x}^{5}\\
\mathbf{if}\;t\_0 \leq -4 \cdot 10^{-303} \lor \neg \left(t\_0 \leq 0\right):\\
\;\;\;\;t\_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < -3.99999999999999972e-303 or 0.0 < (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64)))

    1. Initial program 96.2%

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

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

    1. Initial program 83.6%

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

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

        \[\leadsto \left(4 \cdot {x}^{4} + {x}^{4}\right) \cdot \color{blue}{\varepsilon} \]
      2. lower-*.f64N/A

        \[\leadsto \left(4 \cdot {x}^{4} + {x}^{4}\right) \cdot \color{blue}{\varepsilon} \]
      3. distribute-lft1-inN/A

        \[\leadsto \left(\left(4 + 1\right) \cdot {x}^{4}\right) \cdot \varepsilon \]
      4. metadata-evalN/A

        \[\leadsto \left(5 \cdot {x}^{4}\right) \cdot \varepsilon \]
      5. lower-*.f64N/A

        \[\leadsto \left(5 \cdot {x}^{4}\right) \cdot \varepsilon \]
      6. lower-pow.f6499.9

        \[\leadsto \left(5 \cdot {x}^{4}\right) \cdot \varepsilon \]
    5. Applied rewrites99.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;{\left(x + \varepsilon\right)}^{5} - {x}^{5} \leq -4 \cdot 10^{-303} \lor \neg \left({\left(x + \varepsilon\right)}^{5} - {x}^{5} \leq 0\right):\\ \;\;\;\;{\left(x + \varepsilon\right)}^{5} - {x}^{5}\\ \mathbf{else}:\\ \;\;\;\;\left(5 \cdot {x}^{4}\right) \cdot \varepsilon\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 98.6% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(x + \varepsilon\right)}^{5} - {x}^{5}\\ \mathbf{if}\;t\_0 \leq -4 \cdot 10^{-303} \lor \neg \left(t\_0 \leq 0\right):\\ \;\;\;\;\left(\frac{\mathsf{fma}\left(\frac{x}{\varepsilon}, 10, 5\right) \cdot x}{\varepsilon} - -1\right) \cdot {\varepsilon}^{5}\\ \mathbf{else}:\\ \;\;\;\;\left(5 \cdot {x}^{4}\right) \cdot \varepsilon\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (let* ((t_0 (- (pow (+ x eps) 5.0) (pow x 5.0))))
   (if (or (<= t_0 -4e-303) (not (<= t_0 0.0)))
     (* (- (/ (* (fma (/ x eps) 10.0 5.0) x) eps) -1.0) (pow eps 5.0))
     (* (* 5.0 (pow x 4.0)) eps))))
double code(double x, double eps) {
	double t_0 = pow((x + eps), 5.0) - pow(x, 5.0);
	double tmp;
	if ((t_0 <= -4e-303) || !(t_0 <= 0.0)) {
		tmp = (((fma((x / eps), 10.0, 5.0) * x) / eps) - -1.0) * pow(eps, 5.0);
	} else {
		tmp = (5.0 * pow(x, 4.0)) * eps;
	}
	return tmp;
}
function code(x, eps)
	t_0 = Float64((Float64(x + eps) ^ 5.0) - (x ^ 5.0))
	tmp = 0.0
	if ((t_0 <= -4e-303) || !(t_0 <= 0.0))
		tmp = Float64(Float64(Float64(Float64(fma(Float64(x / eps), 10.0, 5.0) * x) / eps) - -1.0) * (eps ^ 5.0));
	else
		tmp = Float64(Float64(5.0 * (x ^ 4.0)) * eps);
	end
	return 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[Or[LessEqual[t$95$0, -4e-303], N[Not[LessEqual[t$95$0, 0.0]], $MachinePrecision]], N[(N[(N[(N[(N[(N[(x / eps), $MachinePrecision] * 10.0 + 5.0), $MachinePrecision] * x), $MachinePrecision] / eps), $MachinePrecision] - -1.0), $MachinePrecision] * N[Power[eps, 5.0], $MachinePrecision]), $MachinePrecision], N[(N[(5.0 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\left(x + \varepsilon\right)}^{5} - {x}^{5}\\
\mathbf{if}\;t\_0 \leq -4 \cdot 10^{-303} \lor \neg \left(t\_0 \leq 0\right):\\
\;\;\;\;\left(\frac{\mathsf{fma}\left(\frac{x}{\varepsilon}, 10, 5\right) \cdot x}{\varepsilon} - -1\right) \cdot {\varepsilon}^{5}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < -3.99999999999999972e-303 or 0.0 < (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64)))

    1. Initial program 96.2%

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

      \[\leadsto \color{blue}{-1 \cdot \left({\varepsilon}^{5} \cdot \left(-1 \cdot \frac{x + \left(-1 \cdot \frac{-4 \cdot {x}^{2} + -1 \cdot \left(2 \cdot {x}^{2} + 4 \cdot {x}^{2}\right)}{\varepsilon} + 4 \cdot x\right)}{\varepsilon} - 1\right)\right)} \]
    4. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left({\varepsilon}^{5} \cdot \left(-1 \cdot \frac{x + \left(-1 \cdot \frac{-4 \cdot {x}^{2} + -1 \cdot \left(2 \cdot {x}^{2} + 4 \cdot {x}^{2}\right)}{\varepsilon} + 4 \cdot x\right)}{\varepsilon} - 1\right)\right) \]
      2. lower-neg.f64N/A

        \[\leadsto -{\varepsilon}^{5} \cdot \left(-1 \cdot \frac{x + \left(-1 \cdot \frac{-4 \cdot {x}^{2} + -1 \cdot \left(2 \cdot {x}^{2} + 4 \cdot {x}^{2}\right)}{\varepsilon} + 4 \cdot x\right)}{\varepsilon} - 1\right) \]
      3. *-commutativeN/A

        \[\leadsto -\left(-1 \cdot \frac{x + \left(-1 \cdot \frac{-4 \cdot {x}^{2} + -1 \cdot \left(2 \cdot {x}^{2} + 4 \cdot {x}^{2}\right)}{\varepsilon} + 4 \cdot x\right)}{\varepsilon} - 1\right) \cdot {\varepsilon}^{5} \]
      4. lower-*.f64N/A

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

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

      \[\leadsto -\left(\left(-\frac{x \cdot \left(5 + 10 \cdot \frac{x}{\varepsilon}\right)}{\varepsilon}\right) - 1\right) \cdot {\varepsilon}^{5} \]
    7. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto -\left(\left(-\frac{x \cdot \left(5 + 10 \cdot \frac{x}{\varepsilon}\right)}{\varepsilon}\right) - 1\right) \cdot {\varepsilon}^{5} \]
      2. lower-+.f64N/A

        \[\leadsto -\left(\left(-\frac{x \cdot \left(5 + 10 \cdot \frac{x}{\varepsilon}\right)}{\varepsilon}\right) - 1\right) \cdot {\varepsilon}^{5} \]
      3. lower-*.f64N/A

        \[\leadsto -\left(\left(-\frac{x \cdot \left(5 + 10 \cdot \frac{x}{\varepsilon}\right)}{\varepsilon}\right) - 1\right) \cdot {\varepsilon}^{5} \]
      4. lift-/.f6491.5

        \[\leadsto -\left(\left(-\frac{x \cdot \left(5 + 10 \cdot \frac{x}{\varepsilon}\right)}{\varepsilon}\right) - 1\right) \cdot {\varepsilon}^{5} \]
    8. Applied rewrites91.5%

      \[\leadsto -\left(\left(-\frac{x \cdot \left(5 + 10 \cdot \frac{x}{\varepsilon}\right)}{\varepsilon}\right) - 1\right) \cdot {\varepsilon}^{5} \]
    9. Applied rewrites91.5%

      \[\leadsto \color{blue}{\left(\frac{\mathsf{fma}\left(\frac{x}{\varepsilon}, 10, 5\right) \cdot x}{-\varepsilon} - 1\right) \cdot \left(-{\varepsilon}^{5}\right)} \]

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

    1. Initial program 83.6%

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

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

        \[\leadsto \left(4 \cdot {x}^{4} + {x}^{4}\right) \cdot \color{blue}{\varepsilon} \]
      2. lower-*.f64N/A

        \[\leadsto \left(4 \cdot {x}^{4} + {x}^{4}\right) \cdot \color{blue}{\varepsilon} \]
      3. distribute-lft1-inN/A

        \[\leadsto \left(\left(4 + 1\right) \cdot {x}^{4}\right) \cdot \varepsilon \]
      4. metadata-evalN/A

        \[\leadsto \left(5 \cdot {x}^{4}\right) \cdot \varepsilon \]
      5. lower-*.f64N/A

        \[\leadsto \left(5 \cdot {x}^{4}\right) \cdot \varepsilon \]
      6. lower-pow.f6499.9

        \[\leadsto \left(5 \cdot {x}^{4}\right) \cdot \varepsilon \]
    5. Applied rewrites99.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;{\left(x + \varepsilon\right)}^{5} - {x}^{5} \leq -4 \cdot 10^{-303} \lor \neg \left({\left(x + \varepsilon\right)}^{5} - {x}^{5} \leq 0\right):\\ \;\;\;\;\left(\frac{\mathsf{fma}\left(\frac{x}{\varepsilon}, 10, 5\right) \cdot x}{\varepsilon} - -1\right) \cdot {\varepsilon}^{5}\\ \mathbf{else}:\\ \;\;\;\;\left(5 \cdot {x}^{4}\right) \cdot \varepsilon\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 98.4% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
t_0 := {\left(x + \varepsilon\right)}^{5} - {x}^{5}\\
\mathbf{if}\;t\_0 \leq -4 \cdot 10^{-303}:\\
\;\;\;\;\mathsf{fma}\left(5, \frac{x}{\varepsilon}, 1\right) \cdot {\varepsilon}^{5}\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < -3.99999999999999972e-303

    1. Initial program 96.4%

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

      \[\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. *-commutativeN/A

        \[\leadsto \left(1 + \left(4 \cdot \frac{x}{\varepsilon} + \frac{x}{\varepsilon}\right)\right) \cdot \color{blue}{{\varepsilon}^{5}} \]
      2. lower-*.f64N/A

        \[\leadsto \left(1 + \left(4 \cdot \frac{x}{\varepsilon} + \frac{x}{\varepsilon}\right)\right) \cdot \color{blue}{{\varepsilon}^{5}} \]
      3. +-commutativeN/A

        \[\leadsto \left(\left(4 \cdot \frac{x}{\varepsilon} + \frac{x}{\varepsilon}\right) + 1\right) \cdot {\color{blue}{\varepsilon}}^{5} \]
      4. distribute-lft1-inN/A

        \[\leadsto \left(\left(4 + 1\right) \cdot \frac{x}{\varepsilon} + 1\right) \cdot {\varepsilon}^{5} \]
      5. metadata-evalN/A

        \[\leadsto \left(5 \cdot \frac{x}{\varepsilon} + 1\right) \cdot {\varepsilon}^{5} \]
      6. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(5, \frac{x}{\varepsilon}, 1\right) \cdot {\color{blue}{\varepsilon}}^{5} \]
      7. lower-/.f64N/A

        \[\leadsto \mathsf{fma}\left(5, \frac{x}{\varepsilon}, 1\right) \cdot {\varepsilon}^{5} \]
      8. lower-pow.f6494.9

        \[\leadsto \mathsf{fma}\left(5, \frac{x}{\varepsilon}, 1\right) \cdot {\varepsilon}^{\color{blue}{5}} \]
    5. Applied rewrites94.9%

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

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

    1. Initial program 83.6%

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

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

        \[\leadsto \left(4 \cdot {x}^{4} + {x}^{4}\right) \cdot \color{blue}{\varepsilon} \]
      2. lower-*.f64N/A

        \[\leadsto \left(4 \cdot {x}^{4} + {x}^{4}\right) \cdot \color{blue}{\varepsilon} \]
      3. distribute-lft1-inN/A

        \[\leadsto \left(\left(4 + 1\right) \cdot {x}^{4}\right) \cdot \varepsilon \]
      4. metadata-evalN/A

        \[\leadsto \left(5 \cdot {x}^{4}\right) \cdot \varepsilon \]
      5. lower-*.f64N/A

        \[\leadsto \left(5 \cdot {x}^{4}\right) \cdot \varepsilon \]
      6. lower-pow.f6499.9

        \[\leadsto \left(5 \cdot {x}^{4}\right) \cdot \varepsilon \]
    5. Applied rewrites99.9%

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

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

    1. Initial program 96.1%

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

      \[\leadsto \color{blue}{{\varepsilon}^{5}} \]
    4. Step-by-step derivation
      1. lower-pow.f6487.0

        \[\leadsto {\varepsilon}^{\color{blue}{5}} \]
    5. Applied rewrites87.0%

      \[\leadsto \color{blue}{{\varepsilon}^{5}} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 5: 98.4% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
t_0 := {\left(x + \varepsilon\right)}^{5} - {x}^{5}\\
\mathbf{if}\;t\_0 \leq -4 \cdot 10^{-303}:\\
\;\;\;\;\left(\left(\varepsilon \cdot \varepsilon\right) \cdot \varepsilon\right) \cdot \left(\mathsf{fma}\left(6, x \cdot x, \varepsilon \cdot \left(\varepsilon + 5 \cdot x\right)\right) - -4 \cdot \left(x \cdot x\right)\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < -3.99999999999999972e-303

    1. Initial program 96.4%

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

      \[\leadsto \color{blue}{-1 \cdot \left({\varepsilon}^{5} \cdot \left(-1 \cdot \frac{x + \left(-1 \cdot \frac{-4 \cdot {x}^{2} + -1 \cdot \left(2 \cdot {x}^{2} + 4 \cdot {x}^{2}\right)}{\varepsilon} + 4 \cdot x\right)}{\varepsilon} - 1\right)\right)} \]
    4. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left({\varepsilon}^{5} \cdot \left(-1 \cdot \frac{x + \left(-1 \cdot \frac{-4 \cdot {x}^{2} + -1 \cdot \left(2 \cdot {x}^{2} + 4 \cdot {x}^{2}\right)}{\varepsilon} + 4 \cdot x\right)}{\varepsilon} - 1\right)\right) \]
      2. lower-neg.f64N/A

        \[\leadsto -{\varepsilon}^{5} \cdot \left(-1 \cdot \frac{x + \left(-1 \cdot \frac{-4 \cdot {x}^{2} + -1 \cdot \left(2 \cdot {x}^{2} + 4 \cdot {x}^{2}\right)}{\varepsilon} + 4 \cdot x\right)}{\varepsilon} - 1\right) \]
      3. *-commutativeN/A

        \[\leadsto -\left(-1 \cdot \frac{x + \left(-1 \cdot \frac{-4 \cdot {x}^{2} + -1 \cdot \left(2 \cdot {x}^{2} + 4 \cdot {x}^{2}\right)}{\varepsilon} + 4 \cdot x\right)}{\varepsilon} - 1\right) \cdot {\varepsilon}^{5} \]
      4. lower-*.f64N/A

        \[\leadsto -\left(-1 \cdot \frac{x + \left(-1 \cdot \frac{-4 \cdot {x}^{2} + -1 \cdot \left(2 \cdot {x}^{2} + 4 \cdot {x}^{2}\right)}{\varepsilon} + 4 \cdot x\right)}{\varepsilon} - 1\right) \cdot {\varepsilon}^{5} \]
    5. Applied rewrites95.6%

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

      \[\leadsto {\varepsilon}^{3} \cdot \color{blue}{\left(\left(6 \cdot {x}^{2} + \varepsilon \cdot \left(\varepsilon - -1 \cdot \left(x + 4 \cdot x\right)\right)\right) - -4 \cdot {x}^{2}\right)} \]
    7. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto {\varepsilon}^{3} \cdot \left(\left(6 \cdot {x}^{2} + \varepsilon \cdot \left(\varepsilon - -1 \cdot \left(x + 4 \cdot x\right)\right)\right) - \color{blue}{-4 \cdot {x}^{2}}\right) \]
      2. lower-pow.f64N/A

        \[\leadsto {\varepsilon}^{3} \cdot \left(\left(6 \cdot {x}^{2} + \varepsilon \cdot \left(\varepsilon - -1 \cdot \left(x + 4 \cdot x\right)\right)\right) - \color{blue}{-4} \cdot {x}^{2}\right) \]
      3. lower--.f64N/A

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

      \[\leadsto {\varepsilon}^{3} \cdot \color{blue}{\left(\mathsf{fma}\left(6, x \cdot x, \varepsilon \cdot \left(\varepsilon - \left(-5 \cdot x\right)\right)\right) - -4 \cdot \left(x \cdot x\right)\right)} \]
    9. Step-by-step derivation
      1. lift-pow.f64N/A

        \[\leadsto {\varepsilon}^{3} \cdot \left(\mathsf{fma}\left(6, x \cdot x, \varepsilon \cdot \left(\varepsilon - \left(-5 \cdot x\right)\right)\right) - \color{blue}{-4} \cdot \left(x \cdot x\right)\right) \]
      2. unpow3N/A

        \[\leadsto \left(\left(\varepsilon \cdot \varepsilon\right) \cdot \varepsilon\right) \cdot \left(\mathsf{fma}\left(6, x \cdot x, \varepsilon \cdot \left(\varepsilon - \left(-5 \cdot x\right)\right)\right) - \color{blue}{-4} \cdot \left(x \cdot x\right)\right) \]
      3. pow2N/A

        \[\leadsto \left({\varepsilon}^{2} \cdot \varepsilon\right) \cdot \left(\mathsf{fma}\left(6, x \cdot x, \varepsilon \cdot \left(\varepsilon - \left(-5 \cdot x\right)\right)\right) - -4 \cdot \left(x \cdot x\right)\right) \]
      4. lower-*.f64N/A

        \[\leadsto \left({\varepsilon}^{2} \cdot \varepsilon\right) \cdot \left(\mathsf{fma}\left(6, x \cdot x, \varepsilon \cdot \left(\varepsilon - \left(-5 \cdot x\right)\right)\right) - \color{blue}{-4} \cdot \left(x \cdot x\right)\right) \]
      5. pow2N/A

        \[\leadsto \left(\left(\varepsilon \cdot \varepsilon\right) \cdot \varepsilon\right) \cdot \left(\mathsf{fma}\left(6, x \cdot x, \varepsilon \cdot \left(\varepsilon - \left(-5 \cdot x\right)\right)\right) - -4 \cdot \left(x \cdot x\right)\right) \]
      6. lift-*.f6494.8

        \[\leadsto \left(\left(\varepsilon \cdot \varepsilon\right) \cdot \varepsilon\right) \cdot \left(\mathsf{fma}\left(6, x \cdot x, \varepsilon \cdot \left(\varepsilon - \left(-5 \cdot x\right)\right)\right) - -4 \cdot \left(x \cdot x\right)\right) \]
    10. Applied rewrites94.8%

      \[\leadsto \left(\left(\varepsilon \cdot \varepsilon\right) \cdot \varepsilon\right) \cdot \left(\mathsf{fma}\left(6, x \cdot x, \varepsilon \cdot \left(\varepsilon - \left(-5 \cdot x\right)\right)\right) - \color{blue}{-4} \cdot \left(x \cdot x\right)\right) \]

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

    1. Initial program 83.6%

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

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

        \[\leadsto \left(4 \cdot {x}^{4} + {x}^{4}\right) \cdot \color{blue}{\varepsilon} \]
      2. lower-*.f64N/A

        \[\leadsto \left(4 \cdot {x}^{4} + {x}^{4}\right) \cdot \color{blue}{\varepsilon} \]
      3. distribute-lft1-inN/A

        \[\leadsto \left(\left(4 + 1\right) \cdot {x}^{4}\right) \cdot \varepsilon \]
      4. metadata-evalN/A

        \[\leadsto \left(5 \cdot {x}^{4}\right) \cdot \varepsilon \]
      5. lower-*.f64N/A

        \[\leadsto \left(5 \cdot {x}^{4}\right) \cdot \varepsilon \]
      6. lower-pow.f6499.9

        \[\leadsto \left(5 \cdot {x}^{4}\right) \cdot \varepsilon \]
    5. Applied rewrites99.9%

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

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

    1. Initial program 96.1%

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

      \[\leadsto \color{blue}{{\varepsilon}^{5}} \]
    4. Step-by-step derivation
      1. lower-pow.f6487.0

        \[\leadsto {\varepsilon}^{\color{blue}{5}} \]
    5. Applied rewrites87.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;{\left(x + \varepsilon\right)}^{5} - {x}^{5} \leq -4 \cdot 10^{-303}:\\ \;\;\;\;\left(\left(\varepsilon \cdot \varepsilon\right) \cdot \varepsilon\right) \cdot \left(\mathsf{fma}\left(6, x \cdot x, \varepsilon \cdot \left(\varepsilon + 5 \cdot x\right)\right) - -4 \cdot \left(x \cdot x\right)\right)\\ \mathbf{elif}\;{\left(x + \varepsilon\right)}^{5} - {x}^{5} \leq 0:\\ \;\;\;\;\left(5 \cdot {x}^{4}\right) \cdot \varepsilon\\ \mathbf{else}:\\ \;\;\;\;{\varepsilon}^{5}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 98.4% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
t_0 := {\left(x + \varepsilon\right)}^{5} - {x}^{5}\\
\mathbf{if}\;t\_0 \leq -4 \cdot 10^{-303}:\\
\;\;\;\;\left(\left(\varepsilon \cdot \varepsilon\right) \cdot \varepsilon\right) \cdot \left(\mathsf{fma}\left(6, x \cdot x, \varepsilon \cdot \left(\varepsilon + 5 \cdot x\right)\right) - -4 \cdot \left(x \cdot x\right)\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < -3.99999999999999972e-303

    1. Initial program 96.4%

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

      \[\leadsto \color{blue}{-1 \cdot \left({\varepsilon}^{5} \cdot \left(-1 \cdot \frac{x + \left(-1 \cdot \frac{-4 \cdot {x}^{2} + -1 \cdot \left(2 \cdot {x}^{2} + 4 \cdot {x}^{2}\right)}{\varepsilon} + 4 \cdot x\right)}{\varepsilon} - 1\right)\right)} \]
    4. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left({\varepsilon}^{5} \cdot \left(-1 \cdot \frac{x + \left(-1 \cdot \frac{-4 \cdot {x}^{2} + -1 \cdot \left(2 \cdot {x}^{2} + 4 \cdot {x}^{2}\right)}{\varepsilon} + 4 \cdot x\right)}{\varepsilon} - 1\right)\right) \]
      2. lower-neg.f64N/A

        \[\leadsto -{\varepsilon}^{5} \cdot \left(-1 \cdot \frac{x + \left(-1 \cdot \frac{-4 \cdot {x}^{2} + -1 \cdot \left(2 \cdot {x}^{2} + 4 \cdot {x}^{2}\right)}{\varepsilon} + 4 \cdot x\right)}{\varepsilon} - 1\right) \]
      3. *-commutativeN/A

        \[\leadsto -\left(-1 \cdot \frac{x + \left(-1 \cdot \frac{-4 \cdot {x}^{2} + -1 \cdot \left(2 \cdot {x}^{2} + 4 \cdot {x}^{2}\right)}{\varepsilon} + 4 \cdot x\right)}{\varepsilon} - 1\right) \cdot {\varepsilon}^{5} \]
      4. lower-*.f64N/A

        \[\leadsto -\left(-1 \cdot \frac{x + \left(-1 \cdot \frac{-4 \cdot {x}^{2} + -1 \cdot \left(2 \cdot {x}^{2} + 4 \cdot {x}^{2}\right)}{\varepsilon} + 4 \cdot x\right)}{\varepsilon} - 1\right) \cdot {\varepsilon}^{5} \]
    5. Applied rewrites95.6%

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

      \[\leadsto {\varepsilon}^{3} \cdot \color{blue}{\left(\left(6 \cdot {x}^{2} + \varepsilon \cdot \left(\varepsilon - -1 \cdot \left(x + 4 \cdot x\right)\right)\right) - -4 \cdot {x}^{2}\right)} \]
    7. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto {\varepsilon}^{3} \cdot \left(\left(6 \cdot {x}^{2} + \varepsilon \cdot \left(\varepsilon - -1 \cdot \left(x + 4 \cdot x\right)\right)\right) - \color{blue}{-4 \cdot {x}^{2}}\right) \]
      2. lower-pow.f64N/A

        \[\leadsto {\varepsilon}^{3} \cdot \left(\left(6 \cdot {x}^{2} + \varepsilon \cdot \left(\varepsilon - -1 \cdot \left(x + 4 \cdot x\right)\right)\right) - \color{blue}{-4} \cdot {x}^{2}\right) \]
      3. lower--.f64N/A

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

      \[\leadsto {\varepsilon}^{3} \cdot \color{blue}{\left(\mathsf{fma}\left(6, x \cdot x, \varepsilon \cdot \left(\varepsilon - \left(-5 \cdot x\right)\right)\right) - -4 \cdot \left(x \cdot x\right)\right)} \]
    9. Step-by-step derivation
      1. lift-pow.f64N/A

        \[\leadsto {\varepsilon}^{3} \cdot \left(\mathsf{fma}\left(6, x \cdot x, \varepsilon \cdot \left(\varepsilon - \left(-5 \cdot x\right)\right)\right) - \color{blue}{-4} \cdot \left(x \cdot x\right)\right) \]
      2. unpow3N/A

        \[\leadsto \left(\left(\varepsilon \cdot \varepsilon\right) \cdot \varepsilon\right) \cdot \left(\mathsf{fma}\left(6, x \cdot x, \varepsilon \cdot \left(\varepsilon - \left(-5 \cdot x\right)\right)\right) - \color{blue}{-4} \cdot \left(x \cdot x\right)\right) \]
      3. pow2N/A

        \[\leadsto \left({\varepsilon}^{2} \cdot \varepsilon\right) \cdot \left(\mathsf{fma}\left(6, x \cdot x, \varepsilon \cdot \left(\varepsilon - \left(-5 \cdot x\right)\right)\right) - -4 \cdot \left(x \cdot x\right)\right) \]
      4. lower-*.f64N/A

        \[\leadsto \left({\varepsilon}^{2} \cdot \varepsilon\right) \cdot \left(\mathsf{fma}\left(6, x \cdot x, \varepsilon \cdot \left(\varepsilon - \left(-5 \cdot x\right)\right)\right) - \color{blue}{-4} \cdot \left(x \cdot x\right)\right) \]
      5. pow2N/A

        \[\leadsto \left(\left(\varepsilon \cdot \varepsilon\right) \cdot \varepsilon\right) \cdot \left(\mathsf{fma}\left(6, x \cdot x, \varepsilon \cdot \left(\varepsilon - \left(-5 \cdot x\right)\right)\right) - -4 \cdot \left(x \cdot x\right)\right) \]
      6. lift-*.f6494.8

        \[\leadsto \left(\left(\varepsilon \cdot \varepsilon\right) \cdot \varepsilon\right) \cdot \left(\mathsf{fma}\left(6, x \cdot x, \varepsilon \cdot \left(\varepsilon - \left(-5 \cdot x\right)\right)\right) - -4 \cdot \left(x \cdot x\right)\right) \]
    10. Applied rewrites94.8%

      \[\leadsto \left(\left(\varepsilon \cdot \varepsilon\right) \cdot \varepsilon\right) \cdot \left(\mathsf{fma}\left(6, x \cdot x, \varepsilon \cdot \left(\varepsilon - \left(-5 \cdot x\right)\right)\right) - \color{blue}{-4} \cdot \left(x \cdot x\right)\right) \]

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

    1. Initial program 83.6%

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

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

        \[\leadsto \left(\varepsilon + 4 \cdot \varepsilon\right) \cdot \color{blue}{{x}^{4}} \]
      2. lower-*.f64N/A

        \[\leadsto \left(\varepsilon + 4 \cdot \varepsilon\right) \cdot \color{blue}{{x}^{4}} \]
      3. distribute-rgt1-inN/A

        \[\leadsto \left(\left(4 + 1\right) \cdot \varepsilon\right) \cdot {\color{blue}{x}}^{4} \]
      4. metadata-evalN/A

        \[\leadsto \left(5 \cdot \varepsilon\right) \cdot {x}^{4} \]
      5. lower-*.f64N/A

        \[\leadsto \left(5 \cdot \varepsilon\right) \cdot {\color{blue}{x}}^{4} \]
      6. lower-pow.f6499.9

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

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

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

    1. Initial program 96.1%

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

      \[\leadsto \color{blue}{{\varepsilon}^{5}} \]
    4. Step-by-step derivation
      1. lower-pow.f6487.0

        \[\leadsto {\varepsilon}^{\color{blue}{5}} \]
    5. Applied rewrites87.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;{\left(x + \varepsilon\right)}^{5} - {x}^{5} \leq -4 \cdot 10^{-303}:\\ \;\;\;\;\left(\left(\varepsilon \cdot \varepsilon\right) \cdot \varepsilon\right) \cdot \left(\mathsf{fma}\left(6, x \cdot x, \varepsilon \cdot \left(\varepsilon + 5 \cdot x\right)\right) - -4 \cdot \left(x \cdot x\right)\right)\\ \mathbf{elif}\;{\left(x + \varepsilon\right)}^{5} - {x}^{5} \leq 0:\\ \;\;\;\;\left(5 \cdot \varepsilon\right) \cdot {x}^{4}\\ \mathbf{else}:\\ \;\;\;\;{\varepsilon}^{5}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 98.4% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
t_0 := {\left(x + \varepsilon\right)}^{5} - {x}^{5}\\
\mathbf{if}\;t\_0 \leq -4 \cdot 10^{-303}:\\
\;\;\;\;\left(\left(\varepsilon \cdot \varepsilon\right) \cdot \varepsilon\right) \cdot \left(\mathsf{fma}\left(6, x \cdot x, \varepsilon \cdot \left(\varepsilon + 5 \cdot x\right)\right) - -4 \cdot \left(x \cdot x\right)\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < -3.99999999999999972e-303

    1. Initial program 96.4%

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

      \[\leadsto \color{blue}{-1 \cdot \left({\varepsilon}^{5} \cdot \left(-1 \cdot \frac{x + \left(-1 \cdot \frac{-4 \cdot {x}^{2} + -1 \cdot \left(2 \cdot {x}^{2} + 4 \cdot {x}^{2}\right)}{\varepsilon} + 4 \cdot x\right)}{\varepsilon} - 1\right)\right)} \]
    4. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left({\varepsilon}^{5} \cdot \left(-1 \cdot \frac{x + \left(-1 \cdot \frac{-4 \cdot {x}^{2} + -1 \cdot \left(2 \cdot {x}^{2} + 4 \cdot {x}^{2}\right)}{\varepsilon} + 4 \cdot x\right)}{\varepsilon} - 1\right)\right) \]
      2. lower-neg.f64N/A

        \[\leadsto -{\varepsilon}^{5} \cdot \left(-1 \cdot \frac{x + \left(-1 \cdot \frac{-4 \cdot {x}^{2} + -1 \cdot \left(2 \cdot {x}^{2} + 4 \cdot {x}^{2}\right)}{\varepsilon} + 4 \cdot x\right)}{\varepsilon} - 1\right) \]
      3. *-commutativeN/A

        \[\leadsto -\left(-1 \cdot \frac{x + \left(-1 \cdot \frac{-4 \cdot {x}^{2} + -1 \cdot \left(2 \cdot {x}^{2} + 4 \cdot {x}^{2}\right)}{\varepsilon} + 4 \cdot x\right)}{\varepsilon} - 1\right) \cdot {\varepsilon}^{5} \]
      4. lower-*.f64N/A

        \[\leadsto -\left(-1 \cdot \frac{x + \left(-1 \cdot \frac{-4 \cdot {x}^{2} + -1 \cdot \left(2 \cdot {x}^{2} + 4 \cdot {x}^{2}\right)}{\varepsilon} + 4 \cdot x\right)}{\varepsilon} - 1\right) \cdot {\varepsilon}^{5} \]
    5. Applied rewrites95.6%

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

      \[\leadsto {\varepsilon}^{3} \cdot \color{blue}{\left(\left(6 \cdot {x}^{2} + \varepsilon \cdot \left(\varepsilon - -1 \cdot \left(x + 4 \cdot x\right)\right)\right) - -4 \cdot {x}^{2}\right)} \]
    7. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto {\varepsilon}^{3} \cdot \left(\left(6 \cdot {x}^{2} + \varepsilon \cdot \left(\varepsilon - -1 \cdot \left(x + 4 \cdot x\right)\right)\right) - \color{blue}{-4 \cdot {x}^{2}}\right) \]
      2. lower-pow.f64N/A

        \[\leadsto {\varepsilon}^{3} \cdot \left(\left(6 \cdot {x}^{2} + \varepsilon \cdot \left(\varepsilon - -1 \cdot \left(x + 4 \cdot x\right)\right)\right) - \color{blue}{-4} \cdot {x}^{2}\right) \]
      3. lower--.f64N/A

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

      \[\leadsto {\varepsilon}^{3} \cdot \color{blue}{\left(\mathsf{fma}\left(6, x \cdot x, \varepsilon \cdot \left(\varepsilon - \left(-5 \cdot x\right)\right)\right) - -4 \cdot \left(x \cdot x\right)\right)} \]
    9. Step-by-step derivation
      1. lift-pow.f64N/A

        \[\leadsto {\varepsilon}^{3} \cdot \left(\mathsf{fma}\left(6, x \cdot x, \varepsilon \cdot \left(\varepsilon - \left(-5 \cdot x\right)\right)\right) - \color{blue}{-4} \cdot \left(x \cdot x\right)\right) \]
      2. unpow3N/A

        \[\leadsto \left(\left(\varepsilon \cdot \varepsilon\right) \cdot \varepsilon\right) \cdot \left(\mathsf{fma}\left(6, x \cdot x, \varepsilon \cdot \left(\varepsilon - \left(-5 \cdot x\right)\right)\right) - \color{blue}{-4} \cdot \left(x \cdot x\right)\right) \]
      3. pow2N/A

        \[\leadsto \left({\varepsilon}^{2} \cdot \varepsilon\right) \cdot \left(\mathsf{fma}\left(6, x \cdot x, \varepsilon \cdot \left(\varepsilon - \left(-5 \cdot x\right)\right)\right) - -4 \cdot \left(x \cdot x\right)\right) \]
      4. lower-*.f64N/A

        \[\leadsto \left({\varepsilon}^{2} \cdot \varepsilon\right) \cdot \left(\mathsf{fma}\left(6, x \cdot x, \varepsilon \cdot \left(\varepsilon - \left(-5 \cdot x\right)\right)\right) - \color{blue}{-4} \cdot \left(x \cdot x\right)\right) \]
      5. pow2N/A

        \[\leadsto \left(\left(\varepsilon \cdot \varepsilon\right) \cdot \varepsilon\right) \cdot \left(\mathsf{fma}\left(6, x \cdot x, \varepsilon \cdot \left(\varepsilon - \left(-5 \cdot x\right)\right)\right) - -4 \cdot \left(x \cdot x\right)\right) \]
      6. lift-*.f6494.8

        \[\leadsto \left(\left(\varepsilon \cdot \varepsilon\right) \cdot \varepsilon\right) \cdot \left(\mathsf{fma}\left(6, x \cdot x, \varepsilon \cdot \left(\varepsilon - \left(-5 \cdot x\right)\right)\right) - -4 \cdot \left(x \cdot x\right)\right) \]
    10. Applied rewrites94.8%

      \[\leadsto \left(\left(\varepsilon \cdot \varepsilon\right) \cdot \varepsilon\right) \cdot \left(\mathsf{fma}\left(6, x \cdot x, \varepsilon \cdot \left(\varepsilon - \left(-5 \cdot x\right)\right)\right) - \color{blue}{-4} \cdot \left(x \cdot x\right)\right) \]

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

    1. Initial program 83.6%

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

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

        \[\leadsto \left(4 \cdot {x}^{4} + \left(\varepsilon \cdot \left(4 \cdot {x}^{3} + x \cdot \left(2 \cdot {x}^{2} + 4 \cdot {x}^{2}\right)\right) + {x}^{4}\right)\right) \cdot \color{blue}{\varepsilon} \]
      2. lower-*.f64N/A

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

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

      \[\leadsto {x}^{3} \cdot \color{blue}{\left(5 \cdot \left(\varepsilon \cdot x\right) + 10 \cdot {\varepsilon}^{2}\right)} \]
    7. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto {x}^{3} \cdot \left(5 \cdot \left(\varepsilon \cdot x\right) + \color{blue}{10 \cdot {\varepsilon}^{2}}\right) \]
      2. lift-pow.f64N/A

        \[\leadsto {x}^{3} \cdot \left(5 \cdot \left(\varepsilon \cdot x\right) + \color{blue}{10} \cdot {\varepsilon}^{2}\right) \]
      3. lower-fma.f64N/A

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

        \[\leadsto {x}^{3} \cdot \mathsf{fma}\left(5, \varepsilon \cdot x, 10 \cdot {\varepsilon}^{2}\right) \]
      5. lower-*.f64N/A

        \[\leadsto {x}^{3} \cdot \mathsf{fma}\left(5, \varepsilon \cdot x, 10 \cdot {\varepsilon}^{2}\right) \]
      6. unpow2N/A

        \[\leadsto {x}^{3} \cdot \mathsf{fma}\left(5, \varepsilon \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \]
      7. lower-*.f6499.9

        \[\leadsto {x}^{3} \cdot \mathsf{fma}\left(5, \varepsilon \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \]
    8. Applied rewrites99.9%

      \[\leadsto {x}^{3} \cdot \color{blue}{\mathsf{fma}\left(5, \varepsilon \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right)} \]
    9. Step-by-step derivation
      1. lift-pow.f64N/A

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

        \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \mathsf{fma}\left(5, \color{blue}{\varepsilon} \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \]
      3. pow2N/A

        \[\leadsto \left({x}^{2} \cdot x\right) \cdot \mathsf{fma}\left(5, \varepsilon \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \]
      4. lower-*.f64N/A

        \[\leadsto \left({x}^{2} \cdot x\right) \cdot \mathsf{fma}\left(5, \color{blue}{\varepsilon} \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \]
      5. pow2N/A

        \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \mathsf{fma}\left(5, \varepsilon \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \]
      6. lower-*.f6499.9

        \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \mathsf{fma}\left(5, \varepsilon \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \]
    10. Applied rewrites99.9%

      \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \mathsf{fma}\left(5, \color{blue}{\varepsilon} \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \]
    11. Taylor expanded in x around inf

      \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \left(5 \cdot \left(\varepsilon \cdot \color{blue}{x}\right)\right) \]
    12. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(\varepsilon \cdot x\right) \cdot 5\right) \]
      2. lower-*.f64N/A

        \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(\varepsilon \cdot x\right) \cdot 5\right) \]
      3. lift-*.f6499.9

        \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(\varepsilon \cdot x\right) \cdot 5\right) \]
    13. Applied rewrites99.9%

      \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(\varepsilon \cdot x\right) \cdot 5\right) \]

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

    1. Initial program 96.1%

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

      \[\leadsto \color{blue}{{\varepsilon}^{5}} \]
    4. Step-by-step derivation
      1. lower-pow.f6487.0

        \[\leadsto {\varepsilon}^{\color{blue}{5}} \]
    5. Applied rewrites87.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;{\left(x + \varepsilon\right)}^{5} - {x}^{5} \leq -4 \cdot 10^{-303}:\\ \;\;\;\;\left(\left(\varepsilon \cdot \varepsilon\right) \cdot \varepsilon\right) \cdot \left(\mathsf{fma}\left(6, x \cdot x, \varepsilon \cdot \left(\varepsilon + 5 \cdot x\right)\right) - -4 \cdot \left(x \cdot x\right)\right)\\ \mathbf{elif}\;{\left(x + \varepsilon\right)}^{5} - {x}^{5} \leq 0:\\ \;\;\;\;\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(\varepsilon \cdot x\right) \cdot 5\right)\\ \mathbf{else}:\\ \;\;\;\;{\varepsilon}^{5}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 98.5% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := {\left(x + \varepsilon\right)}^{5} - {x}^{5}\\ \mathbf{if}\;t\_0 \leq -4 \cdot 10^{-303} \lor \neg \left(t\_0 \leq 0\right):\\ \;\;\;\;\left(\left(\varepsilon \cdot \varepsilon\right) \cdot \varepsilon\right) \cdot \left(\mathsf{fma}\left(6, x \cdot x, \varepsilon \cdot \left(\varepsilon + 5 \cdot x\right)\right) - -4 \cdot \left(x \cdot x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(\varepsilon \cdot x\right) \cdot 5\right)\\ \end{array} \end{array} \]
(FPCore (x eps)
 :precision binary64
 (let* ((t_0 (- (pow (+ x eps) 5.0) (pow x 5.0))))
   (if (or (<= t_0 -4e-303) (not (<= t_0 0.0)))
     (*
      (* (* eps eps) eps)
      (- (fma 6.0 (* x x) (* eps (+ eps (* 5.0 x)))) (* -4.0 (* x x))))
     (* (* (* x x) x) (* (* eps x) 5.0)))))
double code(double x, double eps) {
	double t_0 = pow((x + eps), 5.0) - pow(x, 5.0);
	double tmp;
	if ((t_0 <= -4e-303) || !(t_0 <= 0.0)) {
		tmp = ((eps * eps) * eps) * (fma(6.0, (x * x), (eps * (eps + (5.0 * x)))) - (-4.0 * (x * x)));
	} else {
		tmp = ((x * x) * x) * ((eps * x) * 5.0);
	}
	return tmp;
}
function code(x, eps)
	t_0 = Float64((Float64(x + eps) ^ 5.0) - (x ^ 5.0))
	tmp = 0.0
	if ((t_0 <= -4e-303) || !(t_0 <= 0.0))
		tmp = Float64(Float64(Float64(eps * eps) * eps) * Float64(fma(6.0, Float64(x * x), Float64(eps * Float64(eps + Float64(5.0 * x)))) - Float64(-4.0 * Float64(x * x))));
	else
		tmp = Float64(Float64(Float64(x * x) * x) * Float64(Float64(eps * x) * 5.0));
	end
	return 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[Or[LessEqual[t$95$0, -4e-303], N[Not[LessEqual[t$95$0, 0.0]], $MachinePrecision]], N[(N[(N[(eps * eps), $MachinePrecision] * eps), $MachinePrecision] * N[(N[(6.0 * N[(x * x), $MachinePrecision] + N[(eps * N[(eps + N[(5.0 * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(-4.0 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * N[(N[(eps * x), $MachinePrecision] * 5.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := {\left(x + \varepsilon\right)}^{5} - {x}^{5}\\
\mathbf{if}\;t\_0 \leq -4 \cdot 10^{-303} \lor \neg \left(t\_0 \leq 0\right):\\
\;\;\;\;\left(\left(\varepsilon \cdot \varepsilon\right) \cdot \varepsilon\right) \cdot \left(\mathsf{fma}\left(6, x \cdot x, \varepsilon \cdot \left(\varepsilon + 5 \cdot x\right)\right) - -4 \cdot \left(x \cdot x\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < -3.99999999999999972e-303 or 0.0 < (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64)))

    1. Initial program 96.2%

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

      \[\leadsto \color{blue}{-1 \cdot \left({\varepsilon}^{5} \cdot \left(-1 \cdot \frac{x + \left(-1 \cdot \frac{-4 \cdot {x}^{2} + -1 \cdot \left(2 \cdot {x}^{2} + 4 \cdot {x}^{2}\right)}{\varepsilon} + 4 \cdot x\right)}{\varepsilon} - 1\right)\right)} \]
    4. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \mathsf{neg}\left({\varepsilon}^{5} \cdot \left(-1 \cdot \frac{x + \left(-1 \cdot \frac{-4 \cdot {x}^{2} + -1 \cdot \left(2 \cdot {x}^{2} + 4 \cdot {x}^{2}\right)}{\varepsilon} + 4 \cdot x\right)}{\varepsilon} - 1\right)\right) \]
      2. lower-neg.f64N/A

        \[\leadsto -{\varepsilon}^{5} \cdot \left(-1 \cdot \frac{x + \left(-1 \cdot \frac{-4 \cdot {x}^{2} + -1 \cdot \left(2 \cdot {x}^{2} + 4 \cdot {x}^{2}\right)}{\varepsilon} + 4 \cdot x\right)}{\varepsilon} - 1\right) \]
      3. *-commutativeN/A

        \[\leadsto -\left(-1 \cdot \frac{x + \left(-1 \cdot \frac{-4 \cdot {x}^{2} + -1 \cdot \left(2 \cdot {x}^{2} + 4 \cdot {x}^{2}\right)}{\varepsilon} + 4 \cdot x\right)}{\varepsilon} - 1\right) \cdot {\varepsilon}^{5} \]
      4. lower-*.f64N/A

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

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

      \[\leadsto {\varepsilon}^{3} \cdot \color{blue}{\left(\left(6 \cdot {x}^{2} + \varepsilon \cdot \left(\varepsilon - -1 \cdot \left(x + 4 \cdot x\right)\right)\right) - -4 \cdot {x}^{2}\right)} \]
    7. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto {\varepsilon}^{3} \cdot \left(\left(6 \cdot {x}^{2} + \varepsilon \cdot \left(\varepsilon - -1 \cdot \left(x + 4 \cdot x\right)\right)\right) - \color{blue}{-4 \cdot {x}^{2}}\right) \]
      2. lower-pow.f64N/A

        \[\leadsto {\varepsilon}^{3} \cdot \left(\left(6 \cdot {x}^{2} + \varepsilon \cdot \left(\varepsilon - -1 \cdot \left(x + 4 \cdot x\right)\right)\right) - \color{blue}{-4} \cdot {x}^{2}\right) \]
      3. lower--.f64N/A

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

      \[\leadsto {\varepsilon}^{3} \cdot \color{blue}{\left(\mathsf{fma}\left(6, x \cdot x, \varepsilon \cdot \left(\varepsilon - \left(-5 \cdot x\right)\right)\right) - -4 \cdot \left(x \cdot x\right)\right)} \]
    9. Step-by-step derivation
      1. lift-pow.f64N/A

        \[\leadsto {\varepsilon}^{3} \cdot \left(\mathsf{fma}\left(6, x \cdot x, \varepsilon \cdot \left(\varepsilon - \left(-5 \cdot x\right)\right)\right) - \color{blue}{-4} \cdot \left(x \cdot x\right)\right) \]
      2. unpow3N/A

        \[\leadsto \left(\left(\varepsilon \cdot \varepsilon\right) \cdot \varepsilon\right) \cdot \left(\mathsf{fma}\left(6, x \cdot x, \varepsilon \cdot \left(\varepsilon - \left(-5 \cdot x\right)\right)\right) - \color{blue}{-4} \cdot \left(x \cdot x\right)\right) \]
      3. pow2N/A

        \[\leadsto \left({\varepsilon}^{2} \cdot \varepsilon\right) \cdot \left(\mathsf{fma}\left(6, x \cdot x, \varepsilon \cdot \left(\varepsilon - \left(-5 \cdot x\right)\right)\right) - -4 \cdot \left(x \cdot x\right)\right) \]
      4. lower-*.f64N/A

        \[\leadsto \left({\varepsilon}^{2} \cdot \varepsilon\right) \cdot \left(\mathsf{fma}\left(6, x \cdot x, \varepsilon \cdot \left(\varepsilon - \left(-5 \cdot x\right)\right)\right) - \color{blue}{-4} \cdot \left(x \cdot x\right)\right) \]
      5. pow2N/A

        \[\leadsto \left(\left(\varepsilon \cdot \varepsilon\right) \cdot \varepsilon\right) \cdot \left(\mathsf{fma}\left(6, x \cdot x, \varepsilon \cdot \left(\varepsilon - \left(-5 \cdot x\right)\right)\right) - -4 \cdot \left(x \cdot x\right)\right) \]
      6. lift-*.f6490.7

        \[\leadsto \left(\left(\varepsilon \cdot \varepsilon\right) \cdot \varepsilon\right) \cdot \left(\mathsf{fma}\left(6, x \cdot x, \varepsilon \cdot \left(\varepsilon - \left(-5 \cdot x\right)\right)\right) - -4 \cdot \left(x \cdot x\right)\right) \]
    10. Applied rewrites90.7%

      \[\leadsto \left(\left(\varepsilon \cdot \varepsilon\right) \cdot \varepsilon\right) \cdot \left(\mathsf{fma}\left(6, x \cdot x, \varepsilon \cdot \left(\varepsilon - \left(-5 \cdot x\right)\right)\right) - \color{blue}{-4} \cdot \left(x \cdot x\right)\right) \]

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

    1. Initial program 83.6%

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

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

        \[\leadsto \left(4 \cdot {x}^{4} + \left(\varepsilon \cdot \left(4 \cdot {x}^{3} + x \cdot \left(2 \cdot {x}^{2} + 4 \cdot {x}^{2}\right)\right) + {x}^{4}\right)\right) \cdot \color{blue}{\varepsilon} \]
      2. lower-*.f64N/A

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

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

      \[\leadsto {x}^{3} \cdot \color{blue}{\left(5 \cdot \left(\varepsilon \cdot x\right) + 10 \cdot {\varepsilon}^{2}\right)} \]
    7. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto {x}^{3} \cdot \left(5 \cdot \left(\varepsilon \cdot x\right) + \color{blue}{10 \cdot {\varepsilon}^{2}}\right) \]
      2. lift-pow.f64N/A

        \[\leadsto {x}^{3} \cdot \left(5 \cdot \left(\varepsilon \cdot x\right) + \color{blue}{10} \cdot {\varepsilon}^{2}\right) \]
      3. lower-fma.f64N/A

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

        \[\leadsto {x}^{3} \cdot \mathsf{fma}\left(5, \varepsilon \cdot x, 10 \cdot {\varepsilon}^{2}\right) \]
      5. lower-*.f64N/A

        \[\leadsto {x}^{3} \cdot \mathsf{fma}\left(5, \varepsilon \cdot x, 10 \cdot {\varepsilon}^{2}\right) \]
      6. unpow2N/A

        \[\leadsto {x}^{3} \cdot \mathsf{fma}\left(5, \varepsilon \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \]
      7. lower-*.f6499.9

        \[\leadsto {x}^{3} \cdot \mathsf{fma}\left(5, \varepsilon \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \]
    8. Applied rewrites99.9%

      \[\leadsto {x}^{3} \cdot \color{blue}{\mathsf{fma}\left(5, \varepsilon \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right)} \]
    9. Step-by-step derivation
      1. lift-pow.f64N/A

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

        \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \mathsf{fma}\left(5, \color{blue}{\varepsilon} \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \]
      3. pow2N/A

        \[\leadsto \left({x}^{2} \cdot x\right) \cdot \mathsf{fma}\left(5, \varepsilon \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \]
      4. lower-*.f64N/A

        \[\leadsto \left({x}^{2} \cdot x\right) \cdot \mathsf{fma}\left(5, \color{blue}{\varepsilon} \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \]
      5. pow2N/A

        \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \mathsf{fma}\left(5, \varepsilon \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \]
      6. lower-*.f6499.9

        \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \mathsf{fma}\left(5, \varepsilon \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \]
    10. Applied rewrites99.9%

      \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \mathsf{fma}\left(5, \color{blue}{\varepsilon} \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \]
    11. Taylor expanded in x around inf

      \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \left(5 \cdot \left(\varepsilon \cdot \color{blue}{x}\right)\right) \]
    12. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(\varepsilon \cdot x\right) \cdot 5\right) \]
      2. lower-*.f64N/A

        \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(\varepsilon \cdot x\right) \cdot 5\right) \]
      3. lift-*.f6499.9

        \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(\varepsilon \cdot x\right) \cdot 5\right) \]
    13. Applied rewrites99.9%

      \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(\varepsilon \cdot x\right) \cdot 5\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;{\left(x + \varepsilon\right)}^{5} - {x}^{5} \leq -4 \cdot 10^{-303} \lor \neg \left({\left(x + \varepsilon\right)}^{5} - {x}^{5} \leq 0\right):\\ \;\;\;\;\left(\left(\varepsilon \cdot \varepsilon\right) \cdot \varepsilon\right) \cdot \left(\mathsf{fma}\left(6, x \cdot x, \varepsilon \cdot \left(\varepsilon + 5 \cdot x\right)\right) - -4 \cdot \left(x \cdot x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(\varepsilon \cdot x\right) \cdot 5\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 82.5% accurate, 5.6× speedup?

\[\begin{array}{l} \\ \left(\left(x \cdot x\right) \cdot x\right) \cdot \mathsf{fma}\left(5, \varepsilon \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \end{array} \]
(FPCore (x eps)
 :precision binary64
 (* (* (* x x) x) (fma 5.0 (* eps x) (* 10.0 (* eps eps)))))
double code(double x, double eps) {
	return ((x * x) * x) * fma(5.0, (eps * x), (10.0 * (eps * eps)));
}
function code(x, eps)
	return Float64(Float64(Float64(x * x) * x) * fma(5.0, Float64(eps * x), Float64(10.0 * Float64(eps * eps))))
end
code[x_, eps_] := N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * N[(5.0 * N[(eps * x), $MachinePrecision] + N[(10.0 * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(\left(x \cdot x\right) \cdot x\right) \cdot \mathsf{fma}\left(5, \varepsilon \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right)
\end{array}
Derivation
  1. Initial program 85.7%

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

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

      \[\leadsto \left(4 \cdot {x}^{4} + \left(\varepsilon \cdot \left(4 \cdot {x}^{3} + x \cdot \left(2 \cdot {x}^{2} + 4 \cdot {x}^{2}\right)\right) + {x}^{4}\right)\right) \cdot \color{blue}{\varepsilon} \]
    2. lower-*.f64N/A

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

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

    \[\leadsto {x}^{3} \cdot \color{blue}{\left(5 \cdot \left(\varepsilon \cdot x\right) + 10 \cdot {\varepsilon}^{2}\right)} \]
  7. Step-by-step derivation
    1. lower-*.f64N/A

      \[\leadsto {x}^{3} \cdot \left(5 \cdot \left(\varepsilon \cdot x\right) + \color{blue}{10 \cdot {\varepsilon}^{2}}\right) \]
    2. lift-pow.f64N/A

      \[\leadsto {x}^{3} \cdot \left(5 \cdot \left(\varepsilon \cdot x\right) + \color{blue}{10} \cdot {\varepsilon}^{2}\right) \]
    3. lower-fma.f64N/A

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

      \[\leadsto {x}^{3} \cdot \mathsf{fma}\left(5, \varepsilon \cdot x, 10 \cdot {\varepsilon}^{2}\right) \]
    5. lower-*.f64N/A

      \[\leadsto {x}^{3} \cdot \mathsf{fma}\left(5, \varepsilon \cdot x, 10 \cdot {\varepsilon}^{2}\right) \]
    6. unpow2N/A

      \[\leadsto {x}^{3} \cdot \mathsf{fma}\left(5, \varepsilon \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \]
    7. lower-*.f6485.7

      \[\leadsto {x}^{3} \cdot \mathsf{fma}\left(5, \varepsilon \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \]
  8. Applied rewrites85.7%

    \[\leadsto {x}^{3} \cdot \color{blue}{\mathsf{fma}\left(5, \varepsilon \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right)} \]
  9. Step-by-step derivation
    1. lift-pow.f64N/A

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

      \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \mathsf{fma}\left(5, \color{blue}{\varepsilon} \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \]
    3. pow2N/A

      \[\leadsto \left({x}^{2} \cdot x\right) \cdot \mathsf{fma}\left(5, \varepsilon \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \]
    4. lower-*.f64N/A

      \[\leadsto \left({x}^{2} \cdot x\right) \cdot \mathsf{fma}\left(5, \color{blue}{\varepsilon} \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \]
    5. pow2N/A

      \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \mathsf{fma}\left(5, \varepsilon \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \]
    6. lower-*.f6485.7

      \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \mathsf{fma}\left(5, \varepsilon \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \]
  10. Applied rewrites85.7%

    \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \mathsf{fma}\left(5, \color{blue}{\varepsilon} \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \]
  11. Add Preprocessing

Alternative 10: 82.5% accurate, 6.5× speedup?

\[\begin{array}{l} \\ \left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\mathsf{fma}\left(10, \varepsilon, 5 \cdot x\right) \cdot \varepsilon\right) \end{array} \]
(FPCore (x eps)
 :precision binary64
 (* (* (* x x) x) (* (fma 10.0 eps (* 5.0 x)) eps)))
double code(double x, double eps) {
	return ((x * x) * x) * (fma(10.0, eps, (5.0 * x)) * eps);
}
function code(x, eps)
	return Float64(Float64(Float64(x * x) * x) * Float64(fma(10.0, eps, Float64(5.0 * x)) * eps))
end
code[x_, eps_] := N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * N[(N[(10.0 * eps + N[(5.0 * x), $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\mathsf{fma}\left(10, \varepsilon, 5 \cdot x\right) \cdot \varepsilon\right)
\end{array}
Derivation
  1. Initial program 85.7%

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

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

      \[\leadsto \left(4 \cdot {x}^{4} + \left(\varepsilon \cdot \left(4 \cdot {x}^{3} + x \cdot \left(2 \cdot {x}^{2} + 4 \cdot {x}^{2}\right)\right) + {x}^{4}\right)\right) \cdot \color{blue}{\varepsilon} \]
    2. lower-*.f64N/A

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

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

    \[\leadsto {x}^{3} \cdot \color{blue}{\left(5 \cdot \left(\varepsilon \cdot x\right) + 10 \cdot {\varepsilon}^{2}\right)} \]
  7. Step-by-step derivation
    1. lower-*.f64N/A

      \[\leadsto {x}^{3} \cdot \left(5 \cdot \left(\varepsilon \cdot x\right) + \color{blue}{10 \cdot {\varepsilon}^{2}}\right) \]
    2. lift-pow.f64N/A

      \[\leadsto {x}^{3} \cdot \left(5 \cdot \left(\varepsilon \cdot x\right) + \color{blue}{10} \cdot {\varepsilon}^{2}\right) \]
    3. lower-fma.f64N/A

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

      \[\leadsto {x}^{3} \cdot \mathsf{fma}\left(5, \varepsilon \cdot x, 10 \cdot {\varepsilon}^{2}\right) \]
    5. lower-*.f64N/A

      \[\leadsto {x}^{3} \cdot \mathsf{fma}\left(5, \varepsilon \cdot x, 10 \cdot {\varepsilon}^{2}\right) \]
    6. unpow2N/A

      \[\leadsto {x}^{3} \cdot \mathsf{fma}\left(5, \varepsilon \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \]
    7. lower-*.f6485.7

      \[\leadsto {x}^{3} \cdot \mathsf{fma}\left(5, \varepsilon \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \]
  8. Applied rewrites85.7%

    \[\leadsto {x}^{3} \cdot \color{blue}{\mathsf{fma}\left(5, \varepsilon \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right)} \]
  9. Step-by-step derivation
    1. lift-pow.f64N/A

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

      \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \mathsf{fma}\left(5, \color{blue}{\varepsilon} \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \]
    3. pow2N/A

      \[\leadsto \left({x}^{2} \cdot x\right) \cdot \mathsf{fma}\left(5, \varepsilon \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \]
    4. lower-*.f64N/A

      \[\leadsto \left({x}^{2} \cdot x\right) \cdot \mathsf{fma}\left(5, \color{blue}{\varepsilon} \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \]
    5. pow2N/A

      \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \mathsf{fma}\left(5, \varepsilon \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \]
    6. lower-*.f6485.7

      \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \mathsf{fma}\left(5, \varepsilon \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \]
  10. Applied rewrites85.7%

    \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \mathsf{fma}\left(5, \color{blue}{\varepsilon} \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \]
  11. Taylor expanded in eps around 0

    \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\varepsilon \cdot \left(5 \cdot x + \color{blue}{10 \cdot \varepsilon}\right)\right) \]
  12. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(5 \cdot x + 10 \cdot \varepsilon\right) \cdot \varepsilon\right) \]
    2. lower-*.f64N/A

      \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(5 \cdot x + 10 \cdot \varepsilon\right) \cdot \varepsilon\right) \]
    3. +-commutativeN/A

      \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(10 \cdot \varepsilon + 5 \cdot x\right) \cdot \varepsilon\right) \]
    4. lower-fma.f64N/A

      \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\mathsf{fma}\left(10, \varepsilon, 5 \cdot x\right) \cdot \varepsilon\right) \]
    5. lift-*.f6485.6

      \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\mathsf{fma}\left(10, \varepsilon, 5 \cdot x\right) \cdot \varepsilon\right) \]
  13. Applied rewrites85.6%

    \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\mathsf{fma}\left(10, \varepsilon, 5 \cdot x\right) \cdot \varepsilon\right) \]
  14. Add Preprocessing

Alternative 11: 82.3% accurate, 8.0× speedup?

\[\begin{array}{l} \\ \left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(\varepsilon \cdot x\right) \cdot 5\right) \end{array} \]
(FPCore (x eps) :precision binary64 (* (* (* x x) x) (* (* eps x) 5.0)))
double code(double x, double eps) {
	return ((x * x) * x) * ((eps * x) * 5.0);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

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

\\
\left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(\varepsilon \cdot x\right) \cdot 5\right)
\end{array}
Derivation
  1. Initial program 85.7%

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

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

      \[\leadsto \left(4 \cdot {x}^{4} + \left(\varepsilon \cdot \left(4 \cdot {x}^{3} + x \cdot \left(2 \cdot {x}^{2} + 4 \cdot {x}^{2}\right)\right) + {x}^{4}\right)\right) \cdot \color{blue}{\varepsilon} \]
    2. lower-*.f64N/A

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

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

    \[\leadsto {x}^{3} \cdot \color{blue}{\left(5 \cdot \left(\varepsilon \cdot x\right) + 10 \cdot {\varepsilon}^{2}\right)} \]
  7. Step-by-step derivation
    1. lower-*.f64N/A

      \[\leadsto {x}^{3} \cdot \left(5 \cdot \left(\varepsilon \cdot x\right) + \color{blue}{10 \cdot {\varepsilon}^{2}}\right) \]
    2. lift-pow.f64N/A

      \[\leadsto {x}^{3} \cdot \left(5 \cdot \left(\varepsilon \cdot x\right) + \color{blue}{10} \cdot {\varepsilon}^{2}\right) \]
    3. lower-fma.f64N/A

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

      \[\leadsto {x}^{3} \cdot \mathsf{fma}\left(5, \varepsilon \cdot x, 10 \cdot {\varepsilon}^{2}\right) \]
    5. lower-*.f64N/A

      \[\leadsto {x}^{3} \cdot \mathsf{fma}\left(5, \varepsilon \cdot x, 10 \cdot {\varepsilon}^{2}\right) \]
    6. unpow2N/A

      \[\leadsto {x}^{3} \cdot \mathsf{fma}\left(5, \varepsilon \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \]
    7. lower-*.f6485.7

      \[\leadsto {x}^{3} \cdot \mathsf{fma}\left(5, \varepsilon \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \]
  8. Applied rewrites85.7%

    \[\leadsto {x}^{3} \cdot \color{blue}{\mathsf{fma}\left(5, \varepsilon \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right)} \]
  9. Step-by-step derivation
    1. lift-pow.f64N/A

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

      \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \mathsf{fma}\left(5, \color{blue}{\varepsilon} \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \]
    3. pow2N/A

      \[\leadsto \left({x}^{2} \cdot x\right) \cdot \mathsf{fma}\left(5, \varepsilon \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \]
    4. lower-*.f64N/A

      \[\leadsto \left({x}^{2} \cdot x\right) \cdot \mathsf{fma}\left(5, \color{blue}{\varepsilon} \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \]
    5. pow2N/A

      \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \mathsf{fma}\left(5, \varepsilon \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \]
    6. lower-*.f6485.7

      \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \mathsf{fma}\left(5, \varepsilon \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \]
  10. Applied rewrites85.7%

    \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \mathsf{fma}\left(5, \color{blue}{\varepsilon} \cdot x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \]
  11. Taylor expanded in x around inf

    \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \left(5 \cdot \left(\varepsilon \cdot \color{blue}{x}\right)\right) \]
  12. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(\varepsilon \cdot x\right) \cdot 5\right) \]
    2. lower-*.f64N/A

      \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(\varepsilon \cdot x\right) \cdot 5\right) \]
    3. lift-*.f6485.5

      \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(\varepsilon \cdot x\right) \cdot 5\right) \]
  13. Applied rewrites85.5%

    \[\leadsto \left(\left(x \cdot x\right) \cdot x\right) \cdot \left(\left(\varepsilon \cdot x\right) \cdot 5\right) \]
  14. Add Preprocessing

Alternative 12: 82.3% accurate, 8.0× speedup?

\[\begin{array}{l} \\ 5 \cdot \left(\varepsilon \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)\right) \end{array} \]
(FPCore (x eps) :precision binary64 (* 5.0 (* eps (* (* x x) (* x x)))))
double code(double x, double eps) {
	return 5.0 * (eps * ((x * x) * (x * x)));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

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

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

\\
5 \cdot \left(\varepsilon \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)\right)
\end{array}
Derivation
  1. Initial program 85.7%

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

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

      \[\leadsto \left(4 \cdot {x}^{4} + \left(\varepsilon \cdot \left(4 \cdot {x}^{3} + x \cdot \left(2 \cdot {x}^{2} + 4 \cdot {x}^{2}\right)\right) + {x}^{4}\right)\right) \cdot \color{blue}{\varepsilon} \]
    2. lower-*.f64N/A

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

    \[\leadsto \color{blue}{\mathsf{fma}\left({x}^{4}, 4, \mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 6, x, {x}^{3} \cdot 4\right), \varepsilon, {x}^{4}\right)\right) \cdot \varepsilon} \]
  6. Taylor expanded in x around inf

    \[\leadsto 5 \cdot \color{blue}{\left(\varepsilon \cdot {x}^{4}\right)} \]
  7. Step-by-step derivation
    1. lower-*.f64N/A

      \[\leadsto 5 \cdot \left(\varepsilon \cdot \color{blue}{{x}^{4}}\right) \]
    2. lower-*.f64N/A

      \[\leadsto 5 \cdot \left(\varepsilon \cdot {x}^{\color{blue}{4}}\right) \]
    3. lift-pow.f6485.4

      \[\leadsto 5 \cdot \left(\varepsilon \cdot {x}^{4}\right) \]
  8. Applied rewrites85.4%

    \[\leadsto 5 \cdot \color{blue}{\left(\varepsilon \cdot {x}^{4}\right)} \]
  9. Step-by-step derivation
    1. lift-pow.f64N/A

      \[\leadsto 5 \cdot \left(\varepsilon \cdot {x}^{4}\right) \]
    2. sqr-powN/A

      \[\leadsto 5 \cdot \left(\varepsilon \cdot \left({x}^{\left(\frac{4}{2}\right)} \cdot {x}^{\color{blue}{\left(\frac{4}{2}\right)}}\right)\right) \]
    3. metadata-evalN/A

      \[\leadsto 5 \cdot \left(\varepsilon \cdot \left({x}^{2} \cdot {x}^{\left(\frac{4}{2}\right)}\right)\right) \]
    4. metadata-evalN/A

      \[\leadsto 5 \cdot \left(\varepsilon \cdot \left({x}^{2} \cdot {x}^{2}\right)\right) \]
    5. lower-*.f64N/A

      \[\leadsto 5 \cdot \left(\varepsilon \cdot \left({x}^{2} \cdot {x}^{\color{blue}{2}}\right)\right) \]
    6. pow2N/A

      \[\leadsto 5 \cdot \left(\varepsilon \cdot \left(\left(x \cdot x\right) \cdot {x}^{2}\right)\right) \]
    7. lower-*.f64N/A

      \[\leadsto 5 \cdot \left(\varepsilon \cdot \left(\left(x \cdot x\right) \cdot {x}^{2}\right)\right) \]
    8. pow2N/A

      \[\leadsto 5 \cdot \left(\varepsilon \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)\right) \]
    9. lower-*.f6485.4

      \[\leadsto 5 \cdot \left(\varepsilon \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)\right) \]
  10. Applied rewrites85.4%

    \[\leadsto 5 \cdot \left(\varepsilon \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot \color{blue}{x}\right)\right)\right) \]
  11. Add Preprocessing

Reproduce

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