Diagrams.Solve.Polynomial:quartForm from diagrams-solve-0.1, C

Percentage Accurate: 97.9% → 97.9%
Time: 4.3s
Alternatives: 9
Speedup: 1.0×

Specification

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

\\
\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

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

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

\\
\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c
\end{array}

Alternative 1: 97.9% accurate, 1.0× speedup?

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

\\
c + \left(\left(y \cdot x + \frac{t \cdot z}{16}\right) - \frac{b \cdot a}{4}\right)
\end{array}
Derivation
  1. Initial program 98.0%

    \[\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c \]
  2. Add Preprocessing
  3. Final simplification98.0%

    \[\leadsto c + \left(\left(y \cdot x + \frac{t \cdot z}{16}\right) - \frac{b \cdot a}{4}\right) \]
  4. Add Preprocessing

Alternative 2: 66.9% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(t \cdot z, 0.0625, c\right)\\
\mathbf{if}\;t \cdot z \leq -4 \cdot 10^{+93}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t \cdot z \leq -5 \cdot 10^{-207}:\\
\;\;\;\;\mathsf{fma}\left(y, x, c\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 z t) < -4.00000000000000017e93 or 2.0000000000000001e138 < (*.f64 z t)

    1. Initial program 94.4%

      \[\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c \]
    2. Add Preprocessing
    3. Taylor expanded in a around 0

      \[\leadsto \color{blue}{c + \left(\frac{1}{16} \cdot \left(t \cdot z\right) + x \cdot y\right)} \]
    4. Step-by-step derivation
      1. associate-+r+N/A

        \[\leadsto \color{blue}{\left(c + \frac{1}{16} \cdot \left(t \cdot z\right)\right) + x \cdot y} \]
      2. +-commutativeN/A

        \[\leadsto \color{blue}{x \cdot y + \left(c + \frac{1}{16} \cdot \left(t \cdot z\right)\right)} \]
      3. *-commutativeN/A

        \[\leadsto \color{blue}{y \cdot x} + \left(c + \frac{1}{16} \cdot \left(t \cdot z\right)\right) \]
      4. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(y, x, c + \frac{1}{16} \cdot \left(t \cdot z\right)\right)} \]
      5. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\frac{1}{16} \cdot \left(t \cdot z\right) + c}\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\left(t \cdot z\right) \cdot \frac{1}{16}} + c\right) \]
      7. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\mathsf{fma}\left(t \cdot z, \frac{1}{16}, c\right)}\right) \]
      8. lower-*.f6490.2

        \[\leadsto \mathsf{fma}\left(y, x, \mathsf{fma}\left(\color{blue}{t \cdot z}, 0.0625, c\right)\right) \]
    5. Applied rewrites90.2%

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

      \[\leadsto c + \color{blue}{\frac{1}{16} \cdot \left(t \cdot z\right)} \]
    7. Step-by-step derivation
      1. Applied rewrites77.3%

        \[\leadsto \mathsf{fma}\left(t \cdot z, \color{blue}{0.0625}, c\right) \]

      if -4.00000000000000017e93 < (*.f64 z t) < -5.00000000000000014e-207

      1. Initial program 100.0%

        \[\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c \]
      2. Add Preprocessing
      3. Taylor expanded in a around 0

        \[\leadsto \color{blue}{c + \left(\frac{1}{16} \cdot \left(t \cdot z\right) + x \cdot y\right)} \]
      4. Step-by-step derivation
        1. associate-+r+N/A

          \[\leadsto \color{blue}{\left(c + \frac{1}{16} \cdot \left(t \cdot z\right)\right) + x \cdot y} \]
        2. +-commutativeN/A

          \[\leadsto \color{blue}{x \cdot y + \left(c + \frac{1}{16} \cdot \left(t \cdot z\right)\right)} \]
        3. *-commutativeN/A

          \[\leadsto \color{blue}{y \cdot x} + \left(c + \frac{1}{16} \cdot \left(t \cdot z\right)\right) \]
        4. lower-fma.f64N/A

          \[\leadsto \color{blue}{\mathsf{fma}\left(y, x, c + \frac{1}{16} \cdot \left(t \cdot z\right)\right)} \]
        5. +-commutativeN/A

          \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\frac{1}{16} \cdot \left(t \cdot z\right) + c}\right) \]
        6. *-commutativeN/A

          \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\left(t \cdot z\right) \cdot \frac{1}{16}} + c\right) \]
        7. lower-fma.f64N/A

          \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\mathsf{fma}\left(t \cdot z, \frac{1}{16}, c\right)}\right) \]
        8. lower-*.f6482.0

          \[\leadsto \mathsf{fma}\left(y, x, \mathsf{fma}\left(\color{blue}{t \cdot z}, 0.0625, c\right)\right) \]
      5. Applied rewrites82.0%

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

        \[\leadsto c + \color{blue}{\frac{1}{16} \cdot \left(t \cdot z\right)} \]
      7. Step-by-step derivation
        1. Applied rewrites40.6%

          \[\leadsto \mathsf{fma}\left(t \cdot z, \color{blue}{0.0625}, c\right) \]
        2. Taylor expanded in z around 0

          \[\leadsto c + \color{blue}{x \cdot y} \]
        3. Step-by-step derivation
          1. Applied rewrites75.0%

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

          if -5.00000000000000014e-207 < (*.f64 z t) < 2.0000000000000001e138

          1. Initial program 100.0%

            \[\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c \]
          2. Add Preprocessing
          3. Taylor expanded in z around 0

            \[\leadsto \color{blue}{\left(c + x \cdot y\right) - \frac{1}{4} \cdot \left(a \cdot b\right)} \]
          4. Step-by-step derivation
            1. cancel-sign-sub-invN/A

              \[\leadsto \color{blue}{\left(c + x \cdot y\right) + \left(\mathsf{neg}\left(\frac{1}{4}\right)\right) \cdot \left(a \cdot b\right)} \]
            2. metadata-evalN/A

              \[\leadsto \left(c + x \cdot y\right) + \color{blue}{\frac{-1}{4}} \cdot \left(a \cdot b\right) \]
            3. +-commutativeN/A

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

              \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-1}{4}, a \cdot b, c + x \cdot y\right)} \]
            5. *-commutativeN/A

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

              \[\leadsto \mathsf{fma}\left(\frac{-1}{4}, \color{blue}{b \cdot a}, c + x \cdot y\right) \]
            7. +-commutativeN/A

              \[\leadsto \mathsf{fma}\left(\frac{-1}{4}, b \cdot a, \color{blue}{x \cdot y + c}\right) \]
            8. *-commutativeN/A

              \[\leadsto \mathsf{fma}\left(\frac{-1}{4}, b \cdot a, \color{blue}{y \cdot x} + c\right) \]
            9. lower-fma.f6497.4

              \[\leadsto \mathsf{fma}\left(-0.25, b \cdot a, \color{blue}{\mathsf{fma}\left(y, x, c\right)}\right) \]
          5. Applied rewrites97.4%

            \[\leadsto \color{blue}{\mathsf{fma}\left(-0.25, b \cdot a, \mathsf{fma}\left(y, x, c\right)\right)} \]
          6. Taylor expanded in c around 0

            \[\leadsto \frac{-1}{4} \cdot \left(a \cdot b\right) + \color{blue}{x \cdot y} \]
          7. Step-by-step derivation
            1. Applied rewrites72.8%

              \[\leadsto \mathsf{fma}\left(-0.25, \color{blue}{b \cdot a}, y \cdot x\right) \]
          8. Recombined 3 regimes into one program.
          9. Final simplification74.8%

            \[\leadsto \begin{array}{l} \mathbf{if}\;t \cdot z \leq -4 \cdot 10^{+93}:\\ \;\;\;\;\mathsf{fma}\left(t \cdot z, 0.0625, c\right)\\ \mathbf{elif}\;t \cdot z \leq -5 \cdot 10^{-207}:\\ \;\;\;\;\mathsf{fma}\left(y, x, c\right)\\ \mathbf{elif}\;t \cdot z \leq 2 \cdot 10^{+138}:\\ \;\;\;\;\mathsf{fma}\left(-0.25, b \cdot a, y \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(t \cdot z, 0.0625, c\right)\\ \end{array} \]
          10. Add Preprocessing

          Alternative 3: 90.3% accurate, 1.2× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_1 := \mathsf{fma}\left(y, x, \mathsf{fma}\left(t \cdot z, 0.0625, c\right)\right)\\ \mathbf{if}\;t \cdot z \leq -4 \cdot 10^{+93}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t \cdot z \leq 5 \cdot 10^{+66}:\\ \;\;\;\;\mathsf{fma}\left(-0.25, b \cdot a, \mathsf{fma}\left(y, x, c\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
          (FPCore (x y z t a b c)
           :precision binary64
           (let* ((t_1 (fma y x (fma (* t z) 0.0625 c))))
             (if (<= (* t z) -4e+93)
               t_1
               (if (<= (* t z) 5e+66) (fma -0.25 (* b a) (fma y x c)) t_1))))
          double code(double x, double y, double z, double t, double a, double b, double c) {
          	double t_1 = fma(y, x, fma((t * z), 0.0625, c));
          	double tmp;
          	if ((t * z) <= -4e+93) {
          		tmp = t_1;
          	} else if ((t * z) <= 5e+66) {
          		tmp = fma(-0.25, (b * a), fma(y, x, c));
          	} else {
          		tmp = t_1;
          	}
          	return tmp;
          }
          
          function code(x, y, z, t, a, b, c)
          	t_1 = fma(y, x, fma(Float64(t * z), 0.0625, c))
          	tmp = 0.0
          	if (Float64(t * z) <= -4e+93)
          		tmp = t_1;
          	elseif (Float64(t * z) <= 5e+66)
          		tmp = fma(-0.25, Float64(b * a), fma(y, x, c));
          	else
          		tmp = t_1;
          	end
          	return tmp
          end
          
          code[x_, y_, z_, t_, a_, b_, c_] := Block[{t$95$1 = N[(y * x + N[(N[(t * z), $MachinePrecision] * 0.0625 + c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t * z), $MachinePrecision], -4e+93], t$95$1, If[LessEqual[N[(t * z), $MachinePrecision], 5e+66], N[(-0.25 * N[(b * a), $MachinePrecision] + N[(y * x + c), $MachinePrecision]), $MachinePrecision], t$95$1]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_1 := \mathsf{fma}\left(y, x, \mathsf{fma}\left(t \cdot z, 0.0625, c\right)\right)\\
          \mathbf{if}\;t \cdot z \leq -4 \cdot 10^{+93}:\\
          \;\;\;\;t\_1\\
          
          \mathbf{elif}\;t \cdot z \leq 5 \cdot 10^{+66}:\\
          \;\;\;\;\mathsf{fma}\left(-0.25, b \cdot a, \mathsf{fma}\left(y, x, c\right)\right)\\
          
          \mathbf{else}:\\
          \;\;\;\;t\_1\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if (*.f64 z t) < -4.00000000000000017e93 or 4.99999999999999991e66 < (*.f64 z t)

            1. Initial program 94.9%

              \[\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c \]
            2. Add Preprocessing
            3. Taylor expanded in a around 0

              \[\leadsto \color{blue}{c + \left(\frac{1}{16} \cdot \left(t \cdot z\right) + x \cdot y\right)} \]
            4. Step-by-step derivation
              1. associate-+r+N/A

                \[\leadsto \color{blue}{\left(c + \frac{1}{16} \cdot \left(t \cdot z\right)\right) + x \cdot y} \]
              2. +-commutativeN/A

                \[\leadsto \color{blue}{x \cdot y + \left(c + \frac{1}{16} \cdot \left(t \cdot z\right)\right)} \]
              3. *-commutativeN/A

                \[\leadsto \color{blue}{y \cdot x} + \left(c + \frac{1}{16} \cdot \left(t \cdot z\right)\right) \]
              4. lower-fma.f64N/A

                \[\leadsto \color{blue}{\mathsf{fma}\left(y, x, c + \frac{1}{16} \cdot \left(t \cdot z\right)\right)} \]
              5. +-commutativeN/A

                \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\frac{1}{16} \cdot \left(t \cdot z\right) + c}\right) \]
              6. *-commutativeN/A

                \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\left(t \cdot z\right) \cdot \frac{1}{16}} + c\right) \]
              7. lower-fma.f64N/A

                \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\mathsf{fma}\left(t \cdot z, \frac{1}{16}, c\right)}\right) \]
              8. lower-*.f6491.1

                \[\leadsto \mathsf{fma}\left(y, x, \mathsf{fma}\left(\color{blue}{t \cdot z}, 0.0625, c\right)\right) \]
            5. Applied rewrites91.1%

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

            if -4.00000000000000017e93 < (*.f64 z t) < 4.99999999999999991e66

            1. Initial program 100.0%

              \[\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c \]
            2. Add Preprocessing
            3. Taylor expanded in z around 0

              \[\leadsto \color{blue}{\left(c + x \cdot y\right) - \frac{1}{4} \cdot \left(a \cdot b\right)} \]
            4. Step-by-step derivation
              1. cancel-sign-sub-invN/A

                \[\leadsto \color{blue}{\left(c + x \cdot y\right) + \left(\mathsf{neg}\left(\frac{1}{4}\right)\right) \cdot \left(a \cdot b\right)} \]
              2. metadata-evalN/A

                \[\leadsto \left(c + x \cdot y\right) + \color{blue}{\frac{-1}{4}} \cdot \left(a \cdot b\right) \]
              3. +-commutativeN/A

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

                \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-1}{4}, a \cdot b, c + x \cdot y\right)} \]
              5. *-commutativeN/A

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

                \[\leadsto \mathsf{fma}\left(\frac{-1}{4}, \color{blue}{b \cdot a}, c + x \cdot y\right) \]
              7. +-commutativeN/A

                \[\leadsto \mathsf{fma}\left(\frac{-1}{4}, b \cdot a, \color{blue}{x \cdot y + c}\right) \]
              8. *-commutativeN/A

                \[\leadsto \mathsf{fma}\left(\frac{-1}{4}, b \cdot a, \color{blue}{y \cdot x} + c\right) \]
              9. lower-fma.f6496.9

                \[\leadsto \mathsf{fma}\left(-0.25, b \cdot a, \color{blue}{\mathsf{fma}\left(y, x, c\right)}\right) \]
            5. Applied rewrites96.9%

              \[\leadsto \color{blue}{\mathsf{fma}\left(-0.25, b \cdot a, \mathsf{fma}\left(y, x, c\right)\right)} \]
          3. Recombined 2 regimes into one program.
          4. Final simplification94.7%

            \[\leadsto \begin{array}{l} \mathbf{if}\;t \cdot z \leq -4 \cdot 10^{+93}:\\ \;\;\;\;\mathsf{fma}\left(y, x, \mathsf{fma}\left(t \cdot z, 0.0625, c\right)\right)\\ \mathbf{elif}\;t \cdot z \leq 5 \cdot 10^{+66}:\\ \;\;\;\;\mathsf{fma}\left(-0.25, b \cdot a, \mathsf{fma}\left(y, x, c\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y, x, \mathsf{fma}\left(t \cdot z, 0.0625, c\right)\right)\\ \end{array} \]
          5. Add Preprocessing

          Alternative 4: 85.5% accurate, 1.2× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} t_1 := \mathsf{fma}\left(t \cdot z, 0.0625, c\right)\\ \mathbf{if}\;t \cdot z \leq -4 \cdot 10^{+93}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t \cdot z \leq 10^{+253}:\\ \;\;\;\;\mathsf{fma}\left(-0.25, b \cdot a, \mathsf{fma}\left(y, x, c\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
          (FPCore (x y z t a b c)
           :precision binary64
           (let* ((t_1 (fma (* t z) 0.0625 c)))
             (if (<= (* t z) -4e+93)
               t_1
               (if (<= (* t z) 1e+253) (fma -0.25 (* b a) (fma y x c)) t_1))))
          double code(double x, double y, double z, double t, double a, double b, double c) {
          	double t_1 = fma((t * z), 0.0625, c);
          	double tmp;
          	if ((t * z) <= -4e+93) {
          		tmp = t_1;
          	} else if ((t * z) <= 1e+253) {
          		tmp = fma(-0.25, (b * a), fma(y, x, c));
          	} else {
          		tmp = t_1;
          	}
          	return tmp;
          }
          
          function code(x, y, z, t, a, b, c)
          	t_1 = fma(Float64(t * z), 0.0625, c)
          	tmp = 0.0
          	if (Float64(t * z) <= -4e+93)
          		tmp = t_1;
          	elseif (Float64(t * z) <= 1e+253)
          		tmp = fma(-0.25, Float64(b * a), fma(y, x, c));
          	else
          		tmp = t_1;
          	end
          	return tmp
          end
          
          code[x_, y_, z_, t_, a_, b_, c_] := Block[{t$95$1 = N[(N[(t * z), $MachinePrecision] * 0.0625 + c), $MachinePrecision]}, If[LessEqual[N[(t * z), $MachinePrecision], -4e+93], t$95$1, If[LessEqual[N[(t * z), $MachinePrecision], 1e+253], N[(-0.25 * N[(b * a), $MachinePrecision] + N[(y * x + c), $MachinePrecision]), $MachinePrecision], t$95$1]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          t_1 := \mathsf{fma}\left(t \cdot z, 0.0625, c\right)\\
          \mathbf{if}\;t \cdot z \leq -4 \cdot 10^{+93}:\\
          \;\;\;\;t\_1\\
          
          \mathbf{elif}\;t \cdot z \leq 10^{+253}:\\
          \;\;\;\;\mathsf{fma}\left(-0.25, b \cdot a, \mathsf{fma}\left(y, x, c\right)\right)\\
          
          \mathbf{else}:\\
          \;\;\;\;t\_1\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if (*.f64 z t) < -4.00000000000000017e93 or 9.9999999999999994e252 < (*.f64 z t)

            1. Initial program 94.8%

              \[\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c \]
            2. Add Preprocessing
            3. Taylor expanded in a around 0

              \[\leadsto \color{blue}{c + \left(\frac{1}{16} \cdot \left(t \cdot z\right) + x \cdot y\right)} \]
            4. Step-by-step derivation
              1. associate-+r+N/A

                \[\leadsto \color{blue}{\left(c + \frac{1}{16} \cdot \left(t \cdot z\right)\right) + x \cdot y} \]
              2. +-commutativeN/A

                \[\leadsto \color{blue}{x \cdot y + \left(c + \frac{1}{16} \cdot \left(t \cdot z\right)\right)} \]
              3. *-commutativeN/A

                \[\leadsto \color{blue}{y \cdot x} + \left(c + \frac{1}{16} \cdot \left(t \cdot z\right)\right) \]
              4. lower-fma.f64N/A

                \[\leadsto \color{blue}{\mathsf{fma}\left(y, x, c + \frac{1}{16} \cdot \left(t \cdot z\right)\right)} \]
              5. +-commutativeN/A

                \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\frac{1}{16} \cdot \left(t \cdot z\right) + c}\right) \]
              6. *-commutativeN/A

                \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\left(t \cdot z\right) \cdot \frac{1}{16}} + c\right) \]
              7. lower-fma.f64N/A

                \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\mathsf{fma}\left(t \cdot z, \frac{1}{16}, c\right)}\right) \]
              8. lower-*.f6492.5

                \[\leadsto \mathsf{fma}\left(y, x, \mathsf{fma}\left(\color{blue}{t \cdot z}, 0.0625, c\right)\right) \]
            5. Applied rewrites92.5%

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

              \[\leadsto c + \color{blue}{\frac{1}{16} \cdot \left(t \cdot z\right)} \]
            7. Step-by-step derivation
              1. Applied rewrites81.1%

                \[\leadsto \mathsf{fma}\left(t \cdot z, \color{blue}{0.0625}, c\right) \]

              if -4.00000000000000017e93 < (*.f64 z t) < 9.9999999999999994e252

              1. Initial program 99.4%

                \[\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c \]
              2. Add Preprocessing
              3. Taylor expanded in z around 0

                \[\leadsto \color{blue}{\left(c + x \cdot y\right) - \frac{1}{4} \cdot \left(a \cdot b\right)} \]
              4. Step-by-step derivation
                1. cancel-sign-sub-invN/A

                  \[\leadsto \color{blue}{\left(c + x \cdot y\right) + \left(\mathsf{neg}\left(\frac{1}{4}\right)\right) \cdot \left(a \cdot b\right)} \]
                2. metadata-evalN/A

                  \[\leadsto \left(c + x \cdot y\right) + \color{blue}{\frac{-1}{4}} \cdot \left(a \cdot b\right) \]
                3. +-commutativeN/A

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

                  \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{-1}{4}, a \cdot b, c + x \cdot y\right)} \]
                5. *-commutativeN/A

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

                  \[\leadsto \mathsf{fma}\left(\frac{-1}{4}, \color{blue}{b \cdot a}, c + x \cdot y\right) \]
                7. +-commutativeN/A

                  \[\leadsto \mathsf{fma}\left(\frac{-1}{4}, b \cdot a, \color{blue}{x \cdot y + c}\right) \]
                8. *-commutativeN/A

                  \[\leadsto \mathsf{fma}\left(\frac{-1}{4}, b \cdot a, \color{blue}{y \cdot x} + c\right) \]
                9. lower-fma.f6494.5

                  \[\leadsto \mathsf{fma}\left(-0.25, b \cdot a, \color{blue}{\mathsf{fma}\left(y, x, c\right)}\right) \]
              5. Applied rewrites94.5%

                \[\leadsto \color{blue}{\mathsf{fma}\left(-0.25, b \cdot a, \mathsf{fma}\left(y, x, c\right)\right)} \]
            8. Recombined 2 regimes into one program.
            9. Final simplification90.5%

              \[\leadsto \begin{array}{l} \mathbf{if}\;t \cdot z \leq -4 \cdot 10^{+93}:\\ \;\;\;\;\mathsf{fma}\left(t \cdot z, 0.0625, c\right)\\ \mathbf{elif}\;t \cdot z \leq 10^{+253}:\\ \;\;\;\;\mathsf{fma}\left(-0.25, b \cdot a, \mathsf{fma}\left(y, x, c\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(t \cdot z, 0.0625, c\right)\\ \end{array} \]
            10. Add Preprocessing

            Alternative 5: 65.7% accurate, 1.4× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} t_1 := \mathsf{fma}\left(t \cdot z, 0.0625, c\right)\\ \mathbf{if}\;t \cdot z \leq -4 \cdot 10^{+93}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t \cdot z \leq 2 \cdot 10^{+167}:\\ \;\;\;\;\mathsf{fma}\left(y, x, c\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
            (FPCore (x y z t a b c)
             :precision binary64
             (let* ((t_1 (fma (* t z) 0.0625 c)))
               (if (<= (* t z) -4e+93) t_1 (if (<= (* t z) 2e+167) (fma y x c) t_1))))
            double code(double x, double y, double z, double t, double a, double b, double c) {
            	double t_1 = fma((t * z), 0.0625, c);
            	double tmp;
            	if ((t * z) <= -4e+93) {
            		tmp = t_1;
            	} else if ((t * z) <= 2e+167) {
            		tmp = fma(y, x, c);
            	} else {
            		tmp = t_1;
            	}
            	return tmp;
            }
            
            function code(x, y, z, t, a, b, c)
            	t_1 = fma(Float64(t * z), 0.0625, c)
            	tmp = 0.0
            	if (Float64(t * z) <= -4e+93)
            		tmp = t_1;
            	elseif (Float64(t * z) <= 2e+167)
            		tmp = fma(y, x, c);
            	else
            		tmp = t_1;
            	end
            	return tmp
            end
            
            code[x_, y_, z_, t_, a_, b_, c_] := Block[{t$95$1 = N[(N[(t * z), $MachinePrecision] * 0.0625 + c), $MachinePrecision]}, If[LessEqual[N[(t * z), $MachinePrecision], -4e+93], t$95$1, If[LessEqual[N[(t * z), $MachinePrecision], 2e+167], N[(y * x + c), $MachinePrecision], t$95$1]]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            t_1 := \mathsf{fma}\left(t \cdot z, 0.0625, c\right)\\
            \mathbf{if}\;t \cdot z \leq -4 \cdot 10^{+93}:\\
            \;\;\;\;t\_1\\
            
            \mathbf{elif}\;t \cdot z \leq 2 \cdot 10^{+167}:\\
            \;\;\;\;\mathsf{fma}\left(y, x, c\right)\\
            
            \mathbf{else}:\\
            \;\;\;\;t\_1\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if (*.f64 z t) < -4.00000000000000017e93 or 2.0000000000000001e167 < (*.f64 z t)

              1. Initial program 95.3%

                \[\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c \]
              2. Add Preprocessing
              3. Taylor expanded in a around 0

                \[\leadsto \color{blue}{c + \left(\frac{1}{16} \cdot \left(t \cdot z\right) + x \cdot y\right)} \]
              4. Step-by-step derivation
                1. associate-+r+N/A

                  \[\leadsto \color{blue}{\left(c + \frac{1}{16} \cdot \left(t \cdot z\right)\right) + x \cdot y} \]
                2. +-commutativeN/A

                  \[\leadsto \color{blue}{x \cdot y + \left(c + \frac{1}{16} \cdot \left(t \cdot z\right)\right)} \]
                3. *-commutativeN/A

                  \[\leadsto \color{blue}{y \cdot x} + \left(c + \frac{1}{16} \cdot \left(t \cdot z\right)\right) \]
                4. lower-fma.f64N/A

                  \[\leadsto \color{blue}{\mathsf{fma}\left(y, x, c + \frac{1}{16} \cdot \left(t \cdot z\right)\right)} \]
                5. +-commutativeN/A

                  \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\frac{1}{16} \cdot \left(t \cdot z\right) + c}\right) \]
                6. *-commutativeN/A

                  \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\left(t \cdot z\right) \cdot \frac{1}{16}} + c\right) \]
                7. lower-fma.f64N/A

                  \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\mathsf{fma}\left(t \cdot z, \frac{1}{16}, c\right)}\right) \]
                8. lower-*.f6490.9

                  \[\leadsto \mathsf{fma}\left(y, x, \mathsf{fma}\left(\color{blue}{t \cdot z}, 0.0625, c\right)\right) \]
              5. Applied rewrites90.9%

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

                \[\leadsto c + \color{blue}{\frac{1}{16} \cdot \left(t \cdot z\right)} \]
              7. Step-by-step derivation
                1. Applied rewrites78.4%

                  \[\leadsto \mathsf{fma}\left(t \cdot z, \color{blue}{0.0625}, c\right) \]

                if -4.00000000000000017e93 < (*.f64 z t) < 2.0000000000000001e167

                1. Initial program 99.4%

                  \[\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c \]
                2. Add Preprocessing
                3. Taylor expanded in a around 0

                  \[\leadsto \color{blue}{c + \left(\frac{1}{16} \cdot \left(t \cdot z\right) + x \cdot y\right)} \]
                4. Step-by-step derivation
                  1. associate-+r+N/A

                    \[\leadsto \color{blue}{\left(c + \frac{1}{16} \cdot \left(t \cdot z\right)\right) + x \cdot y} \]
                  2. +-commutativeN/A

                    \[\leadsto \color{blue}{x \cdot y + \left(c + \frac{1}{16} \cdot \left(t \cdot z\right)\right)} \]
                  3. *-commutativeN/A

                    \[\leadsto \color{blue}{y \cdot x} + \left(c + \frac{1}{16} \cdot \left(t \cdot z\right)\right) \]
                  4. lower-fma.f64N/A

                    \[\leadsto \color{blue}{\mathsf{fma}\left(y, x, c + \frac{1}{16} \cdot \left(t \cdot z\right)\right)} \]
                  5. +-commutativeN/A

                    \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\frac{1}{16} \cdot \left(t \cdot z\right) + c}\right) \]
                  6. *-commutativeN/A

                    \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\left(t \cdot z\right) \cdot \frac{1}{16}} + c\right) \]
                  7. lower-fma.f64N/A

                    \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\mathsf{fma}\left(t \cdot z, \frac{1}{16}, c\right)}\right) \]
                  8. lower-*.f6472.5

                    \[\leadsto \mathsf{fma}\left(y, x, \mathsf{fma}\left(\color{blue}{t \cdot z}, 0.0625, c\right)\right) \]
                5. Applied rewrites72.5%

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

                  \[\leadsto c + \color{blue}{\frac{1}{16} \cdot \left(t \cdot z\right)} \]
                7. Step-by-step derivation
                  1. Applied rewrites33.7%

                    \[\leadsto \mathsf{fma}\left(t \cdot z, \color{blue}{0.0625}, c\right) \]
                  2. Taylor expanded in z around 0

                    \[\leadsto c + \color{blue}{x \cdot y} \]
                  3. Step-by-step derivation
                    1. Applied rewrites68.5%

                      \[\leadsto \mathsf{fma}\left(y, \color{blue}{x}, c\right) \]
                  4. Recombined 2 regimes into one program.
                  5. Final simplification71.8%

                    \[\leadsto \begin{array}{l} \mathbf{if}\;t \cdot z \leq -4 \cdot 10^{+93}:\\ \;\;\;\;\mathsf{fma}\left(t \cdot z, 0.0625, c\right)\\ \mathbf{elif}\;t \cdot z \leq 2 \cdot 10^{+167}:\\ \;\;\;\;\mathsf{fma}\left(y, x, c\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(t \cdot z, 0.0625, c\right)\\ \end{array} \]
                  6. Add Preprocessing

                  Alternative 6: 62.7% accurate, 1.4× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} t_1 := 0.0625 \cdot \left(t \cdot z\right)\\ \mathbf{if}\;t \cdot z \leq -1 \cdot 10^{+203}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t \cdot z \leq 10^{+253}:\\ \;\;\;\;\mathsf{fma}\left(y, x, c\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
                  (FPCore (x y z t a b c)
                   :precision binary64
                   (let* ((t_1 (* 0.0625 (* t z))))
                     (if (<= (* t z) -1e+203) t_1 (if (<= (* t z) 1e+253) (fma y x c) t_1))))
                  double code(double x, double y, double z, double t, double a, double b, double c) {
                  	double t_1 = 0.0625 * (t * z);
                  	double tmp;
                  	if ((t * z) <= -1e+203) {
                  		tmp = t_1;
                  	} else if ((t * z) <= 1e+253) {
                  		tmp = fma(y, x, c);
                  	} else {
                  		tmp = t_1;
                  	}
                  	return tmp;
                  }
                  
                  function code(x, y, z, t, a, b, c)
                  	t_1 = Float64(0.0625 * Float64(t * z))
                  	tmp = 0.0
                  	if (Float64(t * z) <= -1e+203)
                  		tmp = t_1;
                  	elseif (Float64(t * z) <= 1e+253)
                  		tmp = fma(y, x, c);
                  	else
                  		tmp = t_1;
                  	end
                  	return tmp
                  end
                  
                  code[x_, y_, z_, t_, a_, b_, c_] := Block[{t$95$1 = N[(0.0625 * N[(t * z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t * z), $MachinePrecision], -1e+203], t$95$1, If[LessEqual[N[(t * z), $MachinePrecision], 1e+253], N[(y * x + c), $MachinePrecision], t$95$1]]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  t_1 := 0.0625 \cdot \left(t \cdot z\right)\\
                  \mathbf{if}\;t \cdot z \leq -1 \cdot 10^{+203}:\\
                  \;\;\;\;t\_1\\
                  
                  \mathbf{elif}\;t \cdot z \leq 10^{+253}:\\
                  \;\;\;\;\mathsf{fma}\left(y, x, c\right)\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;t\_1\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if (*.f64 z t) < -9.9999999999999999e202 or 9.9999999999999994e252 < (*.f64 z t)

                    1. Initial program 93.4%

                      \[\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c \]
                    2. Add Preprocessing
                    3. Taylor expanded in a around inf

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

                        \[\leadsto \color{blue}{\frac{-1}{4} \cdot \left(a \cdot b\right)} \]
                      2. *-commutativeN/A

                        \[\leadsto \frac{-1}{4} \cdot \color{blue}{\left(b \cdot a\right)} \]
                      3. lower-*.f647.9

                        \[\leadsto -0.25 \cdot \color{blue}{\left(b \cdot a\right)} \]
                    5. Applied rewrites7.9%

                      \[\leadsto \color{blue}{-0.25 \cdot \left(b \cdot a\right)} \]
                    6. Taylor expanded in z around inf

                      \[\leadsto \color{blue}{\frac{1}{16} \cdot \left(t \cdot z\right)} \]
                    7. Step-by-step derivation
                      1. *-commutativeN/A

                        \[\leadsto \color{blue}{\left(t \cdot z\right) \cdot \frac{1}{16}} \]
                      2. lower-*.f64N/A

                        \[\leadsto \color{blue}{\left(t \cdot z\right) \cdot \frac{1}{16}} \]
                      3. lower-*.f6480.8

                        \[\leadsto \color{blue}{\left(t \cdot z\right)} \cdot 0.0625 \]
                    8. Applied rewrites80.8%

                      \[\leadsto \color{blue}{\left(t \cdot z\right) \cdot 0.0625} \]

                    if -9.9999999999999999e202 < (*.f64 z t) < 9.9999999999999994e252

                    1. Initial program 99.5%

                      \[\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c \]
                    2. Add Preprocessing
                    3. Taylor expanded in a around 0

                      \[\leadsto \color{blue}{c + \left(\frac{1}{16} \cdot \left(t \cdot z\right) + x \cdot y\right)} \]
                    4. Step-by-step derivation
                      1. associate-+r+N/A

                        \[\leadsto \color{blue}{\left(c + \frac{1}{16} \cdot \left(t \cdot z\right)\right) + x \cdot y} \]
                      2. +-commutativeN/A

                        \[\leadsto \color{blue}{x \cdot y + \left(c + \frac{1}{16} \cdot \left(t \cdot z\right)\right)} \]
                      3. *-commutativeN/A

                        \[\leadsto \color{blue}{y \cdot x} + \left(c + \frac{1}{16} \cdot \left(t \cdot z\right)\right) \]
                      4. lower-fma.f64N/A

                        \[\leadsto \color{blue}{\mathsf{fma}\left(y, x, c + \frac{1}{16} \cdot \left(t \cdot z\right)\right)} \]
                      5. +-commutativeN/A

                        \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\frac{1}{16} \cdot \left(t \cdot z\right) + c}\right) \]
                      6. *-commutativeN/A

                        \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\left(t \cdot z\right) \cdot \frac{1}{16}} + c\right) \]
                      7. lower-fma.f64N/A

                        \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\mathsf{fma}\left(t \cdot z, \frac{1}{16}, c\right)}\right) \]
                      8. lower-*.f6474.4

                        \[\leadsto \mathsf{fma}\left(y, x, \mathsf{fma}\left(\color{blue}{t \cdot z}, 0.0625, c\right)\right) \]
                    5. Applied rewrites74.4%

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

                      \[\leadsto c + \color{blue}{\frac{1}{16} \cdot \left(t \cdot z\right)} \]
                    7. Step-by-step derivation
                      1. Applied rewrites36.9%

                        \[\leadsto \mathsf{fma}\left(t \cdot z, \color{blue}{0.0625}, c\right) \]
                      2. Taylor expanded in z around 0

                        \[\leadsto c + \color{blue}{x \cdot y} \]
                      3. Step-by-step derivation
                        1. Applied rewrites66.2%

                          \[\leadsto \mathsf{fma}\left(y, \color{blue}{x}, c\right) \]
                      4. Recombined 2 regimes into one program.
                      5. Final simplification69.7%

                        \[\leadsto \begin{array}{l} \mathbf{if}\;t \cdot z \leq -1 \cdot 10^{+203}:\\ \;\;\;\;0.0625 \cdot \left(t \cdot z\right)\\ \mathbf{elif}\;t \cdot z \leq 10^{+253}:\\ \;\;\;\;\mathsf{fma}\left(y, x, c\right)\\ \mathbf{else}:\\ \;\;\;\;0.0625 \cdot \left(t \cdot z\right)\\ \end{array} \]
                      6. Add Preprocessing

                      Alternative 7: 62.5% accurate, 1.4× speedup?

                      \[\begin{array}{l} \\ \begin{array}{l} t_1 := \left(b \cdot a\right) \cdot -0.25\\ \mathbf{if}\;b \cdot a \leq -2 \cdot 10^{+228}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;b \cdot a \leq 2 \cdot 10^{+215}:\\ \;\;\;\;\mathsf{fma}\left(y, x, c\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
                      (FPCore (x y z t a b c)
                       :precision binary64
                       (let* ((t_1 (* (* b a) -0.25)))
                         (if (<= (* b a) -2e+228) t_1 (if (<= (* b a) 2e+215) (fma y x c) t_1))))
                      double code(double x, double y, double z, double t, double a, double b, double c) {
                      	double t_1 = (b * a) * -0.25;
                      	double tmp;
                      	if ((b * a) <= -2e+228) {
                      		tmp = t_1;
                      	} else if ((b * a) <= 2e+215) {
                      		tmp = fma(y, x, c);
                      	} else {
                      		tmp = t_1;
                      	}
                      	return tmp;
                      }
                      
                      function code(x, y, z, t, a, b, c)
                      	t_1 = Float64(Float64(b * a) * -0.25)
                      	tmp = 0.0
                      	if (Float64(b * a) <= -2e+228)
                      		tmp = t_1;
                      	elseif (Float64(b * a) <= 2e+215)
                      		tmp = fma(y, x, c);
                      	else
                      		tmp = t_1;
                      	end
                      	return tmp
                      end
                      
                      code[x_, y_, z_, t_, a_, b_, c_] := Block[{t$95$1 = N[(N[(b * a), $MachinePrecision] * -0.25), $MachinePrecision]}, If[LessEqual[N[(b * a), $MachinePrecision], -2e+228], t$95$1, If[LessEqual[N[(b * a), $MachinePrecision], 2e+215], N[(y * x + c), $MachinePrecision], t$95$1]]]
                      
                      \begin{array}{l}
                      
                      \\
                      \begin{array}{l}
                      t_1 := \left(b \cdot a\right) \cdot -0.25\\
                      \mathbf{if}\;b \cdot a \leq -2 \cdot 10^{+228}:\\
                      \;\;\;\;t\_1\\
                      
                      \mathbf{elif}\;b \cdot a \leq 2 \cdot 10^{+215}:\\
                      \;\;\;\;\mathsf{fma}\left(y, x, c\right)\\
                      
                      \mathbf{else}:\\
                      \;\;\;\;t\_1\\
                      
                      
                      \end{array}
                      \end{array}
                      
                      Derivation
                      1. Split input into 2 regimes
                      2. if (*.f64 a b) < -1.9999999999999998e228 or 1.99999999999999981e215 < (*.f64 a b)

                        1. Initial program 92.9%

                          \[\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c \]
                        2. Add Preprocessing
                        3. Taylor expanded in a around inf

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

                            \[\leadsto \color{blue}{\frac{-1}{4} \cdot \left(a \cdot b\right)} \]
                          2. *-commutativeN/A

                            \[\leadsto \frac{-1}{4} \cdot \color{blue}{\left(b \cdot a\right)} \]
                          3. lower-*.f6488.3

                            \[\leadsto -0.25 \cdot \color{blue}{\left(b \cdot a\right)} \]
                        5. Applied rewrites88.3%

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

                        if -1.9999999999999998e228 < (*.f64 a b) < 1.99999999999999981e215

                        1. Initial program 99.1%

                          \[\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c \]
                        2. Add Preprocessing
                        3. Taylor expanded in a around 0

                          \[\leadsto \color{blue}{c + \left(\frac{1}{16} \cdot \left(t \cdot z\right) + x \cdot y\right)} \]
                        4. Step-by-step derivation
                          1. associate-+r+N/A

                            \[\leadsto \color{blue}{\left(c + \frac{1}{16} \cdot \left(t \cdot z\right)\right) + x \cdot y} \]
                          2. +-commutativeN/A

                            \[\leadsto \color{blue}{x \cdot y + \left(c + \frac{1}{16} \cdot \left(t \cdot z\right)\right)} \]
                          3. *-commutativeN/A

                            \[\leadsto \color{blue}{y \cdot x} + \left(c + \frac{1}{16} \cdot \left(t \cdot z\right)\right) \]
                          4. lower-fma.f64N/A

                            \[\leadsto \color{blue}{\mathsf{fma}\left(y, x, c + \frac{1}{16} \cdot \left(t \cdot z\right)\right)} \]
                          5. +-commutativeN/A

                            \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\frac{1}{16} \cdot \left(t \cdot z\right) + c}\right) \]
                          6. *-commutativeN/A

                            \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\left(t \cdot z\right) \cdot \frac{1}{16}} + c\right) \]
                          7. lower-fma.f64N/A

                            \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\mathsf{fma}\left(t \cdot z, \frac{1}{16}, c\right)}\right) \]
                          8. lower-*.f6489.1

                            \[\leadsto \mathsf{fma}\left(y, x, \mathsf{fma}\left(\color{blue}{t \cdot z}, 0.0625, c\right)\right) \]
                        5. Applied rewrites89.1%

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

                          \[\leadsto c + \color{blue}{\frac{1}{16} \cdot \left(t \cdot z\right)} \]
                        7. Step-by-step derivation
                          1. Applied rewrites55.7%

                            \[\leadsto \mathsf{fma}\left(t \cdot z, \color{blue}{0.0625}, c\right) \]
                          2. Taylor expanded in z around 0

                            \[\leadsto c + \color{blue}{x \cdot y} \]
                          3. Step-by-step derivation
                            1. Applied rewrites61.6%

                              \[\leadsto \mathsf{fma}\left(y, \color{blue}{x}, c\right) \]
                          4. Recombined 2 regimes into one program.
                          5. Final simplification66.0%

                            \[\leadsto \begin{array}{l} \mathbf{if}\;b \cdot a \leq -2 \cdot 10^{+228}:\\ \;\;\;\;\left(b \cdot a\right) \cdot -0.25\\ \mathbf{elif}\;b \cdot a \leq 2 \cdot 10^{+215}:\\ \;\;\;\;\mathsf{fma}\left(y, x, c\right)\\ \mathbf{else}:\\ \;\;\;\;\left(b \cdot a\right) \cdot -0.25\\ \end{array} \]
                          6. Add Preprocessing

                          Alternative 8: 49.1% accurate, 6.7× speedup?

                          \[\begin{array}{l} \\ \mathsf{fma}\left(y, x, c\right) \end{array} \]
                          (FPCore (x y z t a b c) :precision binary64 (fma y x c))
                          double code(double x, double y, double z, double t, double a, double b, double c) {
                          	return fma(y, x, c);
                          }
                          
                          function code(x, y, z, t, a, b, c)
                          	return fma(y, x, c)
                          end
                          
                          code[x_, y_, z_, t_, a_, b_, c_] := N[(y * x + c), $MachinePrecision]
                          
                          \begin{array}{l}
                          
                          \\
                          \mathsf{fma}\left(y, x, c\right)
                          \end{array}
                          
                          Derivation
                          1. Initial program 98.0%

                            \[\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c \]
                          2. Add Preprocessing
                          3. Taylor expanded in a around 0

                            \[\leadsto \color{blue}{c + \left(\frac{1}{16} \cdot \left(t \cdot z\right) + x \cdot y\right)} \]
                          4. Step-by-step derivation
                            1. associate-+r+N/A

                              \[\leadsto \color{blue}{\left(c + \frac{1}{16} \cdot \left(t \cdot z\right)\right) + x \cdot y} \]
                            2. +-commutativeN/A

                              \[\leadsto \color{blue}{x \cdot y + \left(c + \frac{1}{16} \cdot \left(t \cdot z\right)\right)} \]
                            3. *-commutativeN/A

                              \[\leadsto \color{blue}{y \cdot x} + \left(c + \frac{1}{16} \cdot \left(t \cdot z\right)\right) \]
                            4. lower-fma.f64N/A

                              \[\leadsto \color{blue}{\mathsf{fma}\left(y, x, c + \frac{1}{16} \cdot \left(t \cdot z\right)\right)} \]
                            5. +-commutativeN/A

                              \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\frac{1}{16} \cdot \left(t \cdot z\right) + c}\right) \]
                            6. *-commutativeN/A

                              \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\left(t \cdot z\right) \cdot \frac{1}{16}} + c\right) \]
                            7. lower-fma.f64N/A

                              \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\mathsf{fma}\left(t \cdot z, \frac{1}{16}, c\right)}\right) \]
                            8. lower-*.f6478.6

                              \[\leadsto \mathsf{fma}\left(y, x, \mathsf{fma}\left(\color{blue}{t \cdot z}, 0.0625, c\right)\right) \]
                          5. Applied rewrites78.6%

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

                            \[\leadsto c + \color{blue}{\frac{1}{16} \cdot \left(t \cdot z\right)} \]
                          7. Step-by-step derivation
                            1. Applied rewrites48.5%

                              \[\leadsto \mathsf{fma}\left(t \cdot z, \color{blue}{0.0625}, c\right) \]
                            2. Taylor expanded in z around 0

                              \[\leadsto c + \color{blue}{x \cdot y} \]
                            3. Step-by-step derivation
                              1. Applied rewrites54.0%

                                \[\leadsto \mathsf{fma}\left(y, \color{blue}{x}, c\right) \]
                              2. Add Preprocessing

                              Alternative 9: 28.6% accurate, 7.8× speedup?

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

                                \[\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c \]
                              2. Add Preprocessing
                              3. Taylor expanded in a around inf

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

                                  \[\leadsto \color{blue}{\frac{-1}{4} \cdot \left(a \cdot b\right)} \]
                                2. *-commutativeN/A

                                  \[\leadsto \frac{-1}{4} \cdot \color{blue}{\left(b \cdot a\right)} \]
                                3. lower-*.f6425.1

                                  \[\leadsto -0.25 \cdot \color{blue}{\left(b \cdot a\right)} \]
                              5. Applied rewrites25.1%

                                \[\leadsto \color{blue}{-0.25 \cdot \left(b \cdot a\right)} \]
                              6. Taylor expanded in x around inf

                                \[\leadsto \color{blue}{x \cdot y} \]
                              7. Step-by-step derivation
                                1. *-commutativeN/A

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

                                  \[\leadsto \color{blue}{y \cdot x} \]
                              8. Applied rewrites33.2%

                                \[\leadsto \color{blue}{y \cdot x} \]
                              9. Add Preprocessing

                              Reproduce

                              ?
                              herbie shell --seed 2024304 
                              (FPCore (x y z t a b c)
                                :name "Diagrams.Solve.Polynomial:quartForm  from diagrams-solve-0.1, C"
                                :precision binary64
                                (+ (- (+ (* x y) (/ (* z t) 16.0)) (/ (* a b) 4.0)) c))