?

Average Error: 0.13% → 0.12%
Time: 12.8s
Precision: binary64
Cost: 7104

?

\[x \cdot \left(\left(\left(\left(y + z\right) + z\right) + y\right) + t\right) + y \cdot 5 \]
\[\mathsf{fma}\left(x, 2 \cdot \left(y + z\right) + t, y \cdot 5\right) \]
(FPCore (x y z t)
 :precision binary64
 (+ (* x (+ (+ (+ (+ y z) z) y) t)) (* y 5.0)))
(FPCore (x y z t) :precision binary64 (fma x (+ (* 2.0 (+ y z)) t) (* y 5.0)))
double code(double x, double y, double z, double t) {
	return (x * ((((y + z) + z) + y) + t)) + (y * 5.0);
}
double code(double x, double y, double z, double t) {
	return fma(x, ((2.0 * (y + z)) + t), (y * 5.0));
}
function code(x, y, z, t)
	return Float64(Float64(x * Float64(Float64(Float64(Float64(y + z) + z) + y) + t)) + Float64(y * 5.0))
end
function code(x, y, z, t)
	return fma(x, Float64(Float64(2.0 * Float64(y + z)) + t), Float64(y * 5.0))
end
code[x_, y_, z_, t_] := N[(N[(x * N[(N[(N[(N[(y + z), $MachinePrecision] + z), $MachinePrecision] + y), $MachinePrecision] + t), $MachinePrecision]), $MachinePrecision] + N[(y * 5.0), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := N[(x * N[(N[(2.0 * N[(y + z), $MachinePrecision]), $MachinePrecision] + t), $MachinePrecision] + N[(y * 5.0), $MachinePrecision]), $MachinePrecision]
x \cdot \left(\left(\left(\left(y + z\right) + z\right) + y\right) + t\right) + y \cdot 5
\mathsf{fma}\left(x, 2 \cdot \left(y + z\right) + t, y \cdot 5\right)

Error?

Derivation?

  1. Initial program 0.13

    \[x \cdot \left(\left(\left(\left(y + z\right) + z\right) + y\right) + t\right) + y \cdot 5 \]
  2. Simplified0.12

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, 2 \cdot \left(y + z\right) + t, y \cdot 5\right)} \]
    Proof

    [Start]0.13

    \[ x \cdot \left(\left(\left(\left(y + z\right) + z\right) + y\right) + t\right) + y \cdot 5 \]

    fma-def [=>]0.12

    \[ \color{blue}{\mathsf{fma}\left(x, \left(\left(\left(y + z\right) + z\right) + y\right) + t, y \cdot 5\right)} \]

    associate-+l+ [=>]0.12

    \[ \mathsf{fma}\left(x, \color{blue}{\left(\left(y + z\right) + \left(z + y\right)\right)} + t, y \cdot 5\right) \]

    +-commutative [<=]0.12

    \[ \mathsf{fma}\left(x, \left(\left(y + z\right) + \color{blue}{\left(y + z\right)}\right) + t, y \cdot 5\right) \]

    count-2 [=>]0.12

    \[ \mathsf{fma}\left(x, \color{blue}{2 \cdot \left(y + z\right)} + t, y \cdot 5\right) \]
  3. Final simplification0.12

    \[\leadsto \mathsf{fma}\left(x, 2 \cdot \left(y + z\right) + t, y \cdot 5\right) \]

Alternatives

Alternative 1
Error45.64%
Cost1769
\[\begin{array}{l} t_1 := y \cdot \left(5 + x \cdot 2\right)\\ t_2 := \left(y + z\right) \cdot \left(x \cdot 2\right)\\ \mathbf{if}\;z \leq -2.15 \cdot 10^{+71}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \leq -1 \cdot 10^{-279}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -7.2 \cdot 10^{-302}:\\ \;\;\;\;x \cdot t\\ \mathbf{elif}\;z \leq 2.2 \cdot 10^{-269}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 4.8 \cdot 10^{-243}:\\ \;\;\;\;x \cdot t\\ \mathbf{elif}\;z \leq 2.45 \cdot 10^{-203}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 2.05 \cdot 10^{-184}:\\ \;\;\;\;x \cdot t\\ \mathbf{elif}\;z \leq 21500 \lor \neg \left(z \leq 1.05 \cdot 10^{+130}\right) \land z \leq 8.5 \cdot 10^{+179}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error58.43%
Cost1512
\[\begin{array}{l} t_1 := 2 \cdot \left(x \cdot z\right)\\ \mathbf{if}\;t \leq -1.06 \cdot 10^{-47}:\\ \;\;\;\;x \cdot t\\ \mathbf{elif}\;t \leq -7.5 \cdot 10^{-178}:\\ \;\;\;\;y \cdot 5\\ \mathbf{elif}\;t \leq -8.2 \cdot 10^{-217}:\\ \;\;\;\;y \cdot \left(x \cdot 2\right)\\ \mathbf{elif}\;t \leq -2.6 \cdot 10^{-229}:\\ \;\;\;\;y \cdot 5\\ \mathbf{elif}\;t \leq -2.15 \cdot 10^{-281}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.45 \cdot 10^{-128}:\\ \;\;\;\;y \cdot 5\\ \mathbf{elif}\;t \leq 2.2 \cdot 10^{-44}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 4.8 \cdot 10^{-12}:\\ \;\;\;\;y \cdot 5\\ \mathbf{elif}\;t \leq 1.98 \cdot 10^{+59}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 3.5 \cdot 10^{+79}:\\ \;\;\;\;y \cdot 5\\ \mathbf{else}:\\ \;\;\;\;x \cdot t\\ \end{array} \]
Alternative 3
Error14.96%
Cost1364
\[\begin{array}{l} t_1 := 2 \cdot \left(y + z\right)\\ t_2 := x \cdot \left(t_1 + t\right)\\ t_3 := x \cdot t + y \cdot 5\\ t_4 := y \cdot 5 + x \cdot t_1\\ \mathbf{if}\;t \leq -4.7 \cdot 10^{+52}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t \leq -1.06 \cdot 10^{-47}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 9000000000:\\ \;\;\;\;t_4\\ \mathbf{elif}\;t \leq 1.62 \cdot 10^{+62}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 1.2 \cdot 10^{+101}:\\ \;\;\;\;t_4\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 4
Error57.94%
Cost1248
\[\begin{array}{l} t_1 := 2 \cdot \left(x \cdot z\right)\\ \mathbf{if}\;t \leq -9.2 \cdot 10^{-48}:\\ \;\;\;\;x \cdot t\\ \mathbf{elif}\;t \leq -3 \cdot 10^{-229}:\\ \;\;\;\;y \cdot 5\\ \mathbf{elif}\;t \leq -1.5 \cdot 10^{-281}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 2.1 \cdot 10^{-131}:\\ \;\;\;\;y \cdot 5\\ \mathbf{elif}\;t \leq 2.6 \cdot 10^{-44}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 4.5 \cdot 10^{-11}:\\ \;\;\;\;y \cdot 5\\ \mathbf{elif}\;t \leq 1.9 \cdot 10^{+57}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 3.7 \cdot 10^{+79}:\\ \;\;\;\;y \cdot 5\\ \mathbf{else}:\\ \;\;\;\;x \cdot t\\ \end{array} \]
Alternative 5
Error23.8%
Cost978
\[\begin{array}{l} \mathbf{if}\;y \leq -7.8 \cdot 10^{-7} \lor \neg \left(y \leq 7.3 \cdot 10^{-87}\right) \land \left(y \leq 6 \cdot 10^{-8} \lor \neg \left(y \leq 8.5 \cdot 10^{+37}\right)\right):\\ \;\;\;\;y \cdot \left(5 + x \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(t + 2 \cdot z\right)\\ \end{array} \]
Alternative 6
Error22.72%
Cost976
\[\begin{array}{l} t_1 := x \cdot \left(t + 2 \cdot z\right)\\ t_2 := y \cdot \left(5 + x \cdot 2\right)\\ \mathbf{if}\;y \leq -3.2 \cdot 10^{-6}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 9.8 \cdot 10^{-88}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.25 \cdot 10^{-7}:\\ \;\;\;\;x \cdot t + y \cdot 5\\ \mathbf{elif}\;y \leq 8.5 \cdot 10^{+37}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 7
Error0.13%
Cost960
\[x \cdot \left(t + \left(y + \left(z + \left(y + z\right)\right)\right)\right) + y \cdot 5 \]
Alternative 8
Error0.14%
Cost960
\[x \cdot \left(t + 2 \cdot z\right) + y \cdot \left(5 + x \cdot 2\right) \]
Alternative 9
Error40.51%
Cost844
\[\begin{array}{l} t_1 := \left(y + z\right) \cdot \left(x \cdot 2\right)\\ \mathbf{if}\;x \leq -2.5 \cdot 10^{-12}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.26 \cdot 10^{-26}:\\ \;\;\;\;y \cdot 5\\ \mathbf{elif}\;x \leq 6800000000:\\ \;\;\;\;x \cdot t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error15.96%
Cost841
\[\begin{array}{l} \mathbf{if}\;x \leq -1.1 \cdot 10^{-8} \lor \neg \left(x \leq 1.5 \cdot 10^{-26}\right):\\ \;\;\;\;x \cdot \left(2 \cdot \left(y + z\right) + t\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot t + y \cdot 5\\ \end{array} \]
Alternative 11
Error50.87%
Cost721
\[\begin{array}{l} \mathbf{if}\;y \leq -9 \cdot 10^{-70}:\\ \;\;\;\;y \cdot 5\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{-108} \lor \neg \left(y \leq 16\right) \land y \leq 2.25 \cdot 10^{+31}:\\ \;\;\;\;x \cdot t\\ \mathbf{else}:\\ \;\;\;\;y \cdot 5\\ \end{array} \]
Alternative 12
Error60.7%
Cost192
\[y \cdot 5 \]

Error

Reproduce?

herbie shell --seed 2023088 
(FPCore (x y z t)
  :name "Graphics.Rendering.Plot.Render.Plot.Legend:renderLegendOutside from plot-0.2.3.4, B"
  :precision binary64
  (+ (* x (+ (+ (+ (+ y z) z) y) t)) (* y 5.0)))