Average Error: 0.0 → 0.0
Time: 2.9s
Precision: binary64
Cost: 6976
\[\left(x + y\right) \cdot \left(1 - z\right) \]
\[\mathsf{fma}\left(1 - z, y, \left(1 - z\right) \cdot x\right) \]
(FPCore (x y z) :precision binary64 (* (+ x y) (- 1.0 z)))
(FPCore (x y z) :precision binary64 (fma (- 1.0 z) y (* (- 1.0 z) x)))
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), y, ((1.0 - z) * x));
}
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), y, Float64(Float64(1.0 - z) * x))
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] * y + N[(N[(1.0 - z), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]
\left(x + y\right) \cdot \left(1 - z\right)
\mathsf{fma}\left(1 - z, y, \left(1 - z\right) \cdot x\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, y, \left(1 - z\right) \cdot x\right)} \]
  4. Final simplification0.0

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

Alternatives

Alternative 1
Error12.6
Cost1036
\[\begin{array}{l} t_0 := z \cdot \left(-x\right)\\ \mathbf{if}\;1 - z \leq -4 \cdot 10^{+81}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;1 - z \leq -2:\\ \;\;\;\;\left(1 - z\right) \cdot y\\ \mathbf{elif}\;1 - z \leq 2:\\ \;\;\;\;y + x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error24.7
Cost716
\[\begin{array}{l} t_0 := \left(1 - z\right) \cdot x\\ t_1 := \left(1 - z\right) \cdot y\\ \mathbf{if}\;x \leq -1.15 \cdot 10^{-42}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -9.5 \cdot 10^{-79}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -3.5 \cdot 10^{-132}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error0.0
Cost704
\[\left(1 - z\right) \cdot x + \left(1 - z\right) \cdot y \]
Alternative 4
Error1.7
Cost648
\[\begin{array}{l} t_0 := z \cdot \left(\left(-x\right) - y\right)\\ \mathbf{if}\;z \leq -1:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;y + x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error12.8
Cost520
\[\begin{array}{l} t_0 := z \cdot \left(-x\right)\\ \mathbf{if}\;z \leq -27.5:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;y + x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error0.0
Cost448
\[\left(1 - z\right) \cdot \left(y + x\right) \]
Alternative 7
Error23.5
Cost192
\[y + x \]

Error

Reproduce

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