?

Average Error: 0.0 → 0.0
Time: 6.9s
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 0.0

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

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

    [Start]0.0

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

    +-commutative [=>]0.0

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

    fma-def [=>]0.0

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

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

Alternatives

Alternative 1
Error26.1
Cost1048
\[\begin{array}{l} t_0 := x \cdot \left(-y\right)\\ \mathbf{if}\;x \leq -1.8 \cdot 10^{+33}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -5.5 \cdot 10^{-112}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;x \leq -6.3 \cdot 10^{-139}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 4.6 \cdot 10^{-95}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;x \leq 3.2 \cdot 10^{+40}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2 \cdot 10^{+56}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Error15.8
Cost585
\[\begin{array}{l} \mathbf{if}\;x \leq -2.25 \cdot 10^{-139} \lor \neg \left(x \leq 4.2 \cdot 10^{-116}\right):\\ \;\;\;\;x \cdot \left(1 - y\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \]
Alternative 3
Error14.0
Cost585
\[\begin{array}{l} \mathbf{if}\;x \leq -1.8 \cdot 10^{+33} \lor \neg \left(x \leq 2.85 \cdot 10^{-95}\right):\\ \;\;\;\;x \cdot \left(1 - y\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(z - x\right)\\ \end{array} \]
Alternative 4
Error0.8
Cost585
\[\begin{array}{l} \mathbf{if}\;y \leq -400 \lor \neg \left(y \leq 0.044\right):\\ \;\;\;\;y \cdot \left(z - x\right)\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot z\\ \end{array} \]
Alternative 5
Error25.3
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -1.8 \cdot 10^{+33}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.75 \cdot 10^{-95}:\\ \;\;\;\;y \cdot z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Error0.0
Cost448
\[x + y \cdot \left(z - x\right) \]
Alternative 7
Error34.6
Cost64
\[x \]

Error

Reproduce?

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