Average Error: 7.3 → 7.3
Time: 12.8s
Precision: 64
\[\frac{x \cdot y - z \cdot t}{a}\]
\[\frac{\mathsf{fma}\left(-t, z, x \cdot y\right)}{a}\]
\frac{x \cdot y - z \cdot t}{a}
\frac{\mathsf{fma}\left(-t, z, x \cdot y\right)}{a}
double f(double x, double y, double z, double t, double a) {
        double r615816 = x;
        double r615817 = y;
        double r615818 = r615816 * r615817;
        double r615819 = z;
        double r615820 = t;
        double r615821 = r615819 * r615820;
        double r615822 = r615818 - r615821;
        double r615823 = a;
        double r615824 = r615822 / r615823;
        return r615824;
}

double f(double x, double y, double z, double t, double a) {
        double r615825 = t;
        double r615826 = -r615825;
        double r615827 = z;
        double r615828 = x;
        double r615829 = y;
        double r615830 = r615828 * r615829;
        double r615831 = fma(r615826, r615827, r615830);
        double r615832 = a;
        double r615833 = r615831 / r615832;
        return r615833;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Target

Original7.3
Target6.1
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. Simplified7.3

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

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

Reproduce

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