?

Average Accuracy: 99.8% → 100.0%
Time: 16.8s
Precision: binary64
Cost: 13632

?

\[\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(t, \frac{z}{16}, c - a \cdot \frac{b}{4}\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 t (/ z 16.0) (- c (* a (/ b 4.0))))))
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(t, (z / 16.0), (c - (a * (b / 4.0)))));
}
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(t, Float64(z / 16.0), Float64(c - Float64(a * Float64(b / 4.0)))))
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[(t * N[(z / 16.0), $MachinePrecision] + N[(c - N[(a * N[(b / 4.0), $MachinePrecision]), $MachinePrecision]), $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(t, \frac{z}{16}, c - a \cdot \frac{b}{4}\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(t, \frac{z}{16}, c - a \cdot \frac{b}{4}\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 + \left(\frac{z \cdot t}{16} - \frac{a \cdot b}{4}\right)\right)} + c \]

    associate-+l+ [=>]99.8

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

    fma-def [=>]99.8

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

    associate-+l- [=>]99.8

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

    associate-*l/ [<=]99.9

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

    *-commutative [=>]99.9

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

    fma-neg [=>]99.9

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

    neg-sub0 [=>]99.9

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

    associate-+l- [<=]99.9

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

    neg-sub0 [<=]99.9

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

    +-commutative [=>]99.9

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

    unsub-neg [=>]99.9

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

    associate-*r/ [<=]100.0

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

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

Alternatives

Alternative 1
Accuracy65.6%
Cost2396
\[\begin{array}{l} t_1 := \left(t \cdot z\right) \cdot 0.0625\\ t_2 := c + b \cdot \left(a \cdot -0.25\right)\\ t_3 := t_1 + x \cdot y\\ t_4 := c + x \cdot y\\ \mathbf{if}\;a \cdot b \leq -500000:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq -2 \cdot 10^{-129}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \cdot b \leq -1 \cdot 10^{-321}:\\ \;\;\;\;c + t_1\\ \mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{-129}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;a \cdot b \leq 10^{+17}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{+37}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;a \cdot b \leq 10^{+64}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Accuracy45.0%
Cost1640
\[\begin{array}{l} t_1 := \left(a \cdot b\right) \cdot -0.25\\ t_2 := \left(t \cdot z\right) \cdot 0.0625\\ \mathbf{if}\;c \leq -1.85 \cdot 10^{+74}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq -1900000:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq -1.8 \cdot 10^{-56}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq -5 \cdot 10^{-123}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -1.05 \cdot 10^{-138}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq -1.25 \cdot 10^{-164}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -2.3 \cdot 10^{-290}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 7.4 \cdot 10^{-165}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 1.12 \cdot 10^{-89}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 1.1 \cdot 10^{+78}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 3
Accuracy62.5%
Cost1488
\[\begin{array}{l} t_1 := c + \left(t \cdot z\right) \cdot 0.0625\\ t_2 := \left(a \cdot b\right) \cdot -0.25\\ \mathbf{if}\;a \cdot b \leq -1.22 \cdot 10^{+173}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq -1 \cdot 10^{-321}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 1780:\\ \;\;\;\;c + x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 1.36 \cdot 10^{+138}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Accuracy67.1%
Cost1488
\[\begin{array}{l} t_1 := c + \left(t \cdot z\right) \cdot 0.0625\\ t_2 := c + b \cdot \left(a \cdot -0.25\right)\\ \mathbf{if}\;a \cdot b \leq -1 \cdot 10^{-50}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq -1 \cdot 10^{-321}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 20:\\ \;\;\;\;c + x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 5 \cdot 10^{+103}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Accuracy51.6%
Cost1377
\[\begin{array}{l} t_1 := \left(a \cdot b\right) \cdot -0.25\\ t_2 := \left(t \cdot z\right) \cdot 0.0625\\ t_3 := c + x \cdot y\\ \mathbf{if}\;c \leq -1.85 \cdot 10^{+74}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \leq -5800000:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq -4.8 \cdot 10^{-104}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \leq -1.1 \cdot 10^{-285}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 9 \cdot 10^{-165}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 1.15 \cdot 10^{-89}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 4.7 \cdot 10^{+17} \lor \neg \left(c \leq 8 \cdot 10^{+71}\right):\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Accuracy67.3%
Cost1236
\[\begin{array}{l} t_1 := x \cdot y + \left(a \cdot b\right) \cdot -0.25\\ t_2 := \left(t \cdot z\right) \cdot 0.0625 + x \cdot y\\ \mathbf{if}\;c \leq -1.85 \cdot 10^{+74}:\\ \;\;\;\;c + b \cdot \left(a \cdot -0.25\right)\\ \mathbf{elif}\;c \leq -3.2 \cdot 10^{-282}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 2.2 \cdot 10^{-168}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 4.5 \cdot 10^{-90}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 1.25 \cdot 10^{+72}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;c + x \cdot y\\ \end{array} \]
Alternative 7
Accuracy87.1%
Cost1225
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -1.5 \cdot 10^{+153} \lor \neg \left(a \cdot b \leq 5 \cdot 10^{+109}\right):\\ \;\;\;\;c + b \cdot \left(a \cdot -0.25\right)\\ \mathbf{else}:\\ \;\;\;\;c + \left(\left(t \cdot z\right) \cdot 0.0625 + x \cdot y\right)\\ \end{array} \]
Alternative 8
Accuracy90.2%
Cost1225
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -1 \cdot 10^{-50} \lor \neg \left(a \cdot b \leq 5 \cdot 10^{+103}\right):\\ \;\;\;\;\left(c + x \cdot y\right) + \left(a \cdot b\right) \cdot -0.25\\ \mathbf{else}:\\ \;\;\;\;c + \left(\left(t \cdot z\right) \cdot 0.0625 + x \cdot y\right)\\ \end{array} \]
Alternative 9
Accuracy86.3%
Cost1224
\[\begin{array}{l} t_1 := \left(t \cdot z\right) \cdot 0.0625\\ \mathbf{if}\;a \cdot b \leq -1 \cdot 10^{+74}:\\ \;\;\;\;t_1 - \left(a \cdot b\right) \cdot 0.25\\ \mathbf{elif}\;a \cdot b \leq 5 \cdot 10^{+109}:\\ \;\;\;\;c + \left(t_1 + x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;c + b \cdot \left(a \cdot -0.25\right)\\ \end{array} \]
Alternative 10
Accuracy89.6%
Cost1224
\[\begin{array}{l} t_1 := \left(t \cdot z\right) \cdot 0.0625\\ \mathbf{if}\;a \cdot b \leq -1 \cdot 10^{-50}:\\ \;\;\;\;\left(c + t_1\right) - \left(a \cdot b\right) \cdot 0.25\\ \mathbf{elif}\;a \cdot b \leq 5 \cdot 10^{+103}:\\ \;\;\;\;c + \left(t_1 + x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\left(c + x \cdot y\right) + \left(a \cdot b\right) \cdot -0.25\\ \end{array} \]
Alternative 11
Accuracy45.0%
Cost1116
\[\begin{array}{l} t_1 := \left(t \cdot z\right) \cdot 0.0625\\ \mathbf{if}\;c \leq -1.85 \cdot 10^{+74}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq -1700000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -5.8 \cdot 10^{-70}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 9.6 \cdot 10^{-284}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 7.8 \cdot 10^{-165}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 2.5 \cdot 10^{-89}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 3.5 \cdot 10^{+78}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 12
Accuracy99.8%
Cost1088
\[c + \left(\left(\frac{t \cdot z}{16} + x \cdot y\right) - \frac{a \cdot b}{4}\right) \]
Alternative 13
Accuracy45.7%
Cost456
\[\begin{array}{l} \mathbf{if}\;c \leq -780000:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq 3.1 \cdot 10^{+78}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 14
Accuracy33.0%
Cost64
\[c \]

Error

Reproduce?

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