Average Error: 0.1 → 0.0
Time: 24.8s
Precision: binary64
Cost: 19904
\[\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, z \cdot 0.0625, \mathsf{fma}\left(a \cdot b, -0.25, c\right)\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 0.0625) (fma (* a b) -0.25 c))))
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 * 0.0625), fma((a * b), -0.25, c)));
}
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 * 0.0625), fma(Float64(a * b), -0.25, c)))
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 * 0.0625), $MachinePrecision] + N[(N[(a * b), $MachinePrecision] * -0.25 + c), $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, z \cdot 0.0625, \mathsf{fma}\left(a \cdot b, -0.25, c\right)\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, z \cdot 0.0625, \mathsf{fma}\left(a \cdot b, -0.25, c\right)\right)\right)} \]
    Proof
    (fma.f64 x y (fma.f64 t (*.f64 z 1/16) (fma.f64 (*.f64 a b) -1/4 c))): 0 points increase in error, 0 points decrease in error
    (fma.f64 x y (fma.f64 t (*.f64 z (Rewrite<= metadata-eval (neg.f64 -1/16))) (fma.f64 (*.f64 a b) -1/4 c))): 0 points increase in error, 0 points decrease in error
    (fma.f64 x y (fma.f64 t (*.f64 z (neg.f64 (Rewrite<= metadata-eval (/.f64 -1 16)))) (fma.f64 (*.f64 a b) -1/4 c))): 0 points increase in error, 0 points decrease in error
    (fma.f64 x y (fma.f64 t (Rewrite<= distribute-rgt-neg-in_binary64 (neg.f64 (*.f64 z (/.f64 -1 16)))) (fma.f64 (*.f64 a b) -1/4 c))): 0 points increase in error, 0 points decrease in error
    (fma.f64 x y (fma.f64 t (neg.f64 (Rewrite<= *-commutative_binary64 (*.f64 (/.f64 -1 16) z))) (fma.f64 (*.f64 a b) -1/4 c))): 0 points increase in error, 0 points decrease in error
    (fma.f64 x y (fma.f64 t (neg.f64 (Rewrite<= associate-/r/_binary64 (/.f64 -1 (/.f64 16 z)))) (fma.f64 (*.f64 a b) -1/4 c))): 11 points increase in error, 0 points decrease in error
    (fma.f64 x y (fma.f64 t (neg.f64 (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 -1 z) 16))) (fma.f64 (*.f64 a b) -1/4 c))): 0 points increase in error, 11 points decrease in error
    (fma.f64 x y (fma.f64 t (neg.f64 (/.f64 (Rewrite<= neg-mul-1_binary64 (neg.f64 z)) 16)) (fma.f64 (*.f64 a b) -1/4 c))): 0 points increase in error, 0 points decrease in error
    (fma.f64 x y (fma.f64 t (neg.f64 (Rewrite<= distribute-neg-frac_binary64 (neg.f64 (/.f64 z 16)))) (fma.f64 (*.f64 a b) -1/4 c))): 0 points increase in error, 0 points decrease in error
    (fma.f64 x y (fma.f64 t (Rewrite=> remove-double-neg_binary64 (/.f64 z 16)) (fma.f64 (*.f64 a b) -1/4 c))): 0 points increase in error, 0 points decrease in error
    (fma.f64 x y (fma.f64 t (/.f64 z 16) (fma.f64 (*.f64 a b) (Rewrite<= metadata-eval (/.f64 -1 4)) c))): 0 points increase in error, 0 points decrease in error
    (fma.f64 x y (fma.f64 t (/.f64 z 16) (Rewrite<= fma-def_binary64 (+.f64 (*.f64 (*.f64 a b) (/.f64 -1 4)) c)))): 0 points increase in error, 0 points decrease in error
    (fma.f64 x y (fma.f64 t (/.f64 z 16) (+.f64 (Rewrite<= *-commutative_binary64 (*.f64 (/.f64 -1 4) (*.f64 a b))) c))): 0 points increase in error, 0 points decrease in error
    (fma.f64 x y (fma.f64 t (/.f64 z 16) (+.f64 (Rewrite<= associate-/r/_binary64 (/.f64 -1 (/.f64 4 (*.f64 a b)))) c))): 8 points increase in error, 0 points decrease in error
    (fma.f64 x y (fma.f64 t (/.f64 z 16) (+.f64 (Rewrite<= associate-/l*_binary64 (/.f64 (*.f64 -1 (*.f64 a b)) 4)) c))): 0 points increase in error, 8 points decrease in error
    (fma.f64 x y (fma.f64 t (/.f64 z 16) (+.f64 (/.f64 (Rewrite<= neg-mul-1_binary64 (neg.f64 (*.f64 a b))) 4) c))): 0 points increase in error, 0 points decrease in error
    (fma.f64 x y (fma.f64 t (/.f64 z 16) (+.f64 (Rewrite<= distribute-neg-frac_binary64 (neg.f64 (/.f64 (*.f64 a b) 4))) c))): 0 points increase in error, 0 points decrease in error
    (fma.f64 x y (fma.f64 t (/.f64 z 16) (+.f64 (neg.f64 (/.f64 (*.f64 a b) 4)) (Rewrite<= remove-double-neg_binary64 (neg.f64 (neg.f64 c)))))): 0 points increase in error, 0 points decrease in error
    (fma.f64 x y (fma.f64 t (/.f64 z 16) (Rewrite<= distribute-neg-in_binary64 (neg.f64 (+.f64 (/.f64 (*.f64 a b) 4) (neg.f64 c)))))): 0 points increase in error, 0 points decrease in error
    (fma.f64 x y (fma.f64 t (/.f64 z 16) (neg.f64 (Rewrite<= sub-neg_binary64 (-.f64 (/.f64 (*.f64 a b) 4) c))))): 0 points increase in error, 0 points decrease in error
    (fma.f64 x y (Rewrite<= fma-neg_binary64 (-.f64 (*.f64 t (/.f64 z 16)) (-.f64 (/.f64 (*.f64 a b) 4) c)))): 1 points increase in error, 0 points decrease in error
    (fma.f64 x y (-.f64 (Rewrite<= *-commutative_binary64 (*.f64 (/.f64 z 16) t)) (-.f64 (/.f64 (*.f64 a b) 4) c))): 0 points increase in error, 0 points decrease in error
    (fma.f64 x y (-.f64 (Rewrite=> associate-*l/_binary64 (/.f64 (*.f64 z t) 16)) (-.f64 (/.f64 (*.f64 a b) 4) c))): 1 points increase in error, 0 points decrease in error
    (Rewrite<= fma-def_binary64 (+.f64 (*.f64 x y) (-.f64 (/.f64 (*.f64 z t) 16) (-.f64 (/.f64 (*.f64 a b) 4) c)))): 2 points increase in error, 0 points decrease in error
    (Rewrite<= associate--l+_binary64 (-.f64 (+.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(x, y, \mathsf{fma}\left(t, z \cdot 0.0625, \mathsf{fma}\left(a \cdot b, -0.25, c\right)\right)\right) \]

Alternatives

Alternative 1
Error0.0
Cost7360
\[\mathsf{fma}\left(x, y, z \cdot \left(t \cdot 0.0625\right)\right) + \left(c + a \cdot \left(b \cdot -0.25\right)\right) \]
Alternative 2
Error22.1
Cost3176
\[\begin{array}{l} t_1 := c + x \cdot y\\ t_2 := x \cdot y + \left(a \cdot b\right) \cdot -0.25\\ t_3 := 0.0625 \cdot \left(t \cdot z\right)\\ t_4 := c + t_3\\ t_5 := x \cdot y + t_3\\ t_6 := c + a \cdot \left(b \cdot -0.25\right)\\ \mathbf{if}\;a \cdot b \leq -1 \cdot 10^{+126}:\\ \;\;\;\;t_6\\ \mathbf{elif}\;a \cdot b \leq -1 \cdot 10^{+49}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;a \cdot b \leq -2 \cdot 10^{+42}:\\ \;\;\;\;b \cdot \left(a \cdot -0.25\right)\\ \mathbf{elif}\;a \cdot b \leq -5 \cdot 10^{-86}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq -1 \cdot 10^{-310}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;a \cdot b \leq 10^{-151}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 10^{-35}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;a \cdot b \leq 2.5 \cdot 10^{-11}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq 4 \cdot 10^{+18}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;a \cdot b \leq 10^{+122}:\\ \;\;\;\;t_6\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error26.8
Cost2028
\[\begin{array}{l} t_1 := c + a \cdot \left(b \cdot -0.25\right)\\ t_2 := 0.0625 \cdot \left(t \cdot z\right)\\ t_3 := x \cdot y + t_2\\ t_4 := c + t_2\\ \mathbf{if}\;x \leq -4.4 \cdot 10^{+73}:\\ \;\;\;\;c + x \cdot y\\ \mathbf{elif}\;x \leq -0.16501664926263998:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -8.269763606094789 \cdot 10^{-25}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq -7.305750771074481 \cdot 10^{-40}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.695715971087681 \cdot 10^{-59}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq -5.687119870227335 \cdot 10^{-88}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -6.598316983568828 \cdot 10^{-99}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;x \leq -1.2401305368535216 \cdot 10^{-160}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -6.618420965792936 \cdot 10^{-201}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;x \leq -2.3721818655726184 \cdot 10^{-285}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.832398686660416 \cdot 10^{-140}:\\ \;\;\;\;t_4\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 4
Error5.9
Cost1872
\[\begin{array}{l} t_1 := c + \left(t \cdot \left(z \cdot 0.0625\right) - \frac{a \cdot b}{4}\right)\\ \mathbf{if}\;a \cdot b \leq -2 \cdot 10^{+42}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 10^{+37}:\\ \;\;\;\;c + \left(x \cdot y + 0.0625 \cdot \left(t \cdot z\right)\right)\\ \mathbf{elif}\;a \cdot b \leq 10^{+122}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 5 \cdot 10^{+172}:\\ \;\;\;\;x \cdot y + \left(a \cdot b\right) \cdot -0.25\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error35.6
Cost1644
\[\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 -5.170436210575785 \cdot 10^{-17}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq -1.471416526519102 \cdot 10^{-79}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq -3.8738560977013384 \cdot 10^{-129}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -1.1008325274549221 \cdot 10^{-136}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq -1.810805619398735 \cdot 10^{-199}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 7.830017421239475 \cdot 10^{-277}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 5.346663648970479 \cdot 10^{-210}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 2.8569692090418266 \cdot 10^{-169}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 6.3743488984377186 \cdot 10^{-142}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 3.8693172508226037 \cdot 10^{-28}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 1.5550410951439922 \cdot 10^{+69}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 6
Error30.6
Cost1640
\[\begin{array}{l} t_1 := b \cdot \left(a \cdot -0.25\right)\\ t_2 := 0.0625 \cdot \left(t \cdot z\right)\\ t_3 := c + x \cdot y\\ \mathbf{if}\;c \leq -5.170436210575785 \cdot 10^{-17}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \leq -1.471416526519102 \cdot 10^{-79}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -3.8738560977013384 \cdot 10^{-129}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq -1.1008325274549221 \cdot 10^{-136}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -1.810805619398735 \cdot 10^{-199}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \leq 7.830017421239475 \cdot 10^{-277}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 5.346663648970479 \cdot 10^{-210}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 2.8569692090418266 \cdot 10^{-169}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 6.3743488984377186 \cdot 10^{-142}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 6.538315320491884 \cdot 10^{-72}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 7
Error24.9
Cost1636
\[\begin{array}{l} t_1 := c + a \cdot \left(b \cdot -0.25\right)\\ t_2 := c + x \cdot y\\ t_3 := c + 0.0625 \cdot \left(t \cdot z\right)\\ \mathbf{if}\;x \leq -4.4 \cdot 10^{+73}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -0.16501664926263998:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.2246943374522902 \cdot 10^{-57}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq -5.687119870227335 \cdot 10^{-88}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -6.598316983568828 \cdot 10^{-99}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq -1.2401305368535216 \cdot 10^{-160}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -6.618420965792936 \cdot 10^{-201}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;x \leq -2.3721818655726184 \cdot 10^{-285}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.0857484745672529 \cdot 10^{-44}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 8
Error8.2
Cost1224
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -1 \cdot 10^{+126}:\\ \;\;\;\;c + a \cdot \left(b \cdot -0.25\right)\\ \mathbf{elif}\;a \cdot b \leq 10^{+122}:\\ \;\;\;\;c + \left(x \cdot y + 0.0625 \cdot \left(t \cdot z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot y + \left(a \cdot b\right) \cdot -0.25\\ \end{array} \]
Alternative 9
Error5.5
Cost1224
\[\begin{array}{l} t_1 := \left(c + x \cdot y\right) + \left(a \cdot b\right) \cdot -0.25\\ \mathbf{if}\;a \cdot b \leq -2 \cdot 10^{+91}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 4 \cdot 10^{+18}:\\ \;\;\;\;c + \left(x \cdot y + 0.0625 \cdot \left(t \cdot z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error35.9
Cost1116
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(t \cdot z\right)\\ \mathbf{if}\;c \leq -5.170436210575785 \cdot 10^{-17}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq -3.8738560977013384 \cdot 10^{-129}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -1.810805619398735 \cdot 10^{-199}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 7.830017421239475 \cdot 10^{-277}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 5.346663648970479 \cdot 10^{-210}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 2.8569692090418266 \cdot 10^{-169}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 1.5550410951439922 \cdot 10^{+69}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 11
Error0.0
Cost1088
\[c + \left(\left(t \cdot \frac{z}{16} + x \cdot y\right) - \frac{a \cdot b}{4}\right) \]
Alternative 12
Error24.9
Cost712
\[\begin{array}{l} t_1 := c + x \cdot y\\ \mathbf{if}\;x \leq -1.4783708656028674 \cdot 10^{+45}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.0857484745672529 \cdot 10^{-44}:\\ \;\;\;\;c + 0.0625 \cdot \left(t \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 13
Error35.8
Cost456
\[\begin{array}{l} \mathbf{if}\;c \leq -1.3778412877726965 \cdot 10^{-29}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq 1.5550410951439922 \cdot 10^{+69}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 14
Error43.9
Cost64
\[c \]

Error

Reproduce

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