?

Average Accuracy: 100.0% → 100.0%
Time: 4.3s
Precision: binary64
Cost: 6720

?

\[x + y \cdot \left(z - x\right) \]
\[\mathsf{fma}\left(y, z - x, x\right) \]
(FPCore (x y z) :precision binary64 (+ x (* y (- z x))))
(FPCore (x y z) :precision binary64 (fma y (- z x) x))
double code(double x, double y, double z) {
	return x + (y * (z - x));
}
double code(double x, double y, double z) {
	return fma(y, (z - x), x);
}
function code(x, y, z)
	return Float64(x + Float64(y * Float64(z - x)))
end
function code(x, y, z)
	return fma(y, Float64(z - x), x)
end
code[x_, y_, z_] := N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := N[(y * N[(z - x), $MachinePrecision] + x), $MachinePrecision]
x + y \cdot \left(z - x\right)
\mathsf{fma}\left(y, z - x, x\right)

Error?

Derivation?

  1. Initial program 100.0%

    \[x + y \cdot \left(z - x\right) \]
  2. Simplified100.0%

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

    [Start]100.0

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

    +-commutative [=>]100.0

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

    fma-def [=>]100.0

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

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

Alternatives

Alternative 1
Accuracy62.6%
Cost852
\[\begin{array}{l} \mathbf{if}\;y \leq -1.9 \cdot 10^{+181}:\\ \;\;\;\;y \cdot \left(-x\right)\\ \mathbf{elif}\;y \leq -7.5 \cdot 10^{-5}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq -2.25 \cdot 10^{-57}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -2.4 \cdot 10^{-76}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 10^{-9}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \]
Alternative 2
Accuracy80.7%
Cost850
\[\begin{array}{l} \mathbf{if}\;y \leq -0.00155 \lor \neg \left(y \leq -3.2 \cdot 10^{-57} \lor \neg \left(y \leq -9.2 \cdot 10^{-77}\right) \land y \leq 1.2\right):\\ \;\;\;\;y \cdot \left(z - x\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - y\right)\\ \end{array} \]
Alternative 3
Accuracy62.9%
Cost720
\[\begin{array}{l} \mathbf{if}\;y \leq -4.5 \cdot 10^{-5}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq -7.5 \cdot 10^{-57}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -1.55 \cdot 10^{-76}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 5.8 \cdot 10^{-7}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \]
Alternative 4
Accuracy74.8%
Cost585
\[\begin{array}{l} \mathbf{if}\;x \leq -1.5 \cdot 10^{-141} \lor \neg \left(x \leq 4.5 \cdot 10^{-152}\right):\\ \;\;\;\;x \cdot \left(1 - y\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \]
Alternative 5
Accuracy97.9%
Cost585
\[\begin{array}{l} \mathbf{if}\;y \leq -1.5 \cdot 10^{+28} \lor \neg \left(y \leq 1\right):\\ \;\;\;\;y \cdot \left(z - x\right)\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot z\\ \end{array} \]
Alternative 6
Accuracy100.0%
Cost448
\[x + y \cdot \left(z - x\right) \]
Alternative 7
Accuracy45.8%
Cost64
\[x \]

Error

Reproduce?

herbie shell --seed 2023137 
(FPCore (x y z)
  :name "SynthBasics:oscSampleBasedAux from YampaSynth-0.2"
  :precision binary64
  (+ x (* y (- z x))))