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

Alternatives

Alternative 1
Error0.0
Cost19904
\[\mathsf{fma}\left(x, y, \mathsf{fma}\left(a, b \cdot -0.25, \mathsf{fma}\left(t, \frac{z}{16}, c\right)\right)\right) \]
Alternative 2
Error20.9
Cost2656
\[\begin{array}{l} t_1 := \left(z \cdot t\right) \cdot 0.0625\\ t_2 := c + t_1\\ t_3 := t_1 + x \cdot y\\ t_4 := c + x \cdot y\\ t_5 := c - b \cdot \left(a \cdot 0.25\right)\\ \mathbf{if}\;b \cdot a \leq -2 \cdot 10^{+102}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;b \cdot a \leq -2 \cdot 10^{+55}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;b \cdot a \leq -5 \cdot 10^{+14}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;b \cdot a \leq -4 \cdot 10^{-118}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \cdot a \leq -2 \cdot 10^{-158}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;b \cdot a \leq 10^{-118}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \cdot a \leq 5 \cdot 10^{+27}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;b \cdot a \leq 10^{+74}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_5\\ \end{array} \]
Alternative 3
Error30.3
Cost1246
\[\begin{array}{l} t_1 := c + x \cdot y\\ t_2 := a \cdot \left(b \cdot -0.25\right)\\ \mathbf{if}\;b \leq -2.1 \cdot 10^{+28}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \leq 9.5 \cdot 10^{+75}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq 5.2 \cdot 10^{+84}:\\ \;\;\;\;\left(z \cdot t\right) \cdot 0.0625\\ \mathbf{elif}\;b \leq 6.4 \cdot 10^{+94} \lor \neg \left(b \leq 6.8 \cdot 10^{+112} \lor \neg \left(b \leq 5.6 \cdot 10^{+202}\right) \land b \leq 9.8 \cdot 10^{+232}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error9.9
Cost1228
\[\begin{array}{l} t_1 := -0.25 \cdot \left(b \cdot a\right)\\ t_2 := \left(z \cdot t\right) \cdot 0.0625\\ t_3 := c + \left(t_2 + t_1\right)\\ \mathbf{if}\;t \leq -4 \cdot 10^{-90}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq 4 \cdot 10^{+30}:\\ \;\;\;\;c + \left(x \cdot y + t_1\right)\\ \mathbf{elif}\;t \leq 9.5 \cdot 10^{+194}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;c + \left(t_2 + x \cdot y\right)\\ \end{array} \]
Alternative 5
Error5.8
Cost1225
\[\begin{array}{l} \mathbf{if}\;b \cdot a \leq -2 \cdot 10^{+102} \lor \neg \left(b \cdot a \leq 5 \cdot 10^{-32}\right):\\ \;\;\;\;c + \left(x \cdot y + -0.25 \cdot \left(b \cdot a\right)\right)\\ \mathbf{else}:\\ \;\;\;\;c + \left(\left(z \cdot t\right) \cdot 0.0625 + x \cdot y\right)\\ \end{array} \]
Alternative 6
Error8.5
Cost1224
\[\begin{array}{l} \mathbf{if}\;b \cdot a \leq -2 \cdot 10^{+109}:\\ \;\;\;\;c - b \cdot \left(a \cdot 0.25\right)\\ \mathbf{elif}\;b \cdot a \leq 2 \cdot 10^{+163}:\\ \;\;\;\;c + \left(\left(z \cdot t\right) \cdot 0.0625 + x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;b \cdot \left(-0.25 \cdot a + \frac{x \cdot y}{b}\right)\\ \end{array} \]
Alternative 7
Error36.1
Cost1112
\[\begin{array}{l} t_1 := \left(z \cdot t\right) \cdot 0.0625\\ \mathbf{if}\;c \leq -2.1 \cdot 10^{+64}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq -1.1 \cdot 10^{-104}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -1.3 \cdot 10^{-223}:\\ \;\;\;\;a \cdot \left(b \cdot -0.25\right)\\ \mathbf{elif}\;c \leq 1.1 \cdot 10^{-234}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 7.2 \cdot 10^{-207}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 1.6 \cdot 10^{+33}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 8
Error24.7
Cost1108
\[\begin{array}{l} t_1 := c - b \cdot \left(a \cdot 0.25\right)\\ t_2 := c + \left(z \cdot t\right) \cdot 0.0625\\ \mathbf{if}\;t \leq -1.25 \cdot 10^{-70}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -8.8 \cdot 10^{-272}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 2.9 \cdot 10^{-24}:\\ \;\;\;\;c + x \cdot y\\ \mathbf{elif}\;t \leq 3.6 \cdot 10^{+30}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 3.7 \cdot 10^{+30}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 9
Error0.1
Cost1088
\[c + \left(\left(\frac{z \cdot t}{16} + x \cdot y\right) - \frac{b \cdot a}{4}\right) \]
Alternative 10
Error35.9
Cost848
\[\begin{array}{l} t_1 := \left(z \cdot t\right) \cdot 0.0625\\ \mathbf{if}\;c \leq -9 \cdot 10^{+63}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq 6.6 \cdot 10^{-238}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 2.45 \cdot 10^{-204}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 6 \cdot 10^{+31}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 11
Error24.9
Cost713
\[\begin{array}{l} \mathbf{if}\;t \leq -9.5 \cdot 10^{-144} \lor \neg \left(t \leq 1.35 \cdot 10^{+31}\right):\\ \;\;\;\;c + \left(z \cdot t\right) \cdot 0.0625\\ \mathbf{else}:\\ \;\;\;\;c + x \cdot y\\ \end{array} \]
Alternative 12
Error35.1
Cost456
\[\begin{array}{l} \mathbf{if}\;c \leq -1.42 \cdot 10^{+43}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq 1.28 \cdot 10^{+42}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 13
Error43.7
Cost64
\[c \]

Error

Reproduce

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