?

Average Error: 0.0 → 0.0
Time: 4.3s
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
Error0.0
Cost6720
\[\mathsf{fma}\left(x, y - z, z\right) \]
Alternative 2
Error23.4
Cost1049
\[\begin{array}{l} t_0 := x \cdot \left(-z\right)\\ \mathbf{if}\;x \leq -8.5 \cdot 10^{+103}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -0.012:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \leq 1.22 \cdot 10^{-67}:\\ \;\;\;\;z\\ \mathbf{elif}\;x \leq 10^{+41} \lor \neg \left(x \leq 2.1 \cdot 10^{+55}\right) \land x \leq 1.65 \cdot 10^{+97}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error16.6
Cost585
\[\begin{array}{l} \mathbf{if}\;z \leq -8.4 \cdot 10^{-190} \lor \neg \left(z \leq 8 \cdot 10^{-143}\right):\\ \;\;\;\;\left(1 - x\right) \cdot z\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 4
Error12.5
Cost585
\[\begin{array}{l} \mathbf{if}\;x \leq -0.012 \lor \neg \left(x \leq 6.1 \cdot 10^{-68}\right):\\ \;\;\;\;x \cdot \left(y - z\right)\\ \mathbf{else}:\\ \;\;\;\;\left(1 - x\right) \cdot z\\ \end{array} \]
Alternative 5
Error1.0
Cost585
\[\begin{array}{l} \mathbf{if}\;x \leq -10500000 \lor \neg \left(x \leq 1\right):\\ \;\;\;\;x \cdot \left(y - z\right)\\ \mathbf{else}:\\ \;\;\;\;z + x \cdot y\\ \end{array} \]
Alternative 6
Error0.0
Cost576
\[x \cdot y + \left(1 - x\right) \cdot z \]
Alternative 7
Error23.9
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -0.012:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \leq 1.05 \cdot 10^{-67}:\\ \;\;\;\;z\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
Alternative 8
Error0.0
Cost448
\[z - x \cdot \left(z - y\right) \]
Alternative 9
Error34.8
Cost64
\[z \]

Error

Reproduce?

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