?

Average Accuracy: 99.9% → 100.0%
Time: 18.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.9%

    \[\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.9

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

    associate--l+ [=>]99.9

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

    associate-+l+ [=>]99.9

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

    fma-def [=>]99.9

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

    associate-+l- [=>]99.9

    \[ \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 [=>]100.0

    \[ \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 [=>]100.0

    \[ \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- [<=]100.0

    \[ \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 [<=]100.0

    \[ \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 [=>]100.0

    \[ \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 [=>]100.0

    \[ \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
Accuracy66.1%
Cost3304
\[\begin{array}{l} t_1 := \left(t \cdot z\right) \cdot 0.0625\\ t_2 := t_1 + \left(a \cdot b\right) \cdot -0.25\\ t_3 := c + t_1\\ t_4 := c + a \cdot \left(b \cdot -0.25\right)\\ t_5 := c + x \cdot y\\ \mathbf{if}\;a \cdot b \leq -4 \cdot 10^{+87}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;a \cdot b \leq -2 \cdot 10^{-72}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \cdot b \leq -5 \cdot 10^{-138}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;a \cdot b \leq -2 \cdot 10^{-317}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \cdot b \leq 0:\\ \;\;\;\;t_1 + x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{-198}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \cdot b \leq 4 \cdot 10^{-34}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{-5}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq 10^{+62}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{+129}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_4\\ \end{array} \]
Alternative 2
Accuracy67.0%
Cost2268
\[\begin{array}{l} t_1 := \left(t \cdot z\right) \cdot 0.0625\\ t_2 := c + t_1\\ t_3 := c + a \cdot \left(b \cdot -0.25\right)\\ t_4 := c + x \cdot y\\ \mathbf{if}\;a \cdot b \leq -4 \cdot 10^{+87}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \cdot b \leq -2 \cdot 10^{-72}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq -5 \cdot 10^{-138}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;a \cdot b \leq -2 \cdot 10^{-317}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq 0:\\ \;\;\;\;t_1 + x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{-198}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq 10^{+62}:\\ \;\;\;\;t_4\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 3
Accuracy62.8%
Cost2140
\[\begin{array}{l} t_1 := c + x \cdot y\\ t_2 := \left(a \cdot b\right) \cdot -0.25\\ t_3 := c + \left(t \cdot z\right) \cdot 0.0625\\ \mathbf{if}\;a \cdot b \leq -2.4 \cdot 10^{+170}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq -2.9 \cdot 10^{+103}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq -4 \cdot 10^{+87}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq -6 \cdot 10^{-74}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \cdot b \leq -4.9 \cdot 10^{-142}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 2.75 \cdot 10^{-198}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \cdot b \leq 5.2 \cdot 10^{+67}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Accuracy67.8%
Cost1748
\[\begin{array}{l} t_1 := c + \left(t \cdot z\right) \cdot 0.0625\\ t_2 := c + a \cdot \left(b \cdot -0.25\right)\\ t_3 := c + x \cdot y\\ \mathbf{if}\;a \cdot b \leq -4 \cdot 10^{+87}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq -2 \cdot 10^{-72}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq -5 \cdot 10^{-138}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{-198}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 10^{+62}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Accuracy43.6%
Cost1640
\[\begin{array}{l} t_1 := \left(a \cdot b\right) \cdot -0.25\\ t_2 := z \cdot \left(t \cdot 0.0625\right)\\ \mathbf{if}\;c \leq -6 \cdot 10^{+67}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq -5 \cdot 10^{-150}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq -8.5 \cdot 10^{-271}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 5.8 \cdot 10^{-273}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 3.4 \cdot 10^{-242}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 2.3 \cdot 10^{-198}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 3.8 \cdot 10^{-158}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 5.4 \cdot 10^{-34}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 1.25 \cdot 10^{-11}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 9 \cdot 10^{+120}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 6
Accuracy66.1%
Cost1632
\[\begin{array}{l} t_1 := \left(t \cdot z\right) \cdot 0.0625\\ t_2 := c + t_1\\ t_3 := t_1 + x \cdot y\\ t_4 := x \cdot y - \left(a \cdot b\right) \cdot 0.25\\ \mathbf{if}\;c \leq -4.2 \cdot 10^{+117}:\\ \;\;\;\;c + a \cdot \left(b \cdot -0.25\right)\\ \mathbf{elif}\;c \leq -0.0001:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq -4.5 \cdot 10^{-95}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;c \leq -8 \cdot 10^{-151}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \leq -2.1 \cdot 10^{-270}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;c \leq 3.5 \cdot 10^{-273}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \leq 3.4 \cdot 10^{-12}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;c \leq 1.5 \cdot 10^{+120}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 7
Accuracy62.1%
Cost1620
\[\begin{array}{l} t_1 := c + x \cdot y\\ t_2 := \left(a \cdot b\right) \cdot -0.25\\ \mathbf{if}\;a \cdot b \leq -2.2 \cdot 10^{+172}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq -4.8 \cdot 10^{+109}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq -4.4 \cdot 10^{+86}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq -1.2 \cdot 10^{+55}:\\ \;\;\;\;z \cdot \left(t \cdot 0.0625\right)\\ \mathbf{elif}\;a \cdot b \leq 5.2 \cdot 10^{+67}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 8
Accuracy86.5%
Cost1484
\[\begin{array}{l} t_1 := \left(t \cdot z\right) \cdot 0.0625\\ t_2 := t_1 + \left(a \cdot b\right) \cdot -0.25\\ \mathbf{if}\;a \cdot b \leq -5 \cdot 10^{+172}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq 10^{+62}:\\ \;\;\;\;c + \left(t_1 + x \cdot y\right)\\ \mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{+129}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;c + a \cdot \left(b \cdot -0.25\right)\\ \end{array} \]
Alternative 9
Accuracy89.4%
Cost1484
\[\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 := \left(c + x \cdot y\right) + t_1\\ \mathbf{if}\;a \cdot b \leq -4 \cdot 10^{+87}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \cdot b \leq 10^{+62}:\\ \;\;\;\;c + \left(t_2 + x \cdot y\right)\\ \mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{+129}:\\ \;\;\;\;t_2 + t_1\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 10
Accuracy91.2%
Cost1353
\[\begin{array}{l} t_1 := \left(t \cdot z\right) \cdot 0.0625\\ \mathbf{if}\;a \cdot b \leq -4 \cdot 10^{+87} \lor \neg \left(a \cdot b \leq 10^{+62}\right):\\ \;\;\;\;c + \left(t_1 + \left(a \cdot b\right) \cdot -0.25\right)\\ \mathbf{else}:\\ \;\;\;\;c + \left(t_1 + x \cdot y\right)\\ \end{array} \]
Alternative 11
Accuracy43.9%
Cost1112
\[\begin{array}{l} t_1 := z \cdot \left(t \cdot 0.0625\right)\\ \mathbf{if}\;c \leq -1.05 \cdot 10^{+69}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq -2.4 \cdot 10^{-179}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -3.2 \cdot 10^{-238}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 1.1 \cdot 10^{-233}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 0.00055:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 1.8 \cdot 10^{+121}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 12
Accuracy99.9%
Cost1088
\[c + \left(\left(\frac{t \cdot z}{16} + x \cdot y\right) - \frac{a \cdot b}{4}\right) \]
Alternative 13
Accuracy43.9%
Cost456
\[\begin{array}{l} \mathbf{if}\;c \leq -1.1 \cdot 10^{+70}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq 9 \cdot 10^{+120}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 14
Accuracy31.5%
Cost64
\[c \]

Error

Reproduce?

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