?

Average Accuracy: 99.8% → 100.0%
Time: 19.6s
Precision: binary64
Cost: 19904

?

\[\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c \]
\[\mathsf{fma}\left(x, y, \mathsf{fma}\left(b, -0.25 \cdot a, \mathsf{fma}\left(z, \frac{t}{16}, c\right)\right)\right) \]
(FPCore (x y z t a b c)
 :precision binary64
 (+ (- (+ (* x y) (/ (* z t) 16.0)) (/ (* a b) 4.0)) c))
(FPCore (x y z t a b c)
 :precision binary64
 (fma x y (fma b (* -0.25 a) (fma z (/ t 16.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;
}
double code(double x, double y, double z, double t, double a, double b, double c) {
	return fma(x, y, fma(b, (-0.25 * a), fma(z, (t / 16.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 code(x, y, z, t, a, b, c)
	return fma(x, y, fma(b, Float64(-0.25 * a), fma(z, Float64(t / 16.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]
code[x_, y_, z_, t_, a_, b_, c_] := N[(x * y + N[(b * N[(-0.25 * a), $MachinePrecision] + N[(z * N[(t / 16.0), $MachinePrecision] + c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c
\mathsf{fma}\left(x, y, \mathsf{fma}\left(b, -0.25 \cdot a, \mathsf{fma}\left(z, \frac{t}{16}, c\right)\right)\right)

Error?

Derivation?

  1. Initial program 99.8%

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, y, \mathsf{fma}\left(b, -0.25 \cdot a, \mathsf{fma}\left(z, \frac{t}{16}, c\right)\right)\right)} \]
    Proof

    [Start]99.8

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

    associate-+l- [=>]99.8

    \[ \color{blue}{\left(x \cdot y + \frac{z \cdot t}{16}\right) - \left(\frac{a \cdot b}{4} - c\right)} \]

    +-commutative [=>]99.8

    \[ \color{blue}{\left(\frac{z \cdot t}{16} + x \cdot y\right)} - \left(\frac{a \cdot b}{4} - c\right) \]

    associate--l+ [=>]99.8

    \[ \color{blue}{\frac{z \cdot t}{16} + \left(x \cdot y - \left(\frac{a \cdot b}{4} - c\right)\right)} \]

    +-commutative [=>]99.8

    \[ \color{blue}{\left(x \cdot y - \left(\frac{a \cdot b}{4} - c\right)\right) + \frac{z \cdot t}{16}} \]

    associate-+l- [=>]99.8

    \[ \color{blue}{x \cdot y - \left(\left(\frac{a \cdot b}{4} - c\right) - \frac{z \cdot t}{16}\right)} \]

    fma-neg [=>]99.9

    \[ \color{blue}{\mathsf{fma}\left(x, y, -\left(\left(\frac{a \cdot b}{4} - c\right) - \frac{z \cdot t}{16}\right)\right)} \]

    neg-sub0 [=>]99.9

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

    associate--l- [=>]99.9

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

    associate-+l- [<=]99.9

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

    neg-sub0 [<=]99.9

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

    *-commutative [=>]99.9

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

    associate-*r/ [<=]99.9

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

    distribute-rgt-neg-in [=>]99.9

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

    fma-def [=>]99.9

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

    distribute-frac-neg [<=]99.9

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

    neg-mul-1 [=>]99.9

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

    associate-/l* [=>]99.9

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

    associate-/r/ [=>]99.9

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

    metadata-eval [=>]99.9

    \[ \mathsf{fma}\left(x, y, \mathsf{fma}\left(b, \color{blue}{-0.25} \cdot a, c + \frac{z \cdot t}{16}\right)\right) \]
  3. Final simplification100.0%

    \[\leadsto \mathsf{fma}\left(x, y, \mathsf{fma}\left(b, -0.25 \cdot a, \mathsf{fma}\left(z, \frac{t}{16}, c\right)\right)\right) \]

Alternatives

Alternative 1
Accuracy100.0%
Cost13632
\[\mathsf{fma}\left(t, \frac{z}{16}, \mathsf{fma}\left(x, y, c - b \cdot \frac{a}{4}\right)\right) \]
Alternative 2
Accuracy100.0%
Cost7360
\[\mathsf{fma}\left(y, x, t \cdot \left(z \cdot 0.0625\right) - \left(b \cdot \left(a \cdot 0.25\right) - c\right)\right) \]
Alternative 3
Accuracy65.4%
Cost3048
\[\begin{array}{l} t_1 := 0.25 \cdot \left(b \cdot a\right)\\ t_2 := c - t_1\\ t_3 := 0.0625 \cdot \left(z \cdot t\right)\\ t_4 := x \cdot y + t_3\\ t_5 := c + t_3\\ t_6 := c + x \cdot y\\ \mathbf{if}\;b \cdot a \leq -1.85 \cdot 10^{+100}:\\ \;\;\;\;x \cdot y - t_1\\ \mathbf{elif}\;b \cdot a \leq -1.16 \cdot 10^{+60}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;b \cdot a \leq -7.8 \cdot 10^{+28}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \cdot a \leq -1.25 \cdot 10^{-132}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;b \cdot a \leq -1.25 \cdot 10^{-257}:\\ \;\;\;\;t_6\\ \mathbf{elif}\;b \cdot a \leq -3.9 \cdot 10^{-307}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;b \cdot a \leq 0:\\ \;\;\;\;t_5\\ \mathbf{elif}\;b \cdot a \leq 1.62 \cdot 10^{-258}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;b \cdot a \leq 6.8 \cdot 10^{-60}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;b \cdot a \leq 4.8 \cdot 10^{+43}:\\ \;\;\;\;t_6\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Accuracy61.8%
Cost2788
\[\begin{array}{l} t_1 := c + 0.0625 \cdot \left(z \cdot t\right)\\ t_2 := -0.25 \cdot \left(b \cdot a\right)\\ t_3 := c + x \cdot y\\ \mathbf{if}\;b \cdot a \leq -8 \cdot 10^{+100}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \cdot a \leq -1.6 \cdot 10^{+54}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq -5.6 \cdot 10^{+38}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \cdot a \leq -5.2 \cdot 10^{+20}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \cdot a \leq -2.6 \cdot 10^{-131}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq -2 \cdot 10^{-215}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \cdot a \leq 6.5 \cdot 10^{-58}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq 4.7 \cdot 10^{+42}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \cdot a \leq 5.8 \cdot 10^{+189}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Accuracy66.5%
Cost2528
\[\begin{array}{l} t_1 := c + x \cdot y\\ t_2 := 0.0625 \cdot \left(z \cdot t\right)\\ t_3 := x \cdot y + t_2\\ t_4 := c + t_2\\ t_5 := c - 0.25 \cdot \left(b \cdot a\right)\\ \mathbf{if}\;b \cdot a \leq -6.2 \cdot 10^{+28}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;b \cdot a \leq -8.2 \cdot 10^{-132}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \cdot a \leq -8 \cdot 10^{-260}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq -8.8 \cdot 10^{-307}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \cdot a \leq 0:\\ \;\;\;\;t_4\\ \mathbf{elif}\;b \cdot a \leq 3.3 \cdot 10^{-260}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \cdot a \leq 4.5 \cdot 10^{-58}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;b \cdot a \leq 8.5 \cdot 10^{+43}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_5\\ \end{array} \]
Alternative 6
Accuracy33.3%
Cost2300
\[\begin{array}{l} t_1 := -0.25 \cdot \left(b \cdot a\right)\\ t_2 := 0.0625 \cdot \left(z \cdot t\right)\\ \mathbf{if}\;t \leq -4.6 \cdot 10^{-42}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -5.2 \cdot 10^{-292}:\\ \;\;\;\;c\\ \mathbf{elif}\;t \leq 2.1 \cdot 10^{-299}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 5.4 \cdot 10^{-286}:\\ \;\;\;\;c\\ \mathbf{elif}\;t \leq 2.5 \cdot 10^{-254}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;t \leq 5.6 \cdot 10^{-188}:\\ \;\;\;\;c\\ \mathbf{elif}\;t \leq 1.35 \cdot 10^{-121}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 4.4 \cdot 10^{-82}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;t \leq 2.45 \cdot 10^{-57}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.15 \cdot 10^{-52}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 7.6 \cdot 10^{-28}:\\ \;\;\;\;c\\ \mathbf{elif}\;t \leq 4 \cdot 10^{+14}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 5.5 \cdot 10^{+29}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 8 \cdot 10^{+51}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;t \leq 2.7 \cdot 10^{+131}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 7
Accuracy57.9%
Cost1880
\[\begin{array}{l} t_1 := c + x \cdot y\\ t_2 := 0.0625 \cdot \left(z \cdot t\right)\\ t_3 := -0.25 \cdot \left(b \cdot a\right)\\ \mathbf{if}\;b \cdot a \leq -1.5 \cdot 10^{+102}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \cdot a \leq -1 \cdot 10^{-15}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq -9.5 \cdot 10^{-132}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \cdot a \leq 3.8 \cdot 10^{-143}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq 3.4 \cdot 10^{-65}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \cdot a \leq 5.5 \cdot 10^{+189}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 8
Accuracy67.9%
Cost1748
\[\begin{array}{l} t_1 := c + 0.0625 \cdot \left(z \cdot t\right)\\ t_2 := c - 0.25 \cdot \left(b \cdot a\right)\\ t_3 := c + x \cdot y\\ \mathbf{if}\;b \cdot a \leq -5 \cdot 10^{+28}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \cdot a \leq -6 \cdot 10^{-135}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq -3.5 \cdot 10^{-215}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \cdot a \leq 5.8 \cdot 10^{-66}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq 1.06 \cdot 10^{+43}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 9
Accuracy86.7%
Cost1745
\[\begin{array}{l} t_1 := 0.25 \cdot \left(b \cdot a\right)\\ \mathbf{if}\;b \cdot a \leq -1.95 \cdot 10^{+102}:\\ \;\;\;\;x \cdot y - t_1\\ \mathbf{elif}\;b \cdot a \leq -1.1 \cdot 10^{+60} \lor \neg \left(b \cdot a \leq -1.1 \cdot 10^{+29}\right) \land b \cdot a \leq 3.5 \cdot 10^{+88}:\\ \;\;\;\;c + \left(x \cdot y + 0.0625 \cdot \left(z \cdot t\right)\right)\\ \mathbf{else}:\\ \;\;\;\;c - t_1\\ \end{array} \]
Alternative 10
Accuracy85.2%
Cost1744
\[\begin{array}{l} t_1 := 0.25 \cdot \left(b \cdot a\right)\\ t_2 := 0.0625 \cdot \left(z \cdot t\right)\\ t_3 := c + \left(x \cdot y + t_2\right)\\ \mathbf{if}\;b \cdot a \leq -3 \cdot 10^{+103}:\\ \;\;\;\;x \cdot y - t_1\\ \mathbf{elif}\;b \cdot a \leq -1.1 \cdot 10^{+60}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \cdot a \leq -1.1 \cdot 10^{+29}:\\ \;\;\;\;c - t_1\\ \mathbf{elif}\;b \cdot a \leq 8 \cdot 10^{+189}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_2 - t_1\\ \end{array} \]
Alternative 11
Accuracy91.4%
Cost1352
\[\begin{array}{l} t_1 := 0.25 \cdot \left(b \cdot a\right)\\ t_2 := 0.0625 \cdot \left(z \cdot t\right)\\ \mathbf{if}\;b \cdot a \leq -3.8 \cdot 10^{+28}:\\ \;\;\;\;\left(c + x \cdot y\right) - t_1\\ \mathbf{elif}\;b \cdot a \leq 3.7 \cdot 10^{+43}:\\ \;\;\;\;c + \left(x \cdot y + t_2\right)\\ \mathbf{else}:\\ \;\;\;\;\left(c + t_2\right) - t_1\\ \end{array} \]
Alternative 12
Accuracy91.3%
Cost1225
\[\begin{array}{l} \mathbf{if}\;b \cdot a \leq -7.8 \cdot 10^{+27} \lor \neg \left(b \cdot a \leq 1.25 \cdot 10^{+91}\right):\\ \;\;\;\;\left(c + x \cdot y\right) - 0.25 \cdot \left(b \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;c + \left(x \cdot y + 0.0625 \cdot \left(z \cdot t\right)\right)\\ \end{array} \]
Alternative 13
Accuracy99.8%
Cost1088
\[c + \left(\left(\frac{z \cdot t}{16} + x \cdot y\right) - \frac{b \cdot a}{4}\right) \]
Alternative 14
Accuracy43.9%
Cost848
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(z \cdot t\right)\\ \mathbf{if}\;c \leq -1 \cdot 10^{+92}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq 1.28 \cdot 10^{-232}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 600000000:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 3.1 \cdot 10^{+103}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 15
Accuracy45.8%
Cost456
\[\begin{array}{l} \mathbf{if}\;c \leq -6.5 \cdot 10^{+34}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq 500000000:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 16
Accuracy32.3%
Cost64
\[c \]

Error

Reproduce?

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