Average Error: 11.3 → 5.0
Time: 12.4s
Precision: 64
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;b1 \cdot b2 \le -3.58664145041220608751762177013649404527 \cdot 10^{295}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \le -1.977094403295562009633117616926065832914 \cdot 10^{-180}:\\ \;\;\;\;\frac{a1}{b1 \cdot b2} \cdot a2\\ \mathbf{elif}\;b1 \cdot b2 \le 1.695237226331841275115612229868088975953 \cdot 10^{-314}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \le 1.479757665365577781832274190873386765909 \cdot 10^{235}:\\ \;\;\;\;\frac{a1}{b1 \cdot b2} \cdot a2\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{a1}{b1}}{\frac{b2}{a2}}\\ \end{array}\]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
\mathbf{if}\;b1 \cdot b2 \le -3.58664145041220608751762177013649404527 \cdot 10^{295}:\\
\;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\

\mathbf{elif}\;b1 \cdot b2 \le -1.977094403295562009633117616926065832914 \cdot 10^{-180}:\\
\;\;\;\;\frac{a1}{b1 \cdot b2} \cdot a2\\

\mathbf{elif}\;b1 \cdot b2 \le 1.695237226331841275115612229868088975953 \cdot 10^{-314}:\\
\;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\

\mathbf{elif}\;b1 \cdot b2 \le 1.479757665365577781832274190873386765909 \cdot 10^{235}:\\
\;\;\;\;\frac{a1}{b1 \cdot b2} \cdot a2\\

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

\end{array}
double f(double a1, double a2, double b1, double b2) {
        double r6860054 = a1;
        double r6860055 = a2;
        double r6860056 = r6860054 * r6860055;
        double r6860057 = b1;
        double r6860058 = b2;
        double r6860059 = r6860057 * r6860058;
        double r6860060 = r6860056 / r6860059;
        return r6860060;
}

double f(double a1, double a2, double b1, double b2) {
        double r6860061 = b1;
        double r6860062 = b2;
        double r6860063 = r6860061 * r6860062;
        double r6860064 = -3.586641450412206e+295;
        bool r6860065 = r6860063 <= r6860064;
        double r6860066 = a1;
        double r6860067 = r6860066 / r6860061;
        double r6860068 = a2;
        double r6860069 = r6860068 / r6860062;
        double r6860070 = r6860067 * r6860069;
        double r6860071 = -1.977094403295562e-180;
        bool r6860072 = r6860063 <= r6860071;
        double r6860073 = r6860066 / r6860063;
        double r6860074 = r6860073 * r6860068;
        double r6860075 = 1.6952372263318e-314;
        bool r6860076 = r6860063 <= r6860075;
        double r6860077 = 1.4797576653655778e+235;
        bool r6860078 = r6860063 <= r6860077;
        double r6860079 = r6860062 / r6860068;
        double r6860080 = r6860067 / r6860079;
        double r6860081 = r6860078 ? r6860074 : r6860080;
        double r6860082 = r6860076 ? r6860070 : r6860081;
        double r6860083 = r6860072 ? r6860074 : r6860082;
        double r6860084 = r6860065 ? r6860070 : r6860083;
        return r6860084;
}

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.3
Target11.4
Herbie5.0
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]

Derivation

  1. Split input into 3 regimes
  2. if (* b1 b2) < -3.586641450412206e+295 or -1.977094403295562e-180 < (* b1 b2) < 1.6952372263318e-314

    1. Initial program 30.3

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

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

    if -3.586641450412206e+295 < (* b1 b2) < -1.977094403295562e-180 or 1.6952372263318e-314 < (* b1 b2) < 1.4797576653655778e+235

    1. Initial program 5.4

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

      \[\leadsto \color{blue}{\frac{a1}{\frac{b1 \cdot b2}{a2}}}\]
    4. Using strategy rm
    5. Applied associate-/r/4.8

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

    if 1.4797576653655778e+235 < (* b1 b2)

    1. Initial program 16.1

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

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

      \[\leadsto \frac{a1}{\frac{b1 \cdot b2}{\color{blue}{1 \cdot a2}}}\]
    6. Applied times-frac6.9

      \[\leadsto \frac{a1}{\color{blue}{\frac{b1}{1} \cdot \frac{b2}{a2}}}\]
    7. Applied associate-/r*3.4

      \[\leadsto \color{blue}{\frac{\frac{a1}{\frac{b1}{1}}}{\frac{b2}{a2}}}\]
    8. Simplified3.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b1 \cdot b2 \le -3.58664145041220608751762177013649404527 \cdot 10^{295}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \le -1.977094403295562009633117616926065832914 \cdot 10^{-180}:\\ \;\;\;\;\frac{a1}{b1 \cdot b2} \cdot a2\\ \mathbf{elif}\;b1 \cdot b2 \le 1.695237226331841275115612229868088975953 \cdot 10^{-314}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \le 1.479757665365577781832274190873386765909 \cdot 10^{235}:\\ \;\;\;\;\frac{a1}{b1 \cdot b2} \cdot a2\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{a1}{b1}}{\frac{b2}{a2}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019171 
(FPCore (a1 a2 b1 b2)
  :name "Quotient of products"

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

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