Average Error: 11.8 → 3.9
Time: 13.1s
Precision: 64
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} = -\infty:\\ \;\;\;\;\frac{a1}{\frac{b1 \cdot b2}{a2}}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -6.70415471086550637493707435050808693496 \cdot 10^{-315}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -0.0:\\ \;\;\;\;\left(\left(\sqrt[3]{\frac{a2}{b2}} \cdot \sqrt[3]{\frac{a2}{b2}}\right) \cdot a1\right) \cdot \frac{\sqrt[3]{\frac{a2}{b2}}}{b1}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 3.55240378150326106810509497578384630044 \cdot 10^{307}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{a1}{b1} \cdot a2\right) \cdot \frac{1}{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}{\frac{b1 \cdot b2}{a2}}\\

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

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

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

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

\end{array}
double f(double a1, double a2, double b1, double b2) {
        double r101576 = a1;
        double r101577 = a2;
        double r101578 = r101576 * r101577;
        double r101579 = b1;
        double r101580 = b2;
        double r101581 = r101579 * r101580;
        double r101582 = r101578 / r101581;
        return r101582;
}

double f(double a1, double a2, double b1, double b2) {
        double r101583 = a1;
        double r101584 = a2;
        double r101585 = r101583 * r101584;
        double r101586 = b1;
        double r101587 = b2;
        double r101588 = r101586 * r101587;
        double r101589 = r101585 / r101588;
        double r101590 = -inf.0;
        bool r101591 = r101589 <= r101590;
        double r101592 = r101588 / r101584;
        double r101593 = r101583 / r101592;
        double r101594 = -6.7041547108655e-315;
        bool r101595 = r101589 <= r101594;
        double r101596 = -0.0;
        bool r101597 = r101589 <= r101596;
        double r101598 = r101584 / r101587;
        double r101599 = cbrt(r101598);
        double r101600 = r101599 * r101599;
        double r101601 = r101600 * r101583;
        double r101602 = r101599 / r101586;
        double r101603 = r101601 * r101602;
        double r101604 = 3.552403781503261e+307;
        bool r101605 = r101589 <= r101604;
        double r101606 = r101583 / r101586;
        double r101607 = r101606 * r101584;
        double r101608 = 1.0;
        double r101609 = r101608 / r101587;
        double r101610 = r101607 * r101609;
        double r101611 = r101605 ? r101589 : r101610;
        double r101612 = r101597 ? r101603 : r101611;
        double r101613 = r101595 ? r101589 : r101612;
        double r101614 = r101591 ? r101593 : r101613;
        return r101614;
}

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.8
Target11.2
Herbie3.9
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]

Derivation

  1. Split input into 4 regimes
  2. if (/ (* a1 a2) (* b1 b2)) < -inf.0

    1. Initial program 64.0

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

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

    if -inf.0 < (/ (* a1 a2) (* b1 b2)) < -6.7041547108655e-315 or -0.0 < (/ (* a1 a2) (* b1 b2)) < 3.552403781503261e+307

    1. Initial program 3.6

      \[\frac{a1 \cdot a2}{b1 \cdot b2}\]

    if -6.7041547108655e-315 < (/ (* a1 a2) (* b1 b2)) < -0.0

    1. Initial program 14.6

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

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

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

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

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

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

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

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

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

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

    if 3.552403781503261e+307 < (/ (* a1 a2) (* b1 b2))

    1. Initial program 63.7

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} = -\infty:\\ \;\;\;\;\frac{a1}{\frac{b1 \cdot b2}{a2}}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -6.70415471086550637493707435050808693496 \cdot 10^{-315}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -0.0:\\ \;\;\;\;\left(\left(\sqrt[3]{\frac{a2}{b2}} \cdot \sqrt[3]{\frac{a2}{b2}}\right) \cdot a1\right) \cdot \frac{\sqrt[3]{\frac{a2}{b2}}}{b1}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 3.55240378150326106810509497578384630044 \cdot 10^{307}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{a1}{b1} \cdot a2\right) \cdot \frac{1}{b2}\\ \end{array}\]

Reproduce

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

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

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