Average Error: 11.5 → 5.1
Time: 8.6s
Precision: 64
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;b1 \cdot b2 \le -3.78185687302351595353600927911780875218 \cdot 10^{144}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \le -4.150210671513833606732172966148884455885 \cdot 10^{-228}:\\ \;\;\;\;\frac{a1}{\frac{1}{\frac{a2}{b1 \cdot b2}}}\\ \mathbf{elif}\;b1 \cdot b2 \le 4.343720045836759282443581250746346844563 \cdot 10^{-182} \lor \neg \left(b1 \cdot b2 \le 4.542196225721951094431610617285657897859 \cdot 10^{280}\right):\\ \;\;\;\;\frac{1}{b1} \cdot \left(\frac{a1}{b2} \cdot a2\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{a1}{b1 \cdot b2} \cdot a2\\ \end{array}\]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
\mathbf{if}\;b1 \cdot b2 \le -3.78185687302351595353600927911780875218 \cdot 10^{144}:\\
\;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\

\mathbf{elif}\;b1 \cdot b2 \le -4.150210671513833606732172966148884455885 \cdot 10^{-228}:\\
\;\;\;\;\frac{a1}{\frac{1}{\frac{a2}{b1 \cdot b2}}}\\

\mathbf{elif}\;b1 \cdot b2 \le 4.343720045836759282443581250746346844563 \cdot 10^{-182} \lor \neg \left(b1 \cdot b2 \le 4.542196225721951094431610617285657897859 \cdot 10^{280}\right):\\
\;\;\;\;\frac{1}{b1} \cdot \left(\frac{a1}{b2} \cdot a2\right)\\

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

\end{array}
double f(double a1, double a2, double b1, double b2) {
        double r134331 = a1;
        double r134332 = a2;
        double r134333 = r134331 * r134332;
        double r134334 = b1;
        double r134335 = b2;
        double r134336 = r134334 * r134335;
        double r134337 = r134333 / r134336;
        return r134337;
}

double f(double a1, double a2, double b1, double b2) {
        double r134338 = b1;
        double r134339 = b2;
        double r134340 = r134338 * r134339;
        double r134341 = -3.781856873023516e+144;
        bool r134342 = r134340 <= r134341;
        double r134343 = a1;
        double r134344 = r134343 / r134338;
        double r134345 = a2;
        double r134346 = r134345 / r134339;
        double r134347 = r134344 * r134346;
        double r134348 = -4.1502106715138336e-228;
        bool r134349 = r134340 <= r134348;
        double r134350 = 1.0;
        double r134351 = r134345 / r134340;
        double r134352 = r134350 / r134351;
        double r134353 = r134343 / r134352;
        double r134354 = 4.343720045836759e-182;
        bool r134355 = r134340 <= r134354;
        double r134356 = 4.542196225721951e+280;
        bool r134357 = r134340 <= r134356;
        double r134358 = !r134357;
        bool r134359 = r134355 || r134358;
        double r134360 = r134350 / r134338;
        double r134361 = r134343 / r134339;
        double r134362 = r134361 * r134345;
        double r134363 = r134360 * r134362;
        double r134364 = r134343 / r134340;
        double r134365 = r134364 * r134345;
        double r134366 = r134359 ? r134363 : r134365;
        double r134367 = r134349 ? r134353 : r134366;
        double r134368 = r134342 ? r134347 : r134367;
        return r134368;
}

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.5
Target11.2
Herbie5.1
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]

Derivation

  1. Split input into 4 regimes
  2. if (* b1 b2) < -3.781856873023516e+144

    1. Initial program 14.7

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

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

    if -3.781856873023516e+144 < (* b1 b2) < -4.1502106715138336e-228

    1. Initial program 4.4

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

      \[\leadsto \color{blue}{\frac{a1}{\frac{b1 \cdot b2}{a2}}}\]
    4. Using strategy rm
    5. Applied clear-num4.4

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

    if -4.1502106715138336e-228 < (* b1 b2) < 4.343720045836759e-182 or 4.542196225721951e+280 < (* b1 b2)

    1. Initial program 26.9

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

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

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

      \[\leadsto \frac{\color{blue}{1 \cdot a1}}{b1 \cdot b2} \cdot a2\]
    8. Applied times-frac13.2

      \[\leadsto \color{blue}{\left(\frac{1}{b1} \cdot \frac{a1}{b2}\right)} \cdot a2\]
    9. Applied associate-*l*6.6

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

    if 4.343720045836759e-182 < (* b1 b2) < 4.542196225721951e+280

    1. Initial program 5.3

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b1 \cdot b2 \le -3.78185687302351595353600927911780875218 \cdot 10^{144}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \le -4.150210671513833606732172966148884455885 \cdot 10^{-228}:\\ \;\;\;\;\frac{a1}{\frac{1}{\frac{a2}{b1 \cdot b2}}}\\ \mathbf{elif}\;b1 \cdot b2 \le 4.343720045836759282443581250746346844563 \cdot 10^{-182} \lor \neg \left(b1 \cdot b2 \le 4.542196225721951094431610617285657897859 \cdot 10^{280}\right):\\ \;\;\;\;\frac{1}{b1} \cdot \left(\frac{a1}{b2} \cdot a2\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{a1}{b1 \cdot b2} \cdot a2\\ \end{array}\]

Reproduce

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

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

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