?

Average Accuracy: 100.0% → 100.0%
Time: 1.9s
Precision: binary64
Cost: 6656

?

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

Error?

Bogosity?

Bogosity

Target

Original100.0%
Target87.5%
Herbie100.0%
\[\frac{x + y \cdot z}{\frac{x + y \cdot z}{x - y \cdot z}} \]

Derivation?

  1. Initial program 100.0%

    \[x - y \cdot z \]
  2. Simplified100.0%

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

    [Start]100.0

    \[ x - y \cdot z \]

    sub-neg [=>]100.0

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

    +-commutative [=>]100.0

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

    distribute-rgt-neg-in [=>]100.0

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

    fma-def [=>]100.0

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

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

Alternatives

Alternative 1
Accuracy69.1%
Cost786
\[\begin{array}{l} \mathbf{if}\;y \leq -7.8 \cdot 10^{+124} \lor \neg \left(y \leq -8.5 \cdot 10^{+75} \lor \neg \left(y \leq -2.2 \cdot 10^{+45}\right) \land y \leq 6.1 \cdot 10^{-55}\right):\\ \;\;\;\;-y \cdot z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Accuracy100.0%
Cost320
\[x - y \cdot z \]
Alternative 3
Accuracy51.1%
Cost64
\[x \]

Error

Reproduce?

herbie shell --seed 2023160 
(FPCore (x y z)
  :name "Diagrams.Solve.Tridiagonal:solveTriDiagonal from diagrams-solve-0.1, C"
  :precision binary64

  :herbie-target
  (/ (+ x (* y z)) (/ (+ x (* y z)) (- x (* y z))))

  (- x (* y z)))