?

Average Error: 0.0 → 0.0
Time: 4.9s
Precision: binary64
Cost: 6848

?

\[x \cdot y + \left(1 - x\right) \cdot z \]
\[\mathsf{fma}\left(x, y, \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 x y (* (- 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(x, y, ((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(x, y, 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[(x * y + N[(N[(1.0 - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
x \cdot y + \left(1 - x\right) \cdot z
\mathsf{fma}\left(x, y, \left(1 - x\right) \cdot z\right)

Error?

Derivation?

  1. Initial program 0.0

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

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

    [Start]0.0

    \[ x \cdot y + \left(1 - x\right) \cdot z \]

    fma-def [=>]0.0

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

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

Alternatives

Alternative 1
Error24.1
Cost784
\[\begin{array}{l} t_0 := x \cdot \left(-z\right)\\ \mathbf{if}\;x \leq -1 \cdot 10^{+165}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -1.6 \cdot 10^{-68}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \leq 7.4 \cdot 10^{-53}:\\ \;\;\;\;z\\ \mathbf{elif}\;x \leq 1.8 \cdot 10^{+181}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error12.5
Cost585
\[\begin{array}{l} \mathbf{if}\;x \leq -1.4 \cdot 10^{-68} \lor \neg \left(x \leq 2.9 \cdot 10^{-37}\right):\\ \;\;\;\;x \cdot \left(y - z\right)\\ \mathbf{else}:\\ \;\;\;\;z\\ \end{array} \]
Alternative 3
Error1.8
Cost585
\[\begin{array}{l} \mathbf{if}\;x \leq -1 \lor \neg \left(x \leq 2 \cdot 10^{-34}\right):\\ \;\;\;\;x \cdot \left(y - z\right)\\ \mathbf{else}:\\ \;\;\;\;z + x \cdot y\\ \end{array} \]
Alternative 4
Error0.0
Cost576
\[\left(1 - x\right) \cdot z + x \cdot y \]
Alternative 5
Error23.8
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -1.35 \cdot 10^{-68}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \leq 7.8 \cdot 10^{-53}:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 6
Error0.0
Cost448
\[z + x \cdot \left(y - z\right) \]
Alternative 7
Error34.7
Cost64
\[z \]

Error

Reproduce?

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