?

Average Error: 0.0 → 0.0
Time: 35.8s
Precision: binary64
Cost: 6720

?

\[x + \left(y - x\right) \cdot z \]
\[\mathsf{fma}\left(z, y - x, x\right) \]
(FPCore (x y z) :precision binary64 (+ x (* (- y x) z)))
(FPCore (x y z) :precision binary64 (fma z (- y x) x))
double code(double x, double y, double z) {
	return x + ((y - x) * z);
}
double code(double x, double y, double z) {
	return fma(z, (y - x), x);
}
function code(x, y, z)
	return Float64(x + Float64(Float64(y - x) * z))
end
function code(x, y, z)
	return fma(z, Float64(y - x), x)
end
code[x_, y_, z_] := N[(x + N[(N[(y - x), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := N[(z * N[(y - x), $MachinePrecision] + x), $MachinePrecision]
x + \left(y - x\right) \cdot z
\mathsf{fma}\left(z, y - x, x\right)

Error?

Derivation?

  1. Initial program 0.0

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

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

Alternatives

Alternative 1
Error24.0
Cost1048
\[\begin{array}{l} t_0 := -x \cdot z\\ \mathbf{if}\;z \leq -8.8 \cdot 10^{+142}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -1.76 \cdot 10^{+103}:\\ \;\;\;\;z \cdot y\\ \mathbf{elif}\;z \leq -4.2 \cdot 10^{+36}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -2.6 \cdot 10^{-44}:\\ \;\;\;\;z \cdot y\\ \mathbf{elif}\;z \leq 2.1 \cdot 10^{-85}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 3.4 \cdot 10^{+16}:\\ \;\;\;\;z \cdot y\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error12.5
Cost584
\[\begin{array}{l} t_0 := \left(y - x\right) \cdot z\\ \mathbf{if}\;z \leq -2.6 \cdot 10^{-44}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 2.6 \cdot 10^{-83}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error2.0
Cost584
\[\begin{array}{l} t_0 := \left(y - x\right) \cdot z\\ \mathbf{if}\;z \leq -1750000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 4.4 \cdot 10^{-37}:\\ \;\;\;\;x + y \cdot z\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error24.4
Cost456
\[\begin{array}{l} \mathbf{if}\;z \leq -2.6 \cdot 10^{-44}:\\ \;\;\;\;z \cdot y\\ \mathbf{elif}\;z \leq 2.5 \cdot 10^{-83}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;z \cdot y\\ \end{array} \]
Alternative 5
Error0.0
Cost448
\[x + \left(y - x\right) \cdot z \]
Alternative 6
Error35.1
Cost64
\[x \]

Error

Reproduce?

herbie shell --seed 2023033 
(FPCore (x y z)
  :name "Diagrams.ThreeD.Shapes:frustum from diagrams-lib-1.3.0.3, B"
  :precision binary64
  (+ x (* (- y x) z)))