Average Error: 7.8 → 0.8
Time: 5.6s
Precision: 64
\[\frac{x \cdot y - z \cdot t}{a}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \le -5.571537105635647305055441915656520766598 \cdot 10^{201}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{1}, \frac{y}{a}, -\frac{t}{\frac{a}{z}}\right)\\ \mathbf{elif}\;x \cdot y - z \cdot t \le -5.318639919188520705096400337034496027923 \cdot 10^{-101}:\\ \;\;\;\;\frac{1}{a} \cdot \left(x \cdot y - t \cdot z\right)\\ \mathbf{elif}\;x \cdot y - z \cdot t \le 2.705096932880445635207773638884756059712 \cdot 10^{-219}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{1}, \frac{y}{a}, -\frac{t}{\frac{a}{z}}\right)\\ \mathbf{elif}\;x \cdot y - z \cdot t \le 9.866299714254808615331411381510550183903 \cdot 10^{207}:\\ \;\;\;\;\frac{1}{a} \cdot \left(x \cdot y - t \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{a}{y}} - \frac{t}{\frac{a}{z}}\\ \end{array}\]
\frac{x \cdot y - z \cdot t}{a}
\begin{array}{l}
\mathbf{if}\;x \cdot y - z \cdot t \le -5.571537105635647305055441915656520766598 \cdot 10^{201}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{1}, \frac{y}{a}, -\frac{t}{\frac{a}{z}}\right)\\

\mathbf{elif}\;x \cdot y - z \cdot t \le -5.318639919188520705096400337034496027923 \cdot 10^{-101}:\\
\;\;\;\;\frac{1}{a} \cdot \left(x \cdot y - t \cdot z\right)\\

\mathbf{elif}\;x \cdot y - z \cdot t \le 2.705096932880445635207773638884756059712 \cdot 10^{-219}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{1}, \frac{y}{a}, -\frac{t}{\frac{a}{z}}\right)\\

\mathbf{elif}\;x \cdot y - z \cdot t \le 9.866299714254808615331411381510550183903 \cdot 10^{207}:\\
\;\;\;\;\frac{1}{a} \cdot \left(x \cdot y - t \cdot z\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{a}{y}} - \frac{t}{\frac{a}{z}}\\

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r744628 = x;
        double r744629 = y;
        double r744630 = r744628 * r744629;
        double r744631 = z;
        double r744632 = t;
        double r744633 = r744631 * r744632;
        double r744634 = r744630 - r744633;
        double r744635 = a;
        double r744636 = r744634 / r744635;
        return r744636;
}

double f(double x, double y, double z, double t, double a) {
        double r744637 = x;
        double r744638 = y;
        double r744639 = r744637 * r744638;
        double r744640 = z;
        double r744641 = t;
        double r744642 = r744640 * r744641;
        double r744643 = r744639 - r744642;
        double r744644 = -5.571537105635647e+201;
        bool r744645 = r744643 <= r744644;
        double r744646 = 1.0;
        double r744647 = r744637 / r744646;
        double r744648 = a;
        double r744649 = r744638 / r744648;
        double r744650 = r744648 / r744640;
        double r744651 = r744641 / r744650;
        double r744652 = -r744651;
        double r744653 = fma(r744647, r744649, r744652);
        double r744654 = -5.318639919188521e-101;
        bool r744655 = r744643 <= r744654;
        double r744656 = r744646 / r744648;
        double r744657 = r744641 * r744640;
        double r744658 = r744639 - r744657;
        double r744659 = r744656 * r744658;
        double r744660 = 2.7050969328804456e-219;
        bool r744661 = r744643 <= r744660;
        double r744662 = 9.866299714254809e+207;
        bool r744663 = r744643 <= r744662;
        double r744664 = r744648 / r744638;
        double r744665 = r744637 / r744664;
        double r744666 = r744665 - r744651;
        double r744667 = r744663 ? r744659 : r744666;
        double r744668 = r744661 ? r744653 : r744667;
        double r744669 = r744655 ? r744659 : r744668;
        double r744670 = r744645 ? r744653 : r744669;
        return r744670;
}

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
Herbie0.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. Split input into 3 regimes
  2. if (- (* x y) (* z t)) < -5.571537105635647e+201 or -5.318639919188521e-101 < (- (* x y) (* z t)) < 2.7050969328804456e-219

    1. Initial program 17.9

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{a} - \frac{z \cdot t}{a}}\]
    4. Simplified17.9

      \[\leadsto \frac{x \cdot y}{a} - \color{blue}{\frac{t \cdot z}{a}}\]
    5. Using strategy rm
    6. Applied associate-/l*10.5

      \[\leadsto \frac{x \cdot y}{a} - \color{blue}{\frac{t}{\frac{a}{z}}}\]
    7. Using strategy rm
    8. Applied *-un-lft-identity10.5

      \[\leadsto \frac{x \cdot y}{\color{blue}{1 \cdot a}} - \frac{t}{\frac{a}{z}}\]
    9. Applied times-frac1.8

      \[\leadsto \color{blue}{\frac{x}{1} \cdot \frac{y}{a}} - \frac{t}{\frac{a}{z}}\]
    10. Applied fma-neg1.8

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

    if -5.571537105635647e+201 < (- (* x y) (* z t)) < -5.318639919188521e-101 or 2.7050969328804456e-219 < (- (* x y) (* z t)) < 9.866299714254809e+207

    1. Initial program 0.3

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{a} - \frac{z \cdot t}{a}}\]
    4. Simplified0.3

      \[\leadsto \frac{x \cdot y}{a} - \color{blue}{\frac{t \cdot z}{a}}\]
    5. Using strategy rm
    6. Applied div-inv0.3

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

      \[\leadsto \color{blue}{\left(x \cdot y\right) \cdot \frac{1}{a}} - \left(t \cdot z\right) \cdot \frac{1}{a}\]
    8. Applied distribute-rgt-out--0.3

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

    if 9.866299714254809e+207 < (- (* x y) (* z t))

    1. Initial program 29.1

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

      \[\leadsto \color{blue}{\frac{x \cdot y}{a} - \frac{z \cdot t}{a}}\]
    4. Simplified29.1

      \[\leadsto \frac{x \cdot y}{a} - \color{blue}{\frac{t \cdot z}{a}}\]
    5. Using strategy rm
    6. Applied associate-/l*16.8

      \[\leadsto \frac{x \cdot y}{a} - \color{blue}{\frac{t}{\frac{a}{z}}}\]
    7. Using strategy rm
    8. Applied associate-/l*0.9

      \[\leadsto \color{blue}{\frac{x}{\frac{a}{y}}} - \frac{t}{\frac{a}{z}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.8

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y - z \cdot t \le -5.571537105635647305055441915656520766598 \cdot 10^{201}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{1}, \frac{y}{a}, -\frac{t}{\frac{a}{z}}\right)\\ \mathbf{elif}\;x \cdot y - z \cdot t \le -5.318639919188520705096400337034496027923 \cdot 10^{-101}:\\ \;\;\;\;\frac{1}{a} \cdot \left(x \cdot y - t \cdot z\right)\\ \mathbf{elif}\;x \cdot y - z \cdot t \le 2.705096932880445635207773638884756059712 \cdot 10^{-219}:\\ \;\;\;\;\mathsf{fma}\left(\frac{x}{1}, \frac{y}{a}, -\frac{t}{\frac{a}{z}}\right)\\ \mathbf{elif}\;x \cdot y - z \cdot t \le 9.866299714254808615331411381510550183903 \cdot 10^{207}:\\ \;\;\;\;\frac{1}{a} \cdot \left(x \cdot y - t \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{x}{\frac{a}{y}} - \frac{t}{\frac{a}{z}}\\ \end{array}\]

Reproduce

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