?

Average Error: 0.15% → 0.01%
Time: 20.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(x, y, \mathsf{fma}\left(a, b \cdot -0.25, \mathsf{fma}\left(t, \frac{z}{16}, 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 a (* b -0.25) (fma t (/ z 16.0) 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(a, (b * -0.25), fma(t, (z / 16.0), 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(a, Float64(b * -0.25), fma(t, Float64(z / 16.0), 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[(a * N[(b * -0.25), $MachinePrecision] + N[(t * N[(z / 16.0), $MachinePrecision] + 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(a, b \cdot -0.25, \mathsf{fma}\left(t, \frac{z}{16}, c\right)\right)\right)

Error?

Derivation?

  1. Initial program 0.15

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

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

    [Start]0.15

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

    associate--l+ [=>]0.15

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

    associate-+l+ [=>]0.15

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

    fma-def [=>]0.15

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

    +-commutative [=>]0.15

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

    sub-neg [=>]0.15

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

    associate-+r+ [=>]0.15

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

    +-commutative [<=]0.15

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

    distribute-neg-frac [=>]0.15

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

    distribute-rgt-neg-in [=>]0.15

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

    associate-*r/ [<=]0.11

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

    fma-def [=>]0.1

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

    mul-1-neg [<=]0.1

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

    associate-/l* [=>]0.15

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

    associate-/r/ [=>]0.1

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

    *-commutative [<=]0.1

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

    metadata-eval [=>]0.1

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

    +-commutative [=>]0.1

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

    associate-*l/ [<=]0.02

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

    *-commutative [=>]0.02

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

    fma-def [=>]0.01

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

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

Alternatives

Alternative 1
Error0.02%
Cost13632
\[\mathsf{fma}\left(x, y, \mathsf{fma}\left(t, \frac{z}{16}, c - a \cdot \frac{b}{4}\right)\right) \]
Alternative 2
Error34.89%
Cost3436
\[\begin{array}{l} t_1 := c + z \cdot \left(t \cdot 0.0625\right)\\ t_2 := c + a \cdot \left(b \cdot -0.25\right)\\ t_3 := c + x \cdot y\\ t_4 := x \cdot y + 0.0625 \cdot \left(t \cdot z\right)\\ \mathbf{if}\;a \cdot b \leq -2 \cdot 10^{+168}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq -1 \cdot 10^{-105}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \cdot b \leq 0:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 4 \cdot 10^{-232}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;a \cdot b \leq 3 \cdot 10^{-201}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 10^{-148}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \cdot b \leq 4 \cdot 10^{-87}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 10^{-33}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{-16}:\\ \;\;\;\;x \cdot y + -0.25 \cdot \left(a \cdot b\right)\\ \mathbf{elif}\;a \cdot b \leq 100:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{+101}:\\ \;\;\;\;t_4\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error34.65%
Cost2656
\[\begin{array}{l} t_1 := c + z \cdot \left(t \cdot 0.0625\right)\\ t_2 := c + a \cdot \left(b \cdot -0.25\right)\\ t_3 := c + x \cdot y\\ t_4 := x \cdot y + 0.0625 \cdot \left(t \cdot z\right)\\ \mathbf{if}\;a \cdot b \leq -2 \cdot 10^{+168}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq -1 \cdot 10^{-105}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \cdot b \leq 0:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 4 \cdot 10^{-232}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;a \cdot b \leq 3 \cdot 10^{-201}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{-16}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \cdot b \leq 100:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{+101}:\\ \;\;\;\;t_4\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error47.73%
Cost1900
\[\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 := c + x \cdot y\\ \mathbf{if}\;z \leq -9.2 \cdot 10^{+233}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -1.28 \cdot 10^{+188}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -2.05 \cdot 10^{+170}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -3 \cdot 10^{+110}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -3.5 \cdot 10^{+94}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -3.4 \cdot 10^{+30}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -3200000000:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -1.06 \cdot 10^{-258}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq -4 \cdot 10^{-299}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1.5 \cdot 10^{-200}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \leq 3.1 \cdot 10^{-41}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Error48.04%
Cost1509
\[\begin{array}{l} t_1 := c + x \cdot y\\ t_2 := 0.0625 \cdot \left(t \cdot z\right)\\ \mathbf{if}\;t \leq 3.1 \cdot 10^{-240}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 2.7 \cdot 10^{-215}:\\ \;\;\;\;-0.25 \cdot \left(a \cdot b\right)\\ \mathbf{elif}\;t \leq 8.2 \cdot 10^{-31}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 5.8 \cdot 10^{+98}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 1.15 \cdot 10^{+142}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 10^{+162}:\\ \;\;\;\;z \cdot \left(t \cdot 0.0625\right)\\ \mathbf{elif}\;t \leq 1.18 \cdot 10^{+194} \lor \neg \left(t \leq 8.8 \cdot 10^{+229}\right) \land t \leq 2.45 \cdot 10^{+266}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 6
Error32.82%
Cost1488
\[\begin{array}{l} t_1 := c + x \cdot y\\ t_2 := c + a \cdot \left(b \cdot -0.25\right)\\ \mathbf{if}\;a \cdot b \leq -2 \cdot 10^{+168}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq -1 \cdot 10^{-105}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 3 \cdot 10^{-201}:\\ \;\;\;\;c + z \cdot \left(t \cdot 0.0625\right)\\ \mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{+73}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 7
Error9.09%
Cost1353
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(t \cdot z\right)\\ \mathbf{if}\;a \cdot b \leq -5 \cdot 10^{+35} \lor \neg \left(a \cdot b \leq 2 \cdot 10^{+73}\right):\\ \;\;\;\;\left(c + t_1\right) + -0.25 \cdot \left(a \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;c + \left(x \cdot y + t_1\right)\\ \end{array} \]
Alternative 8
Error55.01%
Cost1248
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(t \cdot z\right)\\ \mathbf{if}\;c \leq -5.5 \cdot 10^{+47}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq -3.8 \cdot 10^{-105}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -4.6 \cdot 10^{-228}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 3.8 \cdot 10^{-59}:\\ \;\;\;\;z \cdot \left(t \cdot 0.0625\right)\\ \mathbf{elif}\;c \leq 3.35 \cdot 10^{-22}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 8.1 \cdot 10^{-19}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 29000000:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq 2.65 \cdot 10^{+29}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 9
Error11.32%
Cost1228
\[\begin{array}{l} t_1 := -0.25 \cdot \left(a \cdot b\right)\\ t_2 := 0.0625 \cdot \left(t \cdot z\right)\\ t_3 := x \cdot y + t_2\\ \mathbf{if}\;c \leq -3.3 \cdot 10^{+49}:\\ \;\;\;\;c + \left(x \cdot y + t_1\right)\\ \mathbf{elif}\;c \leq 1.05 \cdot 10^{-101}:\\ \;\;\;\;t_3 + t_1\\ \mathbf{elif}\;c \leq 2.3 \cdot 10^{+114}:\\ \;\;\;\;c + t_3\\ \mathbf{else}:\\ \;\;\;\;\left(c + t_2\right) + t_1\\ \end{array} \]
Alternative 10
Error13.22%
Cost1225
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -2 \cdot 10^{+168} \lor \neg \left(a \cdot b \leq 2 \cdot 10^{+145}\right):\\ \;\;\;\;c + a \cdot \left(b \cdot -0.25\right)\\ \mathbf{else}:\\ \;\;\;\;c + \left(x \cdot y + 0.0625 \cdot \left(t \cdot z\right)\right)\\ \end{array} \]
Alternative 11
Error10.6%
Cost1225
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -5 \cdot 10^{+159} \lor \neg \left(a \cdot b \leq 10^{+63}\right):\\ \;\;\;\;c + \left(x \cdot y + -0.25 \cdot \left(a \cdot b\right)\right)\\ \mathbf{else}:\\ \;\;\;\;c + \left(x \cdot y + 0.0625 \cdot \left(t \cdot z\right)\right)\\ \end{array} \]
Alternative 12
Error0.07%
Cost1088
\[c + \left(\left(t \cdot \frac{z}{16} + x \cdot y\right) - \frac{a \cdot b}{4}\right) \]
Alternative 13
Error54.53%
Cost852
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(t \cdot z\right)\\ \mathbf{if}\;c \leq -7 \cdot 10^{+48}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq -2.65 \cdot 10^{-104}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq -2 \cdot 10^{-225}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 4.9 \cdot 10^{-147}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 1.3 \cdot 10^{+29}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 14
Error54.29%
Cost456
\[\begin{array}{l} \mathbf{if}\;c \leq -8.5 \cdot 10^{+37}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq 5.6 \cdot 10^{+29}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 15
Error67.29%
Cost64
\[c \]

Error

Reproduce?

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