?

Average Error: 0.1 → 0.0
Time: 15.5s
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

    [Start]0.1

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

    associate-+l- [=>]0.1

    \[ \color{blue}{\left(x \cdot y + \frac{z \cdot t}{16}\right) - \left(\frac{a \cdot b}{4} - c\right)} \]

    +-commutative [=>]0.1

    \[ \color{blue}{\left(\frac{z \cdot t}{16} + x \cdot y\right)} - \left(\frac{a \cdot b}{4} - c\right) \]

    associate--l+ [=>]0.1

    \[ \color{blue}{\frac{z \cdot t}{16} + \left(x \cdot y - \left(\frac{a \cdot b}{4} - c\right)\right)} \]

    associate-*r/ [<=]0.0

    \[ \color{blue}{z \cdot \frac{t}{16}} + \left(x \cdot y - \left(\frac{a \cdot b}{4} - c\right)\right) \]

    *-commutative [<=]0.0

    \[ \color{blue}{\frac{t}{16} \cdot z} + \left(x \cdot y - \left(\frac{a \cdot b}{4} - c\right)\right) \]

    *-commutative [=>]0.0

    \[ \color{blue}{z \cdot \frac{t}{16}} + \left(x \cdot y - \left(\frac{a \cdot b}{4} - c\right)\right) \]

    fma-def [=>]0.0

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

    associate--r- [=>]0.0

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

    +-commutative [=>]0.0

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

    associate-+r- [=>]0.0

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

    sub-neg [=>]0.0

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

    +-commutative [<=]0.0

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

    neg-mul-1 [=>]0.0

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

    associate-*l/ [<=]0.0

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

    associate-*r* [=>]0.0

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

    *-commutative [=>]0.0

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

    fma-def [=>]0.0

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

    associate-*r/ [=>]0.0

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

    associate-/l* [=>]0.0

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

    associate-/r/ [=>]0.0

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

    metadata-eval [=>]0.0

    \[ \mathsf{fma}\left(z, \frac{t}{16}, \mathsf{fma}\left(b, \color{blue}{-0.25} \cdot a, c + x \cdot y\right)\right) \]

    +-commutative [=>]0.0

    \[ \mathsf{fma}\left(z, \frac{t}{16}, \mathsf{fma}\left(b, -0.25 \cdot a, \color{blue}{x \cdot y + c}\right)\right) \]

    fma-def [=>]0.0

    \[ \mathsf{fma}\left(z, \frac{t}{16}, \mathsf{fma}\left(b, -0.25 \cdot a, \color{blue}{\mathsf{fma}\left(x, y, c\right)}\right)\right) \]
  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
Cost13632
\[c + \mathsf{fma}\left(z, t \cdot 0.0625, \mathsf{fma}\left(a, b \cdot -0.25, x \cdot y\right)\right) \]
Alternative 2
Error8.5
Cost1746
\[\begin{array}{l} \mathbf{if}\;b \cdot a \leq -1 \cdot 10^{+91} \lor \neg \left(b \cdot a \leq 4 \cdot 10^{-11}\right) \land \left(b \cdot a \leq 4 \cdot 10^{+27} \lor \neg \left(b \cdot a \leq 10^{+74}\right)\right):\\ \;\;\;\;c + a \cdot \left(b \cdot -0.25\right)\\ \mathbf{else}:\\ \;\;\;\;c + \left(x \cdot y + 0.0625 \cdot \left(z \cdot t\right)\right)\\ \end{array} \]
Alternative 3
Error24.5
Cost1504
\[\begin{array}{l} t_1 := c + x \cdot y\\ t_2 := c + t \cdot \left(z \cdot 0.0625\right)\\ t_3 := c + a \cdot \left(b \cdot -0.25\right)\\ \mathbf{if}\;z \leq -4 \cdot 10^{+124}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -1.65 \cdot 10^{+91}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -2.3 \cdot 10^{+79}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -4.4 \cdot 10^{+39}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -3.3 \cdot 10^{+16}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -4.8 \cdot 10^{-60}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -7 \cdot 10^{-264}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.9 \cdot 10^{-88}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error26.3
Cost1501
\[\begin{array}{l} t_1 := c + t \cdot \left(z \cdot 0.0625\right)\\ t_2 := x \cdot y + -0.25 \cdot \left(b \cdot a\right)\\ \mathbf{if}\;b \leq -7.2 \cdot 10^{-106}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \leq -7 \cdot 10^{-200}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq -1.9 \cdot 10^{-250}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;b \leq 2.15 \cdot 10^{-277}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;b \leq 0.00034:\\ \;\;\;\;c + x \cdot y\\ \mathbf{elif}\;b \leq 3.4 \cdot 10^{+257} \lor \neg \left(b \leq 3.2 \cdot 10^{+277}\right):\\ \;\;\;\;c + a \cdot \left(b \cdot -0.25\right)\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Error21.1
Cost1372
\[\begin{array}{l} t_1 := x \cdot y + -0.25 \cdot \left(b \cdot a\right)\\ t_2 := x \cdot y + 0.0625 \cdot \left(z \cdot t\right)\\ t_3 := c + a \cdot \left(b \cdot -0.25\right)\\ \mathbf{if}\;c \leq -6.9 \cdot 10^{+22}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \leq -6.3 \cdot 10^{-136}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 6 \cdot 10^{-251}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 2.8 \cdot 10^{-196}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 1.2 \cdot 10^{-132}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 7 \cdot 10^{-68}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 1.8 \cdot 10^{+74}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;c + x \cdot y\\ \end{array} \]
Alternative 6
Error5.5
Cost1225
\[\begin{array}{l} \mathbf{if}\;b \cdot a \leq -1 \cdot 10^{+38} \lor \neg \left(b \cdot a \leq 5 \cdot 10^{-43}\right):\\ \;\;\;\;-0.25 \cdot \left(b \cdot a\right) + \left(c + x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;c + \left(x \cdot y + 0.0625 \cdot \left(z \cdot t\right)\right)\\ \end{array} \]
Alternative 7
Error35.6
Cost1116
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(z \cdot t\right)\\ \mathbf{if}\;c \leq -1.25 \cdot 10^{+17}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq -3.5 \cdot 10^{-169}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -3.6 \cdot 10^{-288}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 9.8 \cdot 10^{-213}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 2.9 \cdot 10^{+34}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 8 \cdot 10^{+88}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq 2.4 \cdot 10^{+148}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 8
Error30.2
Cost1113
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(z \cdot t\right)\\ t_2 := a \cdot \left(b \cdot -0.25\right)\\ t_3 := c + x \cdot y\\ \mathbf{if}\;c \leq -1.6 \cdot 10^{+15}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \leq -5.4 \cdot 10^{-136}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 1.06 \cdot 10^{-250}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 1.05 \cdot 10^{-212}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 6.9 \cdot 10^{-68} \lor \neg \left(c \leq 9.5 \cdot 10^{-12}\right):\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 9
Error35.0
Cost1112
\[\begin{array}{l} t_1 := a \cdot \left(b \cdot -0.25\right)\\ t_2 := 0.0625 \cdot \left(z \cdot t\right)\\ \mathbf{if}\;c \leq -4.2 \cdot 10^{+16}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq -9.2 \cdot 10^{-136}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 7 \cdot 10^{-251}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 1.1 \cdot 10^{-212}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 3.4 \cdot 10^{-68}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 1.9 \cdot 10^{+31}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 10
Error0.1
Cost1088
\[c + \left(\left(x \cdot y + \frac{z \cdot t}{16}\right) - \frac{b \cdot a}{4}\right) \]
Alternative 11
Error24.3
Cost978
\[\begin{array}{l} \mathbf{if}\;y \leq -7.6 \cdot 10^{-103} \lor \neg \left(y \leq 7.2 \cdot 10^{-34}\right) \land \left(y \leq 1.05 \cdot 10^{+96} \lor \neg \left(y \leq 2.9 \cdot 10^{+154}\right)\right):\\ \;\;\;\;c + x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c + a \cdot \left(b \cdot -0.25\right)\\ \end{array} \]
Alternative 12
Error35.3
Cost720
\[\begin{array}{l} \mathbf{if}\;c \leq -2.4 \cdot 10^{+22}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq 2.5 \cdot 10^{+33}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 3.5 \cdot 10^{+86}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq 2.4 \cdot 10^{+148}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 13
Error42.9
Cost64
\[c \]

Error

Reproduce?

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