Graphics.Rasterific.CubicBezier:cachedBezierAt from Rasterific-0.6.1

Percentage Accurate: 92.6% → 93.9%
Time: 2.4s
Alternatives: 13
Speedup: 1.1×

Specification

?
\[\begin{array}{l} \\ \left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (+ (+ (+ x (* y z)) (* t a)) (* (* a z) b)))
double code(double x, double y, double z, double t, double a, double b) {
	return ((x + (y * z)) + (t * a)) + ((a * z) * b);
}
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, y, z, t, a, b)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = ((x + (y * z)) + (t * a)) + ((a * z) * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	return ((x + (y * z)) + (t * a)) + ((a * z) * b);
}
def code(x, y, z, t, a, b):
	return ((x + (y * z)) + (t * a)) + ((a * z) * b)
function code(x, y, z, t, a, b)
	return Float64(Float64(Float64(x + Float64(y * z)) + Float64(t * a)) + Float64(Float64(a * z) * b))
end
function tmp = code(x, y, z, t, a, b)
	tmp = ((x + (y * z)) + (t * a)) + ((a * z) * b);
end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision] + N[(t * a), $MachinePrecision]), $MachinePrecision] + N[(N[(a * z), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b
\end{array}

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 13 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: 92.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (+ (+ (+ x (* y z)) (* t a)) (* (* a z) b)))
double code(double x, double y, double z, double t, double a, double b) {
	return ((x + (y * z)) + (t * a)) + ((a * z) * b);
}
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, y, z, t, a, b)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = ((x + (y * z)) + (t * a)) + ((a * z) * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	return ((x + (y * z)) + (t * a)) + ((a * z) * b);
}
def code(x, y, z, t, a, b):
	return ((x + (y * z)) + (t * a)) + ((a * z) * b)
function code(x, y, z, t, a, b)
	return Float64(Float64(Float64(x + Float64(y * z)) + Float64(t * a)) + Float64(Float64(a * z) * b))
end
function tmp = code(x, y, z, t, a, b)
	tmp = ((x + (y * z)) + (t * a)) + ((a * z) * b);
end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision] + N[(t * a), $MachinePrecision]), $MachinePrecision] + N[(N[(a * z), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b
\end{array}

Alternative 1: 93.9% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq 1.6 \cdot 10^{+117}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, \mathsf{fma}\left(a, t, x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(z, b, t\right), a, x\right)\\ \end{array} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (if (<= b 1.6e+117) (fma (fma b a y) z (fma a t x)) (fma (fma z b t) a x)))
double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if (b <= 1.6e+117) {
		tmp = fma(fma(b, a, y), z, fma(a, t, x));
	} else {
		tmp = fma(fma(z, b, t), a, x);
	}
	return tmp;
}
function code(x, y, z, t, a, b)
	tmp = 0.0
	if (b <= 1.6e+117)
		tmp = fma(fma(b, a, y), z, fma(a, t, x));
	else
		tmp = fma(fma(z, b, t), a, x);
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[b, 1.6e+117], N[(N[(b * a + y), $MachinePrecision] * z + N[(a * t + x), $MachinePrecision]), $MachinePrecision], N[(N[(z * b + t), $MachinePrecision] * a + x), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq 1.6 \cdot 10^{+117}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, \mathsf{fma}\left(a, t, x\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(z, b, t\right), a, x\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if b < 1.60000000000000002e117

    1. Initial program 92.6%

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b} \]
      2. lift-*.f64N/A

        \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \color{blue}{\left(a \cdot z\right) \cdot b} \]
      3. fp-cancel-sign-sub-invN/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) - \left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b} \]
      4. sub-flipN/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right)} \]
      5. +-commutativeN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\left(x + y \cdot z\right) + t \cdot a\right)} \]
      6. lift-+.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\left(x + y \cdot z\right) + \color{blue}{t \cdot a}\right) \]
      8. fp-cancel-sign-sub-invN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(\left(x + y \cdot z\right) - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)} \]
      9. lift-+.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\color{blue}{\left(x + y \cdot z\right)} - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right) \]
      10. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\color{blue}{\left(y \cdot z + x\right)} - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right) \]
      11. associate--l+N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(y \cdot z + \left(x - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)\right)} \]
      12. associate-+r+N/A

        \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + y \cdot z\right) + \left(x - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)} \]
    3. Applied rewrites94.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, \mathsf{fma}\left(a, t, x\right)\right)} \]

    if 1.60000000000000002e117 < b

    1. Initial program 92.6%

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \]
    2. Taylor expanded in y around 0

      \[\leadsto \color{blue}{x + \left(a \cdot t + a \cdot \left(b \cdot z\right)\right)} \]
    3. Step-by-step derivation
      1. lower-+.f64N/A

        \[\leadsto x + \color{blue}{\left(a \cdot t + a \cdot \left(b \cdot z\right)\right)} \]
      2. lower-fma.f64N/A

        \[\leadsto x + \mathsf{fma}\left(a, \color{blue}{t}, a \cdot \left(b \cdot z\right)\right) \]
      3. lower-*.f64N/A

        \[\leadsto x + \mathsf{fma}\left(a, t, a \cdot \left(b \cdot z\right)\right) \]
      4. lower-*.f6474.5

        \[\leadsto x + \mathsf{fma}\left(a, t, a \cdot \left(b \cdot z\right)\right) \]
    4. Applied rewrites74.5%

      \[\leadsto \color{blue}{x + \mathsf{fma}\left(a, t, a \cdot \left(b \cdot z\right)\right)} \]
    5. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto x + \color{blue}{\mathsf{fma}\left(a, t, a \cdot \left(b \cdot z\right)\right)} \]
      2. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(a, t, a \cdot \left(b \cdot z\right)\right) + \color{blue}{x} \]
      3. lift-fma.f64N/A

        \[\leadsto \left(a \cdot t + a \cdot \left(b \cdot z\right)\right) + x \]
      4. lift-*.f64N/A

        \[\leadsto \left(a \cdot t + a \cdot \left(b \cdot z\right)\right) + x \]
      5. distribute-lft-outN/A

        \[\leadsto a \cdot \left(t + b \cdot z\right) + x \]
      6. lift-+.f64N/A

        \[\leadsto a \cdot \left(t + b \cdot z\right) + x \]
      7. *-commutativeN/A

        \[\leadsto \left(t + b \cdot z\right) \cdot a + x \]
      8. lower-fma.f6475.2

        \[\leadsto \mathsf{fma}\left(t + b \cdot z, \color{blue}{a}, x\right) \]
      9. lift-+.f64N/A

        \[\leadsto \mathsf{fma}\left(t + b \cdot z, a, x\right) \]
      10. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b \cdot z + t, a, x\right) \]
      11. add-flipN/A

        \[\leadsto \mathsf{fma}\left(b \cdot z - \left(\mathsf{neg}\left(t\right)\right), a, x\right) \]
      12. sub-flipN/A

        \[\leadsto \mathsf{fma}\left(b \cdot z + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(t\right)\right)\right)\right), a, x\right) \]
      13. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(b \cdot z + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(t\right)\right)\right)\right), a, x\right) \]
      14. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(z \cdot b + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(t\right)\right)\right)\right), a, x\right) \]
      15. remove-double-negN/A

        \[\leadsto \mathsf{fma}\left(z \cdot b + t, a, x\right) \]
      16. lower-fma.f6475.2

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(z, b, t\right), a, x\right) \]
    6. Applied rewrites75.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(z, b, t\right), a, x\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 2: 87.2% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -1.6 \cdot 10^{+96}:\\ \;\;\;\;\left(x + a \cdot t\right) + \left(a \cdot z\right) \cdot b\\ \mathbf{elif}\;b \leq 1.3 \cdot 10^{+117}:\\ \;\;\;\;\mathsf{fma}\left(z, y, \mathsf{fma}\left(t, a, x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(z, b, t\right), a, x\right)\\ \end{array} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (if (<= b -1.6e+96)
   (+ (+ x (* a t)) (* (* a z) b))
   (if (<= b 1.3e+117) (fma z y (fma t a x)) (fma (fma z b t) a x))))
double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if (b <= -1.6e+96) {
		tmp = (x + (a * t)) + ((a * z) * b);
	} else if (b <= 1.3e+117) {
		tmp = fma(z, y, fma(t, a, x));
	} else {
		tmp = fma(fma(z, b, t), a, x);
	}
	return tmp;
}
function code(x, y, z, t, a, b)
	tmp = 0.0
	if (b <= -1.6e+96)
		tmp = Float64(Float64(x + Float64(a * t)) + Float64(Float64(a * z) * b));
	elseif (b <= 1.3e+117)
		tmp = fma(z, y, fma(t, a, x));
	else
		tmp = fma(fma(z, b, t), a, x);
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[b, -1.6e+96], N[(N[(x + N[(a * t), $MachinePrecision]), $MachinePrecision] + N[(N[(a * z), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 1.3e+117], N[(z * y + N[(t * a + x), $MachinePrecision]), $MachinePrecision], N[(N[(z * b + t), $MachinePrecision] * a + x), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq -1.6 \cdot 10^{+96}:\\
\;\;\;\;\left(x + a \cdot t\right) + \left(a \cdot z\right) \cdot b\\

\mathbf{elif}\;b \leq 1.3 \cdot 10^{+117}:\\
\;\;\;\;\mathsf{fma}\left(z, y, \mathsf{fma}\left(t, a, x\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(z, b, t\right), a, x\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b < -1.60000000000000003e96

    1. Initial program 92.6%

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \]
    2. Taylor expanded in y around 0

      \[\leadsto \color{blue}{\left(x + a \cdot t\right)} + \left(a \cdot z\right) \cdot b \]
    3. Step-by-step derivation
      1. lower-+.f64N/A

        \[\leadsto \left(x + \color{blue}{a \cdot t}\right) + \left(a \cdot z\right) \cdot b \]
      2. lower-*.f6472.5

        \[\leadsto \left(x + a \cdot \color{blue}{t}\right) + \left(a \cdot z\right) \cdot b \]
    4. Applied rewrites72.5%

      \[\leadsto \color{blue}{\left(x + a \cdot t\right)} + \left(a \cdot z\right) \cdot b \]

    if -1.60000000000000003e96 < b < 1.3e117

    1. Initial program 92.6%

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b} \]
      2. lift-*.f64N/A

        \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \color{blue}{\left(a \cdot z\right) \cdot b} \]
      3. fp-cancel-sign-sub-invN/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) - \left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b} \]
      4. sub-flipN/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right)} \]
      5. +-commutativeN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\left(x + y \cdot z\right) + t \cdot a\right)} \]
      6. lift-+.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\left(x + y \cdot z\right) + \color{blue}{t \cdot a}\right) \]
      8. fp-cancel-sign-sub-invN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(\left(x + y \cdot z\right) - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)} \]
      9. lift-+.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\color{blue}{\left(x + y \cdot z\right)} - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right) \]
      10. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\color{blue}{\left(y \cdot z + x\right)} - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right) \]
      11. associate--l+N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(y \cdot z + \left(x - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)\right)} \]
      12. associate-+r+N/A

        \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + y \cdot z\right) + \left(x - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)} \]
    3. Applied rewrites94.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, \mathsf{fma}\left(a, t, x\right)\right)} \]
    4. Taylor expanded in b around 0

      \[\leadsto \color{blue}{x + \left(a \cdot t + y \cdot z\right)} \]
    5. Step-by-step derivation
      1. lower-+.f64N/A

        \[\leadsto x + \color{blue}{\left(a \cdot t + y \cdot z\right)} \]
      2. lower-fma.f64N/A

        \[\leadsto x + \mathsf{fma}\left(a, \color{blue}{t}, y \cdot z\right) \]
      3. lower-*.f6477.4

        \[\leadsto x + \mathsf{fma}\left(a, t, y \cdot z\right) \]
    6. Applied rewrites77.4%

      \[\leadsto \color{blue}{x + \mathsf{fma}\left(a, t, y \cdot z\right)} \]
    7. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto x + \color{blue}{\mathsf{fma}\left(a, t, y \cdot z\right)} \]
      2. lift-fma.f64N/A

        \[\leadsto x + \left(a \cdot t + \color{blue}{y \cdot z}\right) \]
      3. associate-+r+N/A

        \[\leadsto \left(x + a \cdot t\right) + \color{blue}{y \cdot z} \]
      4. +-commutativeN/A

        \[\leadsto \left(a \cdot t + x\right) + \color{blue}{y} \cdot z \]
      5. +-commutativeN/A

        \[\leadsto y \cdot z + \color{blue}{\left(a \cdot t + x\right)} \]
      6. lift-*.f64N/A

        \[\leadsto y \cdot z + \left(\color{blue}{a \cdot t} + x\right) \]
      7. *-commutativeN/A

        \[\leadsto z \cdot y + \left(\color{blue}{a \cdot t} + x\right) \]
      8. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{y}, a \cdot t + x\right) \]
      9. add-flipN/A

        \[\leadsto \mathsf{fma}\left(z, y, a \cdot t - \left(\mathsf{neg}\left(x\right)\right)\right) \]
      10. sub-negate-revN/A

        \[\leadsto \mathsf{fma}\left(z, y, \mathsf{neg}\left(\left(\left(\mathsf{neg}\left(x\right)\right) - a \cdot t\right)\right)\right) \]
      11. sub-flip-reverseN/A

        \[\leadsto \mathsf{fma}\left(z, y, \mathsf{neg}\left(\left(\left(\mathsf{neg}\left(x\right)\right) + \left(\mathsf{neg}\left(a \cdot t\right)\right)\right)\right)\right) \]
      12. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(z, y, \mathsf{neg}\left(\left(\left(\mathsf{neg}\left(x\right)\right) + \left(\mathsf{neg}\left(t \cdot a\right)\right)\right)\right)\right) \]
      13. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(z, y, \mathsf{neg}\left(\left(\left(\mathsf{neg}\left(t \cdot a\right)\right) + \left(\mathsf{neg}\left(x\right)\right)\right)\right)\right) \]
      14. distribute-neg-inN/A

        \[\leadsto \mathsf{fma}\left(z, y, \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(t \cdot a\right)\right)\right)\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)\right) \]
      15. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(z, y, \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot t\right)\right)\right)\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)\right) \]
      16. remove-double-negN/A

        \[\leadsto \mathsf{fma}\left(z, y, a \cdot t + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)\right) \]
      17. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(z, y, t \cdot a + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)\right) \]
      18. remove-double-negN/A

        \[\leadsto \mathsf{fma}\left(z, y, t \cdot a + x\right) \]
      19. lower-fma.f6477.4

        \[\leadsto \mathsf{fma}\left(z, y, \mathsf{fma}\left(t, a, x\right)\right) \]
    8. Applied rewrites77.4%

      \[\leadsto \mathsf{fma}\left(z, \color{blue}{y}, \mathsf{fma}\left(t, a, x\right)\right) \]

    if 1.3e117 < b

    1. Initial program 92.6%

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \]
    2. Taylor expanded in y around 0

      \[\leadsto \color{blue}{x + \left(a \cdot t + a \cdot \left(b \cdot z\right)\right)} \]
    3. Step-by-step derivation
      1. lower-+.f64N/A

        \[\leadsto x + \color{blue}{\left(a \cdot t + a \cdot \left(b \cdot z\right)\right)} \]
      2. lower-fma.f64N/A

        \[\leadsto x + \mathsf{fma}\left(a, \color{blue}{t}, a \cdot \left(b \cdot z\right)\right) \]
      3. lower-*.f64N/A

        \[\leadsto x + \mathsf{fma}\left(a, t, a \cdot \left(b \cdot z\right)\right) \]
      4. lower-*.f6474.5

        \[\leadsto x + \mathsf{fma}\left(a, t, a \cdot \left(b \cdot z\right)\right) \]
    4. Applied rewrites74.5%

      \[\leadsto \color{blue}{x + \mathsf{fma}\left(a, t, a \cdot \left(b \cdot z\right)\right)} \]
    5. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto x + \color{blue}{\mathsf{fma}\left(a, t, a \cdot \left(b \cdot z\right)\right)} \]
      2. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(a, t, a \cdot \left(b \cdot z\right)\right) + \color{blue}{x} \]
      3. lift-fma.f64N/A

        \[\leadsto \left(a \cdot t + a \cdot \left(b \cdot z\right)\right) + x \]
      4. lift-*.f64N/A

        \[\leadsto \left(a \cdot t + a \cdot \left(b \cdot z\right)\right) + x \]
      5. distribute-lft-outN/A

        \[\leadsto a \cdot \left(t + b \cdot z\right) + x \]
      6. lift-+.f64N/A

        \[\leadsto a \cdot \left(t + b \cdot z\right) + x \]
      7. *-commutativeN/A

        \[\leadsto \left(t + b \cdot z\right) \cdot a + x \]
      8. lower-fma.f6475.2

        \[\leadsto \mathsf{fma}\left(t + b \cdot z, \color{blue}{a}, x\right) \]
      9. lift-+.f64N/A

        \[\leadsto \mathsf{fma}\left(t + b \cdot z, a, x\right) \]
      10. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b \cdot z + t, a, x\right) \]
      11. add-flipN/A

        \[\leadsto \mathsf{fma}\left(b \cdot z - \left(\mathsf{neg}\left(t\right)\right), a, x\right) \]
      12. sub-flipN/A

        \[\leadsto \mathsf{fma}\left(b \cdot z + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(t\right)\right)\right)\right), a, x\right) \]
      13. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(b \cdot z + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(t\right)\right)\right)\right), a, x\right) \]
      14. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(z \cdot b + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(t\right)\right)\right)\right), a, x\right) \]
      15. remove-double-negN/A

        \[\leadsto \mathsf{fma}\left(z \cdot b + t, a, x\right) \]
      16. lower-fma.f6475.2

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(z, b, t\right), a, x\right) \]
    6. Applied rewrites75.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(z, b, t\right), a, x\right)} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 3: 86.4% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \mathsf{fma}\left(z, y, \mathsf{fma}\left(t, a, x\right)\right)\\ \mathbf{if}\;y \leq -5.4 \cdot 10^{+35}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;y \leq 1.02 \cdot 10^{-35}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(z, b, t\right), a, x\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (fma z y (fma t a x))))
   (if (<= y -5.4e+35) t_1 (if (<= y 1.02e-35) (fma (fma z b t) a x) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = fma(z, y, fma(t, a, x));
	double tmp;
	if (y <= -5.4e+35) {
		tmp = t_1;
	} else if (y <= 1.02e-35) {
		tmp = fma(fma(z, b, t), a, x);
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, y, z, t, a, b)
	t_1 = fma(z, y, fma(t, a, x))
	tmp = 0.0
	if (y <= -5.4e+35)
		tmp = t_1;
	elseif (y <= 1.02e-35)
		tmp = fma(fma(z, b, t), a, x);
	else
		tmp = t_1;
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(z * y + N[(t * a + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -5.4e+35], t$95$1, If[LessEqual[y, 1.02e-35], N[(N[(z * b + t), $MachinePrecision] * a + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(z, y, \mathsf{fma}\left(t, a, x\right)\right)\\
\mathbf{if}\;y \leq -5.4 \cdot 10^{+35}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;y \leq 1.02 \cdot 10^{-35}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(z, b, t\right), a, x\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -5.40000000000000005e35 or 1.01999999999999995e-35 < y

    1. Initial program 92.6%

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b} \]
      2. lift-*.f64N/A

        \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \color{blue}{\left(a \cdot z\right) \cdot b} \]
      3. fp-cancel-sign-sub-invN/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) - \left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b} \]
      4. sub-flipN/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right)} \]
      5. +-commutativeN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\left(x + y \cdot z\right) + t \cdot a\right)} \]
      6. lift-+.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\left(x + y \cdot z\right) + \color{blue}{t \cdot a}\right) \]
      8. fp-cancel-sign-sub-invN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(\left(x + y \cdot z\right) - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)} \]
      9. lift-+.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\color{blue}{\left(x + y \cdot z\right)} - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right) \]
      10. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\color{blue}{\left(y \cdot z + x\right)} - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right) \]
      11. associate--l+N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(y \cdot z + \left(x - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)\right)} \]
      12. associate-+r+N/A

        \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + y \cdot z\right) + \left(x - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)} \]
    3. Applied rewrites94.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, \mathsf{fma}\left(a, t, x\right)\right)} \]
    4. Taylor expanded in b around 0

      \[\leadsto \color{blue}{x + \left(a \cdot t + y \cdot z\right)} \]
    5. Step-by-step derivation
      1. lower-+.f64N/A

        \[\leadsto x + \color{blue}{\left(a \cdot t + y \cdot z\right)} \]
      2. lower-fma.f64N/A

        \[\leadsto x + \mathsf{fma}\left(a, \color{blue}{t}, y \cdot z\right) \]
      3. lower-*.f6477.4

        \[\leadsto x + \mathsf{fma}\left(a, t, y \cdot z\right) \]
    6. Applied rewrites77.4%

      \[\leadsto \color{blue}{x + \mathsf{fma}\left(a, t, y \cdot z\right)} \]
    7. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto x + \color{blue}{\mathsf{fma}\left(a, t, y \cdot z\right)} \]
      2. lift-fma.f64N/A

        \[\leadsto x + \left(a \cdot t + \color{blue}{y \cdot z}\right) \]
      3. associate-+r+N/A

        \[\leadsto \left(x + a \cdot t\right) + \color{blue}{y \cdot z} \]
      4. +-commutativeN/A

        \[\leadsto \left(a \cdot t + x\right) + \color{blue}{y} \cdot z \]
      5. +-commutativeN/A

        \[\leadsto y \cdot z + \color{blue}{\left(a \cdot t + x\right)} \]
      6. lift-*.f64N/A

        \[\leadsto y \cdot z + \left(\color{blue}{a \cdot t} + x\right) \]
      7. *-commutativeN/A

        \[\leadsto z \cdot y + \left(\color{blue}{a \cdot t} + x\right) \]
      8. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{y}, a \cdot t + x\right) \]
      9. add-flipN/A

        \[\leadsto \mathsf{fma}\left(z, y, a \cdot t - \left(\mathsf{neg}\left(x\right)\right)\right) \]
      10. sub-negate-revN/A

        \[\leadsto \mathsf{fma}\left(z, y, \mathsf{neg}\left(\left(\left(\mathsf{neg}\left(x\right)\right) - a \cdot t\right)\right)\right) \]
      11. sub-flip-reverseN/A

        \[\leadsto \mathsf{fma}\left(z, y, \mathsf{neg}\left(\left(\left(\mathsf{neg}\left(x\right)\right) + \left(\mathsf{neg}\left(a \cdot t\right)\right)\right)\right)\right) \]
      12. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(z, y, \mathsf{neg}\left(\left(\left(\mathsf{neg}\left(x\right)\right) + \left(\mathsf{neg}\left(t \cdot a\right)\right)\right)\right)\right) \]
      13. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(z, y, \mathsf{neg}\left(\left(\left(\mathsf{neg}\left(t \cdot a\right)\right) + \left(\mathsf{neg}\left(x\right)\right)\right)\right)\right) \]
      14. distribute-neg-inN/A

        \[\leadsto \mathsf{fma}\left(z, y, \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(t \cdot a\right)\right)\right)\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)\right) \]
      15. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(z, y, \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot t\right)\right)\right)\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)\right) \]
      16. remove-double-negN/A

        \[\leadsto \mathsf{fma}\left(z, y, a \cdot t + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)\right) \]
      17. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(z, y, t \cdot a + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)\right) \]
      18. remove-double-negN/A

        \[\leadsto \mathsf{fma}\left(z, y, t \cdot a + x\right) \]
      19. lower-fma.f6477.4

        \[\leadsto \mathsf{fma}\left(z, y, \mathsf{fma}\left(t, a, x\right)\right) \]
    8. Applied rewrites77.4%

      \[\leadsto \mathsf{fma}\left(z, \color{blue}{y}, \mathsf{fma}\left(t, a, x\right)\right) \]

    if -5.40000000000000005e35 < y < 1.01999999999999995e-35

    1. Initial program 92.6%

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \]
    2. Taylor expanded in y around 0

      \[\leadsto \color{blue}{x + \left(a \cdot t + a \cdot \left(b \cdot z\right)\right)} \]
    3. Step-by-step derivation
      1. lower-+.f64N/A

        \[\leadsto x + \color{blue}{\left(a \cdot t + a \cdot \left(b \cdot z\right)\right)} \]
      2. lower-fma.f64N/A

        \[\leadsto x + \mathsf{fma}\left(a, \color{blue}{t}, a \cdot \left(b \cdot z\right)\right) \]
      3. lower-*.f64N/A

        \[\leadsto x + \mathsf{fma}\left(a, t, a \cdot \left(b \cdot z\right)\right) \]
      4. lower-*.f6474.5

        \[\leadsto x + \mathsf{fma}\left(a, t, a \cdot \left(b \cdot z\right)\right) \]
    4. Applied rewrites74.5%

      \[\leadsto \color{blue}{x + \mathsf{fma}\left(a, t, a \cdot \left(b \cdot z\right)\right)} \]
    5. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto x + \color{blue}{\mathsf{fma}\left(a, t, a \cdot \left(b \cdot z\right)\right)} \]
      2. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(a, t, a \cdot \left(b \cdot z\right)\right) + \color{blue}{x} \]
      3. lift-fma.f64N/A

        \[\leadsto \left(a \cdot t + a \cdot \left(b \cdot z\right)\right) + x \]
      4. lift-*.f64N/A

        \[\leadsto \left(a \cdot t + a \cdot \left(b \cdot z\right)\right) + x \]
      5. distribute-lft-outN/A

        \[\leadsto a \cdot \left(t + b \cdot z\right) + x \]
      6. lift-+.f64N/A

        \[\leadsto a \cdot \left(t + b \cdot z\right) + x \]
      7. *-commutativeN/A

        \[\leadsto \left(t + b \cdot z\right) \cdot a + x \]
      8. lower-fma.f6475.2

        \[\leadsto \mathsf{fma}\left(t + b \cdot z, \color{blue}{a}, x\right) \]
      9. lift-+.f64N/A

        \[\leadsto \mathsf{fma}\left(t + b \cdot z, a, x\right) \]
      10. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b \cdot z + t, a, x\right) \]
      11. add-flipN/A

        \[\leadsto \mathsf{fma}\left(b \cdot z - \left(\mathsf{neg}\left(t\right)\right), a, x\right) \]
      12. sub-flipN/A

        \[\leadsto \mathsf{fma}\left(b \cdot z + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(t\right)\right)\right)\right), a, x\right) \]
      13. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(b \cdot z + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(t\right)\right)\right)\right), a, x\right) \]
      14. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(z \cdot b + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(t\right)\right)\right)\right), a, x\right) \]
      15. remove-double-negN/A

        \[\leadsto \mathsf{fma}\left(z \cdot b + t, a, x\right) \]
      16. lower-fma.f6475.2

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(z, b, t\right), a, x\right) \]
    6. Applied rewrites75.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(z, b, t\right), a, x\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 4: 85.5% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \mathsf{fma}\left(\mathsf{fma}\left(a, b, y\right), z, x\right)\\ \mathbf{if}\;z \leq -2.7 \cdot 10^{-92}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 2.16 \cdot 10^{+117}:\\ \;\;\;\;\mathsf{fma}\left(z, y, \mathsf{fma}\left(t, a, x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (fma (fma a b y) z x)))
   (if (<= z -2.7e-92) t_1 (if (<= z 2.16e+117) (fma z y (fma t a x)) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = fma(fma(a, b, y), z, x);
	double tmp;
	if (z <= -2.7e-92) {
		tmp = t_1;
	} else if (z <= 2.16e+117) {
		tmp = fma(z, y, fma(t, a, x));
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, y, z, t, a, b)
	t_1 = fma(fma(a, b, y), z, x)
	tmp = 0.0
	if (z <= -2.7e-92)
		tmp = t_1;
	elseif (z <= 2.16e+117)
		tmp = fma(z, y, fma(t, a, x));
	else
		tmp = t_1;
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a * b + y), $MachinePrecision] * z + x), $MachinePrecision]}, If[LessEqual[z, -2.7e-92], t$95$1, If[LessEqual[z, 2.16e+117], N[(z * y + N[(t * a + x), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(\mathsf{fma}\left(a, b, y\right), z, x\right)\\
\mathbf{if}\;z \leq -2.7 \cdot 10^{-92}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \leq 2.16 \cdot 10^{+117}:\\
\;\;\;\;\mathsf{fma}\left(z, y, \mathsf{fma}\left(t, a, x\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -2.69999999999999995e-92 or 2.16e117 < z

    1. Initial program 92.6%

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \]
    2. Taylor expanded in t around 0

      \[\leadsto \color{blue}{x + \left(a \cdot \left(b \cdot z\right) + y \cdot z\right)} \]
    3. Step-by-step derivation
      1. lower-+.f64N/A

        \[\leadsto x + \color{blue}{\left(a \cdot \left(b \cdot z\right) + y \cdot z\right)} \]
      2. lower-fma.f64N/A

        \[\leadsto x + \mathsf{fma}\left(a, \color{blue}{b \cdot z}, y \cdot z\right) \]
      3. lower-*.f64N/A

        \[\leadsto x + \mathsf{fma}\left(a, b \cdot \color{blue}{z}, y \cdot z\right) \]
      4. lower-*.f6471.0

        \[\leadsto x + \mathsf{fma}\left(a, b \cdot z, y \cdot z\right) \]
    4. Applied rewrites71.0%

      \[\leadsto \color{blue}{x + \mathsf{fma}\left(a, b \cdot z, y \cdot z\right)} \]
    5. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto x + \color{blue}{\mathsf{fma}\left(a, b \cdot z, y \cdot z\right)} \]
      2. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(a, b \cdot z, y \cdot z\right) + \color{blue}{x} \]
      3. lift-fma.f64N/A

        \[\leadsto \left(a \cdot \left(b \cdot z\right) + y \cdot z\right) + x \]
      4. lift-*.f64N/A

        \[\leadsto \left(a \cdot \left(b \cdot z\right) + y \cdot z\right) + x \]
      5. associate-*r*N/A

        \[\leadsto \left(\left(a \cdot b\right) \cdot z + y \cdot z\right) + x \]
      6. lift-*.f64N/A

        \[\leadsto \left(\left(a \cdot b\right) \cdot z + y \cdot z\right) + x \]
      7. lift-*.f64N/A

        \[\leadsto \left(\left(a \cdot b\right) \cdot z + y \cdot z\right) + x \]
      8. distribute-rgt-outN/A

        \[\leadsto z \cdot \left(a \cdot b + y\right) + x \]
      9. lift-*.f64N/A

        \[\leadsto z \cdot \left(a \cdot b + y\right) + x \]
      10. *-commutativeN/A

        \[\leadsto z \cdot \left(b \cdot a + y\right) + x \]
      11. lift-fma.f64N/A

        \[\leadsto z \cdot \mathsf{fma}\left(b, a, y\right) + x \]
      12. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, a, y\right) \cdot z + x \]
      13. add-flipN/A

        \[\leadsto \mathsf{fma}\left(b, a, y\right) \cdot z - \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \]
      14. sub-flipN/A

        \[\leadsto \mathsf{fma}\left(b, a, y\right) \cdot z + \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)} \]
      15. lift-fma.f64N/A

        \[\leadsto \left(b \cdot a + y\right) \cdot z + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\color{blue}{x}\right)\right)\right)\right) \]
      16. *-commutativeN/A

        \[\leadsto \left(a \cdot b + y\right) \cdot z + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right) \]
      17. lift-*.f64N/A

        \[\leadsto \left(a \cdot b + y\right) \cdot z + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right) \]
      18. +-commutativeN/A

        \[\leadsto \left(y + a \cdot b\right) \cdot z + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\color{blue}{x}\right)\right)\right)\right) \]
      19. lift-+.f64N/A

        \[\leadsto \left(y + a \cdot b\right) \cdot z + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\color{blue}{x}\right)\right)\right)\right) \]
      20. remove-double-negN/A

        \[\leadsto \left(y + a \cdot b\right) \cdot z + x \]
      21. lower-fma.f6474.4

        \[\leadsto \mathsf{fma}\left(y + a \cdot b, \color{blue}{z}, x\right) \]
      22. lift-+.f64N/A

        \[\leadsto \mathsf{fma}\left(y + a \cdot b, z, x\right) \]
      23. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(a \cdot b + y, z, x\right) \]
      24. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(a \cdot b + y, z, x\right) \]
      25. lower-fma.f6474.4

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a, b, y\right), z, x\right) \]
    6. Applied rewrites74.4%

      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a, b, y\right), \color{blue}{z}, x\right) \]

    if -2.69999999999999995e-92 < z < 2.16e117

    1. Initial program 92.6%

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b} \]
      2. lift-*.f64N/A

        \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \color{blue}{\left(a \cdot z\right) \cdot b} \]
      3. fp-cancel-sign-sub-invN/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) - \left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b} \]
      4. sub-flipN/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right)} \]
      5. +-commutativeN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\left(x + y \cdot z\right) + t \cdot a\right)} \]
      6. lift-+.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\left(x + y \cdot z\right) + \color{blue}{t \cdot a}\right) \]
      8. fp-cancel-sign-sub-invN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(\left(x + y \cdot z\right) - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)} \]
      9. lift-+.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\color{blue}{\left(x + y \cdot z\right)} - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right) \]
      10. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\color{blue}{\left(y \cdot z + x\right)} - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right) \]
      11. associate--l+N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(y \cdot z + \left(x - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)\right)} \]
      12. associate-+r+N/A

        \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + y \cdot z\right) + \left(x - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)} \]
    3. Applied rewrites94.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, \mathsf{fma}\left(a, t, x\right)\right)} \]
    4. Taylor expanded in b around 0

      \[\leadsto \color{blue}{x + \left(a \cdot t + y \cdot z\right)} \]
    5. Step-by-step derivation
      1. lower-+.f64N/A

        \[\leadsto x + \color{blue}{\left(a \cdot t + y \cdot z\right)} \]
      2. lower-fma.f64N/A

        \[\leadsto x + \mathsf{fma}\left(a, \color{blue}{t}, y \cdot z\right) \]
      3. lower-*.f6477.4

        \[\leadsto x + \mathsf{fma}\left(a, t, y \cdot z\right) \]
    6. Applied rewrites77.4%

      \[\leadsto \color{blue}{x + \mathsf{fma}\left(a, t, y \cdot z\right)} \]
    7. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto x + \color{blue}{\mathsf{fma}\left(a, t, y \cdot z\right)} \]
      2. lift-fma.f64N/A

        \[\leadsto x + \left(a \cdot t + \color{blue}{y \cdot z}\right) \]
      3. associate-+r+N/A

        \[\leadsto \left(x + a \cdot t\right) + \color{blue}{y \cdot z} \]
      4. +-commutativeN/A

        \[\leadsto \left(a \cdot t + x\right) + \color{blue}{y} \cdot z \]
      5. +-commutativeN/A

        \[\leadsto y \cdot z + \color{blue}{\left(a \cdot t + x\right)} \]
      6. lift-*.f64N/A

        \[\leadsto y \cdot z + \left(\color{blue}{a \cdot t} + x\right) \]
      7. *-commutativeN/A

        \[\leadsto z \cdot y + \left(\color{blue}{a \cdot t} + x\right) \]
      8. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{y}, a \cdot t + x\right) \]
      9. add-flipN/A

        \[\leadsto \mathsf{fma}\left(z, y, a \cdot t - \left(\mathsf{neg}\left(x\right)\right)\right) \]
      10. sub-negate-revN/A

        \[\leadsto \mathsf{fma}\left(z, y, \mathsf{neg}\left(\left(\left(\mathsf{neg}\left(x\right)\right) - a \cdot t\right)\right)\right) \]
      11. sub-flip-reverseN/A

        \[\leadsto \mathsf{fma}\left(z, y, \mathsf{neg}\left(\left(\left(\mathsf{neg}\left(x\right)\right) + \left(\mathsf{neg}\left(a \cdot t\right)\right)\right)\right)\right) \]
      12. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(z, y, \mathsf{neg}\left(\left(\left(\mathsf{neg}\left(x\right)\right) + \left(\mathsf{neg}\left(t \cdot a\right)\right)\right)\right)\right) \]
      13. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(z, y, \mathsf{neg}\left(\left(\left(\mathsf{neg}\left(t \cdot a\right)\right) + \left(\mathsf{neg}\left(x\right)\right)\right)\right)\right) \]
      14. distribute-neg-inN/A

        \[\leadsto \mathsf{fma}\left(z, y, \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(t \cdot a\right)\right)\right)\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)\right) \]
      15. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(z, y, \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot t\right)\right)\right)\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)\right) \]
      16. remove-double-negN/A

        \[\leadsto \mathsf{fma}\left(z, y, a \cdot t + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)\right) \]
      17. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(z, y, t \cdot a + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)\right) \]
      18. remove-double-negN/A

        \[\leadsto \mathsf{fma}\left(z, y, t \cdot a + x\right) \]
      19. lower-fma.f6477.4

        \[\leadsto \mathsf{fma}\left(z, y, \mathsf{fma}\left(t, a, x\right)\right) \]
    8. Applied rewrites77.4%

      \[\leadsto \mathsf{fma}\left(z, \color{blue}{y}, \mathsf{fma}\left(t, a, x\right)\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 5: 82.1% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;b \leq -5.3 \cdot 10^{+181}:\\ \;\;\;\;\mathsf{fma}\left(a \cdot b, z, x\right)\\ \mathbf{elif}\;b \leq 2.3 \cdot 10^{+120}:\\ \;\;\;\;\mathsf{fma}\left(z, y, \mathsf{fma}\left(t, a, x\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x + a \cdot \left(b \cdot z\right)\\ \end{array} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (if (<= b -5.3e+181)
   (fma (* a b) z x)
   (if (<= b 2.3e+120) (fma z y (fma t a x)) (+ x (* a (* b z))))))
double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if (b <= -5.3e+181) {
		tmp = fma((a * b), z, x);
	} else if (b <= 2.3e+120) {
		tmp = fma(z, y, fma(t, a, x));
	} else {
		tmp = x + (a * (b * z));
	}
	return tmp;
}
function code(x, y, z, t, a, b)
	tmp = 0.0
	if (b <= -5.3e+181)
		tmp = fma(Float64(a * b), z, x);
	elseif (b <= 2.3e+120)
		tmp = fma(z, y, fma(t, a, x));
	else
		tmp = Float64(x + Float64(a * Float64(b * z)));
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[b, -5.3e+181], N[(N[(a * b), $MachinePrecision] * z + x), $MachinePrecision], If[LessEqual[b, 2.3e+120], N[(z * y + N[(t * a + x), $MachinePrecision]), $MachinePrecision], N[(x + N[(a * N[(b * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;b \leq -5.3 \cdot 10^{+181}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot b, z, x\right)\\

\mathbf{elif}\;b \leq 2.3 \cdot 10^{+120}:\\
\;\;\;\;\mathsf{fma}\left(z, y, \mathsf{fma}\left(t, a, x\right)\right)\\

\mathbf{else}:\\
\;\;\;\;x + a \cdot \left(b \cdot z\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if b < -5.2999999999999996e181

    1. Initial program 92.6%

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \]
    2. Taylor expanded in t around 0

      \[\leadsto \color{blue}{x + \left(a \cdot \left(b \cdot z\right) + y \cdot z\right)} \]
    3. Step-by-step derivation
      1. lower-+.f64N/A

        \[\leadsto x + \color{blue}{\left(a \cdot \left(b \cdot z\right) + y \cdot z\right)} \]
      2. lower-fma.f64N/A

        \[\leadsto x + \mathsf{fma}\left(a, \color{blue}{b \cdot z}, y \cdot z\right) \]
      3. lower-*.f64N/A

        \[\leadsto x + \mathsf{fma}\left(a, b \cdot \color{blue}{z}, y \cdot z\right) \]
      4. lower-*.f6471.0

        \[\leadsto x + \mathsf{fma}\left(a, b \cdot z, y \cdot z\right) \]
    4. Applied rewrites71.0%

      \[\leadsto \color{blue}{x + \mathsf{fma}\left(a, b \cdot z, y \cdot z\right)} \]
    5. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto x + \color{blue}{\mathsf{fma}\left(a, b \cdot z, y \cdot z\right)} \]
      2. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(a, b \cdot z, y \cdot z\right) + \color{blue}{x} \]
      3. lift-fma.f64N/A

        \[\leadsto \left(a \cdot \left(b \cdot z\right) + y \cdot z\right) + x \]
      4. lift-*.f64N/A

        \[\leadsto \left(a \cdot \left(b \cdot z\right) + y \cdot z\right) + x \]
      5. associate-*r*N/A

        \[\leadsto \left(\left(a \cdot b\right) \cdot z + y \cdot z\right) + x \]
      6. lift-*.f64N/A

        \[\leadsto \left(\left(a \cdot b\right) \cdot z + y \cdot z\right) + x \]
      7. lift-*.f64N/A

        \[\leadsto \left(\left(a \cdot b\right) \cdot z + y \cdot z\right) + x \]
      8. distribute-rgt-outN/A

        \[\leadsto z \cdot \left(a \cdot b + y\right) + x \]
      9. lift-*.f64N/A

        \[\leadsto z \cdot \left(a \cdot b + y\right) + x \]
      10. *-commutativeN/A

        \[\leadsto z \cdot \left(b \cdot a + y\right) + x \]
      11. lift-fma.f64N/A

        \[\leadsto z \cdot \mathsf{fma}\left(b, a, y\right) + x \]
      12. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, a, y\right) \cdot z + x \]
      13. add-flipN/A

        \[\leadsto \mathsf{fma}\left(b, a, y\right) \cdot z - \color{blue}{\left(\mathsf{neg}\left(x\right)\right)} \]
      14. sub-flipN/A

        \[\leadsto \mathsf{fma}\left(b, a, y\right) \cdot z + \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)} \]
      15. lift-fma.f64N/A

        \[\leadsto \left(b \cdot a + y\right) \cdot z + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\color{blue}{x}\right)\right)\right)\right) \]
      16. *-commutativeN/A

        \[\leadsto \left(a \cdot b + y\right) \cdot z + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right) \]
      17. lift-*.f64N/A

        \[\leadsto \left(a \cdot b + y\right) \cdot z + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right) \]
      18. +-commutativeN/A

        \[\leadsto \left(y + a \cdot b\right) \cdot z + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\color{blue}{x}\right)\right)\right)\right) \]
      19. lift-+.f64N/A

        \[\leadsto \left(y + a \cdot b\right) \cdot z + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(\color{blue}{x}\right)\right)\right)\right) \]
      20. remove-double-negN/A

        \[\leadsto \left(y + a \cdot b\right) \cdot z + x \]
      21. lower-fma.f6474.4

        \[\leadsto \mathsf{fma}\left(y + a \cdot b, \color{blue}{z}, x\right) \]
      22. lift-+.f64N/A

        \[\leadsto \mathsf{fma}\left(y + a \cdot b, z, x\right) \]
      23. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(a \cdot b + y, z, x\right) \]
      24. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(a \cdot b + y, z, x\right) \]
      25. lower-fma.f6474.4

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a, b, y\right), z, x\right) \]
    6. Applied rewrites74.4%

      \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(a, b, y\right), \color{blue}{z}, x\right) \]
    7. Taylor expanded in y around 0

      \[\leadsto \mathsf{fma}\left(a \cdot b, z, x\right) \]
    8. Step-by-step derivation
      1. lower-*.f6450.9

        \[\leadsto \mathsf{fma}\left(a \cdot b, z, x\right) \]
    9. Applied rewrites50.9%

      \[\leadsto \mathsf{fma}\left(a \cdot b, z, x\right) \]

    if -5.2999999999999996e181 < b < 2.29999999999999993e120

    1. Initial program 92.6%

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b} \]
      2. lift-*.f64N/A

        \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \color{blue}{\left(a \cdot z\right) \cdot b} \]
      3. fp-cancel-sign-sub-invN/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) - \left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b} \]
      4. sub-flipN/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right)} \]
      5. +-commutativeN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\left(x + y \cdot z\right) + t \cdot a\right)} \]
      6. lift-+.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\left(x + y \cdot z\right) + \color{blue}{t \cdot a}\right) \]
      8. fp-cancel-sign-sub-invN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(\left(x + y \cdot z\right) - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)} \]
      9. lift-+.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\color{blue}{\left(x + y \cdot z\right)} - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right) \]
      10. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\color{blue}{\left(y \cdot z + x\right)} - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right) \]
      11. associate--l+N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(y \cdot z + \left(x - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)\right)} \]
      12. associate-+r+N/A

        \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + y \cdot z\right) + \left(x - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)} \]
    3. Applied rewrites94.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, \mathsf{fma}\left(a, t, x\right)\right)} \]
    4. Taylor expanded in b around 0

      \[\leadsto \color{blue}{x + \left(a \cdot t + y \cdot z\right)} \]
    5. Step-by-step derivation
      1. lower-+.f64N/A

        \[\leadsto x + \color{blue}{\left(a \cdot t + y \cdot z\right)} \]
      2. lower-fma.f64N/A

        \[\leadsto x + \mathsf{fma}\left(a, \color{blue}{t}, y \cdot z\right) \]
      3. lower-*.f6477.4

        \[\leadsto x + \mathsf{fma}\left(a, t, y \cdot z\right) \]
    6. Applied rewrites77.4%

      \[\leadsto \color{blue}{x + \mathsf{fma}\left(a, t, y \cdot z\right)} \]
    7. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto x + \color{blue}{\mathsf{fma}\left(a, t, y \cdot z\right)} \]
      2. lift-fma.f64N/A

        \[\leadsto x + \left(a \cdot t + \color{blue}{y \cdot z}\right) \]
      3. associate-+r+N/A

        \[\leadsto \left(x + a \cdot t\right) + \color{blue}{y \cdot z} \]
      4. +-commutativeN/A

        \[\leadsto \left(a \cdot t + x\right) + \color{blue}{y} \cdot z \]
      5. +-commutativeN/A

        \[\leadsto y \cdot z + \color{blue}{\left(a \cdot t + x\right)} \]
      6. lift-*.f64N/A

        \[\leadsto y \cdot z + \left(\color{blue}{a \cdot t} + x\right) \]
      7. *-commutativeN/A

        \[\leadsto z \cdot y + \left(\color{blue}{a \cdot t} + x\right) \]
      8. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{y}, a \cdot t + x\right) \]
      9. add-flipN/A

        \[\leadsto \mathsf{fma}\left(z, y, a \cdot t - \left(\mathsf{neg}\left(x\right)\right)\right) \]
      10. sub-negate-revN/A

        \[\leadsto \mathsf{fma}\left(z, y, \mathsf{neg}\left(\left(\left(\mathsf{neg}\left(x\right)\right) - a \cdot t\right)\right)\right) \]
      11. sub-flip-reverseN/A

        \[\leadsto \mathsf{fma}\left(z, y, \mathsf{neg}\left(\left(\left(\mathsf{neg}\left(x\right)\right) + \left(\mathsf{neg}\left(a \cdot t\right)\right)\right)\right)\right) \]
      12. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(z, y, \mathsf{neg}\left(\left(\left(\mathsf{neg}\left(x\right)\right) + \left(\mathsf{neg}\left(t \cdot a\right)\right)\right)\right)\right) \]
      13. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(z, y, \mathsf{neg}\left(\left(\left(\mathsf{neg}\left(t \cdot a\right)\right) + \left(\mathsf{neg}\left(x\right)\right)\right)\right)\right) \]
      14. distribute-neg-inN/A

        \[\leadsto \mathsf{fma}\left(z, y, \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(t \cdot a\right)\right)\right)\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)\right) \]
      15. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(z, y, \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot t\right)\right)\right)\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)\right) \]
      16. remove-double-negN/A

        \[\leadsto \mathsf{fma}\left(z, y, a \cdot t + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)\right) \]
      17. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(z, y, t \cdot a + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)\right) \]
      18. remove-double-negN/A

        \[\leadsto \mathsf{fma}\left(z, y, t \cdot a + x\right) \]
      19. lower-fma.f6477.4

        \[\leadsto \mathsf{fma}\left(z, y, \mathsf{fma}\left(t, a, x\right)\right) \]
    8. Applied rewrites77.4%

      \[\leadsto \mathsf{fma}\left(z, \color{blue}{y}, \mathsf{fma}\left(t, a, x\right)\right) \]

    if 2.29999999999999993e120 < b

    1. Initial program 92.6%

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \]
    2. Taylor expanded in t around 0

      \[\leadsto \color{blue}{x + \left(a \cdot \left(b \cdot z\right) + y \cdot z\right)} \]
    3. Step-by-step derivation
      1. lower-+.f64N/A

        \[\leadsto x + \color{blue}{\left(a \cdot \left(b \cdot z\right) + y \cdot z\right)} \]
      2. lower-fma.f64N/A

        \[\leadsto x + \mathsf{fma}\left(a, \color{blue}{b \cdot z}, y \cdot z\right) \]
      3. lower-*.f64N/A

        \[\leadsto x + \mathsf{fma}\left(a, b \cdot \color{blue}{z}, y \cdot z\right) \]
      4. lower-*.f6471.0

        \[\leadsto x + \mathsf{fma}\left(a, b \cdot z, y \cdot z\right) \]
    4. Applied rewrites71.0%

      \[\leadsto \color{blue}{x + \mathsf{fma}\left(a, b \cdot z, y \cdot z\right)} \]
    5. Taylor expanded in y around 0

      \[\leadsto x + \color{blue}{a \cdot \left(b \cdot z\right)} \]
    6. Step-by-step derivation
      1. lower-+.f64N/A

        \[\leadsto x + a \cdot \color{blue}{\left(b \cdot z\right)} \]
      2. lower-*.f64N/A

        \[\leadsto x + a \cdot \left(b \cdot \color{blue}{z}\right) \]
      3. lower-*.f6451.1

        \[\leadsto x + a \cdot \left(b \cdot z\right) \]
    7. Applied rewrites51.1%

      \[\leadsto x + \color{blue}{a \cdot \left(b \cdot z\right)} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 6: 72.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \leq -8 \cdot 10^{-62}:\\ \;\;\;\;z \cdot \left(y + a \cdot b\right)\\ \mathbf{elif}\;z \leq 1.1 \cdot 10^{-74}:\\ \;\;\;\;x + a \cdot t\\ \mathbf{elif}\;z \leq 3.5 \cdot 10^{+122}:\\ \;\;\;\;x + y \cdot z\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(a, b, y\right) \cdot z\\ \end{array} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (if (<= z -8e-62)
   (* z (+ y (* a b)))
   (if (<= z 1.1e-74)
     (+ x (* a t))
     (if (<= z 3.5e+122) (+ x (* y z)) (* (fma a b y) z)))))
double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if (z <= -8e-62) {
		tmp = z * (y + (a * b));
	} else if (z <= 1.1e-74) {
		tmp = x + (a * t);
	} else if (z <= 3.5e+122) {
		tmp = x + (y * z);
	} else {
		tmp = fma(a, b, y) * z;
	}
	return tmp;
}
function code(x, y, z, t, a, b)
	tmp = 0.0
	if (z <= -8e-62)
		tmp = Float64(z * Float64(y + Float64(a * b)));
	elseif (z <= 1.1e-74)
		tmp = Float64(x + Float64(a * t));
	elseif (z <= 3.5e+122)
		tmp = Float64(x + Float64(y * z));
	else
		tmp = Float64(fma(a, b, y) * z);
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[z, -8e-62], N[(z * N[(y + N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.1e-74], N[(x + N[(a * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 3.5e+122], N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision], N[(N[(a * b + y), $MachinePrecision] * z), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \leq -8 \cdot 10^{-62}:\\
\;\;\;\;z \cdot \left(y + a \cdot b\right)\\

\mathbf{elif}\;z \leq 1.1 \cdot 10^{-74}:\\
\;\;\;\;x + a \cdot t\\

\mathbf{elif}\;z \leq 3.5 \cdot 10^{+122}:\\
\;\;\;\;x + y \cdot z\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a, b, y\right) \cdot z\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if z < -8.0000000000000003e-62

    1. Initial program 92.6%

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \]
    2. Taylor expanded in z around inf

      \[\leadsto \color{blue}{z \cdot \left(y + a \cdot b\right)} \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto z \cdot \color{blue}{\left(y + a \cdot b\right)} \]
      2. lower-+.f64N/A

        \[\leadsto z \cdot \left(y + \color{blue}{a \cdot b}\right) \]
      3. lower-*.f6450.1

        \[\leadsto z \cdot \left(y + a \cdot \color{blue}{b}\right) \]
    4. Applied rewrites50.1%

      \[\leadsto \color{blue}{z \cdot \left(y + a \cdot b\right)} \]

    if -8.0000000000000003e-62 < z < 1.10000000000000005e-74

    1. Initial program 92.6%

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b} \]
      2. lift-*.f64N/A

        \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \color{blue}{\left(a \cdot z\right) \cdot b} \]
      3. fp-cancel-sign-sub-invN/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) - \left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b} \]
      4. sub-flipN/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right)} \]
      5. +-commutativeN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\left(x + y \cdot z\right) + t \cdot a\right)} \]
      6. lift-+.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\left(x + y \cdot z\right) + \color{blue}{t \cdot a}\right) \]
      8. fp-cancel-sign-sub-invN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(\left(x + y \cdot z\right) - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)} \]
      9. lift-+.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\color{blue}{\left(x + y \cdot z\right)} - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right) \]
      10. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\color{blue}{\left(y \cdot z + x\right)} - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right) \]
      11. associate--l+N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(y \cdot z + \left(x - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)\right)} \]
      12. associate-+r+N/A

        \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + y \cdot z\right) + \left(x - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)} \]
    3. Applied rewrites94.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, \mathsf{fma}\left(a, t, x\right)\right)} \]
    4. Taylor expanded in b around 0

      \[\leadsto \color{blue}{x + \left(a \cdot t + y \cdot z\right)} \]
    5. Step-by-step derivation
      1. lower-+.f64N/A

        \[\leadsto x + \color{blue}{\left(a \cdot t + y \cdot z\right)} \]
      2. lower-fma.f64N/A

        \[\leadsto x + \mathsf{fma}\left(a, \color{blue}{t}, y \cdot z\right) \]
      3. lower-*.f6477.4

        \[\leadsto x + \mathsf{fma}\left(a, t, y \cdot z\right) \]
    6. Applied rewrites77.4%

      \[\leadsto \color{blue}{x + \mathsf{fma}\left(a, t, y \cdot z\right)} \]
    7. Taylor expanded in y around 0

      \[\leadsto x + a \cdot \color{blue}{t} \]
    8. Step-by-step derivation
      1. lower-*.f6452.9

        \[\leadsto x + a \cdot t \]
    9. Applied rewrites52.9%

      \[\leadsto x + a \cdot \color{blue}{t} \]

    if 1.10000000000000005e-74 < z < 3.50000000000000014e122

    1. Initial program 92.6%

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b} \]
      2. lift-*.f64N/A

        \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \color{blue}{\left(a \cdot z\right) \cdot b} \]
      3. fp-cancel-sign-sub-invN/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) - \left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b} \]
      4. sub-flipN/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right)} \]
      5. +-commutativeN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\left(x + y \cdot z\right) + t \cdot a\right)} \]
      6. lift-+.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\left(x + y \cdot z\right) + \color{blue}{t \cdot a}\right) \]
      8. fp-cancel-sign-sub-invN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(\left(x + y \cdot z\right) - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)} \]
      9. lift-+.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\color{blue}{\left(x + y \cdot z\right)} - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right) \]
      10. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\color{blue}{\left(y \cdot z + x\right)} - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right) \]
      11. associate--l+N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(y \cdot z + \left(x - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)\right)} \]
      12. associate-+r+N/A

        \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + y \cdot z\right) + \left(x - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)} \]
    3. Applied rewrites94.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, \mathsf{fma}\left(a, t, x\right)\right)} \]
    4. Taylor expanded in a around 0

      \[\leadsto \color{blue}{x + y \cdot z} \]
    5. Step-by-step derivation
      1. lower-+.f64N/A

        \[\leadsto x + \color{blue}{y \cdot z} \]
      2. lower-*.f6452.2

        \[\leadsto x + y \cdot \color{blue}{z} \]
    6. Applied rewrites52.2%

      \[\leadsto \color{blue}{x + y \cdot z} \]

    if 3.50000000000000014e122 < z

    1. Initial program 92.6%

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \]
    2. Taylor expanded in z around inf

      \[\leadsto \color{blue}{z \cdot \left(y + a \cdot b\right)} \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto z \cdot \color{blue}{\left(y + a \cdot b\right)} \]
      2. lower-+.f64N/A

        \[\leadsto z \cdot \left(y + \color{blue}{a \cdot b}\right) \]
      3. lower-*.f6450.1

        \[\leadsto z \cdot \left(y + a \cdot \color{blue}{b}\right) \]
    4. Applied rewrites50.1%

      \[\leadsto \color{blue}{z \cdot \left(y + a \cdot b\right)} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto z \cdot \color{blue}{\left(y + a \cdot b\right)} \]
      2. *-commutativeN/A

        \[\leadsto \left(y + a \cdot b\right) \cdot \color{blue}{z} \]
      3. lower-*.f6450.1

        \[\leadsto \left(y + a \cdot b\right) \cdot \color{blue}{z} \]
      4. lift-+.f64N/A

        \[\leadsto \left(y + a \cdot b\right) \cdot z \]
      5. +-commutativeN/A

        \[\leadsto \left(a \cdot b + y\right) \cdot z \]
      6. lift-*.f64N/A

        \[\leadsto \left(a \cdot b + y\right) \cdot z \]
      7. lower-fma.f6450.1

        \[\leadsto \mathsf{fma}\left(a, b, y\right) \cdot z \]
    6. Applied rewrites50.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(a, b, y\right) \cdot z} \]
  3. Recombined 4 regimes into one program.
  4. Add Preprocessing

Alternative 7: 72.4% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \mathsf{fma}\left(a, b, y\right) \cdot z\\ \mathbf{if}\;z \leq -8 \cdot 10^{-62}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 1.1 \cdot 10^{-74}:\\ \;\;\;\;x + a \cdot t\\ \mathbf{elif}\;z \leq 3.5 \cdot 10^{+122}:\\ \;\;\;\;x + y \cdot z\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (* (fma a b y) z)))
   (if (<= z -8e-62)
     t_1
     (if (<= z 1.1e-74)
       (+ x (* a t))
       (if (<= z 3.5e+122) (+ x (* y z)) t_1)))))
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = fma(a, b, y) * z;
	double tmp;
	if (z <= -8e-62) {
		tmp = t_1;
	} else if (z <= 1.1e-74) {
		tmp = x + (a * t);
	} else if (z <= 3.5e+122) {
		tmp = x + (y * z);
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, y, z, t, a, b)
	t_1 = Float64(fma(a, b, y) * z)
	tmp = 0.0
	if (z <= -8e-62)
		tmp = t_1;
	elseif (z <= 1.1e-74)
		tmp = Float64(x + Float64(a * t));
	elseif (z <= 3.5e+122)
		tmp = Float64(x + Float64(y * z));
	else
		tmp = t_1;
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a * b + y), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[z, -8e-62], t$95$1, If[LessEqual[z, 1.1e-74], N[(x + N[(a * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 3.5e+122], N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(a, b, y\right) \cdot z\\
\mathbf{if}\;z \leq -8 \cdot 10^{-62}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \leq 1.1 \cdot 10^{-74}:\\
\;\;\;\;x + a \cdot t\\

\mathbf{elif}\;z \leq 3.5 \cdot 10^{+122}:\\
\;\;\;\;x + y \cdot z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -8.0000000000000003e-62 or 3.50000000000000014e122 < z

    1. Initial program 92.6%

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \]
    2. Taylor expanded in z around inf

      \[\leadsto \color{blue}{z \cdot \left(y + a \cdot b\right)} \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto z \cdot \color{blue}{\left(y + a \cdot b\right)} \]
      2. lower-+.f64N/A

        \[\leadsto z \cdot \left(y + \color{blue}{a \cdot b}\right) \]
      3. lower-*.f6450.1

        \[\leadsto z \cdot \left(y + a \cdot \color{blue}{b}\right) \]
    4. Applied rewrites50.1%

      \[\leadsto \color{blue}{z \cdot \left(y + a \cdot b\right)} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto z \cdot \color{blue}{\left(y + a \cdot b\right)} \]
      2. *-commutativeN/A

        \[\leadsto \left(y + a \cdot b\right) \cdot \color{blue}{z} \]
      3. lower-*.f6450.1

        \[\leadsto \left(y + a \cdot b\right) \cdot \color{blue}{z} \]
      4. lift-+.f64N/A

        \[\leadsto \left(y + a \cdot b\right) \cdot z \]
      5. +-commutativeN/A

        \[\leadsto \left(a \cdot b + y\right) \cdot z \]
      6. lift-*.f64N/A

        \[\leadsto \left(a \cdot b + y\right) \cdot z \]
      7. lower-fma.f6450.1

        \[\leadsto \mathsf{fma}\left(a, b, y\right) \cdot z \]
    6. Applied rewrites50.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(a, b, y\right) \cdot z} \]

    if -8.0000000000000003e-62 < z < 1.10000000000000005e-74

    1. Initial program 92.6%

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b} \]
      2. lift-*.f64N/A

        \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \color{blue}{\left(a \cdot z\right) \cdot b} \]
      3. fp-cancel-sign-sub-invN/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) - \left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b} \]
      4. sub-flipN/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right)} \]
      5. +-commutativeN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\left(x + y \cdot z\right) + t \cdot a\right)} \]
      6. lift-+.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\left(x + y \cdot z\right) + \color{blue}{t \cdot a}\right) \]
      8. fp-cancel-sign-sub-invN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(\left(x + y \cdot z\right) - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)} \]
      9. lift-+.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\color{blue}{\left(x + y \cdot z\right)} - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right) \]
      10. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\color{blue}{\left(y \cdot z + x\right)} - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right) \]
      11. associate--l+N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(y \cdot z + \left(x - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)\right)} \]
      12. associate-+r+N/A

        \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + y \cdot z\right) + \left(x - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)} \]
    3. Applied rewrites94.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, \mathsf{fma}\left(a, t, x\right)\right)} \]
    4. Taylor expanded in b around 0

      \[\leadsto \color{blue}{x + \left(a \cdot t + y \cdot z\right)} \]
    5. Step-by-step derivation
      1. lower-+.f64N/A

        \[\leadsto x + \color{blue}{\left(a \cdot t + y \cdot z\right)} \]
      2. lower-fma.f64N/A

        \[\leadsto x + \mathsf{fma}\left(a, \color{blue}{t}, y \cdot z\right) \]
      3. lower-*.f6477.4

        \[\leadsto x + \mathsf{fma}\left(a, t, y \cdot z\right) \]
    6. Applied rewrites77.4%

      \[\leadsto \color{blue}{x + \mathsf{fma}\left(a, t, y \cdot z\right)} \]
    7. Taylor expanded in y around 0

      \[\leadsto x + a \cdot \color{blue}{t} \]
    8. Step-by-step derivation
      1. lower-*.f6452.9

        \[\leadsto x + a \cdot t \]
    9. Applied rewrites52.9%

      \[\leadsto x + a \cdot \color{blue}{t} \]

    if 1.10000000000000005e-74 < z < 3.50000000000000014e122

    1. Initial program 92.6%

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b} \]
      2. lift-*.f64N/A

        \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \color{blue}{\left(a \cdot z\right) \cdot b} \]
      3. fp-cancel-sign-sub-invN/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) - \left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b} \]
      4. sub-flipN/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right)} \]
      5. +-commutativeN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\left(x + y \cdot z\right) + t \cdot a\right)} \]
      6. lift-+.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\left(x + y \cdot z\right) + \color{blue}{t \cdot a}\right) \]
      8. fp-cancel-sign-sub-invN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(\left(x + y \cdot z\right) - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)} \]
      9. lift-+.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\color{blue}{\left(x + y \cdot z\right)} - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right) \]
      10. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\color{blue}{\left(y \cdot z + x\right)} - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right) \]
      11. associate--l+N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(y \cdot z + \left(x - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)\right)} \]
      12. associate-+r+N/A

        \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + y \cdot z\right) + \left(x - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)} \]
    3. Applied rewrites94.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, \mathsf{fma}\left(a, t, x\right)\right)} \]
    4. Taylor expanded in a around 0

      \[\leadsto \color{blue}{x + y \cdot z} \]
    5. Step-by-step derivation
      1. lower-+.f64N/A

        \[\leadsto x + \color{blue}{y \cdot z} \]
      2. lower-*.f6452.2

        \[\leadsto x + y \cdot \color{blue}{z} \]
    6. Applied rewrites52.2%

      \[\leadsto \color{blue}{x + y \cdot z} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 8: 65.1% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x + y \cdot z\\ \mathbf{if}\;z \leq -7.2 \cdot 10^{+264}:\\ \;\;\;\;\left(a \cdot b\right) \cdot z\\ \mathbf{elif}\;z \leq -8.5 \cdot 10^{+105}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 1.1 \cdot 10^{-74}:\\ \;\;\;\;x + a \cdot t\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (+ x (* y z))))
   (if (<= z -7.2e+264)
     (* (* a b) z)
     (if (<= z -8.5e+105) t_1 (if (<= z 1.1e-74) (+ x (* a t)) t_1)))))
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = x + (y * z);
	double tmp;
	if (z <= -7.2e+264) {
		tmp = (a * b) * z;
	} else if (z <= -8.5e+105) {
		tmp = t_1;
	} else if (z <= 1.1e-74) {
		tmp = x + (a * t);
	} 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, y, z, t, a, b)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: t_1
    real(8) :: tmp
    t_1 = x + (y * z)
    if (z <= (-7.2d+264)) then
        tmp = (a * b) * z
    else if (z <= (-8.5d+105)) then
        tmp = t_1
    else if (z <= 1.1d-74) then
        tmp = x + (a * t)
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = x + (y * z);
	double tmp;
	if (z <= -7.2e+264) {
		tmp = (a * b) * z;
	} else if (z <= -8.5e+105) {
		tmp = t_1;
	} else if (z <= 1.1e-74) {
		tmp = x + (a * t);
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t, a, b):
	t_1 = x + (y * z)
	tmp = 0
	if z <= -7.2e+264:
		tmp = (a * b) * z
	elif z <= -8.5e+105:
		tmp = t_1
	elif z <= 1.1e-74:
		tmp = x + (a * t)
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t, a, b)
	t_1 = Float64(x + Float64(y * z))
	tmp = 0.0
	if (z <= -7.2e+264)
		tmp = Float64(Float64(a * b) * z);
	elseif (z <= -8.5e+105)
		tmp = t_1;
	elseif (z <= 1.1e-74)
		tmp = Float64(x + Float64(a * t));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b)
	t_1 = x + (y * z);
	tmp = 0.0;
	if (z <= -7.2e+264)
		tmp = (a * b) * z;
	elseif (z <= -8.5e+105)
		tmp = t_1;
	elseif (z <= 1.1e-74)
		tmp = x + (a * t);
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -7.2e+264], N[(N[(a * b), $MachinePrecision] * z), $MachinePrecision], If[LessEqual[z, -8.5e+105], t$95$1, If[LessEqual[z, 1.1e-74], N[(x + N[(a * t), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x + y \cdot z\\
\mathbf{if}\;z \leq -7.2 \cdot 10^{+264}:\\
\;\;\;\;\left(a \cdot b\right) \cdot z\\

\mathbf{elif}\;z \leq -8.5 \cdot 10^{+105}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \leq 1.1 \cdot 10^{-74}:\\
\;\;\;\;x + a \cdot t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -7.20000000000000023e264

    1. Initial program 92.6%

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \]
    2. Taylor expanded in z around inf

      \[\leadsto \color{blue}{z \cdot \left(y + a \cdot b\right)} \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto z \cdot \color{blue}{\left(y + a \cdot b\right)} \]
      2. lower-+.f64N/A

        \[\leadsto z \cdot \left(y + \color{blue}{a \cdot b}\right) \]
      3. lower-*.f6450.1

        \[\leadsto z \cdot \left(y + a \cdot \color{blue}{b}\right) \]
    4. Applied rewrites50.1%

      \[\leadsto \color{blue}{z \cdot \left(y + a \cdot b\right)} \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto z \cdot \color{blue}{\left(y + a \cdot b\right)} \]
      2. *-commutativeN/A

        \[\leadsto \left(y + a \cdot b\right) \cdot \color{blue}{z} \]
      3. lower-*.f6450.1

        \[\leadsto \left(y + a \cdot b\right) \cdot \color{blue}{z} \]
      4. lift-+.f64N/A

        \[\leadsto \left(y + a \cdot b\right) \cdot z \]
      5. +-commutativeN/A

        \[\leadsto \left(a \cdot b + y\right) \cdot z \]
      6. lift-*.f64N/A

        \[\leadsto \left(a \cdot b + y\right) \cdot z \]
      7. lower-fma.f6450.1

        \[\leadsto \mathsf{fma}\left(a, b, y\right) \cdot z \]
    6. Applied rewrites50.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(a, b, y\right) \cdot z} \]
    7. Taylor expanded in y around 0

      \[\leadsto \left(a \cdot b\right) \cdot z \]
    8. Step-by-step derivation
      1. lower-*.f6426.9

        \[\leadsto \left(a \cdot b\right) \cdot z \]
    9. Applied rewrites26.9%

      \[\leadsto \left(a \cdot b\right) \cdot z \]

    if -7.20000000000000023e264 < z < -8.49999999999999986e105 or 1.10000000000000005e-74 < z

    1. Initial program 92.6%

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b} \]
      2. lift-*.f64N/A

        \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \color{blue}{\left(a \cdot z\right) \cdot b} \]
      3. fp-cancel-sign-sub-invN/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) - \left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b} \]
      4. sub-flipN/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right)} \]
      5. +-commutativeN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\left(x + y \cdot z\right) + t \cdot a\right)} \]
      6. lift-+.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\left(x + y \cdot z\right) + \color{blue}{t \cdot a}\right) \]
      8. fp-cancel-sign-sub-invN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(\left(x + y \cdot z\right) - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)} \]
      9. lift-+.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\color{blue}{\left(x + y \cdot z\right)} - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right) \]
      10. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\color{blue}{\left(y \cdot z + x\right)} - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right) \]
      11. associate--l+N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(y \cdot z + \left(x - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)\right)} \]
      12. associate-+r+N/A

        \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + y \cdot z\right) + \left(x - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)} \]
    3. Applied rewrites94.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, \mathsf{fma}\left(a, t, x\right)\right)} \]
    4. Taylor expanded in a around 0

      \[\leadsto \color{blue}{x + y \cdot z} \]
    5. Step-by-step derivation
      1. lower-+.f64N/A

        \[\leadsto x + \color{blue}{y \cdot z} \]
      2. lower-*.f6452.2

        \[\leadsto x + y \cdot \color{blue}{z} \]
    6. Applied rewrites52.2%

      \[\leadsto \color{blue}{x + y \cdot z} \]

    if -8.49999999999999986e105 < z < 1.10000000000000005e-74

    1. Initial program 92.6%

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b} \]
      2. lift-*.f64N/A

        \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \color{blue}{\left(a \cdot z\right) \cdot b} \]
      3. fp-cancel-sign-sub-invN/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) - \left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b} \]
      4. sub-flipN/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right)} \]
      5. +-commutativeN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\left(x + y \cdot z\right) + t \cdot a\right)} \]
      6. lift-+.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\left(x + y \cdot z\right) + \color{blue}{t \cdot a}\right) \]
      8. fp-cancel-sign-sub-invN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(\left(x + y \cdot z\right) - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)} \]
      9. lift-+.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\color{blue}{\left(x + y \cdot z\right)} - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right) \]
      10. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\color{blue}{\left(y \cdot z + x\right)} - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right) \]
      11. associate--l+N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(y \cdot z + \left(x - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)\right)} \]
      12. associate-+r+N/A

        \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + y \cdot z\right) + \left(x - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)} \]
    3. Applied rewrites94.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, \mathsf{fma}\left(a, t, x\right)\right)} \]
    4. Taylor expanded in b around 0

      \[\leadsto \color{blue}{x + \left(a \cdot t + y \cdot z\right)} \]
    5. Step-by-step derivation
      1. lower-+.f64N/A

        \[\leadsto x + \color{blue}{\left(a \cdot t + y \cdot z\right)} \]
      2. lower-fma.f64N/A

        \[\leadsto x + \mathsf{fma}\left(a, \color{blue}{t}, y \cdot z\right) \]
      3. lower-*.f6477.4

        \[\leadsto x + \mathsf{fma}\left(a, t, y \cdot z\right) \]
    6. Applied rewrites77.4%

      \[\leadsto \color{blue}{x + \mathsf{fma}\left(a, t, y \cdot z\right)} \]
    7. Taylor expanded in y around 0

      \[\leadsto x + a \cdot \color{blue}{t} \]
    8. Step-by-step derivation
      1. lower-*.f6452.9

        \[\leadsto x + a \cdot t \]
    9. Applied rewrites52.9%

      \[\leadsto x + a \cdot \color{blue}{t} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 9: 63.1% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x + y \cdot z\\ \mathbf{if}\;z \leq -1.6 \cdot 10^{+265}:\\ \;\;\;\;a \cdot \left(b \cdot z\right)\\ \mathbf{elif}\;z \leq -8.5 \cdot 10^{+105}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 1.1 \cdot 10^{-74}:\\ \;\;\;\;x + a \cdot t\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (+ x (* y z))))
   (if (<= z -1.6e+265)
     (* a (* b z))
     (if (<= z -8.5e+105) t_1 (if (<= z 1.1e-74) (+ x (* a t)) t_1)))))
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = x + (y * z);
	double tmp;
	if (z <= -1.6e+265) {
		tmp = a * (b * z);
	} else if (z <= -8.5e+105) {
		tmp = t_1;
	} else if (z <= 1.1e-74) {
		tmp = x + (a * t);
	} 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, y, z, t, a, b)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: t_1
    real(8) :: tmp
    t_1 = x + (y * z)
    if (z <= (-1.6d+265)) then
        tmp = a * (b * z)
    else if (z <= (-8.5d+105)) then
        tmp = t_1
    else if (z <= 1.1d-74) then
        tmp = x + (a * t)
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = x + (y * z);
	double tmp;
	if (z <= -1.6e+265) {
		tmp = a * (b * z);
	} else if (z <= -8.5e+105) {
		tmp = t_1;
	} else if (z <= 1.1e-74) {
		tmp = x + (a * t);
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t, a, b):
	t_1 = x + (y * z)
	tmp = 0
	if z <= -1.6e+265:
		tmp = a * (b * z)
	elif z <= -8.5e+105:
		tmp = t_1
	elif z <= 1.1e-74:
		tmp = x + (a * t)
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t, a, b)
	t_1 = Float64(x + Float64(y * z))
	tmp = 0.0
	if (z <= -1.6e+265)
		tmp = Float64(a * Float64(b * z));
	elseif (z <= -8.5e+105)
		tmp = t_1;
	elseif (z <= 1.1e-74)
		tmp = Float64(x + Float64(a * t));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b)
	t_1 = x + (y * z);
	tmp = 0.0;
	if (z <= -1.6e+265)
		tmp = a * (b * z);
	elseif (z <= -8.5e+105)
		tmp = t_1;
	elseif (z <= 1.1e-74)
		tmp = x + (a * t);
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.6e+265], N[(a * N[(b * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, -8.5e+105], t$95$1, If[LessEqual[z, 1.1e-74], N[(x + N[(a * t), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x + y \cdot z\\
\mathbf{if}\;z \leq -1.6 \cdot 10^{+265}:\\
\;\;\;\;a \cdot \left(b \cdot z\right)\\

\mathbf{elif}\;z \leq -8.5 \cdot 10^{+105}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \leq 1.1 \cdot 10^{-74}:\\
\;\;\;\;x + a \cdot t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.60000000000000007e265

    1. Initial program 92.6%

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \]
    2. Taylor expanded in z around inf

      \[\leadsto \color{blue}{z \cdot \left(y + a \cdot b\right)} \]
    3. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto z \cdot \color{blue}{\left(y + a \cdot b\right)} \]
      2. lower-+.f64N/A

        \[\leadsto z \cdot \left(y + \color{blue}{a \cdot b}\right) \]
      3. lower-*.f6450.1

        \[\leadsto z \cdot \left(y + a \cdot \color{blue}{b}\right) \]
    4. Applied rewrites50.1%

      \[\leadsto \color{blue}{z \cdot \left(y + a \cdot b\right)} \]
    5. Taylor expanded in y around 0

      \[\leadsto a \cdot \color{blue}{\left(b \cdot z\right)} \]
    6. Step-by-step derivation
      1. lower-*.f64N/A

        \[\leadsto a \cdot \left(b \cdot \color{blue}{z}\right) \]
      2. lower-*.f6427.0

        \[\leadsto a \cdot \left(b \cdot z\right) \]
    7. Applied rewrites27.0%

      \[\leadsto a \cdot \color{blue}{\left(b \cdot z\right)} \]

    if -1.60000000000000007e265 < z < -8.49999999999999986e105 or 1.10000000000000005e-74 < z

    1. Initial program 92.6%

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b} \]
      2. lift-*.f64N/A

        \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \color{blue}{\left(a \cdot z\right) \cdot b} \]
      3. fp-cancel-sign-sub-invN/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) - \left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b} \]
      4. sub-flipN/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right)} \]
      5. +-commutativeN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\left(x + y \cdot z\right) + t \cdot a\right)} \]
      6. lift-+.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\left(x + y \cdot z\right) + \color{blue}{t \cdot a}\right) \]
      8. fp-cancel-sign-sub-invN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(\left(x + y \cdot z\right) - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)} \]
      9. lift-+.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\color{blue}{\left(x + y \cdot z\right)} - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right) \]
      10. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\color{blue}{\left(y \cdot z + x\right)} - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right) \]
      11. associate--l+N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(y \cdot z + \left(x - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)\right)} \]
      12. associate-+r+N/A

        \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + y \cdot z\right) + \left(x - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)} \]
    3. Applied rewrites94.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, \mathsf{fma}\left(a, t, x\right)\right)} \]
    4. Taylor expanded in a around 0

      \[\leadsto \color{blue}{x + y \cdot z} \]
    5. Step-by-step derivation
      1. lower-+.f64N/A

        \[\leadsto x + \color{blue}{y \cdot z} \]
      2. lower-*.f6452.2

        \[\leadsto x + y \cdot \color{blue}{z} \]
    6. Applied rewrites52.2%

      \[\leadsto \color{blue}{x + y \cdot z} \]

    if -8.49999999999999986e105 < z < 1.10000000000000005e-74

    1. Initial program 92.6%

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b} \]
      2. lift-*.f64N/A

        \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \color{blue}{\left(a \cdot z\right) \cdot b} \]
      3. fp-cancel-sign-sub-invN/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) - \left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b} \]
      4. sub-flipN/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right)} \]
      5. +-commutativeN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\left(x + y \cdot z\right) + t \cdot a\right)} \]
      6. lift-+.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\left(x + y \cdot z\right) + \color{blue}{t \cdot a}\right) \]
      8. fp-cancel-sign-sub-invN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(\left(x + y \cdot z\right) - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)} \]
      9. lift-+.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\color{blue}{\left(x + y \cdot z\right)} - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right) \]
      10. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\color{blue}{\left(y \cdot z + x\right)} - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right) \]
      11. associate--l+N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(y \cdot z + \left(x - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)\right)} \]
      12. associate-+r+N/A

        \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + y \cdot z\right) + \left(x - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)} \]
    3. Applied rewrites94.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, \mathsf{fma}\left(a, t, x\right)\right)} \]
    4. Taylor expanded in b around 0

      \[\leadsto \color{blue}{x + \left(a \cdot t + y \cdot z\right)} \]
    5. Step-by-step derivation
      1. lower-+.f64N/A

        \[\leadsto x + \color{blue}{\left(a \cdot t + y \cdot z\right)} \]
      2. lower-fma.f64N/A

        \[\leadsto x + \mathsf{fma}\left(a, \color{blue}{t}, y \cdot z\right) \]
      3. lower-*.f6477.4

        \[\leadsto x + \mathsf{fma}\left(a, t, y \cdot z\right) \]
    6. Applied rewrites77.4%

      \[\leadsto \color{blue}{x + \mathsf{fma}\left(a, t, y \cdot z\right)} \]
    7. Taylor expanded in y around 0

      \[\leadsto x + a \cdot \color{blue}{t} \]
    8. Step-by-step derivation
      1. lower-*.f6452.9

        \[\leadsto x + a \cdot t \]
    9. Applied rewrites52.9%

      \[\leadsto x + a \cdot \color{blue}{t} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 10: 63.1% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;y \leq -4.8 \cdot 10^{+35}:\\ \;\;\;\;x + y \cdot z\\ \mathbf{elif}\;y \leq 90:\\ \;\;\;\;x + a \cdot t\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(z, y, a \cdot t\right)\\ \end{array} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (if (<= y -4.8e+35)
   (+ x (* y z))
   (if (<= y 90.0) (+ x (* a t)) (fma z y (* a t)))))
double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if (y <= -4.8e+35) {
		tmp = x + (y * z);
	} else if (y <= 90.0) {
		tmp = x + (a * t);
	} else {
		tmp = fma(z, y, (a * t));
	}
	return tmp;
}
function code(x, y, z, t, a, b)
	tmp = 0.0
	if (y <= -4.8e+35)
		tmp = Float64(x + Float64(y * z));
	elseif (y <= 90.0)
		tmp = Float64(x + Float64(a * t));
	else
		tmp = fma(z, y, Float64(a * t));
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[y, -4.8e+35], N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 90.0], N[(x + N[(a * t), $MachinePrecision]), $MachinePrecision], N[(z * y + N[(a * t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.8 \cdot 10^{+35}:\\
\;\;\;\;x + y \cdot z\\

\mathbf{elif}\;y \leq 90:\\
\;\;\;\;x + a \cdot t\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, y, a \cdot t\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -4.80000000000000029e35

    1. Initial program 92.6%

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b} \]
      2. lift-*.f64N/A

        \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \color{blue}{\left(a \cdot z\right) \cdot b} \]
      3. fp-cancel-sign-sub-invN/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) - \left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b} \]
      4. sub-flipN/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right)} \]
      5. +-commutativeN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\left(x + y \cdot z\right) + t \cdot a\right)} \]
      6. lift-+.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\left(x + y \cdot z\right) + \color{blue}{t \cdot a}\right) \]
      8. fp-cancel-sign-sub-invN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(\left(x + y \cdot z\right) - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)} \]
      9. lift-+.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\color{blue}{\left(x + y \cdot z\right)} - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right) \]
      10. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\color{blue}{\left(y \cdot z + x\right)} - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right) \]
      11. associate--l+N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(y \cdot z + \left(x - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)\right)} \]
      12. associate-+r+N/A

        \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + y \cdot z\right) + \left(x - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)} \]
    3. Applied rewrites94.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, \mathsf{fma}\left(a, t, x\right)\right)} \]
    4. Taylor expanded in a around 0

      \[\leadsto \color{blue}{x + y \cdot z} \]
    5. Step-by-step derivation
      1. lower-+.f64N/A

        \[\leadsto x + \color{blue}{y \cdot z} \]
      2. lower-*.f6452.2

        \[\leadsto x + y \cdot \color{blue}{z} \]
    6. Applied rewrites52.2%

      \[\leadsto \color{blue}{x + y \cdot z} \]

    if -4.80000000000000029e35 < y < 90

    1. Initial program 92.6%

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b} \]
      2. lift-*.f64N/A

        \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \color{blue}{\left(a \cdot z\right) \cdot b} \]
      3. fp-cancel-sign-sub-invN/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) - \left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b} \]
      4. sub-flipN/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right)} \]
      5. +-commutativeN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\left(x + y \cdot z\right) + t \cdot a\right)} \]
      6. lift-+.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\left(x + y \cdot z\right) + \color{blue}{t \cdot a}\right) \]
      8. fp-cancel-sign-sub-invN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(\left(x + y \cdot z\right) - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)} \]
      9. lift-+.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\color{blue}{\left(x + y \cdot z\right)} - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right) \]
      10. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\color{blue}{\left(y \cdot z + x\right)} - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right) \]
      11. associate--l+N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(y \cdot z + \left(x - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)\right)} \]
      12. associate-+r+N/A

        \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + y \cdot z\right) + \left(x - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)} \]
    3. Applied rewrites94.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, \mathsf{fma}\left(a, t, x\right)\right)} \]
    4. Taylor expanded in b around 0

      \[\leadsto \color{blue}{x + \left(a \cdot t + y \cdot z\right)} \]
    5. Step-by-step derivation
      1. lower-+.f64N/A

        \[\leadsto x + \color{blue}{\left(a \cdot t + y \cdot z\right)} \]
      2. lower-fma.f64N/A

        \[\leadsto x + \mathsf{fma}\left(a, \color{blue}{t}, y \cdot z\right) \]
      3. lower-*.f6477.4

        \[\leadsto x + \mathsf{fma}\left(a, t, y \cdot z\right) \]
    6. Applied rewrites77.4%

      \[\leadsto \color{blue}{x + \mathsf{fma}\left(a, t, y \cdot z\right)} \]
    7. Taylor expanded in y around 0

      \[\leadsto x + a \cdot \color{blue}{t} \]
    8. Step-by-step derivation
      1. lower-*.f6452.9

        \[\leadsto x + a \cdot t \]
    9. Applied rewrites52.9%

      \[\leadsto x + a \cdot \color{blue}{t} \]

    if 90 < y

    1. Initial program 92.6%

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b} \]
      2. lift-*.f64N/A

        \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \color{blue}{\left(a \cdot z\right) \cdot b} \]
      3. fp-cancel-sign-sub-invN/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) - \left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b} \]
      4. sub-flipN/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right)} \]
      5. +-commutativeN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\left(x + y \cdot z\right) + t \cdot a\right)} \]
      6. lift-+.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\left(x + y \cdot z\right) + \color{blue}{t \cdot a}\right) \]
      8. fp-cancel-sign-sub-invN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(\left(x + y \cdot z\right) - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)} \]
      9. lift-+.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\color{blue}{\left(x + y \cdot z\right)} - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right) \]
      10. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\color{blue}{\left(y \cdot z + x\right)} - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right) \]
      11. associate--l+N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(y \cdot z + \left(x - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)\right)} \]
      12. associate-+r+N/A

        \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + y \cdot z\right) + \left(x - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)} \]
    3. Applied rewrites94.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, \mathsf{fma}\left(a, t, x\right)\right)} \]
    4. Taylor expanded in b around 0

      \[\leadsto \color{blue}{x + \left(a \cdot t + y \cdot z\right)} \]
    5. Step-by-step derivation
      1. lower-+.f64N/A

        \[\leadsto x + \color{blue}{\left(a \cdot t + y \cdot z\right)} \]
      2. lower-fma.f64N/A

        \[\leadsto x + \mathsf{fma}\left(a, \color{blue}{t}, y \cdot z\right) \]
      3. lower-*.f6477.4

        \[\leadsto x + \mathsf{fma}\left(a, t, y \cdot z\right) \]
    6. Applied rewrites77.4%

      \[\leadsto \color{blue}{x + \mathsf{fma}\left(a, t, y \cdot z\right)} \]
    7. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto x + \color{blue}{\mathsf{fma}\left(a, t, y \cdot z\right)} \]
      2. lift-fma.f64N/A

        \[\leadsto x + \left(a \cdot t + \color{blue}{y \cdot z}\right) \]
      3. associate-+r+N/A

        \[\leadsto \left(x + a \cdot t\right) + \color{blue}{y \cdot z} \]
      4. +-commutativeN/A

        \[\leadsto \left(a \cdot t + x\right) + \color{blue}{y} \cdot z \]
      5. +-commutativeN/A

        \[\leadsto y \cdot z + \color{blue}{\left(a \cdot t + x\right)} \]
      6. lift-*.f64N/A

        \[\leadsto y \cdot z + \left(\color{blue}{a \cdot t} + x\right) \]
      7. *-commutativeN/A

        \[\leadsto z \cdot y + \left(\color{blue}{a \cdot t} + x\right) \]
      8. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(z, \color{blue}{y}, a \cdot t + x\right) \]
      9. add-flipN/A

        \[\leadsto \mathsf{fma}\left(z, y, a \cdot t - \left(\mathsf{neg}\left(x\right)\right)\right) \]
      10. sub-negate-revN/A

        \[\leadsto \mathsf{fma}\left(z, y, \mathsf{neg}\left(\left(\left(\mathsf{neg}\left(x\right)\right) - a \cdot t\right)\right)\right) \]
      11. sub-flip-reverseN/A

        \[\leadsto \mathsf{fma}\left(z, y, \mathsf{neg}\left(\left(\left(\mathsf{neg}\left(x\right)\right) + \left(\mathsf{neg}\left(a \cdot t\right)\right)\right)\right)\right) \]
      12. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(z, y, \mathsf{neg}\left(\left(\left(\mathsf{neg}\left(x\right)\right) + \left(\mathsf{neg}\left(t \cdot a\right)\right)\right)\right)\right) \]
      13. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(z, y, \mathsf{neg}\left(\left(\left(\mathsf{neg}\left(t \cdot a\right)\right) + \left(\mathsf{neg}\left(x\right)\right)\right)\right)\right) \]
      14. distribute-neg-inN/A

        \[\leadsto \mathsf{fma}\left(z, y, \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(t \cdot a\right)\right)\right)\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)\right) \]
      15. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(z, y, \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot t\right)\right)\right)\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)\right) \]
      16. remove-double-negN/A

        \[\leadsto \mathsf{fma}\left(z, y, a \cdot t + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)\right) \]
      17. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(z, y, t \cdot a + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(x\right)\right)\right)\right)\right) \]
      18. remove-double-negN/A

        \[\leadsto \mathsf{fma}\left(z, y, t \cdot a + x\right) \]
      19. lower-fma.f6477.4

        \[\leadsto \mathsf{fma}\left(z, y, \mathsf{fma}\left(t, a, x\right)\right) \]
    8. Applied rewrites77.4%

      \[\leadsto \mathsf{fma}\left(z, \color{blue}{y}, \mathsf{fma}\left(t, a, x\right)\right) \]
    9. Taylor expanded in x around 0

      \[\leadsto \mathsf{fma}\left(z, y, a \cdot t\right) \]
    10. Step-by-step derivation
      1. lower-*.f6452.5

        \[\leadsto \mathsf{fma}\left(z, y, a \cdot t\right) \]
    11. Applied rewrites52.5%

      \[\leadsto \mathsf{fma}\left(z, y, a \cdot t\right) \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 11: 63.0% accurate, 1.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x + y \cdot z\\ \mathbf{if}\;z \leq -8.5 \cdot 10^{+105}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;z \leq 1.1 \cdot 10^{-74}:\\ \;\;\;\;x + a \cdot t\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (+ x (* y z))))
   (if (<= z -8.5e+105) t_1 (if (<= z 1.1e-74) (+ x (* a t)) t_1))))
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = x + (y * z);
	double tmp;
	if (z <= -8.5e+105) {
		tmp = t_1;
	} else if (z <= 1.1e-74) {
		tmp = x + (a * t);
	} 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, y, z, t, a, b)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: t_1
    real(8) :: tmp
    t_1 = x + (y * z)
    if (z <= (-8.5d+105)) then
        tmp = t_1
    else if (z <= 1.1d-74) then
        tmp = x + (a * t)
    else
        tmp = t_1
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = x + (y * z);
	double tmp;
	if (z <= -8.5e+105) {
		tmp = t_1;
	} else if (z <= 1.1e-74) {
		tmp = x + (a * t);
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t, a, b):
	t_1 = x + (y * z)
	tmp = 0
	if z <= -8.5e+105:
		tmp = t_1
	elif z <= 1.1e-74:
		tmp = x + (a * t)
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t, a, b)
	t_1 = Float64(x + Float64(y * z))
	tmp = 0.0
	if (z <= -8.5e+105)
		tmp = t_1;
	elseif (z <= 1.1e-74)
		tmp = Float64(x + Float64(a * t));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b)
	t_1 = x + (y * z);
	tmp = 0.0;
	if (z <= -8.5e+105)
		tmp = t_1;
	elseif (z <= 1.1e-74)
		tmp = x + (a * t);
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(x + N[(y * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -8.5e+105], t$95$1, If[LessEqual[z, 1.1e-74], N[(x + N[(a * t), $MachinePrecision]), $MachinePrecision], t$95$1]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x + y \cdot z\\
\mathbf{if}\;z \leq -8.5 \cdot 10^{+105}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;z \leq 1.1 \cdot 10^{-74}:\\
\;\;\;\;x + a \cdot t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -8.49999999999999986e105 or 1.10000000000000005e-74 < z

    1. Initial program 92.6%

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b} \]
      2. lift-*.f64N/A

        \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \color{blue}{\left(a \cdot z\right) \cdot b} \]
      3. fp-cancel-sign-sub-invN/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) - \left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b} \]
      4. sub-flipN/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right)} \]
      5. +-commutativeN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\left(x + y \cdot z\right) + t \cdot a\right)} \]
      6. lift-+.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\left(x + y \cdot z\right) + \color{blue}{t \cdot a}\right) \]
      8. fp-cancel-sign-sub-invN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(\left(x + y \cdot z\right) - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)} \]
      9. lift-+.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\color{blue}{\left(x + y \cdot z\right)} - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right) \]
      10. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\color{blue}{\left(y \cdot z + x\right)} - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right) \]
      11. associate--l+N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(y \cdot z + \left(x - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)\right)} \]
      12. associate-+r+N/A

        \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + y \cdot z\right) + \left(x - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)} \]
    3. Applied rewrites94.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, \mathsf{fma}\left(a, t, x\right)\right)} \]
    4. Taylor expanded in a around 0

      \[\leadsto \color{blue}{x + y \cdot z} \]
    5. Step-by-step derivation
      1. lower-+.f64N/A

        \[\leadsto x + \color{blue}{y \cdot z} \]
      2. lower-*.f6452.2

        \[\leadsto x + y \cdot \color{blue}{z} \]
    6. Applied rewrites52.2%

      \[\leadsto \color{blue}{x + y \cdot z} \]

    if -8.49999999999999986e105 < z < 1.10000000000000005e-74

    1. Initial program 92.6%

      \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \]
    2. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b} \]
      2. lift-*.f64N/A

        \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \color{blue}{\left(a \cdot z\right) \cdot b} \]
      3. fp-cancel-sign-sub-invN/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) - \left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b} \]
      4. sub-flipN/A

        \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right)} \]
      5. +-commutativeN/A

        \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\left(x + y \cdot z\right) + t \cdot a\right)} \]
      6. lift-+.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right)} \]
      7. lift-*.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\left(x + y \cdot z\right) + \color{blue}{t \cdot a}\right) \]
      8. fp-cancel-sign-sub-invN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(\left(x + y \cdot z\right) - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)} \]
      9. lift-+.f64N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\color{blue}{\left(x + y \cdot z\right)} - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right) \]
      10. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\color{blue}{\left(y \cdot z + x\right)} - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right) \]
      11. associate--l+N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(y \cdot z + \left(x - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)\right)} \]
      12. associate-+r+N/A

        \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + y \cdot z\right) + \left(x - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)} \]
    3. Applied rewrites94.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, \mathsf{fma}\left(a, t, x\right)\right)} \]
    4. Taylor expanded in b around 0

      \[\leadsto \color{blue}{x + \left(a \cdot t + y \cdot z\right)} \]
    5. Step-by-step derivation
      1. lower-+.f64N/A

        \[\leadsto x + \color{blue}{\left(a \cdot t + y \cdot z\right)} \]
      2. lower-fma.f64N/A

        \[\leadsto x + \mathsf{fma}\left(a, \color{blue}{t}, y \cdot z\right) \]
      3. lower-*.f6477.4

        \[\leadsto x + \mathsf{fma}\left(a, t, y \cdot z\right) \]
    6. Applied rewrites77.4%

      \[\leadsto \color{blue}{x + \mathsf{fma}\left(a, t, y \cdot z\right)} \]
    7. Taylor expanded in y around 0

      \[\leadsto x + a \cdot \color{blue}{t} \]
    8. Step-by-step derivation
      1. lower-*.f6452.9

        \[\leadsto x + a \cdot t \]
    9. Applied rewrites52.9%

      \[\leadsto x + a \cdot \color{blue}{t} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 12: 52.9% accurate, 3.1× speedup?

\[\begin{array}{l} \\ x + a \cdot t \end{array} \]
(FPCore (x y z t a b) :precision binary64 (+ x (* a t)))
double code(double x, double y, double z, double t, double a, double b) {
	return x + (a * t);
}
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, y, z, t, a, b)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = x + (a * t)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	return x + (a * t);
}
def code(x, y, z, t, a, b):
	return x + (a * t)
function code(x, y, z, t, a, b)
	return Float64(x + Float64(a * t))
end
function tmp = code(x, y, z, t, a, b)
	tmp = x + (a * t);
end
code[x_, y_, z_, t_, a_, b_] := N[(x + N[(a * t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x + a \cdot t
\end{array}
Derivation
  1. Initial program 92.6%

    \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \]
  2. Step-by-step derivation
    1. lift-+.f64N/A

      \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b} \]
    2. lift-*.f64N/A

      \[\leadsto \left(\left(x + y \cdot z\right) + t \cdot a\right) + \color{blue}{\left(a \cdot z\right) \cdot b} \]
    3. fp-cancel-sign-sub-invN/A

      \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) - \left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b} \]
    4. sub-flipN/A

      \[\leadsto \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right)} \]
    5. +-commutativeN/A

      \[\leadsto \color{blue}{\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\left(x + y \cdot z\right) + t \cdot a\right)} \]
    6. lift-+.f64N/A

      \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(\left(x + y \cdot z\right) + t \cdot a\right)} \]
    7. lift-*.f64N/A

      \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\left(x + y \cdot z\right) + \color{blue}{t \cdot a}\right) \]
    8. fp-cancel-sign-sub-invN/A

      \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(\left(x + y \cdot z\right) - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)} \]
    9. lift-+.f64N/A

      \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\color{blue}{\left(x + y \cdot z\right)} - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right) \]
    10. +-commutativeN/A

      \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \left(\color{blue}{\left(y \cdot z + x\right)} - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right) \]
    11. associate--l+N/A

      \[\leadsto \left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + \color{blue}{\left(y \cdot z + \left(x - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)\right)} \]
    12. associate-+r+N/A

      \[\leadsto \color{blue}{\left(\left(\mathsf{neg}\left(\left(\mathsf{neg}\left(a \cdot z\right)\right) \cdot b\right)\right) + y \cdot z\right) + \left(x - \left(\mathsf{neg}\left(t\right)\right) \cdot a\right)} \]
  3. Applied rewrites94.4%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(b, a, y\right), z, \mathsf{fma}\left(a, t, x\right)\right)} \]
  4. Taylor expanded in b around 0

    \[\leadsto \color{blue}{x + \left(a \cdot t + y \cdot z\right)} \]
  5. Step-by-step derivation
    1. lower-+.f64N/A

      \[\leadsto x + \color{blue}{\left(a \cdot t + y \cdot z\right)} \]
    2. lower-fma.f64N/A

      \[\leadsto x + \mathsf{fma}\left(a, \color{blue}{t}, y \cdot z\right) \]
    3. lower-*.f6477.4

      \[\leadsto x + \mathsf{fma}\left(a, t, y \cdot z\right) \]
  6. Applied rewrites77.4%

    \[\leadsto \color{blue}{x + \mathsf{fma}\left(a, t, y \cdot z\right)} \]
  7. Taylor expanded in y around 0

    \[\leadsto x + a \cdot \color{blue}{t} \]
  8. Step-by-step derivation
    1. lower-*.f6452.9

      \[\leadsto x + a \cdot t \]
  9. Applied rewrites52.9%

    \[\leadsto x + a \cdot \color{blue}{t} \]
  10. Add Preprocessing

Alternative 13: 28.3% accurate, 5.3× speedup?

\[\begin{array}{l} \\ a \cdot t \end{array} \]
(FPCore (x y z t a b) :precision binary64 (* a t))
double code(double x, double y, double z, double t, double a, double b) {
	return a * t;
}
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, y, z, t, a, b)
use fmin_fmax_functions
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = a * t
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	return a * t;
}
def code(x, y, z, t, a, b):
	return a * t
function code(x, y, z, t, a, b)
	return Float64(a * t)
end
function tmp = code(x, y, z, t, a, b)
	tmp = a * t;
end
code[x_, y_, z_, t_, a_, b_] := N[(a * t), $MachinePrecision]
\begin{array}{l}

\\
a \cdot t
\end{array}
Derivation
  1. Initial program 92.6%

    \[\left(\left(x + y \cdot z\right) + t \cdot a\right) + \left(a \cdot z\right) \cdot b \]
  2. Taylor expanded in a around inf

    \[\leadsto \color{blue}{a \cdot \left(t + b \cdot z\right)} \]
  3. Step-by-step derivation
    1. lower-*.f64N/A

      \[\leadsto a \cdot \color{blue}{\left(t + b \cdot z\right)} \]
    2. lower-+.f64N/A

      \[\leadsto a \cdot \left(t + \color{blue}{b \cdot z}\right) \]
    3. lower-*.f6450.8

      \[\leadsto a \cdot \left(t + b \cdot \color{blue}{z}\right) \]
  4. Applied rewrites50.8%

    \[\leadsto \color{blue}{a \cdot \left(t + b \cdot z\right)} \]
  5. Taylor expanded in z around 0

    \[\leadsto a \cdot t \]
  6. Step-by-step derivation
    1. Applied rewrites28.3%

      \[\leadsto a \cdot t \]
    2. Add Preprocessing

    Reproduce

    ?
    herbie shell --seed 2025156 
    (FPCore (x y z t a b)
      :name "Graphics.Rasterific.CubicBezier:cachedBezierAt from Rasterific-0.6.1"
      :precision binary64
      (+ (+ (+ x (* y z)) (* t a)) (* (* a z) b)))