Average Error: 0.0 → 0.0
Time: 3.8s
Precision: binary64
Cost: 6976
\[ \begin{array}{c}[x, y] = \mathsf{sort}([x, y])\\ \end{array} \]
\[\left(x + y\right) \cdot \left(1 - z\right) \]
\[\mathsf{fma}\left(1 - z, x, \left(1 - z\right) \cdot y\right) \]
(FPCore (x y z) :precision binary64 (* (+ x y) (- 1.0 z)))
(FPCore (x y z) :precision binary64 (fma (- 1.0 z) x (* (- 1.0 z) y)))
double code(double x, double y, double z) {
	return (x + y) * (1.0 - z);
}
double code(double x, double y, double z) {
	return fma((1.0 - z), x, ((1.0 - z) * y));
}
function code(x, y, z)
	return Float64(Float64(x + y) * Float64(1.0 - z))
end
function code(x, y, z)
	return fma(Float64(1.0 - z), x, Float64(Float64(1.0 - z) * y))
end
code[x_, y_, z_] := N[(N[(x + y), $MachinePrecision] * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := N[(N[(1.0 - z), $MachinePrecision] * x + N[(N[(1.0 - z), $MachinePrecision] * y), $MachinePrecision]), $MachinePrecision]
\left(x + y\right) \cdot \left(1 - z\right)
\mathsf{fma}\left(1 - z, x, \left(1 - z\right) \cdot y\right)

Error

Derivation

  1. Initial program 0.0

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

    \[\leadsto \color{blue}{\left(1 - z\right) \cdot y + \left(1 - z\right) \cdot x} \]
  3. Applied egg-rr0.0

    \[\leadsto \color{blue}{\mathsf{fma}\left(1 - z, x, \left(1 - z\right) \cdot y\right)} \]
  4. Final simplification0.0

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

Alternatives

Alternative 1
Error31.4
Cost1360
\[\begin{array}{l} t_0 := z \cdot \left(-x\right)\\ t_1 := 1 - z \leq 1\\ t_2 := \left(1 - z\right) \cdot y\\ \mathbf{if}\;1 - z \leq -2 \cdot 10^{+63}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;t_1:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1:\\ \;\;\;\;x + y\\ \mathbf{elif}\;1 - z \leq 2 \cdot 10^{+230}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error1.7
Cost904
\[\begin{array}{l} t_0 := z \cdot \left(\left(-x\right) - y\right)\\ \mathbf{if}\;1 - z \leq -1000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;1 - z \leq 2:\\ \;\;\;\;x + y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error13.0
Cost784
\[\begin{array}{l} t_0 := z \cdot \left(-x\right)\\ t_1 := y \cdot \left(-z\right)\\ \mathbf{if}\;z \leq -3.9 \cdot 10^{+233}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -82:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;x + y\\ \mathbf{elif}\;z \leq 7.2 \cdot 10^{+62}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error31.4
Cost724
\[\begin{array}{l} \mathbf{if}\;x \leq -2.25 \cdot 10^{-11}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -1.8 \cdot 10^{-32}:\\ \;\;\;\;y\\ \mathbf{elif}\;x \leq -1.65 \cdot 10^{-77}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -6.8 \cdot 10^{-162}:\\ \;\;\;\;y\\ \mathbf{elif}\;x \leq -5 \cdot 10^{-203}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]
Alternative 5
Error0.0
Cost704
\[\left(1 - z\right) \cdot y + \left(1 - z\right) \cdot x \]
Alternative 6
Error12.9
Cost520
\[\begin{array}{l} t_0 := y \cdot \left(-z\right)\\ \mathbf{if}\;z \leq -61:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;x + y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error0.0
Cost448
\[\left(1 - z\right) \cdot \left(x + y\right) \]
Alternative 8
Error23.9
Cost192
\[x + y \]
Alternative 9
Error43.5
Cost64
\[x \]

Error

Reproduce

herbie shell --seed 2022325 
(FPCore (x y z)
  :name "Optimisation.CirclePacking:place from circle-packing-0.1.0.4, H"
  :precision binary64
  (* (+ x y) (- 1.0 z)))