Average Error: 0.2 → 0.0
Time: 20.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(x, y, \mathsf{fma}\left(a, b \cdot -0.25, \mathsf{fma}\left(t, \frac{z}{16}, 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 x y (fma a (* b -0.25) (fma t (/ z 16.0) 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(x, y, fma(a, (b * -0.25), fma(t, (z / 16.0), 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(x, y, fma(a, Float64(b * -0.25), fma(t, Float64(z / 16.0), 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[(x * y + N[(a * N[(b * -0.25), $MachinePrecision] + N[(t * N[(z / 16.0), $MachinePrecision] + 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(x, y, \mathsf{fma}\left(a, b \cdot -0.25, \mathsf{fma}\left(t, \frac{z}{16}, c\right)\right)\right)

Error

Derivation

  1. Initial program 0.2

    \[\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(x, y, \mathsf{fma}\left(a, b \cdot -0.25, \mathsf{fma}\left(t, \frac{z}{16}, c\right)\right)\right)} \]
    Proof

    [Start]0.2

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

    associate--l+ [=>]0.2

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

    associate-+l+ [=>]0.2

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

    fma-def [=>]0.1

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

    +-commutative [=>]0.1

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

    sub-neg [=>]0.1

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

    associate-+r+ [=>]0.1

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

    +-commutative [<=]0.1

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

    distribute-neg-frac [=>]0.1

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

    distribute-rgt-neg-in [=>]0.1

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

    associate-*r/ [<=]0.1

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

    fma-def [=>]0.1

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

    mul-1-neg [<=]0.1

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

    associate-/l* [=>]0.2

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

    associate-/r/ [=>]0.1

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

    *-commutative [<=]0.1

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

    metadata-eval [=>]0.1

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

    +-commutative [=>]0.1

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

    associate-*l/ [<=]0.0

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

    *-commutative [=>]0.0

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

    fma-def [=>]0.0

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

    \[\leadsto \mathsf{fma}\left(x, y, \mathsf{fma}\left(a, b \cdot -0.25, \mathsf{fma}\left(t, \frac{z}{16}, 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
Error21.0
Cost1765
\[\begin{array}{l} t_1 := x \cdot y + -0.25 \cdot \left(a \cdot b\right)\\ t_2 := x \cdot y + 0.0625 \cdot \left(t \cdot z\right)\\ \mathbf{if}\;c \leq -1.46 \cdot 10^{+81}:\\ \;\;\;\;c + b \cdot \left(a \cdot -0.25\right)\\ \mathbf{elif}\;c \leq -1 \cdot 10^{-9}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq -9.5 \cdot 10^{-95}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -5.5 \cdot 10^{-198}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 7.2 \cdot 10^{-290}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 6 \cdot 10^{-239}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 9 \cdot 10^{-22} \lor \neg \left(c \leq 75000000000000\right) \land c \leq 1.08 \cdot 10^{+54}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;c + t \cdot \left(z \cdot 0.0625\right)\\ \end{array} \]
Alternative 3
Error6.3
Cost1613
\[\begin{array}{l} t_1 := -0.25 \cdot \left(a \cdot b\right)\\ t_2 := 0.0625 \cdot \left(t \cdot z\right)\\ \mathbf{if}\;a \cdot b \leq -5 \cdot 10^{+176}:\\ \;\;\;\;\left(c + x \cdot y\right) + t_1\\ \mathbf{elif}\;a \cdot b \leq -5 \cdot 10^{-29} \lor \neg \left(a \cdot b \leq 2 \cdot 10^{-76}\right):\\ \;\;\;\;\left(c + t_2\right) + t_1\\ \mathbf{else}:\\ \;\;\;\;c + \left(x \cdot y + t_2\right)\\ \end{array} \]
Alternative 4
Error16.7
Cost1365
\[\begin{array}{l} t_1 := -0.25 \cdot \left(a \cdot b\right)\\ t_2 := 0.0625 \cdot \left(t \cdot z\right)\\ \mathbf{if}\;a \leq -3.2 \cdot 10^{+150}:\\ \;\;\;\;t_2 + t_1\\ \mathbf{elif}\;a \leq -2.2 \cdot 10^{+40}:\\ \;\;\;\;x \cdot y + t_1\\ \mathbf{elif}\;a \leq -1.45 \cdot 10^{-10} \lor \neg \left(a \leq -7.2 \cdot 10^{-31}\right) \land a \leq 3.9 \cdot 10^{-63}:\\ \;\;\;\;c + \left(x \cdot y + t_2\right)\\ \mathbf{else}:\\ \;\;\;\;c + b \cdot \left(a \cdot -0.25\right)\\ \end{array} \]
Alternative 5
Error30.4
Cost1240
\[\begin{array}{l} t_1 := c + x \cdot y\\ t_2 := -0.25 \cdot \left(a \cdot b\right)\\ t_3 := c + t \cdot \left(z \cdot 0.0625\right)\\ \mathbf{if}\;a \leq -2.2 \cdot 10^{+123}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq -1.65 \cdot 10^{+41}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -1.3 \cdot 10^{+40}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq -2 \cdot 10^{+23}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \leq -1.55 \cdot 10^{-132}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 1.8 \cdot 10^{-39}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 6
Error8.0
Cost1225
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -4 \cdot 10^{+49} \lor \neg \left(a \cdot b \leq 5 \cdot 10^{+104}\right):\\ \;\;\;\;c + b \cdot \left(a \cdot -0.25\right)\\ \mathbf{else}:\\ \;\;\;\;c + \left(x \cdot y + 0.0625 \cdot \left(t \cdot z\right)\right)\\ \end{array} \]
Alternative 7
Error32.5
Cost1112
\[\begin{array}{l} t_1 := c + x \cdot y\\ t_2 := 0.0625 \cdot \left(t \cdot z\right)\\ t_3 := -0.25 \cdot \left(a \cdot b\right)\\ \mathbf{if}\;a \leq -2.2 \cdot 10^{+123}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \leq -8 \cdot 10^{-164}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -3.4 \cdot 10^{-204}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq -7.2 \cdot 10^{-239}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -6.2 \cdot 10^{-253}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 4.6 \cdot 10^{-71}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 8
Error23.9
Cost1108
\[\begin{array}{l} t_1 := c + x \cdot y\\ t_2 := c + b \cdot \left(a \cdot -0.25\right)\\ \mathbf{if}\;a \leq -1.7 \cdot 10^{-31}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq -6.2 \cdot 10^{-56}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -3.2 \cdot 10^{-79}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq -1.55 \cdot 10^{-132}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 3.9 \cdot 10^{-63}:\\ \;\;\;\;c + t \cdot \left(z \cdot 0.0625\right)\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 9
Error10.7
Cost1101
\[\begin{array}{l} t_1 := -0.25 \cdot \left(a \cdot b\right)\\ t_2 := 0.0625 \cdot \left(t \cdot z\right)\\ \mathbf{if}\;a \leq -1.25 \cdot 10^{+201}:\\ \;\;\;\;t_2 + t_1\\ \mathbf{elif}\;a \leq -9.7 \cdot 10^{-60} \lor \neg \left(a \leq 1.3 \cdot 10^{-68}\right):\\ \;\;\;\;\left(c + x \cdot y\right) + t_1\\ \mathbf{else}:\\ \;\;\;\;c + \left(x \cdot y + t_2\right)\\ \end{array} \]
Alternative 10
Error0.2
Cost1088
\[c + \left(\left(\frac{t \cdot z}{16} + x \cdot y\right) - \frac{a \cdot b}{4}\right) \]
Alternative 11
Error35.6
Cost980
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(t \cdot z\right)\\ \mathbf{if}\;c \leq -1.1 \cdot 10^{+124}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq -1.92 \cdot 10^{-252}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 5.9 \cdot 10^{-294}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 7 \cdot 10^{-240}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 4.4 \cdot 10^{+58}:\\ \;\;\;\;-0.25 \cdot \left(a \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 12
Error35.5
Cost848
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(t \cdot z\right)\\ \mathbf{if}\;c \leq -1.1 \cdot 10^{+124}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq -1.35 \cdot 10^{-251}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 9.8 \cdot 10^{-295}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 8800000000:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 13
Error36.6
Cost456
\[\begin{array}{l} \mathbf{if}\;c \leq -1.1 \cdot 10^{+124}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq 9 \cdot 10^{+57}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 14
Error43.4
Cost64
\[c \]

Error

Reproduce

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