Average Error: 10.8 → 1.9
Time: 11.4s
Precision: 64
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} = -\infty:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -8.016116290645056929955993350528318122349 \cdot 10^{-318}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -0.0:\\ \;\;\;\;\frac{a1}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \frac{\frac{a2}{\sqrt[3]{b1}}}{b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 8.081691575865167132123952523399231935896 \cdot 10^{299}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \end{array}\]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
\mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} = -\infty:\\
\;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\

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

\mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -0.0:\\
\;\;\;\;\frac{a1}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \frac{\frac{a2}{\sqrt[3]{b1}}}{b2}\\

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

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

\end{array}
double f(double a1, double a2, double b1, double b2) {
        double r155589 = a1;
        double r155590 = a2;
        double r155591 = r155589 * r155590;
        double r155592 = b1;
        double r155593 = b2;
        double r155594 = r155592 * r155593;
        double r155595 = r155591 / r155594;
        return r155595;
}

double f(double a1, double a2, double b1, double b2) {
        double r155596 = a1;
        double r155597 = a2;
        double r155598 = r155596 * r155597;
        double r155599 = b1;
        double r155600 = b2;
        double r155601 = r155599 * r155600;
        double r155602 = r155598 / r155601;
        double r155603 = -inf.0;
        bool r155604 = r155602 <= r155603;
        double r155605 = r155596 / r155599;
        double r155606 = r155597 / r155600;
        double r155607 = r155605 * r155606;
        double r155608 = -8.0161162906451e-318;
        bool r155609 = r155602 <= r155608;
        double r155610 = -0.0;
        bool r155611 = r155602 <= r155610;
        double r155612 = cbrt(r155599);
        double r155613 = r155612 * r155612;
        double r155614 = r155596 / r155613;
        double r155615 = r155597 / r155612;
        double r155616 = r155615 / r155600;
        double r155617 = r155614 * r155616;
        double r155618 = 8.081691575865167e+299;
        bool r155619 = r155602 <= r155618;
        double r155620 = r155619 ? r155602 : r155607;
        double r155621 = r155611 ? r155617 : r155620;
        double r155622 = r155609 ? r155602 : r155621;
        double r155623 = r155604 ? r155607 : r155622;
        return r155623;
}

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

Original10.8
Target11.5
Herbie1.9
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]

Derivation

  1. Split input into 3 regimes
  2. if (/ (* a1 a2) (* b1 b2)) < -inf.0 or 8.081691575865167e+299 < (/ (* a1 a2) (* b1 b2))

    1. Initial program 62.5

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

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

    if -inf.0 < (/ (* a1 a2) (* b1 b2)) < -8.0161162906451e-318 or -0.0 < (/ (* a1 a2) (* b1 b2)) < 8.081691575865167e+299

    1. Initial program 3.4

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

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

      \[\leadsto \frac{\frac{a1 \cdot a2}{b1}}{\color{blue}{1 \cdot b2}}\]
    6. Applied add-cube-cbrt8.5

      \[\leadsto \frac{\frac{a1 \cdot a2}{\color{blue}{\left(\sqrt[3]{b1} \cdot \sqrt[3]{b1}\right) \cdot \sqrt[3]{b1}}}}{1 \cdot b2}\]
    7. Applied times-frac12.1

      \[\leadsto \frac{\color{blue}{\frac{a1}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \frac{a2}{\sqrt[3]{b1}}}}{1 \cdot b2}\]
    8. Applied times-frac12.5

      \[\leadsto \color{blue}{\frac{\frac{a1}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}}}{1} \cdot \frac{\frac{a2}{\sqrt[3]{b1}}}{b2}}\]
    9. Simplified12.5

      \[\leadsto \color{blue}{\frac{a1}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}}} \cdot \frac{\frac{a2}{\sqrt[3]{b1}}}{b2}\]
    10. Using strategy rm
    11. Applied *-un-lft-identity12.5

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

      \[\leadsto \color{blue}{1 \cdot \left(\frac{a1}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \frac{\frac{a2}{\sqrt[3]{b1}}}{b2}\right)}\]
    13. Simplified3.4

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

    if -8.0161162906451e-318 < (/ (* a1 a2) (* b1 b2)) < -0.0

    1. Initial program 13.6

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

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

      \[\leadsto \frac{\frac{a1 \cdot a2}{b1}}{\color{blue}{1 \cdot b2}}\]
    6. Applied add-cube-cbrt6.6

      \[\leadsto \frac{\frac{a1 \cdot a2}{\color{blue}{\left(\sqrt[3]{b1} \cdot \sqrt[3]{b1}\right) \cdot \sqrt[3]{b1}}}}{1 \cdot b2}\]
    7. Applied times-frac3.3

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

      \[\leadsto \color{blue}{\frac{\frac{a1}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}}}{1} \cdot \frac{\frac{a2}{\sqrt[3]{b1}}}{b2}}\]
    9. Simplified2.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} = -\infty:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -8.016116290645056929955993350528318122349 \cdot 10^{-318}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -0.0:\\ \;\;\;\;\frac{a1}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \frac{\frac{a2}{\sqrt[3]{b1}}}{b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 8.081691575865167132123952523399231935896 \cdot 10^{299}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \end{array}\]

Reproduce

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

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

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