?

Average Error: 0.1 → 0.0
Time: 17.6s
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.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, t \cdot \frac{z}{16}\right) - \left(b \cdot \frac{a}{4} - c\right) \]
Alternative 2
Error25.7
Cost2164
\[\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 := c + x \cdot y\\ t_5 := t_2 + x \cdot y\\ \mathbf{if}\;t \leq -1.08 \cdot 10^{-162}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq -2.5 \cdot 10^{-231}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -1.7 \cdot 10^{-237}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq -1.35 \cdot 10^{-271}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;t \leq 5.8 \cdot 10^{-289}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 3.7 \cdot 10^{-137}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;t \leq 2.8 \cdot 10^{-92}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 3.8 \cdot 10^{-66}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;t \leq 3 \cdot 10^{-14}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 3.35 \cdot 10^{+41}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 8.2 \cdot 10^{+49}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.05 \cdot 10^{+68}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;t \leq 1.05 \cdot 10^{+156}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 3
Error42.3
Cost2036
\[\begin{array}{l} t_1 := b \cdot \left(a \cdot -0.25\right)\\ t_2 := 0.0625 \cdot \left(t \cdot z\right)\\ \mathbf{if}\;t \leq -3.2 \cdot 10^{-85}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -1.1 \cdot 10^{-219}:\\ \;\;\;\;c\\ \mathbf{elif}\;t \leq -1.3 \cdot 10^{-238}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -9 \cdot 10^{-272}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;t \leq 4.5 \cdot 10^{-292}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 2.55 \cdot 10^{-161}:\\ \;\;\;\;c\\ \mathbf{elif}\;t \leq 5.5 \cdot 10^{-114}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.45 \cdot 10^{-58}:\\ \;\;\;\;c\\ \mathbf{elif}\;t \leq 2.15 \cdot 10^{-32}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.75 \cdot 10^{-11}:\\ \;\;\;\;c\\ \mathbf{elif}\;t \leq 2.95 \cdot 10^{+69}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 1.5 \cdot 10^{+82}:\\ \;\;\;\;c\\ \mathbf{elif}\;t \leq 2.4 \cdot 10^{+156}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error25.5
Cost1769
\[\begin{array}{l} t_1 := \left(a \cdot b\right) \cdot -0.25\\ t_2 := c + t_1\\ t_3 := 0.0625 \cdot \left(t \cdot z\right)\\ t_4 := c + t_3\\ \mathbf{if}\;t \leq -1.4 \cdot 10^{-162}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;t \leq 1.35 \cdot 10^{-288}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 3 \cdot 10^{-137}:\\ \;\;\;\;c + x \cdot y\\ \mathbf{elif}\;t \leq 4.7 \cdot 10^{-92}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 1.08 \cdot 10^{-66}:\\ \;\;\;\;t_3 + x \cdot y\\ \mathbf{elif}\;t \leq 5.1 \cdot 10^{-14}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 3 \cdot 10^{+42}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;t \leq 8.5 \cdot 10^{+65}:\\ \;\;\;\;x \cdot y + t_1\\ \mathbf{elif}\;t \leq 1.06 \cdot 10^{+84} \lor \neg \left(t \leq 1.05 \cdot 10^{+156}\right):\\ \;\;\;\;t_4\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Error25.2
Cost1637
\[\begin{array}{l} t_1 := c + x \cdot y\\ t_2 := c + \left(a \cdot b\right) \cdot -0.25\\ t_3 := c + 0.0625 \cdot \left(t \cdot z\right)\\ \mathbf{if}\;t \leq -3 \cdot 10^{-163}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq -2.5 \cdot 10^{-231}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -1.7 \cdot 10^{-237}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq -2.7 \cdot 10^{-273}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.6 \cdot 10^{-294}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 3.5 \cdot 10^{-137}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 2.3 \cdot 10^{-14} \lor \neg \left(t \leq 1.06 \cdot 10^{+84}\right) \land t \leq 2.4 \cdot 10^{+156}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 6
Error5.9
Cost1353
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(t \cdot z\right)\\ \mathbf{if}\;a \cdot b \leq -1 \cdot 10^{-14} \lor \neg \left(a \cdot b \leq 750000000000\right):\\ \;\;\;\;\left(c + t_1\right) + \left(a \cdot b\right) \cdot -0.25\\ \mathbf{else}:\\ \;\;\;\;c + \left(t_1 + x \cdot y\right)\\ \end{array} \]
Alternative 7
Error10.4
Cost1234
\[\begin{array}{l} \mathbf{if}\;t \leq -6.5 \cdot 10^{-163} \lor \neg \left(t \leq 2 \cdot 10^{-17}\right) \land \left(t \leq 3.7 \cdot 10^{+83} \lor \neg \left(t \leq 1.05 \cdot 10^{+156}\right)\right):\\ \;\;\;\;c + \left(0.0625 \cdot \left(t \cdot z\right) + x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\left(c + x \cdot y\right) + \left(a \cdot b\right) \cdot -0.25\\ \end{array} \]
Alternative 8
Error9.5
Cost1225
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -1 \cdot 10^{-14} \lor \neg \left(a \cdot b \leq 10^{+125}\right):\\ \;\;\;\;c + \left(a \cdot b\right) \cdot -0.25\\ \mathbf{else}:\\ \;\;\;\;c + \left(0.0625 \cdot \left(t \cdot z\right) + x \cdot y\right)\\ \end{array} \]
Alternative 9
Error32.8
Cost1112
\[\begin{array}{l} t_1 := c + x \cdot y\\ t_2 := b \cdot \left(a \cdot -0.25\right)\\ t_3 := 0.0625 \cdot \left(t \cdot z\right)\\ \mathbf{if}\;t \leq -3.5 \cdot 10^{-85}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq -5.3 \cdot 10^{-275}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 2 \cdot 10^{-306}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 1.16 \cdot 10^{-45}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 7.8 \cdot 10^{-32}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 1.15 \cdot 10^{+141}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 10
Error26.7
Cost1108
\[\begin{array}{l} t_1 := c + x \cdot y\\ t_2 := c + 0.0625 \cdot \left(t \cdot z\right)\\ t_3 := b \cdot \left(a \cdot -0.25\right)\\ \mathbf{if}\;t \leq -1.7 \cdot 10^{-237}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -5.3 \cdot 10^{-275}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.85 \cdot 10^{-306}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 1.2 \cdot 10^{-45}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 5.1 \cdot 10^{-33}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 11
Error0.1
Cost1088
\[c + \left(\left(\frac{t \cdot z}{16} + x \cdot y\right) - \frac{a \cdot b}{4}\right) \]
Alternative 12
Error35.9
Cost848
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(t \cdot z\right)\\ \mathbf{if}\;c \leq -2.8 \cdot 10^{+110}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq 5.8 \cdot 10^{-190}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 6 \cdot 10^{-168}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 2.26 \cdot 10^{-7}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 13
Error35.9
Cost456
\[\begin{array}{l} \mathbf{if}\;c \leq -7 \cdot 10^{+91}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq 10^{-7}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 14
Error43.3
Cost64
\[c \]

Error

Reproduce?

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