Average Error: 0.0 → 0.0
Time: 5.5s
Precision: binary64
Cost: 6848
\[x \cdot y + \left(x - 1\right) \cdot z \]
\[\mathsf{fma}\left(x, y, \left(x + -1\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 (* (+ x -1.0) 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, ((x + -1.0) * 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(x + -1.0) * 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[(x + -1.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
x \cdot y + \left(x - 1\right) \cdot z
\mathsf{fma}\left(x, y, \left(x + -1\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(x + -1\right) \cdot z\right)} \]
    Proof

Alternatives

Alternative 1
Error25.4
Cost720
\[\begin{array}{l} \mathbf{if}\;z \leq -6 \cdot 10^{+87}:\\ \;\;\;\;-z\\ \mathbf{elif}\;z \leq -7.2 \cdot 10^{-12}:\\ \;\;\;\;z \cdot x\\ \mathbf{elif}\;z \leq -1 \cdot 10^{-73}:\\ \;\;\;\;-z\\ \mathbf{elif}\;z \leq 2.4 \cdot 10^{-79}:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;-z\\ \end{array} \]
Alternative 2
Error12.2
Cost584
\[\begin{array}{l} t_0 := \left(y + z\right) \cdot x\\ \mathbf{if}\;x \leq -1 \cdot 10^{-19}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 6.2 \cdot 10^{-40}:\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error12.9
Cost584
\[\begin{array}{l} t_0 := \left(x - 1\right) \cdot z\\ \mathbf{if}\;z \leq -2.3 \cdot 10^{-74}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.95 \cdot 10^{-79}:\\ \;\;\;\;\left(y + z\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error0.0
Cost576
\[x \cdot y + \left(x - 1\right) \cdot z \]
Alternative 5
Error23.1
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -6.4 \cdot 10^{-20}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;x \leq 5.7 \cdot 10^{-40}:\\ \;\;\;\;-z\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \]
Alternative 6
Error34.3
Cost128
\[-z \]

Error

Reproduce

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