Average Error: 11.3 → 5.5
Time: 13.8s
Precision: 64
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;b1 \cdot b2 = -\infty:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \le -3.040762139846367585721209687403289691626 \cdot 10^{-188}:\\ \;\;\;\;\frac{a1}{\frac{b1 \cdot b2}{a2}}\\ \mathbf{elif}\;b1 \cdot b2 \le 5.240375488514302990559782428787746787415 \cdot 10^{-286}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \le 6.850072619734443525451794754710143932114 \cdot 10^{172}:\\ \;\;\;\;\frac{a1}{\frac{b1 \cdot b2}{a2}}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{b1} \cdot \frac{a1}{b2}\right) \cdot a2\\ \end{array}\]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
\mathbf{if}\;b1 \cdot b2 = -\infty:\\
\;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\

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

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

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

\mathbf{else}:\\
\;\;\;\;\left(\frac{1}{b1} \cdot \frac{a1}{b2}\right) \cdot a2\\

\end{array}
double f(double a1, double a2, double b1, double b2) {
        double r6620593 = a1;
        double r6620594 = a2;
        double r6620595 = r6620593 * r6620594;
        double r6620596 = b1;
        double r6620597 = b2;
        double r6620598 = r6620596 * r6620597;
        double r6620599 = r6620595 / r6620598;
        return r6620599;
}

double f(double a1, double a2, double b1, double b2) {
        double r6620600 = b1;
        double r6620601 = b2;
        double r6620602 = r6620600 * r6620601;
        double r6620603 = -inf.0;
        bool r6620604 = r6620602 <= r6620603;
        double r6620605 = a1;
        double r6620606 = r6620605 / r6620600;
        double r6620607 = a2;
        double r6620608 = r6620607 / r6620601;
        double r6620609 = r6620606 * r6620608;
        double r6620610 = -3.0407621398463676e-188;
        bool r6620611 = r6620602 <= r6620610;
        double r6620612 = r6620602 / r6620607;
        double r6620613 = r6620605 / r6620612;
        double r6620614 = 5.240375488514303e-286;
        bool r6620615 = r6620602 <= r6620614;
        double r6620616 = 6.850072619734444e+172;
        bool r6620617 = r6620602 <= r6620616;
        double r6620618 = 1.0;
        double r6620619 = r6620618 / r6620600;
        double r6620620 = r6620605 / r6620601;
        double r6620621 = r6620619 * r6620620;
        double r6620622 = r6620621 * r6620607;
        double r6620623 = r6620617 ? r6620613 : r6620622;
        double r6620624 = r6620615 ? r6620609 : r6620623;
        double r6620625 = r6620611 ? r6620613 : r6620624;
        double r6620626 = r6620604 ? r6620609 : r6620625;
        return r6620626;
}

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

Derivation

  1. Split input into 3 regimes
  2. if (* b1 b2) < -inf.0 or -3.0407621398463676e-188 < (* b1 b2) < 5.240375488514303e-286

    1. Initial program 30.9

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

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

    if -inf.0 < (* b1 b2) < -3.0407621398463676e-188 or 5.240375488514303e-286 < (* b1 b2) < 6.850072619734444e+172

    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. Taylor expanded around 0 4.6

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

    if 6.850072619734444e+172 < (* b1 b2)

    1. Initial program 13.5

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b1 \cdot b2 = -\infty:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \le -3.040762139846367585721209687403289691626 \cdot 10^{-188}:\\ \;\;\;\;\frac{a1}{\frac{b1 \cdot b2}{a2}}\\ \mathbf{elif}\;b1 \cdot b2 \le 5.240375488514302990559782428787746787415 \cdot 10^{-286}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \le 6.850072619734443525451794754710143932114 \cdot 10^{172}:\\ \;\;\;\;\frac{a1}{\frac{b1 \cdot b2}{a2}}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{1}{b1} \cdot \frac{a1}{b2}\right) \cdot a2\\ \end{array}\]

Reproduce

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

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

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