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

Error

Derivation

  1. Initial program 0.0

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

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

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

Alternatives

Alternative 1
Error0.0
Cost6720
\[\mathsf{fma}\left(y - x, z, x\right) \]
Alternative 2
Error26.5
Cost1048
\[\begin{array}{l} \mathbf{if}\;x \leq -95000000000000:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -1.55 \cdot 10^{-79}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;x \leq -3.35 \cdot 10^{-161}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.8 \cdot 10^{-9}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;x \leq 3.4 \cdot 10^{+120}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 8.5 \cdot 10^{+138}:\\ \;\;\;\;-z \cdot x\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error18.6
Cost848
\[\begin{array}{l} t_0 := \left(1 - z\right) \cdot x\\ \mathbf{if}\;y \leq -7.2 \cdot 10^{+41}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 14000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.25 \cdot 10^{+79}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;y \leq 1.1 \cdot 10^{+124}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \]
Alternative 4
Error12.7
Cost584
\[\begin{array}{l} t_0 := \left(y - x\right) \cdot z\\ \mathbf{if}\;z \leq -1.25 \cdot 10^{-70}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 140000000:\\ \;\;\;\;\left(1 - z\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error0.8
Cost584
\[\begin{array}{l} t_0 := \left(y - x\right) \cdot z\\ \mathbf{if}\;z \leq -1:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1:\\ \;\;\;\;x + y \cdot z\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error0.0
Cost576
\[\left(y \cdot z + x\right) - z \cdot x \]
Alternative 7
Error24.1
Cost456
\[\begin{array}{l} \mathbf{if}\;z \leq -7.6 \cdot 10^{-70}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq 3.9 \cdot 10^{-16}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \]
Alternative 8
Error0.0
Cost448
\[x + \left(y - x\right) \cdot z \]
Alternative 9
Error35.4
Cost64
\[x \]

Error

Reproduce

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