?

Average Error: 0.1 → 0.0
Time: 16.7s
Precision: binary64
Cost: 19904

?

\[ \begin{array}{c}[z, t] = \mathsf{sort}([z, t])\\ \end{array} \]
\[\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 0.1

    \[\left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{a \cdot b}{4}\right) + c \]
  2. Simplified0.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]0.1

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

    associate-+l- [=>]0.1

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

    +-commutative [=>]0.1

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

    associate--l+ [=>]0.1

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

    associate-*r/ [<=]0.1

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

    *-commutative [<=]0.1

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

    *-commutative [=>]0.1

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

    fma-def [=>]0.0

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

    associate--r- [=>]0.0

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

    +-commutative [=>]0.0

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

    associate-+r- [=>]0.0

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

    sub-neg [=>]0.0

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

    +-commutative [<=]0.0

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

    \[ \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/ [<=]0.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* [=>]0.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 [=>]0.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 [=>]0.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/ [=>]0.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* [=>]0.0

    \[ \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/ [=>]0.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 [=>]0.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 [=>]0.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 [=>]0.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 simplification0.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
Error24.6
Cost2401
\[\begin{array}{l} t_1 := c + x \cdot y\\ t_2 := -0.25 \cdot \left(b \cdot a\right)\\ \mathbf{if}\;b \cdot a \leq -1.4 \cdot 10^{+147}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \cdot a \leq -3.1 \cdot 10^{+68}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq -4.2 \cdot 10^{+35}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \cdot a \leq -4.5 \cdot 10^{-244}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq -5 \cdot 10^{-315}:\\ \;\;\;\;0.0625 \cdot \left(z \cdot t\right)\\ \mathbf{elif}\;b \cdot a \leq 8.5 \cdot 10^{+55} \lor \neg \left(b \cdot a \leq 8.8 \cdot 10^{+86}\right) \land b \cdot a \leq 1.18 \cdot 10^{+170}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error9.9
Cost2396
\[\begin{array}{l} t_1 := c + \left(0.0625 \cdot \left(z \cdot t\right) + x \cdot y\right)\\ t_2 := \left(b \cdot a\right) \cdot 0.25\\ t_3 := x \cdot y - t_2\\ t_4 := c - t_2\\ \mathbf{if}\;b \cdot a \leq -4.8 \cdot 10^{+178}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \cdot a \leq -2.1 \cdot 10^{+68}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq -1 \cdot 10^{+46}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;b \cdot a \leq 4 \cdot 10^{+31}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq 9.6 \cdot 10^{+86}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \cdot a \leq 6.3 \cdot 10^{+179}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq 3.1 \cdot 10^{+240}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_4\\ \end{array} \]
Alternative 3
Error24.0
Cost2141
\[\begin{array}{l} t_1 := c + x \cdot y\\ t_2 := -0.25 \cdot \left(b \cdot a\right)\\ \mathbf{if}\;b \cdot a \leq -4.7 \cdot 10^{+143}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \cdot a \leq -2 \cdot 10^{+66}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq -4.2 \cdot 10^{+35}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \cdot a \leq -2.2 \cdot 10^{-140}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq 5.7 \cdot 10^{+32}:\\ \;\;\;\;c + 0.0625 \cdot \left(z \cdot t\right)\\ \mathbf{elif}\;b \cdot a \leq 1.6 \cdot 10^{+87} \lor \neg \left(b \cdot a \leq 1.92 \cdot 10^{+171}\right):\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error22.7
Cost1632
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(z \cdot t\right) + x \cdot y\\ t_2 := c - \left(b \cdot a\right) \cdot 0.25\\ \mathbf{if}\;c \leq -2.7 \cdot 10^{-53}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq -1.08 \cdot 10^{-206}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -1 \cdot 10^{-239}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 3.1 \cdot 10^{-223}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 1.3 \cdot 10^{-161}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 4.5 \cdot 10^{-128}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 2.85 \cdot 10^{-105}:\\ \;\;\;\;-0.25 \cdot \left(b \cdot a\right)\\ \mathbf{elif}\;c \leq 1.95 \cdot 10^{+89}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Error20.8
Cost1500
\[\begin{array}{l} t_1 := \left(b \cdot a\right) \cdot 0.25\\ t_2 := x \cdot y - t_1\\ t_3 := c - t_1\\ t_4 := 0.0625 \cdot \left(z \cdot t\right) + x \cdot y\\ \mathbf{if}\;c \leq -12000:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \leq -3.7 \cdot 10^{-64}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq -1.1 \cdot 10^{-205}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;c \leq -9.6 \cdot 10^{-240}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 3.1 \cdot 10^{-223}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;c \leq 3.2 \cdot 10^{-20}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 1.95 \cdot 10^{+89}:\\ \;\;\;\;t_4\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 6
Error20.6
Cost1489
\[\begin{array}{l} t_1 := c - \left(b \cdot a\right) \cdot 0.25\\ \mathbf{if}\;b \cdot a \leq -1.7 \cdot 10^{+143}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq -5 \cdot 10^{+109}:\\ \;\;\;\;c + x \cdot y\\ \mathbf{elif}\;b \cdot a \leq -1.65 \cdot 10^{+39} \lor \neg \left(b \cdot a \leq 6.5 \cdot 10^{-34}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;c + 0.0625 \cdot \left(z \cdot t\right)\\ \end{array} \]
Alternative 7
Error34.9
Cost1244
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(z \cdot t\right)\\ t_2 := -0.25 \cdot \left(b \cdot a\right)\\ \mathbf{if}\;c \leq -8.5 \cdot 10^{-16}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq -1.5 \cdot 10^{-64}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq -2 \cdot 10^{-176}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -9.6 \cdot 10^{-240}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 3.1 \cdot 10^{-223}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 4.8 \cdot 10^{-20}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 7.1 \cdot 10^{+87}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 8
Error5.4
Cost1225
\[\begin{array}{l} \mathbf{if}\;b \cdot a \leq -1 \cdot 10^{+46} \lor \neg \left(b \cdot a \leq 4 \cdot 10^{-34}\right):\\ \;\;\;\;x \cdot y + \left(c - \frac{a}{\frac{4}{b}}\right)\\ \mathbf{else}:\\ \;\;\;\;c + \left(0.0625 \cdot \left(z \cdot t\right) + x \cdot y\right)\\ \end{array} \]
Alternative 9
Error6.6
Cost1225
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(z \cdot t\right)\\ t_2 := -0.25 \cdot \left(b \cdot a\right)\\ \mathbf{if}\;c \leq -145000 \lor \neg \left(c \leq 10^{+68}\right):\\ \;\;\;\;\left(c + t_1\right) + t_2\\ \mathbf{else}:\\ \;\;\;\;\left(t_1 + x \cdot y\right) + t_2\\ \end{array} \]
Alternative 10
Error0.1
Cost1088
\[c + \left(\left(\frac{z \cdot t}{16} + x \cdot y\right) - \frac{b \cdot a}{4}\right) \]
Alternative 11
Error35.1
Cost980
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(z \cdot t\right)\\ \mathbf{if}\;c \leq -92000:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq -1.05 \cdot 10^{-116}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 1.2 \cdot 10^{-270}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 1.7 \cdot 10^{-132}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 6 \cdot 10^{+87}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 12
Error34.5
Cost456
\[\begin{array}{l} \mathbf{if}\;c \leq -24500:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq 6 \cdot 10^{+68}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 13
Error42.9
Cost64
\[c \]

Error

Reproduce?

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