Average Error: 0.0 → 0.0
Time: 4.0s
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
    (fma.f64 y (-.f64 z x) x): 0 points increase in error, 0 points decrease in error
    (Rewrite<= fma-def_binary64 (+.f64 (*.f64 y (-.f64 z x)) x)): 2 points increase in error, 0 points decrease in error
    (Rewrite<= +-commutative_binary64 (+.f64 x (*.f64 y (-.f64 z x)))): 0 points increase in error, 0 points decrease in error
  3. Final simplification0.0

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

Alternatives

Alternative 1
Error23.8
Cost1180
\[\begin{array}{l} t_0 := y \cdot \left(-x\right)\\ \mathbf{if}\;y \leq -1.7 \cdot 10^{+76}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -7.162858245731441 \cdot 10^{-51}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 5.855397166105847 \cdot 10^{-120}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 7.911858793683972 \cdot 10^{-110}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 2.116969914806696 \cdot 10^{-16}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 4.8 \cdot 10^{+55}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 8.2 \cdot 10^{+173}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \]
Alternative 2
Error23.5
Cost720
\[\begin{array}{l} \mathbf{if}\;y \leq -7.162858245731441 \cdot 10^{-51}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 5.855397166105847 \cdot 10^{-120}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 7.911858793683972 \cdot 10^{-110}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 2.116969914806696 \cdot 10^{-16}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \]
Alternative 3
Error12.1
Cost652
\[\begin{array}{l} t_0 := y \cdot \left(-x\right)\\ \mathbf{if}\;y \leq -1.7 \cdot 10^{+76}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 4.8 \cdot 10^{+55}:\\ \;\;\;\;x + y \cdot z\\ \mathbf{elif}\;y \leq 8.2 \cdot 10^{+173}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \]
Alternative 4
Error7.1
Cost584
\[\begin{array}{l} t_0 := x + y \cdot z\\ \mathbf{if}\;z \leq -1.1912780477687877 \cdot 10^{-98}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 3.6007524060720553 \cdot 10^{-67}:\\ \;\;\;\;x \cdot \left(1 - y\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error1.0
Cost584
\[\begin{array}{l} t_0 := y \cdot \left(z - x\right)\\ \mathbf{if}\;y \leq -27470424656.305458:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 0.05060558891981524:\\ \;\;\;\;x + y \cdot z\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error0.0
Cost448
\[x + y \cdot \left(z - x\right) \]
Alternative 7
Error35.2
Cost64
\[x \]

Error

Reproduce

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