Average Error: 7.8 → 7.8
Time: 12.4s
Precision: 64
\[\frac{x \cdot y - z \cdot t}{a}\]
\[\frac{\mathsf{fma}\left(-t, z, y \cdot x\right)}{a}\]
\frac{x \cdot y - z \cdot t}{a}
\frac{\mathsf{fma}\left(-t, z, y \cdot x\right)}{a}
double f(double x, double y, double z, double t, double a) {
        double r549849 = x;
        double r549850 = y;
        double r549851 = r549849 * r549850;
        double r549852 = z;
        double r549853 = t;
        double r549854 = r549852 * r549853;
        double r549855 = r549851 - r549854;
        double r549856 = a;
        double r549857 = r549855 / r549856;
        return r549857;
}

double f(double x, double y, double z, double t, double a) {
        double r549858 = t;
        double r549859 = -r549858;
        double r549860 = z;
        double r549861 = y;
        double r549862 = x;
        double r549863 = r549861 * r549862;
        double r549864 = fma(r549859, r549860, r549863);
        double r549865 = a;
        double r549866 = r549864 / r549865;
        return r549866;
}

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.2
Herbie7.8
\[\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.8

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

    \[\leadsto \color{blue}{\frac{1}{\frac{a}{x \cdot y - z \cdot t}}}\]
  4. Using strategy rm
  5. Applied *-un-lft-identity8.0

    \[\leadsto \frac{1}{\frac{a}{\color{blue}{1 \cdot \left(x \cdot y - z \cdot t\right)}}}\]
  6. Applied *-un-lft-identity8.0

    \[\leadsto \frac{1}{\frac{\color{blue}{1 \cdot a}}{1 \cdot \left(x \cdot y - z \cdot t\right)}}\]
  7. Applied times-frac8.0

    \[\leadsto \frac{1}{\color{blue}{\frac{1}{1} \cdot \frac{a}{x \cdot y - z \cdot t}}}\]
  8. Applied add-cube-cbrt8.0

    \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{\frac{1}{1} \cdot \frac{a}{x \cdot y - z \cdot t}}\]
  9. Applied times-frac8.0

    \[\leadsto \color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\frac{1}{1}} \cdot \frac{\sqrt[3]{1}}{\frac{a}{x \cdot y - z \cdot t}}}\]
  10. Simplified8.0

    \[\leadsto \color{blue}{1} \cdot \frac{\sqrt[3]{1}}{\frac{a}{x \cdot y - z \cdot t}}\]
  11. Simplified7.8

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

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

Reproduce

herbie shell --seed 2019209 +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.46868496869954822e170) (- (* (/ y a) x) (* (/ t a) z)) (if (< z 6.30983112197837121e-71) (/ (- (* x y) (* z t)) a) (- (* (/ y a) x) (* (/ t a) z))))

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