Average Error: 0.0 → 0.0
Time: 5.5s
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
Error12.1
Cost980
\[\begin{array}{l} t_0 := \left(1 - z\right) \cdot x\\ t_1 := y - z \cdot y\\ \mathbf{if}\;x \leq -7.833032822298084 \cdot 10^{-109}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -1.2704406597286932 \cdot 10^{-127}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -9.468226781781555 \cdot 10^{-165}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -9.126119923670348 \cdot 10^{-187}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;x \leq -6.195344930664293 \cdot 10^{-192}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error12.8
Cost916
\[\begin{array}{l} t_0 := x \cdot \left(-z\right)\\ \mathbf{if}\;z \leq -15.303115969212687:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.583013194625646 \cdot 10^{-6}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;z \leq 5.5 \cdot 10^{+52}:\\ \;\;\;\;y - z \cdot y\\ \mathbf{elif}\;z \leq 1.5 \cdot 10^{+89}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 7.4 \cdot 10^{+160}:\\ \;\;\;\;z \cdot \left(-y\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error1.7
Cost904
\[\begin{array}{l} t_0 := z \cdot \left(\left(-y\right) - x\right)\\ \mathbf{if}\;1 - z \leq -20000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;1 - z \leq 2:\\ \;\;\;\;x + y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error13.0
Cost784
\[\begin{array}{l} t_0 := x \cdot \left(-z\right)\\ \mathbf{if}\;z \leq -15.303115969212687:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.583013194625646 \cdot 10^{-6}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;z \leq 1.5 \cdot 10^{+89}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 7.4 \cdot 10^{+160}:\\ \;\;\;\;z \cdot \left(-y\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error0.0
Cost704
\[\left(1 - z\right) \cdot y + \left(1 - z\right) \cdot x \]
Alternative 6
Error13.1
Cost520
\[\begin{array}{l} t_0 := z \cdot \left(-y\right)\\ \mathbf{if}\;z \leq -619957.0844106287:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.583013194625646 \cdot 10^{-6}:\\ \;\;\;\;x + y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error0.0
Cost448
\[\left(1 - z\right) \cdot \left(x + y\right) \]
Alternative 8
Error31.0
Cost196
\[\begin{array}{l} \mathbf{if}\;x \leq -2.0455290131678964 \cdot 10^{-163}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]
Alternative 9
Error23.6
Cost192
\[x + y \]
Alternative 10
Error42.8
Cost64
\[y \]

Error

Reproduce

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