Average Error: 7.3 → 7.3
Time: 15.6s
Precision: 64
\[\frac{x \cdot y - z \cdot t}{a}\]
\[\frac{\mathsf{fma}\left(x, -y, t \cdot z\right)}{-a}\]
\frac{x \cdot y - z \cdot t}{a}
\frac{\mathsf{fma}\left(x, -y, t \cdot z\right)}{-a}
double f(double x, double y, double z, double t, double a) {
        double r627398 = x;
        double r627399 = y;
        double r627400 = r627398 * r627399;
        double r627401 = z;
        double r627402 = t;
        double r627403 = r627401 * r627402;
        double r627404 = r627400 - r627403;
        double r627405 = a;
        double r627406 = r627404 / r627405;
        return r627406;
}

double f(double x, double y, double z, double t, double a) {
        double r627407 = x;
        double r627408 = y;
        double r627409 = -r627408;
        double r627410 = t;
        double r627411 = z;
        double r627412 = r627410 * r627411;
        double r627413 = fma(r627407, r627409, r627412);
        double r627414 = a;
        double r627415 = -r627414;
        double r627416 = r627413 / r627415;
        return r627416;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original7.3
Target5.7
Herbie7.3
\[\begin{array}{l} \mathbf{if}\;z \lt -2.468684968699548224247694913169778644284 \cdot 10^{170}:\\ \;\;\;\;\frac{y}{a} \cdot x - \frac{t}{a} \cdot z\\ \mathbf{elif}\;z \lt 6.309831121978371209578784129518242708809 \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.3

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

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

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

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

Reproduce

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

  :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))