Average Error: 17.3 → 0.0
Time: 19.7s
Precision: 64
\[\left(\left(x \cdot y + y \cdot y\right) - y \cdot z\right) - y \cdot y\]
\[\mathsf{fma}\left(y, x, \left(-y\right) \cdot z\right)\]
\left(\left(x \cdot y + y \cdot y\right) - y \cdot z\right) - y \cdot y
\mathsf{fma}\left(y, x, \left(-y\right) \cdot z\right)
double f(double x, double y, double z) {
        double r1286862 = x;
        double r1286863 = y;
        double r1286864 = r1286862 * r1286863;
        double r1286865 = r1286863 * r1286863;
        double r1286866 = r1286864 + r1286865;
        double r1286867 = z;
        double r1286868 = r1286863 * r1286867;
        double r1286869 = r1286866 - r1286868;
        double r1286870 = r1286869 - r1286865;
        return r1286870;
}

double f(double x, double y, double z) {
        double r1286871 = y;
        double r1286872 = x;
        double r1286873 = -r1286871;
        double r1286874 = z;
        double r1286875 = r1286873 * r1286874;
        double r1286876 = fma(r1286871, r1286872, r1286875);
        return r1286876;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original17.3
Target0.0
Herbie0.0
\[\left(x - z\right) \cdot y\]

Derivation

  1. Initial program 17.3

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

    \[\leadsto \color{blue}{y \cdot \left(x - z\right)}\]
  3. Using strategy rm
  4. Applied sub-neg0.0

    \[\leadsto y \cdot \color{blue}{\left(x + \left(-z\right)\right)}\]
  5. Applied distribute-lft-in0.0

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

    \[\leadsto y \cdot x + \color{blue}{\left(-y\right) \cdot z}\]
  7. Using strategy rm
  8. Applied fma-def0.0

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

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

Reproduce

herbie shell --seed 2019194 +o rules:numerics
(FPCore (x y z)
  :name "Linear.Quaternion:$c/ from linear-1.19.1.3, C"

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

  (- (- (+ (* x y) (* y y)) (* y z)) (* y y)))