Average Error: 0.1 → 0.0
Time: 12.3s
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)))): 2 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)))): 1 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
Error24.7
Cost3696
\[\begin{array}{l} t_1 := \left(b \cdot a\right) \cdot -0.25\\ t_2 := x \cdot y + t_1\\ t_3 := c + z \cdot \left(t \cdot 0.0625\right)\\ t_4 := c + x \cdot y\\ \mathbf{if}\;b \cdot a \leq -1.75 \cdot 10^{+98}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \cdot a \leq -1.5 \cdot 10^{-11}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \cdot a \leq -1.2 \cdot 10^{-129}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \cdot a \leq -2.2 \cdot 10^{-261}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \cdot a \leq 4.5 \cdot 10^{-268}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;b \cdot a \leq 10^{-33}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \cdot a \leq 2.55 \cdot 10^{+20}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;b \cdot a \leq 5.8 \cdot 10^{+82}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \cdot a \leq 1.25 \cdot 10^{+107}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \cdot a \leq 3.8 \cdot 10^{+128}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;b \cdot a \leq 1.9 \cdot 10^{+159}:\\ \;\;\;\;c + t_1\\ \mathbf{elif}\;b \cdot a \leq 1.65 \cdot 10^{+226}:\\ \;\;\;\;t_4\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error11.3
Cost2136
\[\begin{array}{l} t_1 := \left(b \cdot a\right) \cdot -0.25\\ t_2 := c + \left(x \cdot y + 0.0625 \cdot \left(t \cdot z\right)\right)\\ t_3 := x \cdot y + t_1\\ \mathbf{if}\;b \cdot a \leq -6 \cdot 10^{+135}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \cdot a \leq -6.5 \cdot 10^{+52}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \cdot a \leq -2.7 \cdot 10^{-18}:\\ \;\;\;\;t \cdot \left(z \cdot 0.0625\right) + t_1\\ \mathbf{elif}\;b \cdot a \leq 2.5 \cdot 10^{+131}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \cdot a \leq 1.9 \cdot 10^{+159}:\\ \;\;\;\;c + t_1\\ \mathbf{elif}\;b \cdot a \leq 1.65 \cdot 10^{+226}:\\ \;\;\;\;c + x \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 3
Error26.3
Cost1632
\[\begin{array}{l} t_1 := \left(b \cdot a\right) \cdot -0.25\\ t_2 := c + t_1\\ t_3 := x \cdot y + 0.0625 \cdot \left(t \cdot z\right)\\ t_4 := c + z \cdot \left(t \cdot 0.0625\right)\\ \mathbf{if}\;x \leq -1.6 \cdot 10^{+248}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq -4.3 \cdot 10^{+137}:\\ \;\;\;\;c + x \cdot y\\ \mathbf{elif}\;x \leq -3.8 \cdot 10^{+37}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;x \leq -3.2 \cdot 10^{-220}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -1.8 \cdot 10^{-272}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;x \leq 6.8 \cdot 10^{-267}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq 2.1 \cdot 10^{-98}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;x \leq 1.45 \cdot 10^{-24}:\\ \;\;\;\;x \cdot y + t_1\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 4
Error9.7
Cost1616
\[\begin{array}{l} t_1 := \left(b \cdot a\right) \cdot -0.25\\ t_2 := x \cdot y + t_1\\ \mathbf{if}\;b \cdot a \leq -7 \cdot 10^{+133}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \cdot a \leq 2.4 \cdot 10^{+125}:\\ \;\;\;\;c + \left(x \cdot y + 0.0625 \cdot \left(t \cdot z\right)\right)\\ \mathbf{elif}\;b \cdot a \leq 1.9 \cdot 10^{+159}:\\ \;\;\;\;c + t_1\\ \mathbf{elif}\;b \cdot a \leq 1.65 \cdot 10^{+226}:\\ \;\;\;\;c + x \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Error10.1
Cost1360
\[\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 := t_2 + \left(c + x \cdot y\right)\\ \mathbf{if}\;b \leq -3 \cdot 10^{-143}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \leq 1.05 \cdot 10^{-31}:\\ \;\;\;\;c + \left(x \cdot y + t_1\right)\\ \mathbf{elif}\;b \leq 4.8 \cdot 10^{+149}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \leq 5.6 \cdot 10^{+239}:\\ \;\;\;\;\left(c + t_1\right) + t_2\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 6
Error35.7
Cost1244
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(t \cdot z\right)\\ \mathbf{if}\;c \leq -1.45 \cdot 10^{+76}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq -1.55 \cdot 10^{-44}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq -1.25 \cdot 10^{-102}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -7.2 \cdot 10^{-303}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 6.4 \cdot 10^{-246}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 7.8 \cdot 10^{-146}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 5.6 \cdot 10^{+57}:\\ \;\;\;\;\left(b \cdot a\right) \cdot -0.25\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 7
Error25.0
Cost1244
\[\begin{array}{l} t_1 := c + z \cdot \left(t \cdot 0.0625\right)\\ t_2 := \left(b \cdot a\right) \cdot -0.25\\ t_3 := c + x \cdot y\\ t_4 := c + t_2\\ \mathbf{if}\;x \leq -6.5 \cdot 10^{+138}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq -3.3 \cdot 10^{+37}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.4 \cdot 10^{-217}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;x \leq -3 \cdot 10^{-271}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 2.1 \cdot 10^{-267}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;x \leq 2.05 \cdot 10^{-97}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.4 \cdot 10^{-89}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 8
Error27.7
Cost1240
\[\begin{array}{l} t_1 := c + z \cdot \left(t \cdot 0.0625\right)\\ t_2 := c + x \cdot y\\ \mathbf{if}\;y \leq -8.8 \cdot 10^{-82}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -4.5 \cdot 10^{-221}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3.2 \cdot 10^{-259}:\\ \;\;\;\;\left(b \cdot a\right) \cdot -0.25\\ \mathbf{elif}\;y \leq 2.05 \cdot 10^{-59}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 6 \cdot 10^{+37}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 9 \cdot 10^{+104}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 9
Error6.1
Cost1224
\[\begin{array}{l} t_1 := \left(b \cdot a\right) \cdot -0.25 + \left(c + x \cdot y\right)\\ \mathbf{if}\;b \cdot a \leq -1.1 \cdot 10^{+122}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq 3 \cdot 10^{+35}:\\ \;\;\;\;c + \left(x \cdot y + 0.0625 \cdot \left(t \cdot z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error0.1
Cost1088
\[c + \left(\left(\frac{t \cdot z}{16} + x \cdot y\right) - \frac{b \cdot a}{4}\right) \]
Alternative 11
Error35.5
Cost984
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(t \cdot z\right)\\ \mathbf{if}\;c \leq -4.2 \cdot 10^{+82}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq -3.5 \cdot 10^{-44}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq -3.3 \cdot 10^{-103}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -1.12 \cdot 10^{-303}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 1.15 \cdot 10^{-245}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 2.3 \cdot 10^{+14}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 12
Error24.4
Cost840
\[\begin{array}{l} t_1 := \left(b \cdot a\right) \cdot -0.25\\ \mathbf{if}\;b \cdot a \leq -1.3 \cdot 10^{+116}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \cdot a \leq 1.65 \cdot 10^{+226}:\\ \;\;\;\;c + x \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 13
Error35.4
Cost456
\[\begin{array}{l} \mathbf{if}\;c \leq -4.4 \cdot 10^{+78}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq 2.55 \cdot 10^{+14}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 14
Error43.4
Cost64
\[c \]

Error

Reproduce

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