Average Error: 0.0 → 0.0
Time: 3.7s
Precision: binary64
Cost: 6912
\[x + y \cdot \left(z - x\right) \]
\[x + \mathsf{fma}\left(y, -x, y \cdot z\right) \]
(FPCore (x y z) :precision binary64 (+ x (* y (- z x))))
(FPCore (x y z) :precision binary64 (+ x (fma y (- x) (* y z))))
double code(double x, double y, double z) {
	return x + (y * (z - x));
}
double code(double x, double y, double z) {
	return x + fma(y, -x, (y * z));
}
function code(x, y, z)
	return Float64(x + Float64(y * Float64(z - x)))
end
function code(x, y, z)
	return Float64(x + fma(y, Float64(-x), Float64(y * z)))
end
code[x_, y_, z_] := N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := N[(x + N[(y * (-x) + N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x + y \cdot \left(z - x\right)
x + \mathsf{fma}\left(y, -x, y \cdot z\right)

Error

Derivation

  1. Initial program 0.0

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

    \[\leadsto x + \color{blue}{\left(z \cdot y + \left(-x\right) \cdot y\right)} \]
  3. Applied egg-rr0.0

    \[\leadsto x + \color{blue}{\left(z \cdot y - y \cdot x\right)} \]
  4. Taylor expanded in z around 0 0.0

    \[\leadsto x + \color{blue}{\left(y \cdot z + -1 \cdot \left(y \cdot x\right)\right)} \]
  5. Simplified0.0

    \[\leadsto x + \color{blue}{\mathsf{fma}\left(y, -x, y \cdot z\right)} \]
    Proof
    (+.f64 x (fma.f64 y (neg.f64 x) (*.f64 y z))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (fma.f64 y (neg.f64 x) (Rewrite=> *-commutative_binary64 (*.f64 z y)))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (Rewrite<= fma-def_binary64 (+.f64 (*.f64 y (neg.f64 x)) (*.f64 z y)))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (+.f64 (Rewrite=> distribute-rgt-neg-out_binary64 (neg.f64 (*.f64 y x))) (*.f64 z y))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (+.f64 (Rewrite<= mul-1-neg_binary64 (*.f64 -1 (*.f64 y x))) (*.f64 z y))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (+.f64 (*.f64 -1 (*.f64 y x)) (Rewrite<= *-commutative_binary64 (*.f64 y z)))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (Rewrite<= +-commutative_binary64 (+.f64 (*.f64 y z) (*.f64 -1 (*.f64 y x))))): 0 points increase in error, 0 points decrease in error
  6. Final simplification0.0

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

Alternatives

Alternative 1
Error12.3
Cost717
\[\begin{array}{l} \mathbf{if}\;y \leq -3500 \lor \neg \left(y \leq 3.3 \cdot 10^{+173}\right) \land y \leq 1.28 \cdot 10^{+256}:\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot z\\ \end{array} \]
Alternative 2
Error7.3
Cost585
\[\begin{array}{l} \mathbf{if}\;z \leq -2.3 \cdot 10^{-75} \lor \neg \left(z \leq 1.1 \cdot 10^{-50}\right):\\ \;\;\;\;x + y \cdot z\\ \mathbf{else}:\\ \;\;\;\;x - x \cdot y\\ \end{array} \]
Alternative 3
Error0.0
Cost576
\[x + \left(y \cdot z - x \cdot y\right) \]
Alternative 4
Error24.5
Cost521
\[\begin{array}{l} \mathbf{if}\;y \leq -1 \lor \neg \left(y \leq 7500000000000\right):\\ \;\;\;\;x \cdot \left(-y\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error0.0
Cost448
\[x + y \cdot \left(z - x\right) \]
Alternative 6
Error34.9
Cost64
\[x \]

Error

Reproduce

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