Average Error: 17.7 → 0.0
Time: 15.0s
Precision: 64
\[\left(\left(x \cdot y - y \cdot z\right) - y \cdot y\right) + y \cdot y\]
\[\mathsf{fma}\left(x, y, y \cdot \left(-z\right)\right)\]
\left(\left(x \cdot y - y \cdot z\right) - y \cdot y\right) + y \cdot y
\mathsf{fma}\left(x, y, y \cdot \left(-z\right)\right)
double f(double x, double y, double z) {
        double r403330 = x;
        double r403331 = y;
        double r403332 = r403330 * r403331;
        double r403333 = z;
        double r403334 = r403331 * r403333;
        double r403335 = r403332 - r403334;
        double r403336 = r403331 * r403331;
        double r403337 = r403335 - r403336;
        double r403338 = r403337 + r403336;
        return r403338;
}

double f(double x, double y, double z) {
        double r403339 = x;
        double r403340 = y;
        double r403341 = z;
        double r403342 = -r403341;
        double r403343 = r403340 * r403342;
        double r403344 = fma(r403339, r403340, r403343);
        return r403344;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

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

Derivation

  1. Initial program 17.7

    \[\left(\left(x \cdot y - y \cdot z\right) - y \cdot y\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. Simplified0.0

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

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

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

Reproduce

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

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

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