Average Error: 11.7 → 5.4
Time: 6.5s
Precision: 64
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;b1 \cdot b2 \le -1.5996260124258995 \cdot 10^{120} \lor \neg \left(b1 \cdot b2 \le -5.1735635987796945 \cdot 10^{-283} \lor \neg \left(b1 \cdot b2 \le 1.0933637097430604 \cdot 10^{-143}\right) \land b1 \cdot b2 \le 9.4421790138168248 \cdot 10^{173}\right):\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{else}:\\ \;\;\;\;a1 \cdot \frac{1}{\frac{b1 \cdot b2}{a2}}\\ \end{array}\]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
\mathbf{if}\;b1 \cdot b2 \le -1.5996260124258995 \cdot 10^{120} \lor \neg \left(b1 \cdot b2 \le -5.1735635987796945 \cdot 10^{-283} \lor \neg \left(b1 \cdot b2 \le 1.0933637097430604 \cdot 10^{-143}\right) \land b1 \cdot b2 \le 9.4421790138168248 \cdot 10^{173}\right):\\
\;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\

\mathbf{else}:\\
\;\;\;\;a1 \cdot \frac{1}{\frac{b1 \cdot b2}{a2}}\\

\end{array}
double f(double a1, double a2, double b1, double b2) {
        double r85840 = a1;
        double r85841 = a2;
        double r85842 = r85840 * r85841;
        double r85843 = b1;
        double r85844 = b2;
        double r85845 = r85843 * r85844;
        double r85846 = r85842 / r85845;
        return r85846;
}

double f(double a1, double a2, double b1, double b2) {
        double r85847 = b1;
        double r85848 = b2;
        double r85849 = r85847 * r85848;
        double r85850 = -1.5996260124258995e+120;
        bool r85851 = r85849 <= r85850;
        double r85852 = -5.1735635987796945e-283;
        bool r85853 = r85849 <= r85852;
        double r85854 = 1.0933637097430604e-143;
        bool r85855 = r85849 <= r85854;
        double r85856 = !r85855;
        double r85857 = 9.442179013816825e+173;
        bool r85858 = r85849 <= r85857;
        bool r85859 = r85856 && r85858;
        bool r85860 = r85853 || r85859;
        double r85861 = !r85860;
        bool r85862 = r85851 || r85861;
        double r85863 = a1;
        double r85864 = r85863 / r85847;
        double r85865 = a2;
        double r85866 = r85865 / r85848;
        double r85867 = r85864 * r85866;
        double r85868 = 1.0;
        double r85869 = r85849 / r85865;
        double r85870 = r85868 / r85869;
        double r85871 = r85863 * r85870;
        double r85872 = r85862 ? r85867 : r85871;
        return r85872;
}

Error

Bits error versus a1

Bits error versus a2

Bits error versus b1

Bits error versus b2

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original11.7
Target10.7
Herbie5.4
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]

Derivation

  1. Split input into 2 regimes
  2. if (* b1 b2) < -1.5996260124258995e+120 or -5.1735635987796945e-283 < (* b1 b2) < 1.0933637097430604e-143 or 9.442179013816825e+173 < (* b1 b2)

    1. Initial program 19.1

      \[\frac{a1 \cdot a2}{b1 \cdot b2}\]
    2. Using strategy rm
    3. Applied times-frac6.3

      \[\leadsto \color{blue}{\frac{a1}{b1} \cdot \frac{a2}{b2}}\]

    if -1.5996260124258995e+120 < (* b1 b2) < -5.1735635987796945e-283 or 1.0933637097430604e-143 < (* b1 b2) < 9.442179013816825e+173

    1. Initial program 4.3

      \[\frac{a1 \cdot a2}{b1 \cdot b2}\]
    2. Using strategy rm
    3. Applied associate-/l*4.2

      \[\leadsto \color{blue}{\frac{a1}{\frac{b1 \cdot b2}{a2}}}\]
    4. Simplified11.4

      \[\leadsto \frac{a1}{\color{blue}{b1 \cdot \frac{b2}{a2}}}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity11.4

      \[\leadsto \frac{a1}{\color{blue}{1 \cdot \left(b1 \cdot \frac{b2}{a2}\right)}}\]
    7. Using strategy rm
    8. Applied div-inv11.6

      \[\leadsto \color{blue}{a1 \cdot \frac{1}{1 \cdot \left(b1 \cdot \frac{b2}{a2}\right)}}\]
    9. Simplified4.5

      \[\leadsto a1 \cdot \color{blue}{\frac{1}{\frac{b1 \cdot b2}{a2}}}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification5.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;b1 \cdot b2 \le -1.5996260124258995 \cdot 10^{120} \lor \neg \left(b1 \cdot b2 \le -5.1735635987796945 \cdot 10^{-283} \lor \neg \left(b1 \cdot b2 \le 1.0933637097430604 \cdot 10^{-143}\right) \land b1 \cdot b2 \le 9.4421790138168248 \cdot 10^{173}\right):\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{else}:\\ \;\;\;\;a1 \cdot \frac{1}{\frac{b1 \cdot b2}{a2}}\\ \end{array}\]

Reproduce

herbie shell --seed 2020047 +o rules:numerics
(FPCore (a1 a2 b1 b2)
  :name "Quotient of products"
  :precision binary64

  :herbie-target
  (* (/ a1 b1) (/ a2 b2))

  (/ (* a1 a2) (* b1 b2)))