?

Average Error: 0.1 → 0.0
Time: 19.1s
Precision: binary64
Cost: 13632

?

\[\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(t, \frac{z}{16}, c - a \cdot \frac{b}{4}\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 t (/ z 16.0) (- c (* a (/ b 4.0))))))
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(t, (z / 16.0), (c - (a * (b / 4.0)))));
}
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(t, Float64(z / 16.0), Float64(c - Float64(a * Float64(b / 4.0)))))
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[(t * N[(z / 16.0), $MachinePrecision] + N[(c - N[(a * N[(b / 4.0), $MachinePrecision]), $MachinePrecision]), $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(t, \frac{z}{16}, c - a \cdot \frac{b}{4}\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(x, y, \mathsf{fma}\left(t, \frac{z}{16}, c - a \cdot \frac{b}{4}\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 + \left(\frac{z \cdot t}{16} - \frac{a \cdot b}{4}\right)\right)} + c \]

    associate-+l+ [=>]0.1

    \[ \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)} \]

    associate-+l- [=>]0.1

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

    associate-*l/ [<=]0.0

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

    *-commutative [=>]0.0

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

    fma-neg [=>]0.0

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

    neg-sub0 [=>]0.0

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

    associate-+l- [<=]0.0

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

    neg-sub0 [<=]0.0

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

    +-commutative [=>]0.0

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

    unsub-neg [=>]0.0

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

    associate-*r/ [<=]0.0

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

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

Alternatives

Alternative 1
Error0.0
Cost7360
\[\mathsf{fma}\left(t, z \cdot 0.0625, c + a \cdot \left(b \cdot -0.25\right)\right) + x \cdot y \]
Alternative 2
Error22.6
Cost2008
\[\begin{array}{l} t_1 := c + \left(a \cdot b\right) \cdot -0.25\\ t_2 := 0.0625 \cdot \left(t \cdot z\right)\\ t_3 := c + t_2\\ t_4 := x \cdot y - 0.25 \cdot \left(a \cdot b\right)\\ \mathbf{if}\;a \cdot b \leq -5 \cdot 10^{+76}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;a \cdot b \leq 0:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \cdot b \leq 10^{-18}:\\ \;\;\;\;x \cdot y + t_2\\ \mathbf{elif}\;a \cdot b \leq 5 \cdot 10^{+32}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 10^{+56}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;a \cdot b \leq 10^{+90}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error31.2
Cost1641
\[\begin{array}{l} t_1 := c + x \cdot y\\ t_2 := 0.0625 \cdot \left(t \cdot z\right)\\ \mathbf{if}\;c \leq -1.25 \cdot 10^{+56}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -1.7 \cdot 10^{-10}:\\ \;\;\;\;a \cdot \left(b \cdot -0.25\right)\\ \mathbf{elif}\;c \leq -3.1 \cdot 10^{-27}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -6.5 \cdot 10^{-111}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 9 \cdot 10^{-235}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 3 \cdot 10^{-211}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 2.7 \cdot 10^{-172}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 3 \cdot 10^{-128} \lor \neg \left(c \leq 1.2 \cdot 10^{-90}\right) \land c \leq 0.00036:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error35.6
Cost1640
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(t \cdot z\right)\\ t_2 := a \cdot \left(b \cdot -0.25\right)\\ \mathbf{if}\;c \leq -1.52 \cdot 10^{+56}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq -4.9 \cdot 10^{-20}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq -4 \cdot 10^{-110}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -5.2 \cdot 10^{-155}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 1.9 \cdot 10^{-237}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 1.38 \cdot 10^{-210}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 9.5 \cdot 10^{-171}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 0.00042:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 2.7 \cdot 10^{+20}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 5.4 \cdot 10^{+36}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 5
Error35.5
Cost1380
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(t \cdot z\right)\\ \mathbf{if}\;c \leq -2.3 \cdot 10^{+40}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq -7.5 \cdot 10^{-19}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq -3.6 \cdot 10^{-26}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq -1.6 \cdot 10^{-176}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 2.5 \cdot 10^{-233}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 2.8 \cdot 10^{-211}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 1.45 \cdot 10^{-175}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 0.00042:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 7.5 \cdot 10^{+38}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 6
Error30.5
Cost1376
\[\begin{array}{l} t_1 := c + 0.0625 \cdot \left(t \cdot z\right)\\ t_2 := a \cdot \left(b \cdot -0.25\right)\\ t_3 := c + x \cdot y\\ \mathbf{if}\;a \leq -4 \cdot 10^{+202}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq -1.06 \cdot 10^{+162}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -4.6 \cdot 10^{+151}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq -3.7 \cdot 10^{+132}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \leq -420000000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq -3.4 \cdot 10^{-226}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \leq 3.3 \cdot 10^{-292}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 5.5 \cdot 10^{-21}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 7
Error5.8
Cost1352
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(t \cdot z\right)\\ \mathbf{if}\;a \cdot b \leq -2 \cdot 10^{+47}:\\ \;\;\;\;x \cdot y + \left(c - \frac{a}{\frac{4}{b}}\right)\\ \mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{-5}:\\ \;\;\;\;c + \left(x \cdot y + t_1\right)\\ \mathbf{else}:\\ \;\;\;\;\left(c + t_1\right) + \left(a \cdot b\right) \cdot -0.25\\ \end{array} \]
Alternative 8
Error24.4
Cost1240
\[\begin{array}{l} t_1 := c + x \cdot y\\ t_2 := c + 0.0625 \cdot \left(t \cdot z\right)\\ t_3 := c + \left(a \cdot b\right) \cdot -0.25\\ \mathbf{if}\;z \leq -1.42 \cdot 10^{+29}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -2.2 \cdot 10^{-89}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -4.3 \cdot 10^{-269}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 1.8 \cdot 10^{-188}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2 \cdot 10^{-101}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 1.3 \cdot 10^{-68}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 9
Error5.7
Cost1225
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -2 \cdot 10^{+47} \lor \neg \left(a \cdot b \leq 10^{-18}\right):\\ \;\;\;\;x \cdot y + \left(c - \frac{a}{\frac{4}{b}}\right)\\ \mathbf{else}:\\ \;\;\;\;c + \left(x \cdot y + 0.0625 \cdot \left(t \cdot z\right)\right)\\ \end{array} \]
Alternative 10
Error8.4
Cost1224
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -5 \cdot 10^{+112}:\\ \;\;\;\;x \cdot y - 0.25 \cdot \left(a \cdot b\right)\\ \mathbf{elif}\;a \cdot b \leq 10^{+90}:\\ \;\;\;\;c + \left(x \cdot y + 0.0625 \cdot \left(t \cdot z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;c + \left(a \cdot b\right) \cdot -0.25\\ \end{array} \]
Alternative 11
Error5.7
Cost1224
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -2 \cdot 10^{+47}:\\ \;\;\;\;x \cdot y + \left(c - \frac{a}{\frac{4}{b}}\right)\\ \mathbf{elif}\;a \cdot b \leq 10^{-18}:\\ \;\;\;\;c + \left(x \cdot y + 0.0625 \cdot \left(t \cdot z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(c + x \cdot y\right) - 0.25 \cdot \left(a \cdot b\right)\\ \end{array} \]
Alternative 12
Error0.1
Cost1088
\[c + \left(\left(\frac{t \cdot z}{16} + x \cdot y\right) - \frac{a \cdot b}{4}\right) \]
Alternative 13
Error0.1
Cost1088
\[\left(z \cdot \left(t \cdot 0.0625\right) + x \cdot y\right) + \left(c - \frac{a}{\frac{4}{b}}\right) \]
Alternative 14
Error21.6
Cost973
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(t \cdot z\right)\\ \mathbf{if}\;c \leq -7 \cdot 10^{+61}:\\ \;\;\;\;c + t_1\\ \mathbf{elif}\;c \leq -8.2 \cdot 10^{-26} \lor \neg \left(c \leq 3.3 \cdot 10^{+21}\right):\\ \;\;\;\;c + \left(a \cdot b\right) \cdot -0.25\\ \mathbf{else}:\\ \;\;\;\;x \cdot y + t_1\\ \end{array} \]
Alternative 15
Error35.3
Cost456
\[\begin{array}{l} \mathbf{if}\;c \leq -2.05 \cdot 10^{+40}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq 4.4 \cdot 10^{+38}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 16
Error43.8
Cost64
\[c \]

Error

Reproduce?

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