Average Error: 0.0 → 0.0
Time: 5.3s
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.8
Cost980
\[\begin{array}{l} t_0 := x - z \cdot x\\ t_1 := z \cdot \left(-y\right)\\ \mathbf{if}\;z \leq -4 \cdot 10^{+137}:\\ \;\;\;\;x \cdot \left(-z\right)\\ \mathbf{elif}\;z \leq -3.8 \cdot 10^{+48}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -535.2718147454776:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 7.266665387251684 \cdot 10^{-17}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;z \leq 1.02 \cdot 10^{+128}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error13.1
Cost916
\[\begin{array}{l} t_0 := x \cdot \left(-z\right)\\ t_1 := z \cdot \left(-y\right)\\ \mathbf{if}\;z \leq -4 \cdot 10^{+137}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -3.8 \cdot 10^{+48}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -535.2718147454776:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.5838275979479375 \cdot 10^{-7}:\\ \;\;\;\;x + y\\ \mathbf{elif}\;z \leq 1.02 \cdot 10^{+128}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error1.8
Cost648
\[\begin{array}{l} t_0 := z \cdot \left(\left(-y\right) - x\right)\\ \mathbf{if}\;z \leq -535.2718147454776:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.5838275979479375 \cdot 10^{-7}:\\ \;\;\;\;x + y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error12.9
Cost520
\[\begin{array}{l} t_0 := x \cdot \left(-z\right)\\ \mathbf{if}\;z \leq -535.2718147454776:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.5838275979479375 \cdot 10^{-7}:\\ \;\;\;\;x + y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error0.0
Cost448
\[\left(1 - z\right) \cdot \left(x + y\right) \]
Alternative 6
Error31.4
Cost196
\[\begin{array}{l} \mathbf{if}\;y \leq 6.624819284044066 \cdot 10^{+29}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]
Alternative 7
Error23.6
Cost192
\[x + y \]
Alternative 8
Error42.9
Cost64
\[x \]

Error

Reproduce

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