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

Percentage Accurate: 97.7% → 99.1%
Time: 11.8s
Alternatives: 14
Speedup: 1.6×

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 14 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.7% 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: 99.1% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(y, x, \mathsf{fma}\left(b \cdot -0.25, a, \mathsf{fma}\left(z, t \cdot 0.0625, c\right)\right)\right) \end{array} \]
(FPCore (x y z t a b c)
 :precision binary64
 (fma y x (fma (* b -0.25) a (fma z (* t 0.0625) c))))
double code(double x, double y, double z, double t, double a, double b, double c) {
	return fma(y, x, fma((b * -0.25), a, fma(z, (t * 0.0625), c)));
}
function code(x, y, z, t, a, b, c)
	return fma(y, x, fma(Float64(b * -0.25), a, fma(z, Float64(t * 0.0625), c)))
end
code[x_, y_, z_, t_, a_, b_, c_] := N[(y * x + N[(N[(b * -0.25), $MachinePrecision] * a + N[(z * N[(t * 0.0625), $MachinePrecision] + c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(y, x, \mathsf{fma}\left(b \cdot -0.25, a, \mathsf{fma}\left(z, t \cdot 0.0625, c\right)\right)\right)
\end{array}
Derivation
  1. Initial program 97.2%

    \[\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-+.f64N/A

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

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

      \[\leadsto \left(\color{blue}{\left(x \cdot y + \frac{z \cdot t}{16}\right)} - \frac{a \cdot b}{4}\right) + c \]
    4. associate--l+N/A

      \[\leadsto \color{blue}{\left(x \cdot y + \left(\frac{z \cdot t}{16} - \frac{a \cdot b}{4}\right)\right)} + c \]
    5. associate-+l+N/A

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

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

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

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

      \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\left(\frac{z \cdot t}{16} - \frac{a \cdot b}{4}\right) + c}\right) \]
  4. Applied rewrites98.8%

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\left(a \cdot \left(b \cdot \frac{-1}{4}\right) + z \cdot \left(t \cdot \frac{1}{16}\right)\right)} + c\right) \]
    9. associate-+l+N/A

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

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

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

      \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\mathsf{fma}\left(b \cdot \frac{-1}{4}, a, z \cdot \left(t \cdot \frac{1}{16}\right) + c\right)}\right) \]
    13. lower-fma.f6499.2

      \[\leadsto \mathsf{fma}\left(y, x, \mathsf{fma}\left(b \cdot -0.25, a, \color{blue}{\mathsf{fma}\left(z, t \cdot 0.0625, c\right)}\right)\right) \]
  6. Applied rewrites99.2%

    \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\mathsf{fma}\left(b \cdot -0.25, a, \mathsf{fma}\left(z, t \cdot 0.0625, c\right)\right)}\right) \]
  7. Add Preprocessing

Alternative 2: 76.9% accurate, 0.3× speedup?

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

\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(y, x, 0.0625 \cdot \left(z \cdot t\right)\right)\\
t_2 := y \cdot x + \frac{z \cdot t}{16}\\
t_3 := \mathsf{fma}\left(y, x, -0.25 \cdot \left(b \cdot a\right)\right)\\
\mathbf{if}\;t\_2 \leq -5 \cdot 10^{+189}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;t\_2 \leq -2 \cdot 10^{+35}:\\
\;\;\;\;t\_3\\

\mathbf{elif}\;t\_2 \leq 10^{+114}:\\
\;\;\;\;\mathsf{fma}\left(-0.25, b \cdot a, c\right)\\

\mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+277}:\\
\;\;\;\;t\_3\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (+.f64 (*.f64 x y) (/.f64 (*.f64 z t) #s(literal 16 binary64))) < -5.0000000000000004e189 or 4.99999999999999982e277 < (+.f64 (*.f64 x y) (/.f64 (*.f64 z t) #s(literal 16 binary64)))

    1. Initial program 93.6%

      \[\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-+.f64N/A

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

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

        \[\leadsto \left(\color{blue}{\left(x \cdot y + \frac{z \cdot t}{16}\right)} - \frac{a \cdot b}{4}\right) + c \]
      4. associate--l+N/A

        \[\leadsto \color{blue}{\left(x \cdot y + \left(\frac{z \cdot t}{16} - \frac{a \cdot b}{4}\right)\right)} + c \]
      5. associate-+l+N/A

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

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

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

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

        \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\left(\frac{z \cdot t}{16} - \frac{a \cdot b}{4}\right) + c}\right) \]
    4. Applied rewrites97.0%

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

      \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\frac{1}{16} \cdot \left(t \cdot z\right)}\right) \]
    6. Step-by-step derivation
      1. lower-*.f64N/A

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

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

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

    if -5.0000000000000004e189 < (+.f64 (*.f64 x y) (/.f64 (*.f64 z t) #s(literal 16 binary64))) < -1.9999999999999999e35 or 1e114 < (+.f64 (*.f64 x y) (/.f64 (*.f64 z t) #s(literal 16 binary64))) < 4.99999999999999982e277

    1. Initial program 99.8%

      \[\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-+.f64N/A

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

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

        \[\leadsto \left(\color{blue}{\left(x \cdot y + \frac{z \cdot t}{16}\right)} - \frac{a \cdot b}{4}\right) + c \]
      4. associate--l+N/A

        \[\leadsto \color{blue}{\left(x \cdot y + \left(\frac{z \cdot t}{16} - \frac{a \cdot b}{4}\right)\right)} + c \]
      5. associate-+l+N/A

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

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

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

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

        \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\left(\frac{z \cdot t}{16} - \frac{a \cdot b}{4}\right) + c}\right) \]
    4. Applied rewrites99.8%

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

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

        \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\frac{-1}{4} \cdot \left(a \cdot b\right)}\right) \]
      2. lower-*.f6456.2

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

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

    if -1.9999999999999999e35 < (+.f64 (*.f64 x y) (/.f64 (*.f64 z t) #s(literal 16 binary64))) < 1e114

    1. Initial program 99.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 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. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

    Reproduce

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