?

Average Accuracy: 100.0% → 100.0%
Time: 3.7s
Precision: binary64
Cost: 6720

?

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

Error?

Bogosity?

Bogosity

Derivation?

  1. Initial program 100.0%

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

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

    [Start]100.0

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

    +-commutative [=>]100.0

    \[ \color{blue}{\left(y - x\right) \cdot z + x} \]

    fma-def [=>]100.0

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

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

Alternatives

Alternative 1
Accuracy61.1%
Cost652
\[\begin{array}{l} \mathbf{if}\;z \leq -6.6 \cdot 10^{-77}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq 1.65 \cdot 10^{-38}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 6 \cdot 10^{+104}:\\ \;\;\;\;y \cdot z\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(-z\right)\\ \end{array} \]
Alternative 2
Accuracy84.1%
Cost585
\[\begin{array}{l} \mathbf{if}\;z \leq -1.16 \cdot 10^{-76} \lor \neg \left(z \leq 1.65 \cdot 10^{-38}\right):\\ \;\;\;\;\left(y - x\right) \cdot z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Accuracy98.9%
Cost585
\[\begin{array}{l} \mathbf{if}\;z \leq -1 \lor \neg \left(z \leq 1\right):\\ \;\;\;\;\left(y - x\right) \cdot z\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot z\\ \end{array} \]
Alternative 4
Accuracy61.3%
Cost456
\[\begin{array}{l} \mathbf{if}\;z \leq -2.3 \cdot 10^{-77}:\\ \;\;\;\;y \cdot z\\ \mathbf{elif}\;z \leq 1.8 \cdot 10^{-38}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;y \cdot z\\ \end{array} \]
Alternative 5
Accuracy100.0%
Cost448
\[x + \left(y - x\right) \cdot z \]
Alternative 6
Accuracy36.9%
Cost64
\[x \]

Error

Reproduce?

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