Average Error: 0.0 → 0.0
Time: 5.2s
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, 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
Error31.5
Cost1360
\[\begin{array}{l} t_0 := 1 - z \leq 1\\ t_1 := \left(1 - z\right) \cdot y\\ \mathbf{if}\;t_0:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_0:\\ \;\;\;\;y + x\\ \mathbf{elif}\;1 - z \leq 10^{+41}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;1 - z \leq 2 \cdot 10^{+75}:\\ \;\;\;\;x \cdot \left(-z\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error13.7
Cost980
\[\begin{array}{l} t_0 := \left(1 - z\right) \cdot x\\ t_1 := \left(1 - z\right) \cdot y\\ \mathbf{if}\;x \leq -250000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -1.6 \cdot 10^{-85}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -6 \cdot 10^{-114}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -3.8 \cdot 10^{-132}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -8.2 \cdot 10^{-185}:\\ \;\;\;\;y + x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Error13.7
Cost980
\[\begin{array}{l} t_0 := \left(1 - z\right) \cdot y\\ \mathbf{if}\;x \leq -32000000:\\ \;\;\;\;\left(1 - z\right) \cdot x\\ \mathbf{elif}\;x \leq -3.2 \cdot 10^{-90}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -4.2 \cdot 10^{-114}:\\ \;\;\;\;x - z \cdot x\\ \mathbf{elif}\;x \leq -4.2 \cdot 10^{-133}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -8.2 \cdot 10^{-185}:\\ \;\;\;\;y + x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error13.7
Cost980
\[\begin{array}{l} t_0 := \left(1 - z\right) \cdot y\\ \mathbf{if}\;x \leq -420000:\\ \;\;\;\;\left(1 - z\right) \cdot x\\ \mathbf{elif}\;x \leq -1.5 \cdot 10^{-89}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -3.2 \cdot 10^{-113}:\\ \;\;\;\;x - z \cdot x\\ \mathbf{elif}\;x \leq -7.8 \cdot 10^{-132}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -4.2 \cdot 10^{-185}:\\ \;\;\;\;y + x\\ \mathbf{else}:\\ \;\;\;\;y - z \cdot y\\ \end{array} \]
Alternative 5
Error13.2
Cost784
\[\begin{array}{l} t_0 := z \cdot \left(-y\right)\\ \mathbf{if}\;z \leq -1.8 \cdot 10^{+75}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -8.8 \cdot 10^{+41}:\\ \;\;\;\;x \cdot \left(-z\right)\\ \mathbf{elif}\;z \leq -190:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;y + x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error0.0
Cost704
\[\left(1 - z\right) \cdot x + \left(1 - z\right) \cdot y \]
Alternative 7
Error1.6
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 8
Error13.2
Cost520
\[\begin{array}{l} t_0 := z \cdot \left(-y\right)\\ \mathbf{if}\;z \leq -165:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;y + x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 9
Error32.0
Cost460
\[\begin{array}{l} \mathbf{if}\;x \leq -19000000000000:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -1.35 \cdot 10^{-90}:\\ \;\;\;\;y\\ \mathbf{elif}\;x \leq -3.5 \cdot 10^{-114}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]
Alternative 10
Error0.0
Cost448
\[\left(1 - z\right) \cdot \left(y + x\right) \]
Alternative 11
Error24.2
Cost192
\[y + x \]
Alternative 12
Error43.6
Cost64
\[x \]

Error

Reproduce

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