Average Error: 0.1 → 0.0
Time: 12.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(t, \frac{z}{16}, \mathsf{fma}\left(x, y, c - b \cdot \frac{a}{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 t (/ z 16.0) (fma x y (- c (* b (/ a 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(t, (z / 16.0), fma(x, y, (c - (b * (a / 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(t, Float64(z / 16.0), fma(x, y, Float64(c - Float64(b * Float64(a / 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[(t * N[(z / 16.0), $MachinePrecision] + N[(x * y + N[(c - N[(b * N[(a / 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(t, \frac{z}{16}, \mathsf{fma}\left(x, y, c - b \cdot \frac{a}{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(t, \frac{z}{16}, \mathsf{fma}\left(x, y, c - b \cdot \frac{a}{4}\right)\right)} \]
    Proof
    (fma.f64 t (/.f64 z 16) (fma.f64 x y (-.f64 c (*.f64 b (/.f64 a 4))))): 0 points increase in error, 0 points decrease in error
    (fma.f64 t (/.f64 z 16) (fma.f64 x y (-.f64 c (Rewrite<= *-commutative_binary64 (*.f64 (/.f64 a 4) b))))): 0 points increase in error, 0 points decrease in error
    (fma.f64 t (/.f64 z 16) (fma.f64 x y (-.f64 c (Rewrite=> associate-*l/_binary64 (/.f64 (*.f64 a b) 4))))): 0 points increase in error, 0 points decrease in error
    (fma.f64 t (/.f64 z 16) (fma.f64 x y (Rewrite<= unsub-neg_binary64 (+.f64 c (neg.f64 (/.f64 (*.f64 a b) 4)))))): 0 points increase in error, 0 points decrease in error
    (fma.f64 t (/.f64 z 16) (fma.f64 x y (Rewrite<= +-commutative_binary64 (+.f64 (neg.f64 (/.f64 (*.f64 a b) 4)) c)))): 0 points increase in error, 0 points decrease in error
    (fma.f64 t (/.f64 z 16) (fma.f64 x y (+.f64 (Rewrite=> neg-sub0_binary64 (-.f64 0 (/.f64 (*.f64 a b) 4))) c))): 0 points increase in error, 0 points decrease in error
    (fma.f64 t (/.f64 z 16) (fma.f64 x y (Rewrite=> associate-+l-_binary64 (-.f64 0 (-.f64 (/.f64 (*.f64 a b) 4) c))))): 0 points increase in error, 0 points decrease in error
    (fma.f64 t (/.f64 z 16) (fma.f64 x y (Rewrite<= neg-sub0_binary64 (neg.f64 (-.f64 (/.f64 (*.f64 a b) 4) c))))): 0 points increase in error, 0 points decrease in error
    (fma.f64 t (/.f64 z 16) (Rewrite<= fma-neg_binary64 (-.f64 (*.f64 x y) (-.f64 (/.f64 (*.f64 a b) 4) c)))): 1 points increase in error, 0 points decrease in error
    (Rewrite<= fma-def_binary64 (+.f64 (*.f64 t (/.f64 z 16)) (-.f64 (*.f64 x y) (-.f64 (/.f64 (*.f64 a b) 4) c)))): 3 points increase in error, 0 points decrease in error
    (+.f64 (Rewrite<= *-commutative_binary64 (*.f64 (/.f64 z 16) t)) (-.f64 (*.f64 x y) (-.f64 (/.f64 (*.f64 a b) 4) c))): 0 points increase in error, 0 points decrease in error
    (+.f64 (Rewrite=> associate-*l/_binary64 (/.f64 (*.f64 z t) 16)) (-.f64 (*.f64 x y) (-.f64 (/.f64 (*.f64 a b) 4) c))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= associate--l+_binary64 (-.f64 (+.f64 (/.f64 (*.f64 z t) 16) (*.f64 x y)) (-.f64 (/.f64 (*.f64 a b) 4) c))): 0 points increase in error, 0 points decrease in error
    (-.f64 (Rewrite<= +-commutative_binary64 (+.f64 (*.f64 x y) (/.f64 (*.f64 z t) 16))) (-.f64 (/.f64 (*.f64 a b) 4) c)): 0 points increase in error, 0 points decrease in error
    (Rewrite<= associate-+l-_binary64 (+.f64 (-.f64 (+.f64 (*.f64 x y) (/.f64 (*.f64 z t) 16)) (/.f64 (*.f64 a b) 4)) c)): 0 points increase in error, 0 points decrease in error
  3. Final simplification0.0

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

Alternatives

Alternative 1
Error39.4
Cost3440
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(t \cdot z\right)\\ t_2 := \left(b \cdot a\right) \cdot -0.25\\ \mathbf{if}\;b \cdot a \leq -8.4 \cdot 10^{+110}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \cdot a \leq -1.3 \cdot 10^{+59}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq -1.9 \cdot 10^{-5}:\\ \;\;\;\;c\\ \mathbf{elif}\;b \cdot a \leq -2.3 \cdot 10^{-79}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;b \cdot a \leq -2.7 \cdot 10^{-195}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq -5 \cdot 10^{-324}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;b \cdot a \leq 6.6 \cdot 10^{-160}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq 1.55 \cdot 10^{-22}:\\ \;\;\;\;c\\ \mathbf{elif}\;b \cdot a \leq 5.8 \cdot 10^{+20}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq 2.6 \cdot 10^{+68}:\\ \;\;\;\;c\\ \mathbf{elif}\;b \cdot a \leq 1.02 \cdot 10^{+107}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;b \cdot a \leq 1.02 \cdot 10^{+158}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error22.8
Cost2656
\[\begin{array}{l} t_1 := x \cdot y + 0.0625 \cdot \left(t \cdot z\right)\\ t_2 := c + a \cdot \left(b \cdot -0.25\right)\\ \mathbf{if}\;b \cdot a \leq -5 \cdot 10^{+119}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \cdot a \leq -1 \cdot 10^{+61}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq -1 \cdot 10^{+33}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \cdot a \leq -1 \cdot 10^{-55}:\\ \;\;\;\;c + x \cdot y\\ \mathbf{elif}\;b \cdot a \leq 4 \cdot 10^{-185}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq 5 \cdot 10^{+70}:\\ \;\;\;\;c + z \cdot \left(t \cdot 0.0625\right)\\ \mathbf{elif}\;b \cdot a \leq 10^{+107}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq 5 \cdot 10^{+232}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;x \cdot y + \left(b \cdot a\right) \cdot -0.25\\ \end{array} \]
Alternative 3
Error22.6
Cost2396
\[\begin{array}{l} t_1 := x \cdot y + 0.0625 \cdot \left(t \cdot z\right)\\ t_2 := c + a \cdot \left(b \cdot -0.25\right)\\ \mathbf{if}\;b \cdot a \leq -5 \cdot 10^{+119}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \cdot a \leq -1 \cdot 10^{+61}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq -1 \cdot 10^{+24}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \cdot a \leq -1 \cdot 10^{-55}:\\ \;\;\;\;c + x \cdot y\\ \mathbf{elif}\;b \cdot a \leq 4 \cdot 10^{-185}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq 5 \cdot 10^{+70}:\\ \;\;\;\;c + z \cdot \left(t \cdot 0.0625\right)\\ \mathbf{elif}\;b \cdot a \leq 10^{+107}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error20.6
Cost2268
\[\begin{array}{l} t_1 := c + z \cdot \left(t \cdot 0.0625\right)\\ t_2 := c + a \cdot \left(b \cdot -0.25\right)\\ t_3 := c + x \cdot y\\ \mathbf{if}\;b \cdot a \leq -2 \cdot 10^{+116}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \cdot a \leq -5 \cdot 10^{-22}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq -2 \cdot 10^{-79}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \cdot a \leq -1 \cdot 10^{-194}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq -5 \cdot 10^{-324}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \cdot a \leq 10^{+73}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq 10^{+107}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Error22.0
Cost2008
\[\begin{array}{l} t_1 := c + x \cdot y\\ t_2 := 0.0625 \cdot \left(t \cdot z\right)\\ t_3 := c + a \cdot \left(b \cdot -0.25\right)\\ \mathbf{if}\;b \cdot a \leq -1 \cdot 10^{+24}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \cdot a \leq -2 \cdot 10^{-79}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq -5 \cdot 10^{-176}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \cdot a \leq 0:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq 2 \cdot 10^{-288}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \cdot a \leq 10^{+107}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 6
Error10.0
Cost1888
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(t \cdot z\right)\\ t_2 := \left(b \cdot a\right) \cdot -0.25\\ t_3 := c + \left(x \cdot y + t_1\right)\\ t_4 := \left(c + t_1\right) + t_2\\ t_5 := \left(c + x \cdot y\right) + t_2\\ \mathbf{if}\;z \leq -2.25 \cdot 10^{+223}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -7.5 \cdot 10^{+193}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;z \leq -7.6 \cdot 10^{+149}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -3.3 \cdot 10^{+16}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;z \leq -5.5 \cdot 10^{-28}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;z \leq -2.6 \cdot 10^{-91}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;z \leq -8.2 \cdot 10^{-141}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 8.2 \cdot 10^{-114}:\\ \;\;\;\;t_5\\ \mathbf{else}:\\ \;\;\;\;t_4\\ \end{array} \]
Alternative 7
Error24.7
Cost1880
\[\begin{array}{l} t_1 := c + x \cdot y\\ t_2 := 0.0625 \cdot \left(t \cdot z\right)\\ t_3 := \left(b \cdot a\right) \cdot -0.25\\ \mathbf{if}\;b \cdot a \leq -1.15 \cdot 10^{+158}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \cdot a \leq -2.3 \cdot 10^{-94}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq -8.5 \cdot 10^{-176}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \cdot a \leq 0:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq 3.5 \cdot 10^{-282}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \cdot a \leq 7 \cdot 10^{+144}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 8
Error9.5
Cost1224
\[\begin{array}{l} \mathbf{if}\;b \cdot a \leq -2 \cdot 10^{+158}:\\ \;\;\;\;x \cdot y + \left(b \cdot a\right) \cdot -0.25\\ \mathbf{elif}\;b \cdot a \leq 2 \cdot 10^{+208}:\\ \;\;\;\;c + \left(x \cdot y + 0.0625 \cdot \left(t \cdot z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;c + a \cdot \left(b \cdot -0.25\right)\\ \end{array} \]
Alternative 9
Error9.5
Cost1224
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(t \cdot z\right)\\ \mathbf{if}\;b \cdot a \leq -2 \cdot 10^{+158}:\\ \;\;\;\;t_1 + \left(b \cdot a\right) \cdot -0.25\\ \mathbf{elif}\;b \cdot a \leq 2 \cdot 10^{+208}:\\ \;\;\;\;c + \left(x \cdot y + t_1\right)\\ \mathbf{else}:\\ \;\;\;\;c + a \cdot \left(b \cdot -0.25\right)\\ \end{array} \]
Alternative 10
Error7.7
Cost1224
\[\begin{array}{l} t_1 := \left(c + x \cdot y\right) + \left(b \cdot a\right) \cdot -0.25\\ \mathbf{if}\;b \cdot a \leq -2 \cdot 10^{+158}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq 2 \cdot 10^{+158}:\\ \;\;\;\;c + \left(x \cdot y + 0.0625 \cdot \left(t \cdot z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 11
Error36.4
Cost1112
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(t \cdot z\right)\\ \mathbf{if}\;c \leq -3.7 \cdot 10^{+67}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq -6.2 \cdot 10^{-125}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -2.5 \cdot 10^{-169}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 4.5 \cdot 10^{-307}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 1.8 \cdot 10^{-153}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 2.4 \cdot 10^{+134}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 12
Error0.1
Cost1088
\[c + \left(\left(\frac{t \cdot z}{16} + x \cdot y\right) - \frac{b \cdot a}{4}\right) \]
Alternative 13
Error36.7
Cost456
\[\begin{array}{l} \mathbf{if}\;c \leq -0.47:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq 5.5 \cdot 10^{+170}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 14
Error43.5
Cost64
\[c \]

Error

Reproduce

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