Average Error: 0.1 → 0.0
Time: 16.0s
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 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.0

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

    *-commutative [<=]0.0

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

    *-commutative [=>]0.0

    \[ \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
Error0.0
Cost13632
\[\mathsf{fma}\left(x, y, \mathsf{fma}\left(t, \frac{z}{16}, c - a \cdot \frac{b}{4}\right)\right) \]
Alternative 2
Error29.8
Cost2164
\[\begin{array}{l} t_1 := c + 0.0625 \cdot \left(z \cdot t\right)\\ t_2 := c + x \cdot y\\ t_3 := a \cdot \left(b \cdot -0.25\right)\\ \mathbf{if}\;a \leq -9.5 \cdot 10^{+251}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \leq -4.2 \cdot 10^{+227}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -4 \cdot 10^{+196}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \leq -1.75 \cdot 10^{+105}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -4.2 \cdot 10^{+76}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \leq -1.8 \cdot 10^{+71}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq -0.00162:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -2.45 \cdot 10^{-120}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq -2.65 \cdot 10^{-166}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -8.8 \cdot 10^{-211}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 3.7 \cdot 10^{-174}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 1.12 \cdot 10^{-54}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 1700000000:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 3
Error21.2
Cost1768
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(z \cdot t\right)\\ t_2 := c + t_1\\ t_3 := \left(b \cdot a\right) \cdot 0.25\\ t_4 := t_1 + x \cdot y\\ t_5 := x \cdot y - t_3\\ \mathbf{if}\;c \leq -2.8 \cdot 10^{+129}:\\ \;\;\;\;c - t_3\\ \mathbf{elif}\;c \leq -5.8 \cdot 10^{+94}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;c \leq -3.1 \cdot 10^{+31}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq -1.75 \cdot 10^{-169}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;c \leq -1.22 \cdot 10^{-231}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;c \leq 2.4 \cdot 10^{-258}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;c \leq 12.5:\\ \;\;\;\;t_4\\ \mathbf{elif}\;c \leq 6 \cdot 10^{+62}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 6 \cdot 10^{+74}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;c \leq 2 \cdot 10^{+160}:\\ \;\;\;\;c + x \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error21.3
Cost1748
\[\begin{array}{l} t_1 := c + x \cdot y\\ t_2 := 0.0625 \cdot \left(z \cdot t\right)\\ t_3 := c - \left(b \cdot a\right) \cdot 0.25\\ \mathbf{if}\;b \cdot a \leq -4 \cdot 10^{+65}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \cdot a \leq -5 \cdot 10^{-241}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq 2 \cdot 10^{-257}:\\ \;\;\;\;c + t_2\\ \mathbf{elif}\;b \cdot a \leq 2 \cdot 10^{-40}:\\ \;\;\;\;t_2 + x \cdot y\\ \mathbf{elif}\;b \cdot a \leq 4 \cdot 10^{+50}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 5
Error20.3
Cost1488
\[\begin{array}{l} t_1 := c + x \cdot y\\ t_2 := c - \left(b \cdot a\right) \cdot 0.25\\ \mathbf{if}\;b \cdot a \leq -4 \cdot 10^{+65}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \cdot a \leq -5 \cdot 10^{-241}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq 4 \cdot 10^{-162}:\\ \;\;\;\;c + 0.0625 \cdot \left(z \cdot t\right)\\ \mathbf{elif}\;b \cdot a \leq 4 \cdot 10^{+50}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 6
Error10.1
Cost1364
\[\begin{array}{l} t_1 := \left(b \cdot a\right) \cdot 0.25\\ t_2 := 0.0625 \cdot \left(z \cdot t\right)\\ t_3 := c + \left(t_2 + x \cdot y\right)\\ \mathbf{if}\;t \leq -1.5 \cdot 10^{-126}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 6.5 \cdot 10^{-27}:\\ \;\;\;\;\left(c + x \cdot y\right) + -0.25 \cdot \left(b \cdot a\right)\\ \mathbf{elif}\;t \leq 1.9 \cdot 10^{+52}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 7.6 \cdot 10^{+60}:\\ \;\;\;\;c - t_1\\ \mathbf{elif}\;t \leq 4 \cdot 10^{+87}:\\ \;\;\;\;t_2 - t_1\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 7
Error5.7
Cost1353
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(z \cdot t\right)\\ \mathbf{if}\;b \cdot a \leq -4 \cdot 10^{+67} \lor \neg \left(b \cdot a \leq 4 \cdot 10^{+50}\right):\\ \;\;\;\;\left(c + t_1\right) + -0.25 \cdot \left(b \cdot a\right)\\ \mathbf{else}:\\ \;\;\;\;c + \left(t_1 + x \cdot y\right)\\ \end{array} \]
Alternative 8
Error8.2
Cost1225
\[\begin{array}{l} \mathbf{if}\;b \cdot a \leq -2 \cdot 10^{+161} \lor \neg \left(b \cdot a \leq 2 \cdot 10^{+88}\right):\\ \;\;\;\;c - \left(b \cdot a\right) \cdot 0.25\\ \mathbf{else}:\\ \;\;\;\;c + \left(0.0625 \cdot \left(z \cdot t\right) + x \cdot y\right)\\ \end{array} \]
Alternative 9
Error32.3
Cost1112
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(z \cdot t\right)\\ t_2 := c + x \cdot y\\ t_3 := a \cdot \left(b \cdot -0.25\right)\\ \mathbf{if}\;z \leq -1 \cdot 10^{+262}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -6.2 \cdot 10^{+184}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -4.6 \cdot 10^{-157}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -3.3 \cdot 10^{-168}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 8 \cdot 10^{-115}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq 7.4 \cdot 10^{-100}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \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.3
Cost980
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(z \cdot t\right)\\ \mathbf{if}\;c \leq -1.16 \cdot 10^{+23}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq -1.65 \cdot 10^{-169}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 1.38 \cdot 10^{-210}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 8 \cdot 10^{-165}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 3.4 \cdot 10^{+85}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 12
Error35.2
Cost980
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(z \cdot t\right)\\ \mathbf{if}\;c \leq -3.3 \cdot 10^{+25}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq -1.75 \cdot 10^{-169}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq -1.7 \cdot 10^{-234}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 3.6 \cdot 10^{-258}:\\ \;\;\;\;a \cdot \left(b \cdot -0.25\right)\\ \mathbf{elif}\;c \leq 2.5 \cdot 10^{+85}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 13
Error35.1
Cost456
\[\begin{array}{l} \mathbf{if}\;c \leq -2.5 \cdot 10^{+25}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq 19:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 14
Error43.2
Cost64
\[c \]

Error

Reproduce

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