?

Average Error: 0.1 → 0.0
Time: 1.3min
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(y, x, z \cdot \left(x + 5\right)\right) \]
Alternative 2
Error24.6
Cost720
\[\begin{array}{l} \mathbf{if}\;x \leq -1 \cdot 10^{-45}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;x \leq 5.4 \cdot 10^{-13}:\\ \;\;\;\;5 \cdot z\\ \mathbf{elif}\;x \leq 1.65 \cdot 10^{+102}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;x \leq 5.9 \cdot 10^{+147}:\\ \;\;\;\;z \cdot x\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 3
Error16.8
Cost584
\[\begin{array}{l} t_0 := z \cdot \left(x - -5\right)\\ \mathbf{if}\;z \leq -5.6 \cdot 10^{-117}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 18:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error12.7
Cost584
\[\begin{array}{l} t_0 := \left(y + z\right) \cdot x\\ \mathbf{if}\;x \leq -3.8 \cdot 10^{-9}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1250000000:\\ \;\;\;\;z \cdot \left(x - -5\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error0.1
Cost576
\[x \cdot \left(y + z\right) + z \cdot 5 \]
Alternative 6
Error24.7
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -1.2 \cdot 10^{-45}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;x \leq 2.05 \cdot 10^{-7}:\\ \;\;\;\;5 \cdot z\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 7
Error35.4
Cost192
\[5 \cdot z \]

Error

Reproduce?

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