?

Average Error: 0.2 → 0.0
Time: 16.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.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(t, \frac{z}{16}, c - a \cdot \frac{b}{4}\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)} \]

    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.1

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

    *-commutative [=>]0.1

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

    fma-neg [=>]0.1

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

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

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

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

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

    \[ \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(x, y, c\right) + \left(z \cdot \left(t \cdot 0.0625\right) + b \cdot \left(a \cdot -0.25\right)\right) \]
Alternative 2
Error20.9
Cost1748
\[\begin{array}{l} t_1 := c + x \cdot y\\ t_2 := c + a \cdot \left(b \cdot -0.25\right)\\ t_3 := 0.0625 \cdot \left(t \cdot z\right)\\ \mathbf{if}\;a \cdot b \leq -5 \cdot 10^{+124}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq -2 \cdot 10^{-158}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq -1 \cdot 10^{-254}:\\ \;\;\;\;t_3 + x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 5 \cdot 10^{-121}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{+49}:\\ \;\;\;\;c + t_3\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error5.8
Cost1612
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(t \cdot z\right)\\ t_2 := -0.25 \cdot \left(a \cdot b\right)\\ t_3 := \left(c + t_1\right) + t_2\\ \mathbf{if}\;a \cdot b \leq -5 \cdot 10^{+124}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \cdot b \leq -500000:\\ \;\;\;\;\left(c + x \cdot y\right) + t_2\\ \mathbf{elif}\;a \cdot b \leq 10^{+47}:\\ \;\;\;\;c + \left(t_1 + x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 4
Error35.4
Cost1376
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(t \cdot z\right)\\ t_2 := b \cdot \left(a \cdot -0.25\right)\\ \mathbf{if}\;c \leq -4.6 \cdot 10^{+36}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq -9.8 \cdot 10^{-232}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 5.4 \cdot 10^{-301}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 8.2 \cdot 10^{-153}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 3.6 \cdot 10^{-83}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 1.1 \cdot 10^{-41}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 5.8 \cdot 10^{+27}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 1.35 \cdot 10^{+94}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 5
Error29.8
Cost1376
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(t \cdot z\right)\\ t_2 := b \cdot \left(a \cdot -0.25\right)\\ t_3 := c + x \cdot y\\ \mathbf{if}\;c \leq -1:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \leq -1.5 \cdot 10^{-53}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq -7.2 \cdot 10^{-119}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \leq -9.8 \cdot 10^{-232}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 3.5 \cdot 10^{-297}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 3.7 \cdot 10^{-153}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 3.7 \cdot 10^{-83}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 5 \cdot 10^{-42}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 6
Error20.9
Cost1228
\[\begin{array}{l} t_1 := c + a \cdot \left(b \cdot -0.25\right)\\ \mathbf{if}\;a \cdot b \leq -5 \cdot 10^{+124}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 5 \cdot 10^{-121}:\\ \;\;\;\;c + x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{+49}:\\ \;\;\;\;c + 0.0625 \cdot \left(t \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error8.0
Cost1225
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -2 \cdot 10^{+125} \lor \neg \left(a \cdot b \leq 2 \cdot 10^{+49}\right):\\ \;\;\;\;c + a \cdot \left(b \cdot -0.25\right)\\ \mathbf{else}:\\ \;\;\;\;c + \left(0.0625 \cdot \left(t \cdot z\right) + x \cdot y\right)\\ \end{array} \]
Alternative 8
Error5.8
Cost1225
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -500000 \lor \neg \left(a \cdot b \leq 2 \cdot 10^{+49}\right):\\ \;\;\;\;\left(c + x \cdot y\right) + -0.25 \cdot \left(a \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;c + \left(0.0625 \cdot \left(t \cdot z\right) + x \cdot y\right)\\ \end{array} \]
Alternative 9
Error0.1
Cost1088
\[c + \left(\left(t \cdot \frac{z}{16} + x \cdot y\right) - \frac{a \cdot b}{4}\right) \]
Alternative 10
Error35.1
Cost980
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(t \cdot z\right)\\ \mathbf{if}\;c \leq -5.5 \cdot 10^{+28}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq -1.18 \cdot 10^{-288}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 1.26 \cdot 10^{-23}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 4.5 \cdot 10^{+27}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 2.05 \cdot 10^{+54}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 11
Error24.9
Cost977
\[\begin{array}{l} t_1 := c + 0.0625 \cdot \left(t \cdot z\right)\\ \mathbf{if}\;t \leq -3.7 \cdot 10^{-88}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 7.5 \cdot 10^{-25}:\\ \;\;\;\;c + x \cdot y\\ \mathbf{elif}\;t \leq 2.35 \cdot 10^{+87} \lor \neg \left(t \leq 7.8 \cdot 10^{+150}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;b \cdot \left(a \cdot -0.25\right)\\ \end{array} \]
Alternative 12
Error35.2
Cost456
\[\begin{array}{l} \mathbf{if}\;c \leq -5.8 \cdot 10^{+33}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq 5.4 \cdot 10^{+29}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 13
Error43.3
Cost64
\[c \]

Error

Reproduce?

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