Average Error: 0.1 → 0.0
Time: 17.4s
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))): 8 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, 8 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))): 6 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, 6 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))): 0 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)))): 3 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.1
Cost7360
\[c + \left(\mathsf{fma}\left(x, y, \left(a \cdot b\right) \cdot -0.25\right) + 0.0625 \cdot \left(t \cdot z\right)\right) \]
Alternative 2
Error20.8
Cost1760
\[\begin{array}{l} t_1 := \left(a \cdot b\right) \cdot -0.25\\ t_2 := x \cdot y + t_1\\ t_3 := 0.0625 \cdot \left(t \cdot z\right)\\ t_4 := t_3 + x \cdot y\\ t_5 := c + a \cdot \left(b \cdot -0.25\right)\\ t_6 := t_3 + t_1\\ \mathbf{if}\;c \leq -1.717354500672184 \cdot 10^{+65}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;c \leq -1.300896098767146 \cdot 10^{-71}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;c \leq -1.0103983230817872 \cdot 10^{-218}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq -3.640188462521398 \cdot 10^{-291}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;c \leq 3.02471910826935 \cdot 10^{-190}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 2.52 \cdot 10^{-114}:\\ \;\;\;\;t_6\\ \mathbf{elif}\;c \leq 1.4879951691364886 \cdot 10^{-97}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;c \leq 0.043194866258713535:\\ \;\;\;\;t_6\\ \mathbf{else}:\\ \;\;\;\;t_5\\ \end{array} \]
Alternative 3
Error20.6
Cost1504
\[\begin{array}{l} t_1 := x \cdot y + \left(a \cdot b\right) \cdot -0.25\\ t_2 := 0.0625 \cdot \left(t \cdot z\right) + x \cdot y\\ t_3 := c + a \cdot \left(b \cdot -0.25\right)\\ \mathbf{if}\;c \leq -1.717354500672184 \cdot 10^{+65}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \leq -1.300896098767146 \cdot 10^{-71}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq -1.0103983230817872 \cdot 10^{-218}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -3.640188462521398 \cdot 10^{-291}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 2.9771531689061563 \cdot 10^{-182}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 1.7748300888326255 \cdot 10^{-55}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 1.2202773937238373 \cdot 10^{+70}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \leq 8.226075208128725 \cdot 10^{+91}:\\ \;\;\;\;c + z \cdot \left(t \cdot 0.0625\right)\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 4
Error25.6
Cost1240
\[\begin{array}{l} t_1 := c + z \cdot \left(t \cdot 0.0625\right)\\ t_2 := 0.0625 \cdot \left(t \cdot z\right) + x \cdot y\\ t_3 := c + a \cdot \left(b \cdot -0.25\right)\\ \mathbf{if}\;a \leq -1.8 \cdot 10^{+90}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \leq -3.063657059144065 \cdot 10^{+59}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq -5.600394576076928 \cdot 10^{+22}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \leq -1.3249224711385246 \cdot 10^{-289}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \leq 7.108099945646455 \cdot 10^{-250}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \leq 1.1025369304794065 \cdot 10^{-178}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 5
Error8.4
Cost1224
\[\begin{array}{l} t_1 := c + a \cdot \left(b \cdot -0.25\right)\\ \mathbf{if}\;a \cdot b \leq -5 \cdot 10^{+47}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{+52}:\\ \;\;\;\;c + \left(0.0625 \cdot \left(t \cdot z\right) + x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error5.6
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 -5 \cdot 10^{+47}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 5 \cdot 10^{+18}:\\ \;\;\;\;c + \left(0.0625 \cdot \left(t \cdot z\right) + x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error5.5
Cost1224
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(t \cdot z\right)\\ t_2 := \left(a \cdot b\right) \cdot -0.25\\ \mathbf{if}\;a \cdot b \leq -1 \cdot 10^{+25}:\\ \;\;\;\;\left(c + t_1\right) + t_2\\ \mathbf{elif}\;a \cdot b \leq 5 \cdot 10^{+18}:\\ \;\;\;\;c + \left(t_1 + x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\left(c + x \cdot y\right) + t_2\\ \end{array} \]
Alternative 8
Error30.6
Cost1112
\[\begin{array}{l} t_1 := b \cdot \left(a \cdot -0.25\right)\\ t_2 := c + x \cdot y\\ \mathbf{if}\;c \leq 6.147860139599904 \cdot 10^{-290}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 3.5751841831806233 \cdot 10^{-227}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 3.02471910826935 \cdot 10^{-190}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 2.52 \cdot 10^{-114}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 2.128501878854501 \cdot 10^{-92}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 2.6381600781059763 \cdot 10^{+40}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 9
Error0.1
Cost1088
\[c + \left(\left(\frac{t \cdot z}{16} + x \cdot y\right) - \frac{a \cdot b}{4}\right) \]
Alternative 10
Error24.2
Cost976
\[\begin{array}{l} t_1 := c + x \cdot y\\ t_2 := c + z \cdot \left(t \cdot 0.0625\right)\\ \mathbf{if}\;t \leq -9.400101136021763 \cdot 10^{-93}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 2.5596397906009944 \cdot 10^{-231}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.4177761047762913 \cdot 10^{-216}:\\ \;\;\;\;b \cdot \left(a \cdot -0.25\right)\\ \mathbf{elif}\;t \leq 0.000653015847568671:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 11
Error24.0
Cost976
\[\begin{array}{l} t_1 := c + a \cdot \left(b \cdot -0.25\right)\\ t_2 := c + z \cdot \left(t \cdot 0.0625\right)\\ \mathbf{if}\;t \leq -1.5088173329413292 \cdot 10^{-65}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 1.4177761047762913 \cdot 10^{-216}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 8.719633502611478 \cdot 10^{-190}:\\ \;\;\;\;c + x \cdot y\\ \mathbf{elif}\;t \leq 89030207650.82112:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 12
Error31.4
Cost848
\[\begin{array}{l} t_1 := c + x \cdot y\\ t_2 := z \cdot \left(t \cdot 0.0625\right)\\ \mathbf{if}\;t \leq -1.5856978018758584 \cdot 10^{-78}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 2.5596397906009944 \cdot 10^{-231}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.4177761047762913 \cdot 10^{-216}:\\ \;\;\;\;b \cdot \left(a \cdot -0.25\right)\\ \mathbf{elif}\;t \leq 2.4 \cdot 10^{+190}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 13
Error35.1
Cost456
\[\begin{array}{l} \mathbf{if}\;c \leq -8.562924544824932 \cdot 10^{+67}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq 1.087757676446515 \cdot 10^{-33}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 14
Error28.8
Cost320
\[c + x \cdot y \]
Alternative 15
Error42.9
Cost64
\[c \]

Error

Reproduce

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