?

Average Accuracy: 99.8% → 100.0%
Time: 17.9s
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(z, \frac{t}{16}, \mathsf{fma}\left(b, -0.25 \cdot a, \mathsf{fma}\left(x, y, 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 z (/ t 16.0) (fma b (* -0.25 a) (fma x y 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(z, (t / 16.0), fma(b, (-0.25 * a), fma(x, y, 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(z, Float64(t / 16.0), fma(b, Float64(-0.25 * a), fma(x, y, 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[(z * N[(t / 16.0), $MachinePrecision] + N[(b * N[(-0.25 * a), $MachinePrecision] + N[(x * y + 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(z, \frac{t}{16}, \mathsf{fma}\left(b, -0.25 \cdot a, \mathsf{fma}\left(x, y, 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(z, \frac{t}{16}, \mathsf{fma}\left(b, -0.25 \cdot a, \mathsf{fma}\left(x, y, 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)} \]

    associate-*r/ [<=]99.9

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

    *-commutative [<=]99.9

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

    *-commutative [=>]99.9

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

    fma-def [=>]99.9

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

    associate--r- [=>]99.9

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

    +-commutative [=>]99.9

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

    associate-+r- [=>]99.9

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

    sub-neg [=>]99.9

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

    +-commutative [<=]99.9

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

    neg-mul-1 [=>]99.9

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

    associate-*l/ [<=]100.0

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

    associate-*r* [=>]100.0

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

    *-commutative [=>]100.0

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

    fma-def [=>]100.0

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

    associate-*r/ [=>]100.0

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

    associate-/l* [=>]99.9

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

    associate-/r/ [=>]100.0

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

    metadata-eval [=>]100.0

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

    +-commutative [=>]100.0

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

    fma-def [=>]100.0

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

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

Alternatives

Alternative 1
Accuracy100.0%
Cost13632
\[\mathsf{fma}\left(x, y, \mathsf{fma}\left(t, \frac{z}{16}, c - a \cdot \frac{b}{4}\right)\right) \]
Alternative 2
Accuracy100.0%
Cost7424
\[z \cdot \left(t \cdot 0.0625\right) + \left(x \cdot y - \mathsf{fma}\left(a \cdot 0.25, b, -c\right)\right) \]
Alternative 3
Accuracy67.5%
Cost1876
\[\begin{array}{l} t_1 := c + x \cdot y\\ t_2 := c + 0.0625 \cdot \left(z \cdot t\right)\\ \mathbf{if}\;b \cdot a \leq -5 \cdot 10^{+86}:\\ \;\;\;\;c + b \cdot \left(-0.25 \cdot a\right)\\ \mathbf{elif}\;b \cdot a \leq -5 \cdot 10^{-47}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq 0:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \cdot a \leq 2 \cdot 10^{-37}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq 2 \cdot 10^{+106}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;x \cdot y + -0.25 \cdot \left(b \cdot a\right)\\ \end{array} \]
Alternative 4
Accuracy63.8%
Cost1748
\[\begin{array}{l} t_1 := c + x \cdot y\\ t_2 := c + 0.0625 \cdot \left(z \cdot t\right)\\ t_3 := -0.25 \cdot \left(b \cdot a\right)\\ \mathbf{if}\;b \cdot a \leq -3.4 \cdot 10^{+168}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \cdot a \leq -1.56 \cdot 10^{-47}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq 1.8 \cdot 10^{-307}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \cdot a \leq 3.5 \cdot 10^{-35}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq 1.02 \cdot 10^{+110}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 5
Accuracy68.3%
Cost1748
\[\begin{array}{l} t_1 := c + x \cdot y\\ t_2 := c + 0.0625 \cdot \left(z \cdot t\right)\\ t_3 := c + b \cdot \left(-0.25 \cdot a\right)\\ \mathbf{if}\;b \cdot a \leq -5 \cdot 10^{+86}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \cdot a \leq -5 \cdot 10^{-47}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq 0:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \cdot a \leq 2 \cdot 10^{-37}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq 5 \cdot 10^{+90}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 6
Accuracy90.8%
Cost1225
\[\begin{array}{l} \mathbf{if}\;b \cdot a \leq -5 \cdot 10^{-44} \lor \neg \left(b \cdot a \leq 5 \cdot 10^{+90}\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 7
Accuracy87.3%
Cost1224
\[\begin{array}{l} \mathbf{if}\;b \cdot a \leq -5 \cdot 10^{+86}:\\ \;\;\;\;c + b \cdot \left(-0.25 \cdot a\right)\\ \mathbf{elif}\;b \cdot a \leq 2 \cdot 10^{+106}:\\ \;\;\;\;c + \left(x \cdot y + 0.0625 \cdot \left(z \cdot t\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot y + -0.25 \cdot \left(b \cdot a\right)\\ \end{array} \]
Alternative 8
Accuracy43.1%
Cost1112
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(z \cdot t\right)\\ \mathbf{if}\;c \leq -5.2 \cdot 10^{+124}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq -1.1 \cdot 10^{-27}:\\ \;\;\;\;-0.25 \cdot \left(b \cdot a\right)\\ \mathbf{elif}\;c \leq -2.2 \cdot 10^{-226}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq -4.6 \cdot 10^{-304}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 4.2 \cdot 10^{-86}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 8.2 \cdot 10^{+51}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 9
Accuracy99.8%
Cost1088
\[c + \left(\left(\frac{z \cdot t}{16} + x \cdot y\right) - \frac{b \cdot a}{4}\right) \]
Alternative 10
Accuracy44.2%
Cost980
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(z \cdot t\right)\\ \mathbf{if}\;c \leq -820000:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq -2.8 \cdot 10^{-227}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq -5.2 \cdot 10^{-305}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 7.5 \cdot 10^{-86}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 8.2 \cdot 10^{+43}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 11
Accuracy64.8%
Cost841
\[\begin{array}{l} \mathbf{if}\;b \cdot a \leq -2.4 \cdot 10^{+169} \lor \neg \left(b \cdot a \leq 8.5 \cdot 10^{+110}\right):\\ \;\;\;\;-0.25 \cdot \left(b \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;c + x \cdot y\\ \end{array} \]
Alternative 12
Accuracy45.2%
Cost456
\[\begin{array}{l} \mathbf{if}\;c \leq -820000:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq 5.5 \cdot 10^{+58}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 13
Accuracy32.1%
Cost64
\[c \]

Error

Reproduce?

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