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

Error

Derivation

  1. Initial program 0.0

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

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

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

Alternatives

Alternative 1
Error25.3
Cost916
\[\begin{array}{l} t_0 := z \cdot \left(-x\right)\\ \mathbf{if}\;x \leq -1.25 \cdot 10^{+25}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -1.0622751996272954 \cdot 10^{-107}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;x \leq 6.647684751752964 \cdot 10^{-96}:\\ \;\;\;\;z\\ \mathbf{elif}\;x \leq 2.15 \cdot 10^{+98}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;x \leq 4.8 \cdot 10^{+233}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 2
Error19.8
Cost848
\[\begin{array}{l} t_0 := \left(1 - x\right) \cdot z\\ \mathbf{if}\;y \leq -4.8 \cdot 10^{+101}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;y \leq -1.472605459025564 \cdot 10^{-21}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -2.7833487649445906 \cdot 10^{-81}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;y \leq 8.926185148338115 \cdot 10^{-39}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 3
Error25.1
Cost720
\[\begin{array}{l} \mathbf{if}\;x \leq -1.8449012033723863 \cdot 10^{-21}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;x \leq -2.1833745312498129 \cdot 10^{-35}:\\ \;\;\;\;z\\ \mathbf{elif}\;x \leq -1.0622751996272954 \cdot 10^{-107}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;x \leq 6.647684751752964 \cdot 10^{-96}:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 4
Error7.9
Cost584
\[\begin{array}{l} t_0 := z + y \cdot x\\ \mathbf{if}\;y \leq -2.7833487649445906 \cdot 10^{-81}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2.733013438565501 \cdot 10^{-233}:\\ \;\;\;\;\left(1 - x\right) \cdot z\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error1.3
Cost584
\[\begin{array}{l} t_0 := x \cdot \left(y - z\right)\\ \mathbf{if}\;x \leq -332781774239692.56:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.3955334038845188 \cdot 10^{-5}:\\ \;\;\;\;z + y \cdot x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error0.0
Cost576
\[\left(1 - x\right) \cdot z + y \cdot x \]
Alternative 7
Error0.0
Cost448
\[z + x \cdot \left(y - z\right) \]
Alternative 8
Error34.5
Cost64
\[z \]

Error

Reproduce

herbie shell --seed 2022318 
(FPCore (x y z)
  :name "Diagrams.Backend.Rasterific:$crender from diagrams-rasterific-1.3.1.3"
  :precision binary64
  (+ (* x y) (* (- 1.0 x) z)))