?

Average Error: 0.1% → 0.09%
Time: 9.1s
Precision: binary64
Cost: 13120

?

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

Error?

Derivation?

  1. Initial program 0.1

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

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

    [Start]0.1

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

    fma-def [=>]0.09

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

    fma-def [=>]0.09

    \[ \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(x, y, z\right)}, y, t\right) \]
  3. Final simplification0.09

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

Alternatives

Alternative 1
Error42.34%
Cost716
\[\begin{array}{l} t_1 := y \cdot \left(x \cdot y\right)\\ \mathbf{if}\;y \leq -3.5 \cdot 10^{-57}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 2.3 \cdot 10^{-80}:\\ \;\;\;\;t\\ \mathbf{elif}\;y \leq 3900:\\ \;\;\;\;y \cdot z\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error16.1%
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -5 \cdot 10^{-57} \lor \neg \left(y \leq 12.2\right):\\ \;\;\;\;y \cdot \left(z + x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;t + y \cdot z\\ \end{array} \]
Alternative 3
Error7.81%
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -3.7 \cdot 10^{-53} \lor \neg \left(z \leq 95000000000000\right):\\ \;\;\;\;t + y \cdot z\\ \mathbf{else}:\\ \;\;\;\;t + y \cdot \left(x \cdot y\right)\\ \end{array} \]
Alternative 4
Error21.21%
Cost585
\[\begin{array}{l} \mathbf{if}\;y \leq -1700000 \lor \neg \left(y \leq 1.9 \cdot 10^{+153}\right):\\ \;\;\;\;y \cdot \left(x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;t + y \cdot z\\ \end{array} \]
Alternative 5
Error0.1%
Cost576
\[t + y \cdot \left(z + x \cdot y\right) \]
Alternative 6
Error40.33%
Cost456
\[\begin{array}{l} \mathbf{if}\;z \leq -2.1 \cdot 10^{+85}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq 2 \cdot 10^{+141}:\\ \;\;\;\;t\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \]
Alternative 7
Error46.1%
Cost64
\[t \]

Error

Reproduce?

herbie shell --seed 2023090 
(FPCore (x y z t)
  :name "Language.Haskell.HsColour.ColourHighlight:unbase from hscolour-1.23"
  :precision binary64
  (+ (* (+ (* x y) z) y) t))