?

Average Error: 0.2 → 0.0
Time: 13.7s
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.2

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

    associate-+l- [=>]0.2

    \[ \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
Error22.6
Cost1632
\[\begin{array}{l} t_1 := x \cdot y + \left(a \cdot b\right) \cdot -0.25\\ t_2 := c + a \cdot \left(b \cdot -0.25\right)\\ t_3 := c + x \cdot y\\ t_4 := x \cdot y + \left(t \cdot z\right) \cdot 0.0625\\ \mathbf{if}\;c \leq -800000:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \leq -9 \cdot 10^{-63}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -2.6 \cdot 10^{-300}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;c \leq 4.8 \cdot 10^{-144}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 5.2 \cdot 10^{-48}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;c \leq 1.35 \cdot 10^{-42}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 8.6 \cdot 10^{+49}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \leq 6.8 \cdot 10^{+139}:\\ \;\;\;\;t_4\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error23.6
Cost1368
\[\begin{array}{l} t_1 := c + x \cdot y\\ t_2 := x \cdot y + \left(t \cdot z\right) \cdot 0.0625\\ \mathbf{if}\;c \leq -1.38 \cdot 10^{-14}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -1.7 \cdot 10^{-52}:\\ \;\;\;\;\left(a \cdot b\right) \cdot -0.25\\ \mathbf{elif}\;c \leq -4.3 \cdot 10^{-65}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 3.1 \cdot 10^{-74}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 1.1 \cdot 10^{+50}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 1.1 \cdot 10^{+140}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;c + a \cdot \left(b \cdot -0.25\right)\\ \end{array} \]
Alternative 3
Error24.8
Cost1240
\[\begin{array}{l} t_1 := c + t \cdot \left(z \cdot 0.0625\right)\\ t_2 := c + x \cdot y\\ t_3 := c + a \cdot \left(b \cdot -0.25\right)\\ \mathbf{if}\;x \leq -2.2 \cdot 10^{+34}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -4.2 \cdot 10^{-171}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 3.8 \cdot 10^{-296}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq 1.75 \cdot 10^{-251}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 5.4 \cdot 10^{-201}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq 5.7 \cdot 10^{-93}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error9.0
Cost1225
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -1 \cdot 10^{+175} \lor \neg \left(a \cdot b \leq 10^{+117}\right):\\ \;\;\;\;x \cdot y + \left(a \cdot b\right) \cdot -0.25\\ \mathbf{else}:\\ \;\;\;\;c + \left(x \cdot y + \left(t \cdot z\right) \cdot 0.0625\right)\\ \end{array} \]
Alternative 5
Error6.1
Cost1225
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -5 \cdot 10^{-9} \lor \neg \left(a \cdot b \leq 10^{+117}\right):\\ \;\;\;\;\left(c + x \cdot y\right) + \left(a \cdot b\right) \cdot -0.25\\ \mathbf{else}:\\ \;\;\;\;c + \left(x \cdot y + \left(t \cdot z\right) \cdot 0.0625\right)\\ \end{array} \]
Alternative 6
Error0.2
Cost1088
\[c + \left(\left(\frac{t \cdot z}{16} + x \cdot y\right) - \frac{a \cdot b}{4}\right) \]
Alternative 7
Error36.3
Cost984
\[\begin{array}{l} t_1 := \left(t \cdot z\right) \cdot 0.0625\\ \mathbf{if}\;c \leq -650000000:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq -2.5 \cdot 10^{-108}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq -1.14 \cdot 10^{-222}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 9.2 \cdot 10^{+54}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 7.8 \cdot 10^{+94}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 6.8 \cdot 10^{+139}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 8
Error20.7
Cost969
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -1 \cdot 10^{+67} \lor \neg \left(a \cdot b \leq 5 \cdot 10^{+98}\right):\\ \;\;\;\;c + a \cdot \left(b \cdot -0.25\right)\\ \mathbf{else}:\\ \;\;\;\;c + x \cdot y\\ \end{array} \]
Alternative 9
Error24.0
Cost841
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -1.85 \cdot 10^{+172} \lor \neg \left(a \cdot b \leq 8.6 \cdot 10^{+146}\right):\\ \;\;\;\;\left(a \cdot b\right) \cdot -0.25\\ \mathbf{else}:\\ \;\;\;\;c + x \cdot y\\ \end{array} \]
Alternative 10
Error36.4
Cost456
\[\begin{array}{l} \mathbf{if}\;c \leq -740000000:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq 6.8 \cdot 10^{+139}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 11
Error43.8
Cost64
\[c \]

Error

Reproduce?

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