Average Error: 0.0 → 0.0
Time: 6.2s
Precision: binary64
Cost: 6848
\[x + y \cdot \left(z - x\right) \]
\[\mathsf{fma}\left(y, z, x - y \cdot x\right) \]
(FPCore (x y z) :precision binary64 (+ x (* y (- z x))))
(FPCore (x y z) :precision binary64 (fma y z (- x (* y 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 - (y * x)));
}
function code(x, y, z)
	return Float64(x + Float64(y * Float64(z - x)))
end
function code(x, y, z)
	return fma(y, z, Float64(x - Float64(y * x)))
end
code[x_, y_, z_] := N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := N[(y * z + N[(x - N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
x + y \cdot \left(z - x\right)
\mathsf{fma}\left(y, z, x - y \cdot x\right)

Error

Derivation

  1. Initial program 0.0

    \[x + y \cdot \left(z - x\right) \]
  2. Taylor expanded in x around 0 0.0

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(y, z, \left(1 + \left(-y\right)\right) \cdot x\right)} \]
    Proof
    (fma.f64 y z (*.f64 (+.f64 1 (neg.f64 y)) x)): 0 points increase in error, 0 points decrease in error
    (fma.f64 y z (*.f64 (+.f64 1 (Rewrite<= mul-1-neg_binary64 (*.f64 -1 y))) x)): 0 points increase in error, 0 points decrease in error
    (Rewrite<= fma-def_binary64 (+.f64 (*.f64 y z) (*.f64 (+.f64 1 (*.f64 -1 y)) x))): 8 points increase in error, 0 points decrease in error
  4. Taylor expanded in y around 0 0.0

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

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

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

Alternatives

Alternative 1
Error0.0
Cost6720
\[\mathsf{fma}\left(y, z - x, x\right) \]
Alternative 2
Error24.5
Cost1180
\[\begin{array}{l} t_0 := y \cdot \left(-x\right)\\ \mathbf{if}\;y \leq -8.6 \cdot 10^{+48}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -1.45 \cdot 10^{-81}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 2.5 \cdot 10^{-135}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 5 \cdot 10^{-124}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 1.02 \cdot 10^{-14}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 2 \cdot 10^{+115}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 4.2 \cdot 10^{+246}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \]
Alternative 3
Error13.1
Cost848
\[\begin{array}{l} t_0 := y \cdot \left(z - x\right)\\ \mathbf{if}\;y \leq -1.05 \cdot 10^{-81}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2.7 \cdot 10^{-135}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 4.2 \cdot 10^{-124}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 1.9 \cdot 10^{-14}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error13.3
Cost848
\[\begin{array}{l} t_0 := y \cdot \left(z - x\right)\\ \mathbf{if}\;y \leq -1.45 \cdot 10^{-81}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2.1 \cdot 10^{-135}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 2.2 \cdot 10^{-116}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 2.4 \cdot 10^{-13}:\\ \;\;\;\;x \cdot \left(1 - y\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error24.8
Cost720
\[\begin{array}{l} \mathbf{if}\;y \leq -1.8 \cdot 10^{-81}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 2.7 \cdot 10^{-135}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 4.5 \cdot 10^{-124}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 8.2 \cdot 10^{-14}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \]
Alternative 6
Error1.0
Cost584
\[\begin{array}{l} t_0 := y \cdot \left(z - x\right)\\ \mathbf{if}\;y \leq -1:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.45 \cdot 10^{-12}:\\ \;\;\;\;x + y \cdot z\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error0.0
Cost448
\[x + y \cdot \left(z - x\right) \]
Alternative 8
Error35.2
Cost64
\[x \]

Error

Reproduce

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