Average Error: 0.0 → 0.0
Time: 8.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)): 1 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
Error25.1
Cost1576
\[\begin{array}{l} t_0 := y \cdot \left(-x\right)\\ \mathbf{if}\;y \leq -4.5 \cdot 10^{+58}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq -241906161300961.78:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -2.932988695682121 \cdot 10^{-74}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 2.3772021743536337 \cdot 10^{-220}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 5.894651963428366 \cdot 10^{-210}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 2.173746397033535 \cdot 10^{-99}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.355473785437023 \cdot 10^{-57}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 7.702306877238973 \cdot 10^{-13}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 511715009402941:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 6.1 \cdot 10^{+206}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \]
Alternative 2
Error16.8
Cost1112
\[\begin{array}{l} t_0 := x - y \cdot x\\ \mathbf{if}\;x \leq -1.21152117622049 \cdot 10^{-123}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -9.368045642533995 \cdot 10^{-185}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;x \leq -2.851695269204857 \cdot 10^{-207}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.131852731387771 \cdot 10^{-68}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;x \leq 191298760491899500:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.899743910600573 \cdot 10^{+36}:\\ \;\;\;\;y \cdot z\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error16.8
Cost1112
\[\begin{array}{l} t_0 := x - y \cdot x\\ \mathbf{if}\;x \leq -1.21152117622049 \cdot 10^{-123}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -9.368045642533995 \cdot 10^{-185}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;x \leq -2.851695269204857 \cdot 10^{-207}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.131852731387771 \cdot 10^{-68}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;x \leq 191298760491899500:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.899743910600573 \cdot 10^{+36}:\\ \;\;\;\;y \cdot z\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - y\right)\\ \end{array} \]
Alternative 4
Error13.5
Cost1112
\[\begin{array}{l} t_0 := y \cdot \left(z - x\right)\\ \mathbf{if}\;y \leq -2.932988695682121 \cdot 10^{-74}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2.3772021743536337 \cdot 10^{-220}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 5.894651963428366 \cdot 10^{-210}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 2.173746397033535 \cdot 10^{-99}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.355473785437023 \cdot 10^{-57}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 7.702306877238973 \cdot 10^{-13}:\\ \;\;\;\;x - y \cdot x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error24.9
Cost984
\[\begin{array}{l} \mathbf{if}\;y \leq -2.932988695682121 \cdot 10^{-74}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 2.3772021743536337 \cdot 10^{-220}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 5.894651963428366 \cdot 10^{-210}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 2.173746397033535 \cdot 10^{-99}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.355473785437023 \cdot 10^{-57}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 7.702306877238973 \cdot 10^{-13}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \]
Alternative 6
Error1.3
Cost584
\[\begin{array}{l} t_0 := y \cdot \left(z - x\right)\\ \mathbf{if}\;y \leq -241906161300961.78:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 7.702306877238973 \cdot 10^{-13}:\\ \;\;\;\;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.3
Cost64
\[x \]

Error

Reproduce

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