?

Average Error: 0.0 → 0
Time: 5.5s
Precision: binary64
Cost: 6656

?

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

Error?

Target

Original0.0
Target0.0
Herbie0
\[\frac{x + y \cdot z}{\frac{x + y \cdot z}{x - y \cdot z}} \]

Derivation?

  1. Initial program 0.0

    \[x - y \cdot z \]
  2. Applied egg-rr32.1

    \[\leadsto \color{blue}{{\left(\sqrt{x - y \cdot z}\right)}^{2}} \]
  3. Applied egg-rr0.0

    \[\leadsto \color{blue}{y \cdot \left(-z\right) + \left(x + \mathsf{fma}\left(-z, y, y \cdot z\right)\right)} \]
  4. Taylor expanded in y around 0 0.0

    \[\leadsto \color{blue}{\left(-2 \cdot z + z\right) \cdot y + x} \]
  5. Simplified0

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

    [Start]0.0

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

    distribute-lft1-in [=>]0.0

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

    metadata-eval [=>]0.0

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

    fma-def [=>]0

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

    mul-1-neg [=>]0

    \[ \mathsf{fma}\left(\color{blue}{-z}, y, x\right) \]
  6. Final simplification0

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

Alternatives

Alternative 1
Error23.0
Cost1316
\[\begin{array}{l} \mathbf{if}\;y \leq -1.22 \cdot 10^{+104} \lor \neg \left(y \leq -1.56 \cdot 10^{+60} \lor \neg \left(y \leq -520000000\right) \land \left(y \leq -4.2 \cdot 10^{-129} \lor \neg \left(y \leq -5.5 \cdot 10^{-148}\right) \land \left(y \leq 3.6 \cdot 10^{-135} \lor \neg \left(y \leq 3.15 \cdot 10^{-71}\right) \land y \leq 2.2 \cdot 10^{+16}\right)\right)\right):\\ \;\;\;\;z \cdot \left(-y\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Error0.0
Cost320
\[x - z \cdot y \]
Alternative 3
Error27.6
Cost64
\[x \]

Error

Reproduce?

herbie shell --seed 2023056 
(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)))