Average Error: 0.1 → 0.0
Time: 14.0s
Precision: binary64
Cost: 13632
\[\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, \frac{z}{16}, c - a \cdot \frac{b}{4}\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 16.0) (- c (* a (/ b 4.0))))))
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 / 16.0), (c - (a * (b / 4.0)))));
}
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 / 16.0), Float64(c - Float64(a * Float64(b / 4.0)))))
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 / 16.0), $MachinePrecision] + N[(c - N[(a * N[(b / 4.0), $MachinePrecision]), $MachinePrecision]), $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, \frac{z}{16}, c - a \cdot \frac{b}{4}\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, \frac{z}{16}, c - a \cdot \frac{b}{4}\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 + \left(\frac{z \cdot t}{16} - \frac{a \cdot b}{4}\right)\right)} + c \]

    associate-+l+ [=>]0.1

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

    fma-def [=>]0.1

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

    associate-+l- [=>]0.1

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

    associate-*l/ [<=]0.1

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

    *-commutative [=>]0.1

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

    fma-neg [=>]0.1

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

    neg-sub0 [=>]0.1

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

    associate-+l- [<=]0.1

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

    neg-sub0 [<=]0.1

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

    +-commutative [=>]0.1

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

    unsub-neg [=>]0.1

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

    associate-*r/ [<=]0.0

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

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

Alternatives

Alternative 1
Error21.2
Cost3048
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(t \cdot z\right)\\ t_2 := c + t_1\\ t_3 := x \cdot y + t_1\\ t_4 := c + \left(a \cdot b\right) \cdot -0.25\\ t_5 := c + x \cdot y\\ \mathbf{if}\;a \cdot b \leq -3.5 \cdot 10^{+100}:\\ \;\;\;\;t_4\\ \mathbf{elif}\;a \cdot b \leq -1.25 \cdot 10^{-51}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq -3.9 \cdot 10^{-138}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;a \cdot b \leq -1.4 \cdot 10^{-190}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \cdot b \leq -2.6 \cdot 10^{-250}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{-316}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq 1.55 \cdot 10^{-261}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \cdot b \leq 1.52 \cdot 10^{-80}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq 8.2 \cdot 10^{+93}:\\ \;\;\;\;t_5\\ \mathbf{elif}\;a \cdot b \leq 3.2 \cdot 10^{+151}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_4\\ \end{array} \]
Alternative 2
Error23.2
Cost2920
\[\begin{array}{l} t_1 := c + x \cdot y\\ t_2 := c + 0.0625 \cdot \left(t \cdot z\right)\\ t_3 := \left(a \cdot b\right) \cdot -0.25\\ \mathbf{if}\;a \cdot b \leq -5.6 \cdot 10^{+133}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \cdot b \leq -3.4 \cdot 10^{+22}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq -2.4 \cdot 10^{-51}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq -1.25 \cdot 10^{-251}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 0:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq 4.8 \cdot 10^{-292}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 1.95 \cdot 10^{-79}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq 6.4 \cdot 10^{+94}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 4.4 \cdot 10^{+151}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq 3.5 \cdot 10^{+184}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 3
Error20.9
Cost2528
\[\begin{array}{l} t_1 := c + 0.0625 \cdot \left(t \cdot z\right)\\ t_2 := c + \left(a \cdot b\right) \cdot -0.25\\ t_3 := c + x \cdot y\\ \mathbf{if}\;a \cdot b \leq -1.1 \cdot 10^{+102}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq -2.9 \cdot 10^{-51}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq -5.4 \cdot 10^{-250}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \cdot b \leq 0:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 6 \cdot 10^{-295}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \cdot b \leq 2.55 \cdot 10^{-79}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 7 \cdot 10^{+94}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;a \cdot b \leq 3.4 \cdot 10^{+151}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error24.7
Cost1360
\[\begin{array}{l} t_1 := c + x \cdot y\\ t_2 := \left(a \cdot b\right) \cdot -0.25\\ \mathbf{if}\;a \cdot b \leq -4.1 \cdot 10^{+139}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;a \cdot b \leq 1.32 \cdot 10^{-210}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;a \cdot b \leq 1.02 \cdot 10^{-132}:\\ \;\;\;\;0.0625 \cdot \left(t \cdot z\right)\\ \mathbf{elif}\;a \cdot b \leq 4.6 \cdot 10^{+184}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Error21.8
Cost1236
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(t \cdot z\right)\\ t_2 := x \cdot y + t_1\\ t_3 := x \cdot y + \left(a \cdot b\right) \cdot -0.25\\ \mathbf{if}\;c \leq -6.6 \cdot 10^{+103}:\\ \;\;\;\;c + x \cdot y\\ \mathbf{elif}\;c \leq -1.6 \cdot 10^{-251}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq -6 \cdot 10^{-290}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;c \leq 7 \cdot 10^{-103}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \leq 5.4 \cdot 10^{-11}:\\ \;\;\;\;t_3\\ \mathbf{else}:\\ \;\;\;\;c + t_1\\ \end{array} \]
Alternative 6
Error8.1
Cost1225
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -4 \cdot 10^{+138} \lor \neg \left(a \cdot b \leq 1.5 \cdot 10^{+168}\right):\\ \;\;\;\;c + \left(a \cdot b\right) \cdot -0.25\\ \mathbf{else}:\\ \;\;\;\;c + \left(x \cdot y + 0.0625 \cdot \left(t \cdot z\right)\right)\\ \end{array} \]
Alternative 7
Error5.7
Cost1225
\[\begin{array}{l} \mathbf{if}\;a \cdot b \leq -4 \cdot 10^{+100} \lor \neg \left(a \cdot b \leq 1.5 \cdot 10^{+16}\right):\\ \;\;\;\;\left(c + x \cdot y\right) + \left(a \cdot b\right) \cdot -0.25\\ \mathbf{else}:\\ \;\;\;\;c + \left(x \cdot y + 0.0625 \cdot \left(t \cdot z\right)\right)\\ \end{array} \]
Alternative 8
Error0.1
Cost1088
\[c + \left(\left(\frac{t \cdot z}{16} + x \cdot y\right) - \frac{a \cdot b}{4}\right) \]
Alternative 9
Error35.4
Cost980
\[\begin{array}{l} t_1 := 0.0625 \cdot \left(t \cdot z\right)\\ \mathbf{if}\;c \leq -4.6 \cdot 10^{+100}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq -1.15 \cdot 10^{-300}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 1.2 \cdot 10^{-136}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \leq 4.6 \cdot 10^{-20}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \leq 1.1 \cdot 10^{+27}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 10
Error35.5
Cost456
\[\begin{array}{l} \mathbf{if}\;c \leq -2.65 \cdot 10^{+101}:\\ \;\;\;\;c\\ \mathbf{elif}\;c \leq 330000:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c\\ \end{array} \]
Alternative 11
Error43.1
Cost64
\[c \]

Error

Reproduce

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