?

Average Error: 0.18% → 0.01%
Time: 14.7s
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.18

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

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

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

    associate-+l- [=>]0.18

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

    +-commutative [=>]0.18

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

    associate--l+ [=>]0.18

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

    associate-*r/ [<=]0.08

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

    *-commutative [<=]0.08

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

    *-commutative [=>]0.08

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

    fma-def [=>]0.07

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

    associate--r- [=>]0.07

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

    +-commutative [=>]0.07

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

    associate-+r- [=>]0.07

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

    sub-neg [=>]0.07

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\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.02%
Cost13632
\[\mathsf{fma}\left(x, y, \mathsf{fma}\left(t, \frac{z}{16}, c - a \cdot \frac{b}{4}\right)\right) \]
Alternative 2
Error40%
Cost2029
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(z \cdot t\right)\\ t_2 := c + a \cdot \left(b \cdot -0.25\right)\\ t_3 := c + x \cdot y\\ t_4 := c + t_1\\ t_5 := t_1 + x \cdot y\\ \mathbf{if}\;b \leq -3.1 \cdot 10^{-130}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \leq -3.65 \cdot 10^{-249}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;b \leq 3.9 \cdot 10^{-294}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \leq 1.56 \cdot 10^{-264}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;b \leq 1.7 \cdot 10^{-136}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \leq 8.8 \cdot 10^{-69}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;b \leq 49:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \leq 2.8 \cdot 10^{+47}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;b \leq 8 \cdot 10^{+57}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \leq 9 \cdot 10^{+78} \lor \neg \left(b \leq 2 \cdot 10^{+175}\right):\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_5\\ \end{array} \]
Alternative 3
Error13.73%
Cost1744
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(z \cdot t\right)\\ t_2 := c + \left(t_1 + x \cdot y\right)\\ t_3 := c + a \cdot \left(b \cdot -0.25\right)\\ \mathbf{if}\;b \cdot a \leq -1 \cdot 10^{+160}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \cdot a \leq -1 \cdot 10^{+68}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \cdot a \leq -1000000:\\ \;\;\;\;t_1 + -0.25 \cdot \left(b \cdot a\right)\\ \mathbf{elif}\;b \cdot a \leq 4 \cdot 10^{+126}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 4
Error48.09%
Cost1640
\[\begin{array}{l} t_1 := -0.25 \cdot \left(b \cdot a\right)\\ t_2 := c + x \cdot y\\ t_3 := 0.0625 \cdot \left(z \cdot t\right)\\ \mathbf{if}\;c \leq -5.6 \cdot 10^{+88}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq -5 \cdot 10^{+47}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -9.2 \cdot 10^{-24}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq -3 \cdot 10^{-160}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \leq -3.6 \cdot 10^{-211}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -3.9 \cdot 10^{-214}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \leq 1.2 \cdot 10^{-282}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 3.1 \cdot 10^{-253}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \leq 1.26 \cdot 10^{-110}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 1.7 \cdot 10^{-46}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Error55.17%
Cost1508
\[\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 -9.8 \cdot 10^{+88}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq -2.8 \cdot 10^{-6}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq -8.5 \cdot 10^{-151}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -5.2 \cdot 10^{-211}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq -9.5 \cdot 10^{-214}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 2.9 \cdot 10^{-284}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 4.2 \cdot 10^{-248}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 6.8 \cdot 10^{-103}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 2.9 \cdot 10^{+66}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 6
Error37.89%
Cost1504
\[\begin{array}{l} t_1 := c + x \cdot y\\ t_2 := c + 0.0625 \cdot \left(z \cdot t\right)\\ t_3 := c + a \cdot \left(b \cdot -0.25\right)\\ \mathbf{if}\;t \leq -2.15 \cdot 10^{-172}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 1.7 \cdot 10^{-265}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.05 \cdot 10^{-135}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 4 \cdot 10^{-69}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 4.1 \cdot 10^{-41}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 12000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 8.8 \cdot 10^{+39}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 1.15 \cdot 10^{+42}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 7
Error37.54%
Cost1488
\[\begin{array}{l} t_1 := c + 0.0625 \cdot \left(z \cdot t\right)\\ t_2 := -0.25 \cdot \left(b \cdot a\right)\\ \mathbf{if}\;b \cdot a \leq -2.3 \cdot 10^{+152}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \cdot a \leq -8.8 \cdot 10^{-14}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq 9.2 \cdot 10^{-296}:\\ \;\;\;\;c + x \cdot y\\ \mathbf{elif}\;b \cdot a \leq 3.7 \cdot 10^{+172}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 8
Error9.27%
Cost1353
\[\begin{array}{l} \mathbf{if}\;b \cdot a \leq -1000000 \lor \neg \left(b \cdot a \leq 2 \cdot 10^{-29}\right):\\ \;\;\;\;t \cdot \left(z \cdot 0.0625\right) + \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
Error9.3%
Cost1353
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(z \cdot t\right)\\ \mathbf{if}\;b \cdot a \leq -1000000 \lor \neg \left(b \cdot a \leq 2 \cdot 10^{-29}\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 10
Error12.29%
Cost1225
\[\begin{array}{l} \mathbf{if}\;b \cdot a \leq -1 \cdot 10^{+160} \lor \neg \left(b \cdot a \leq 4 \cdot 10^{+126}\right):\\ \;\;\;\;c + a \cdot \left(b \cdot -0.25\right)\\ \mathbf{else}:\\ \;\;\;\;c + \left(0.0625 \cdot \left(z \cdot t\right) + x \cdot y\right)\\ \end{array} \]
Alternative 11
Error54.2%
Cost1112
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(z \cdot t\right)\\ \mathbf{if}\;c \leq -8.4 \cdot 10^{-9}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq -1.75 \cdot 10^{-213}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 3.2 \cdot 10^{-284}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 2.1 \cdot 10^{-248}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 4 \cdot 10^{-174}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 1.32 \cdot 10^{+66}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 12
Error0.18%
Cost1088
\[c + \left(\left(\frac{z \cdot t}{16} + x \cdot y\right) - \frac{b \cdot a}{4}\right) \]
Alternative 13
Error54.57%
Cost456
\[\begin{array}{l} \mathbf{if}\;c \leq -1.8 \cdot 10^{-11}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq 3.05 \cdot 10^{+57}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 14
Error67.53%
Cost64
\[c \]

Error

Reproduce?

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