Average Error: 0.1 → 0.1
Time: 6.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.1

    \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(x, y, z\right), y, t\right)} \]
    Proof
    (fma.f64 (fma.f64 x y z) y t): 0 points increase in error, 0 points decrease in error
    (fma.f64 (Rewrite<= fma-def_binary64 (+.f64 (*.f64 x y) z)) y t): 1 points increase in error, 0 points decrease in error
    (Rewrite<= fma-def_binary64 (+.f64 (*.f64 (+.f64 (*.f64 x y) z) y) t)): 1 points increase in error, 0 points decrease in error
  3. Final simplification0.1

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

Alternatives

Alternative 1
Error11.8
Cost976
\[\begin{array}{l} t_1 := t + y \cdot z\\ t_2 := y \cdot \left(z + x \cdot y\right)\\ \mathbf{if}\;t \leq -3.9 \cdot 10^{-111}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.45 \cdot 10^{-254}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq 6.6 \cdot 10^{-204}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 1.65 \cdot 10^{-65}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error5.8
Cost976
\[\begin{array}{l} t_1 := t + y \cdot z\\ \mathbf{if}\;z \leq -8 \cdot 10^{+164}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -1.8 \cdot 10^{+127}:\\ \;\;\;\;y \cdot \left(z + x \cdot y\right)\\ \mathbf{elif}\;z \leq -1.5 \cdot 10^{+15}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 6.2 \cdot 10^{-75}:\\ \;\;\;\;t + y \cdot \left(x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error0.1
Cost576
\[t + y \cdot \left(z + x \cdot y\right) \]
Alternative 4
Error25.6
Cost456
\[\begin{array}{l} \mathbf{if}\;t \leq -4.4 \cdot 10^{-112}:\\ \;\;\;\;t\\ \mathbf{elif}\;t \leq 5.5 \cdot 10^{-61}:\\ \;\;\;\;y \cdot z\\ \mathbf{else}:\\ \;\;\;\;t\\ \end{array} \]
Alternative 5
Error12.7
Cost452
\[\begin{array}{l} \mathbf{if}\;y \leq -3.6 \cdot 10^{+127}:\\ \;\;\;\;y \cdot \left(x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;t + y \cdot z\\ \end{array} \]
Alternative 6
Error29.8
Cost64
\[t \]

Error

Reproduce

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