?

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

?

\[x \cdot y + \left(x - 1\right) \cdot z \]
\[\mathsf{fma}\left(x, y, \left(-1 + x\right) \cdot z\right) \]
(FPCore (x y z) :precision binary64 (+ (* x y) (* (- x 1.0) 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) + ((x - 1.0) * 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(x - 1.0) * 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[(x - 1.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := N[(x * y + N[(N[(-1.0 + x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
x \cdot y + \left(x - 1\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(x - 1\right) \cdot z \]
  2. Simplified0.0

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

Alternatives

Alternative 1
Error24.4
Cost852
\[\begin{array}{l} \mathbf{if}\;x \leq -2.5 \cdot 10^{+118}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;x \leq -8.3 \cdot 10^{+92}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;x \leq -1 \cdot 10^{+24}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;x \leq -2.45 \cdot 10^{-88}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;z \cdot x\\ \end{array} \]
Alternative 2
Error12.7
Cost584
\[\begin{array}{l} t_0 := \left(y + z\right) \cdot x\\ \mathbf{if}\;x \leq -1.2 \cdot 10^{-87}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1.3 \cdot 10^{-10}:\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error12.7
Cost584
\[\begin{array}{l} t_0 := \left(y + z\right) \cdot x\\ \mathbf{if}\;x \leq -1.2 \cdot 10^{-87}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 0.00155:\\ \;\;\;\;\left(x - 1\right) \cdot z\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error1.4
Cost584
\[\begin{array}{l} t_0 := \left(y + z\right) \cdot x\\ \mathbf{if}\;x \leq -7.6 \cdot 10^{+23}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 1:\\ \;\;\;\;y \cdot x - z\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error24.5
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -1.45 \cdot 10^{-87}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;x \leq 3.8 \cdot 10^{-12}:\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 6
Error0.0
Cost448
\[x \cdot \left(z + y\right) - z \]
Alternative 7
Error35.4
Cost128
\[-z \]

Error

Reproduce?

herbie shell --seed 2023033 
(FPCore (x y z)
  :name "Graphics.Rendering.Chart.Drawing:drawTextsR from Chart-1.5.3"
  :precision binary64
  (+ (* x y) (* (- x 1.0) z)))