Average Error: 17.5 → 0.0
Time: 15.9s
Precision: 64
\[\left(\left(x \cdot y + y \cdot y\right) - y \cdot z\right) - y \cdot y\]
\[\mathsf{fma}\left(x, y, -z \cdot y\right)\]
\left(\left(x \cdot y + y \cdot y\right) - y \cdot z\right) - y \cdot y
\mathsf{fma}\left(x, y, -z \cdot y\right)
double f(double x, double y, double z) {
        double r529876 = x;
        double r529877 = y;
        double r529878 = r529876 * r529877;
        double r529879 = r529877 * r529877;
        double r529880 = r529878 + r529879;
        double r529881 = z;
        double r529882 = r529877 * r529881;
        double r529883 = r529880 - r529882;
        double r529884 = r529883 - r529879;
        return r529884;
}

double f(double x, double y, double z) {
        double r529885 = x;
        double r529886 = y;
        double r529887 = z;
        double r529888 = r529887 * r529886;
        double r529889 = -r529888;
        double r529890 = fma(r529885, r529886, r529889);
        return r529890;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

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

Derivation

  1. Initial program 17.5

    \[\left(\left(x \cdot y + y \cdot y\right) - y \cdot z\right) - y \cdot y\]
  2. Using strategy rm
  3. Applied associate--l+17.5

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

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

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

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

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

Reproduce

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

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

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