Average Error: 17.2 → 0.0
Time: 6.0s
Precision: 64
\[\left(\left(x \cdot y + y \cdot y\right) - y \cdot z\right) - y \cdot y\]
\[\mathsf{fma}\left(x, y, \left(-z\right) \cdot y\right)\]
\left(\left(x \cdot y + y \cdot y\right) - y \cdot z\right) - y \cdot y
\mathsf{fma}\left(x, y, \left(-z\right) \cdot y\right)
double f(double x, double y, double z) {
        double r8551076 = x;
        double r8551077 = y;
        double r8551078 = r8551076 * r8551077;
        double r8551079 = r8551077 * r8551077;
        double r8551080 = r8551078 + r8551079;
        double r8551081 = z;
        double r8551082 = r8551077 * r8551081;
        double r8551083 = r8551080 - r8551082;
        double r8551084 = r8551083 - r8551079;
        return r8551084;
}

double f(double x, double y, double z) {
        double r8551085 = x;
        double r8551086 = y;
        double r8551087 = z;
        double r8551088 = -r8551087;
        double r8551089 = r8551088 * r8551086;
        double r8551090 = fma(r8551085, r8551086, r8551089);
        return r8551090;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

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

Derivation

  1. Initial program 17.2

    \[\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-rgt-in0.0

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

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

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

Reproduce

herbie shell --seed 2019156 +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)))