?

Average Error: 0.01% → 0%
Time: 3.8s
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(Float64(-y), 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?

Target

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

Derivation?

  1. Initial program 0.01

    \[x - y \cdot z \]
  2. Applied egg-rr72.06

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

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

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

    [Start]0.01

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

    +-commutative [=>]0.01

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

    fma-def [=>]0

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

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

Alternatives

Alternative 1
Error27.88%
Cost520
\[\begin{array}{l} \mathbf{if}\;x \leq -1.5 \cdot 10^{-102}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 9 \cdot 10^{-169}:\\ \;\;\;\;y \cdot \left(-z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 2
Error0.01%
Cost320
\[x - y \cdot z \]
Alternative 3
Error42.26%
Cost64
\[x \]

Error

Reproduce?

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