Average Error: 7.6 → 4.3
Time: 12.8s
Precision: 64
\[\frac{x \cdot y - z \cdot t}{a}\]
\[\begin{array}{l} \mathbf{if}\;x \cdot y = -\infty \lor \neg \left(x \cdot y \le 7.081516719569747281595382284979869250524 \cdot 10^{214}\right):\\ \;\;\;\;\frac{x}{\frac{a}{y}} - \frac{t}{\frac{a}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{a}{x \cdot y - z \cdot t}}\\ \end{array}\]
\frac{x \cdot y - z \cdot t}{a}
\begin{array}{l}
\mathbf{if}\;x \cdot y = -\infty \lor \neg \left(x \cdot y \le 7.081516719569747281595382284979869250524 \cdot 10^{214}\right):\\
\;\;\;\;\frac{x}{\frac{a}{y}} - \frac{t}{\frac{a}{z}}\\

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

\end{array}
double f(double x, double y, double z, double t, double a) {
        double r1506853 = x;
        double r1506854 = y;
        double r1506855 = r1506853 * r1506854;
        double r1506856 = z;
        double r1506857 = t;
        double r1506858 = r1506856 * r1506857;
        double r1506859 = r1506855 - r1506858;
        double r1506860 = a;
        double r1506861 = r1506859 / r1506860;
        return r1506861;
}

double f(double x, double y, double z, double t, double a) {
        double r1506862 = x;
        double r1506863 = y;
        double r1506864 = r1506862 * r1506863;
        double r1506865 = -inf.0;
        bool r1506866 = r1506864 <= r1506865;
        double r1506867 = 7.081516719569747e+214;
        bool r1506868 = r1506864 <= r1506867;
        double r1506869 = !r1506868;
        bool r1506870 = r1506866 || r1506869;
        double r1506871 = a;
        double r1506872 = r1506871 / r1506863;
        double r1506873 = r1506862 / r1506872;
        double r1506874 = t;
        double r1506875 = z;
        double r1506876 = r1506871 / r1506875;
        double r1506877 = r1506874 / r1506876;
        double r1506878 = r1506873 - r1506877;
        double r1506879 = 1.0;
        double r1506880 = r1506875 * r1506874;
        double r1506881 = r1506864 - r1506880;
        double r1506882 = r1506871 / r1506881;
        double r1506883 = r1506879 / r1506882;
        double r1506884 = r1506870 ? r1506878 : r1506883;
        return r1506884;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Bits error versus a

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original7.6
Target5.8
Herbie4.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. Split input into 2 regimes
  2. if (* x y) < -inf.0 or 7.081516719569747e+214 < (* x y)

    1. Initial program 43.0

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

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

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

      \[\leadsto \frac{x}{\frac{a}{y}} - \color{blue}{\frac{t}{\frac{a}{z}}}\]

    if -inf.0 < (* x y) < 7.081516719569747e+214

    1. Initial program 4.3

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

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

      \[\leadsto \frac{1}{\color{blue}{\frac{a}{\mathsf{fma}\left(y, x, t \cdot \left(-z\right)\right)}}}\]
    5. Using strategy rm
    6. Applied div-inv4.7

      \[\leadsto \frac{1}{\color{blue}{a \cdot \frac{1}{\mathsf{fma}\left(y, x, t \cdot \left(-z\right)\right)}}}\]
    7. Applied add-cube-cbrt4.7

      \[\leadsto \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{a \cdot \frac{1}{\mathsf{fma}\left(y, x, t \cdot \left(-z\right)\right)}}\]
    8. Applied times-frac4.5

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

      \[\leadsto \color{blue}{\frac{1}{a}} \cdot \frac{\sqrt[3]{1}}{\frac{1}{\mathsf{fma}\left(y, x, t \cdot \left(-z\right)\right)}}\]
    10. Simplified4.4

      \[\leadsto \frac{1}{a} \cdot \color{blue}{\left(x \cdot y - t \cdot z\right)}\]
    11. Using strategy rm
    12. Applied associate-*l/4.3

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

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(x, y, -z \cdot t\right)}}{a}\]
    14. Using strategy rm
    15. Applied clear-num4.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y = -\infty \lor \neg \left(x \cdot y \le 7.081516719569747281595382284979869250524 \cdot 10^{214}\right):\\ \;\;\;\;\frac{x}{\frac{a}{y}} - \frac{t}{\frac{a}{z}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{a}{x \cdot y - z \cdot t}}\\ \end{array}\]

Reproduce

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