Average Error: 7.8 → 7.8
Time: 3.5s
Precision: 64
\[\frac{x \cdot y - z \cdot t}{a}\]
\[\frac{\mathsf{fma}\left(-y, x, z \cdot t\right)}{-a}\]
\frac{x \cdot y - z \cdot t}{a}
\frac{\mathsf{fma}\left(-y, x, z \cdot t\right)}{-a}
double f(double x, double y, double z, double t, double a) {
        double r916130 = x;
        double r916131 = y;
        double r916132 = r916130 * r916131;
        double r916133 = z;
        double r916134 = t;
        double r916135 = r916133 * r916134;
        double r916136 = r916132 - r916135;
        double r916137 = a;
        double r916138 = r916136 / r916137;
        return r916138;
}

double f(double x, double y, double z, double t, double a) {
        double r916139 = y;
        double r916140 = -r916139;
        double r916141 = x;
        double r916142 = z;
        double r916143 = t;
        double r916144 = r916142 * r916143;
        double r916145 = fma(r916140, r916141, r916144);
        double r916146 = a;
        double r916147 = -r916146;
        double r916148 = r916145 / r916147;
        return r916148;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original7.8
Target6.1
Herbie7.8
\[\begin{array}{l} \mathbf{if}\;z \lt -2.46868496869954822 \cdot 10^{170}:\\ \;\;\;\;\frac{y}{a} \cdot x - \frac{t}{a} \cdot z\\ \mathbf{elif}\;z \lt 6.30983112197837121 \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.8

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

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

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

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

Reproduce

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