Average Error: 0.1 → 0.0
Time: 7.2s
Precision: binary64
Cost: 6848
\[x \cdot \left(y + z\right) + z \cdot 5 \]
\[\mathsf{fma}\left(z, 5, x \cdot \left(y + z\right)\right) \]
(FPCore (x y z) :precision binary64 (+ (* x (+ y z)) (* z 5.0)))
(FPCore (x y z) :precision binary64 (fma z 5.0 (* x (+ y z))))
double code(double x, double y, double z) {
	return (x * (y + z)) + (z * 5.0);
}
double code(double x, double y, double z) {
	return fma(z, 5.0, (x * (y + z)));
}
function code(x, y, z)
	return Float64(Float64(x * Float64(y + z)) + Float64(z * 5.0))
end
function code(x, y, z)
	return fma(z, 5.0, Float64(x * Float64(y + z)))
end
code[x_, y_, z_] := N[(N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision] + N[(z * 5.0), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := N[(z * 5.0 + N[(x * N[(y + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x \cdot \left(y + z\right) + z \cdot 5
\mathsf{fma}\left(z, 5, x \cdot \left(y + z\right)\right)

Error

Target

Original0.1
Target0.1
Herbie0.0
\[\left(x + 5\right) \cdot z + x \cdot y \]

Derivation

  1. Initial program 0.1

    \[x \cdot \left(y + z\right) + z \cdot 5 \]
  2. Applied egg-rr0.0

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

Alternatives

Alternative 1
Error0.1
Cost6848
\[\mathsf{fma}\left(x, y + z, z \cdot 5\right) \]
Alternative 2
Error23.3
Cost852
\[\begin{array}{l} \mathbf{if}\;x \leq -4.6 \cdot 10^{+176}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;x \leq -1.22 \cdot 10^{-20}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;x \leq 6.8 \cdot 10^{-12}:\\ \;\;\;\;5 \cdot z\\ \mathbf{elif}\;x \leq 2.5 \cdot 10^{+30}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;x \leq 1.95 \cdot 10^{+53}:\\ \;\;\;\;z \cdot x\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 3
Error16.3
Cost584
\[\begin{array}{l} t_0 := z \cdot \left(5 + x\right)\\ \mathbf{if}\;z \leq -7.2 \cdot 10^{-69}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 3 \cdot 10^{-163}:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error12.2
Cost584
\[\begin{array}{l} t_0 := \left(y + z\right) \cdot x\\ \mathbf{if}\;x \leq -5.2:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 34000000000000:\\ \;\;\;\;z \cdot \left(5 + x\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error0.1
Cost576
\[x \cdot \left(y + z\right) + z \cdot 5 \]
Alternative 6
Error23.2
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -1.08 \cdot 10^{-21}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;x \leq 2.6 \cdot 10^{-12}:\\ \;\;\;\;5 \cdot z\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 7
Error34.4
Cost192
\[5 \cdot z \]

Error

Reproduce

herbie shell --seed 2023010 
(FPCore (x y z)
  :name "Graphics.Rendering.Plot.Render.Plot.Legend:renderLegendOutside from plot-0.2.3.4, C"
  :precision binary64

  :herbie-target
  (+ (* (+ x 5.0) z) (* x y))

  (+ (* x (+ y z)) (* z 5.0)))