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

Error

Derivation

  1. Initial program 0.0

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

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

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

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

Alternatives

Alternative 1
Error23.7
Cost916
\[\begin{array}{l} t_0 := z \cdot \left(-x\right)\\ \mathbf{if}\;z \leq -1.25 \cdot 10^{+215}:\\ \;\;\;\;z \cdot y\\ \mathbf{elif}\;z \leq -2.5279591138776153 \cdot 10^{+30}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -2.6836822942390764 \cdot 10^{-48}:\\ \;\;\;\;z \cdot y\\ \mathbf{elif}\;z \leq 8.640531797436794 \cdot 10^{-8}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 6.4 \cdot 10^{+176}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;z \cdot y\\ \end{array} \]
Alternative 2
Error16.6
Cost584
\[\begin{array}{l} t_0 := x \cdot \left(1 - z\right)\\ \mathbf{if}\;x \leq -9.64741452204481 \cdot 10^{-192}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 2.8031715888660024 \cdot 10^{-147}:\\ \;\;\;\;z \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error11.8
Cost584
\[\begin{array}{l} t_0 := z \cdot \left(y - x\right)\\ \mathbf{if}\;z \leq -2.6836822942390764 \cdot 10^{-48}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 6.771056242562191 \cdot 10^{-27}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error1.6
Cost584
\[\begin{array}{l} t_0 := z \cdot \left(y - x\right)\\ \mathbf{if}\;z \leq -19505355390682.14:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 6.771056242562191 \cdot 10^{-27}:\\ \;\;\;\;x + z \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error1.6
Cost584
\[\begin{array}{l} \mathbf{if}\;z \leq -19505355390682.14:\\ \;\;\;\;z \cdot y - x \cdot z\\ \mathbf{elif}\;z \leq 6.771056242562191 \cdot 10^{-27}:\\ \;\;\;\;x + z \cdot y\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(y - x\right)\\ \end{array} \]
Alternative 6
Error0.0
Cost576
\[x + \left(z \cdot y - x \cdot z\right) \]
Alternative 7
Error23.2
Cost456
\[\begin{array}{l} \mathbf{if}\;z \leq -2.6836822942390764 \cdot 10^{-48}:\\ \;\;\;\;z \cdot y\\ \mathbf{elif}\;z \leq 6.771056242562191 \cdot 10^{-27}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;z \cdot y\\ \end{array} \]
Alternative 8
Error0.0
Cost448
\[x + z \cdot \left(y - x\right) \]
Alternative 9
Error34.3
Cost64
\[x \]

Error

Reproduce

herbie shell --seed 2022316 
(FPCore (x y z)
  :name "Diagrams.ThreeD.Shapes:frustum from diagrams-lib-1.3.0.3, B"
  :precision binary64
  (+ x (* (- y x) z)))