?

Average Accuracy: 100.0% → 100.0%
Time: 5.9s
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 100.0%

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

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

    [Start]100.0

    \[ \left(x + y\right) \cdot \left(1 - z\right) \]

    *-commutative [=>]100.0

    \[ \color{blue}{\left(1 - z\right) \cdot \left(x + y\right)} \]

    +-commutative [=>]100.0

    \[ \left(1 - z\right) \cdot \color{blue}{\left(y + x\right)} \]

    distribute-lft-in [=>]100.0

    \[ \color{blue}{\left(1 - z\right) \cdot y + \left(1 - z\right) \cdot x} \]

    fma-def [=>]100.0

    \[ \color{blue}{\mathsf{fma}\left(1 - z, y, \left(1 - z\right) \cdot x\right)} \]
  3. Final simplification100.0%

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

Alternatives

Alternative 1
Accuracy80.2%
Cost1881
\[\begin{array}{l} t_0 := z \cdot \left(-x\right)\\ \mathbf{if}\;1 - z \leq -1 \cdot 10^{+219}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;1 - z \leq -5 \cdot 10^{+189}:\\ \;\;\;\;z \cdot \left(-y\right)\\ \mathbf{elif}\;1 - z \leq -500000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;1 - z \leq 1:\\ \;\;\;\;y + x\\ \mathbf{elif}\;1 - z \leq 5 \cdot 10^{+163} \lor \neg \left(1 - z \leq 2 \cdot 10^{+200}\right):\\ \;\;\;\;\left(1 - z\right) \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Accuracy80.0%
Cost785
\[\begin{array}{l} t_0 := z \cdot \left(-y\right)\\ \mathbf{if}\;z \leq -8:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;y + x\\ \mathbf{elif}\;z \leq 3.5 \cdot 10^{+187} \lor \neg \left(z \leq 1.08 \cdot 10^{+215}\right):\\ \;\;\;\;z \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Accuracy100.0%
Cost704
\[\left(1 - z\right) \cdot x + \left(1 - z\right) \cdot y \]
Alternative 4
Accuracy97.3%
Cost649
\[\begin{array}{l} \mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\ \;\;\;\;z \cdot \left(\left(-x\right) - y\right)\\ \mathbf{else}:\\ \;\;\;\;y + x\\ \end{array} \]
Alternative 5
Accuracy79.3%
Cost521
\[\begin{array}{l} \mathbf{if}\;z \leq -2800000000 \lor \neg \left(z \leq 1\right):\\ \;\;\;\;z \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;y + x\\ \end{array} \]
Alternative 6
Accuracy51.2%
Cost460
\[\begin{array}{l} \mathbf{if}\;y \leq 1.32 \cdot 10^{-86}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 25000:\\ \;\;\;\;y\\ \mathbf{elif}\;y \leq 2.8 \cdot 10^{+23}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y\\ \end{array} \]
Alternative 7
Accuracy80.6%
Cost452
\[\begin{array}{l} \mathbf{if}\;x \leq -1.2 \cdot 10^{-103}:\\ \;\;\;\;x - z \cdot x\\ \mathbf{else}:\\ \;\;\;\;\left(1 - z\right) \cdot y\\ \end{array} \]
Alternative 8
Accuracy100.0%
Cost448
\[\left(1 - z\right) \cdot \left(y + x\right) \]
Alternative 9
Accuracy62.7%
Cost192
\[y + x \]
Alternative 10
Accuracy31.6%
Cost64
\[x \]

Error

Reproduce?

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