Average Error: 7.2 → 7.2
Time: 15.1s
Precision: 64
\[\frac{x \cdot y - z \cdot t}{a}\]
\[\frac{\mathsf{fma}\left(y, x, \left(-z\right) \cdot t\right)}{a}\]
\frac{x \cdot y - z \cdot t}{a}
\frac{\mathsf{fma}\left(y, x, \left(-z\right) \cdot t\right)}{a}
double f(double x, double y, double z, double t, double a) {
        double r39271533 = x;
        double r39271534 = y;
        double r39271535 = r39271533 * r39271534;
        double r39271536 = z;
        double r39271537 = t;
        double r39271538 = r39271536 * r39271537;
        double r39271539 = r39271535 - r39271538;
        double r39271540 = a;
        double r39271541 = r39271539 / r39271540;
        return r39271541;
}

double f(double x, double y, double z, double t, double a) {
        double r39271542 = y;
        double r39271543 = x;
        double r39271544 = z;
        double r39271545 = -r39271544;
        double r39271546 = t;
        double r39271547 = r39271545 * r39271546;
        double r39271548 = fma(r39271542, r39271543, r39271547);
        double r39271549 = a;
        double r39271550 = r39271548 / r39271549;
        return r39271550;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original7.2
Target5.6
Herbie7.2
\[\begin{array}{l} \mathbf{if}\;z \lt -2.468684968699548 \cdot 10^{+170}:\\ \;\;\;\;\frac{y}{a} \cdot x - \frac{t}{a} \cdot z\\ \mathbf{elif}\;z \lt 6.309831121978371 \cdot 10^{-71}:\\ \;\;\;\;\frac{x \cdot y - z \cdot t}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{y}{a} \cdot x - \frac{t}{a} \cdot z\\ \end{array}\]

Derivation

  1. Initial program 7.2

    \[\frac{x \cdot y - z \cdot t}{a}\]
  2. Using strategy rm
  3. Applied frac-2neg7.2

    \[\leadsto \color{blue}{\frac{-\left(x \cdot y - z \cdot t\right)}{-a}}\]
  4. Simplified7.2

    \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(t, z, y \cdot \left(-x\right)\right)}}{-a}\]
  5. Using strategy rm
  6. Applied frac-2neg7.2

    \[\leadsto \color{blue}{\frac{-\mathsf{fma}\left(t, z, y \cdot \left(-x\right)\right)}{-\left(-a\right)}}\]
  7. Simplified7.2

    \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(y, x, \left(-z\right) \cdot t\right)}}{-\left(-a\right)}\]
  8. Simplified7.2

    \[\leadsto \frac{\mathsf{fma}\left(y, x, \left(-z\right) \cdot t\right)}{\color{blue}{a}}\]
  9. Final simplification7.2

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

Reproduce

herbie shell --seed 2019163 +o rules:numerics
(FPCore (x y z t a)
  :name "Data.Colour.Matrix:inverse from colour-2.3.3, B"

  :herbie-target
  (if (< z -2.468684968699548e+170) (- (* (/ y a) x) (* (/ t a) z)) (if (< z 6.309831121978371e-71) (/ (- (* x y) (* z t)) a) (- (* (/ y a) x) (* (/ t a) z))))

  (/ (- (* x y) (* z t)) a))