?

Average Accuracy: 99.8% → 100.0%
Time: 18.2s
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.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 [=>]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.1%
Cost2528
\[\begin{array}{l} t_1 := c + t \cdot \left(z \cdot 0.0625\right)\\ t_2 := x \cdot y + 0.0625 \cdot \left(t \cdot z\right)\\ t_3 := c + a \cdot \left(b \cdot -0.25\right)\\ \mathbf{if}\;a \cdot b \leq -4 \cdot 10^{+148}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \cdot b \leq -1 \cdot 10^{+61}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq -5 \cdot 10^{-40}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \cdot b \leq -2 \cdot 10^{-72}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq -1 \cdot 10^{-203}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{-139}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 5 \cdot 10^{-61}:\\ \;\;\;\;c + x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 5 \cdot 10^{-27}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 2
Accuracy49.1%
Cost1904
\[\begin{array}{l} t_1 := a \cdot \left(b \cdot -0.25\right)\\ t_2 := c + x \cdot y\\ t_3 := 0.0625 \cdot \left(t \cdot z\right)\\ \mathbf{if}\;x \leq -5.5 \cdot 10^{+75}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -8.8 \cdot 10^{+46}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -51000:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -2.7 \cdot 10^{-54}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq -3.5 \cdot 10^{-115}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -1.05 \cdot 10^{-160}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq -1.5 \cdot 10^{-164}:\\ \;\;\;\;c\\ \mathbf{elif}\;x \leq -2.8 \cdot 10^{-179}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -9.5 \cdot 10^{-247}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq -8.5 \cdot 10^{-298}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 5.6 \cdot 10^{-304}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 6.2 \cdot 10^{-248}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Accuracy66.4%
Cost1768
\[\begin{array}{l} t_1 := x \cdot y - \left(a \cdot b\right) \cdot 0.25\\ t_2 := x \cdot y + 0.0625 \cdot \left(t \cdot z\right)\\ t_3 := c + a \cdot \left(b \cdot -0.25\right)\\ \mathbf{if}\;c \leq -2.65 \cdot 10^{+20}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \leq -2.4 \cdot 10^{-233}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 3.8 \cdot 10^{-236}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 1.58 \cdot 10^{-152}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 1.2 \cdot 10^{-112}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 1.35 \cdot 10^{-45}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 1450000000:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \leq 3.9 \cdot 10^{+44}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 3.5 \cdot 10^{+70}:\\ \;\;\;\;c + t \cdot \left(z \cdot 0.0625\right)\\ \mathbf{elif}\;c \leq 8 \cdot 10^{+107}:\\ \;\;\;\;c + x \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 4
Accuracy52.7%
Cost1376
\[\begin{array}{l} t_1 := c + a \cdot \left(b \cdot -0.25\right)\\ t_2 := c + x \cdot y\\ t_3 := 0.0625 \cdot \left(t \cdot z\right)\\ \mathbf{if}\;z \leq -5.9 \cdot 10^{+249}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -1.3 \cdot 10^{+138}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -7.8 \cdot 10^{+115}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -3.8 \cdot 10^{+16}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 3.2 \cdot 10^{-308}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.85 \cdot 10^{-245}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 4 \cdot 10^{-102}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 7.6 \cdot 10^{-20}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 5
Accuracy62.0%
Cost1240
\[\begin{array}{l} t_1 := c + x \cdot y\\ t_2 := c + t \cdot \left(z \cdot 0.0625\right)\\ t_3 := c + a \cdot \left(b \cdot -0.25\right)\\ \mathbf{if}\;z \leq -5 \cdot 10^{+40}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -1 \cdot 10^{+17}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 3.3 \cdot 10^{-308}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 3.4 \cdot 10^{-245}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 4.2 \cdot 10^{-100}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 2.1 \cdot 10^{-21}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 6
Accuracy87.2%
Cost1225
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -4 \cdot 10^{+148} \lor \neg \left(a \cdot b \leq 10^{+150}\right):\\ \;\;\;\;c + a \cdot \left(b \cdot -0.25\right)\\ \mathbf{else}:\\ \;\;\;\;c + \left(x \cdot y + 0.0625 \cdot \left(t \cdot z\right)\right)\\ \end{array} \]
Alternative 7
Accuracy89.7%
Cost1225
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -4 \cdot 10^{+148} \lor \neg \left(a \cdot b \leq 5 \cdot 10^{-27}\right):\\ \;\;\;\;\left(c + x \cdot y\right) + \left(a \cdot b\right) \cdot -0.25\\ \mathbf{else}:\\ \;\;\;\;c + \left(x \cdot y + 0.0625 \cdot \left(t \cdot z\right)\right)\\ \end{array} \]
Alternative 8
Accuracy99.8%
Cost1152
\[c + \left(\left(\frac{t \cdot z}{16} + x \cdot y\right) - \frac{a}{\frac{-4}{-b}}\right) \]
Alternative 9
Accuracy43.5%
Cost1112
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(t \cdot z\right)\\ \mathbf{if}\;c \leq -7.8 \cdot 10^{+92}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq -1.52 \cdot 10^{-246}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 4.1 \cdot 10^{-234}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 2.55 \cdot 10^{-150}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 1.2 \cdot 10^{-117}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 1.5 \cdot 10^{-46}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 10
Accuracy99.8%
Cost1088
\[c + \left(\left(\frac{t \cdot z}{16} + x \cdot y\right) - \frac{a \cdot b}{4}\right) \]
Alternative 11
Accuracy44.3%
Cost980
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(t \cdot z\right)\\ \mathbf{if}\;c \leq -1.85 \cdot 10^{+92}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq -1.5 \cdot 10^{-237}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 7 \cdot 10^{-234}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 1.85 \cdot 10^{-155}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 2.6 \cdot 10^{+44}:\\ \;\;\;\;a \cdot \left(b \cdot -0.25\right)\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 12
Accuracy44.8%
Cost456
\[\begin{array}{l} \mathbf{if}\;c \leq -3.15 \cdot 10^{+29}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq 2.1 \cdot 10^{+30}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 13
Accuracy31.7%
Cost64
\[c \]

Error

Reproduce?

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