Average Error: 11.6 → 2.3
Time: 3.1s
Precision: 64
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -9.70902822860593018100726549242427629367 \cdot 10^{269}:\\ \;\;\;\;a1 \cdot \frac{\frac{a2}{b2}}{b1}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -1.354165395452925096499840829844842091146 \cdot 10^{-308}:\\ \;\;\;\;\frac{1}{\frac{b1 \cdot b2}{a1 \cdot a2}}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 0.0:\\ \;\;\;\;\frac{a1}{\left(\sqrt[3]{b1} \cdot \sqrt[3]{b1}\right) \cdot \left(\sqrt[3]{b2} \cdot \sqrt[3]{b2}\right)} \cdot \frac{\frac{a2}{\sqrt[3]{b2}}}{\sqrt[3]{b1}}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 8.662421594280041679794721844727974951203 \cdot 10^{306}:\\ \;\;\;\;\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} \le -9.70902822860593018100726549242427629367 \cdot 10^{269}:\\
\;\;\;\;a1 \cdot \frac{\frac{a2}{b2}}{b1}\\

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

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

\mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 8.662421594280041679794721844727974951203 \cdot 10^{306}:\\
\;\;\;\;\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 r155727 = a1;
        double r155728 = a2;
        double r155729 = r155727 * r155728;
        double r155730 = b1;
        double r155731 = b2;
        double r155732 = r155730 * r155731;
        double r155733 = r155729 / r155732;
        return r155733;
}

double f(double a1, double a2, double b1, double b2) {
        double r155734 = a1;
        double r155735 = a2;
        double r155736 = r155734 * r155735;
        double r155737 = b1;
        double r155738 = b2;
        double r155739 = r155737 * r155738;
        double r155740 = r155736 / r155739;
        double r155741 = -9.70902822860593e+269;
        bool r155742 = r155740 <= r155741;
        double r155743 = r155735 / r155738;
        double r155744 = r155743 / r155737;
        double r155745 = r155734 * r155744;
        double r155746 = -1.354165395452925e-308;
        bool r155747 = r155740 <= r155746;
        double r155748 = 1.0;
        double r155749 = r155739 / r155736;
        double r155750 = r155748 / r155749;
        double r155751 = 0.0;
        bool r155752 = r155740 <= r155751;
        double r155753 = cbrt(r155737);
        double r155754 = r155753 * r155753;
        double r155755 = cbrt(r155738);
        double r155756 = r155755 * r155755;
        double r155757 = r155754 * r155756;
        double r155758 = r155734 / r155757;
        double r155759 = r155735 / r155755;
        double r155760 = r155759 / r155753;
        double r155761 = r155758 * r155760;
        double r155762 = 8.662421594280042e+306;
        bool r155763 = r155740 <= r155762;
        double r155764 = r155734 / r155737;
        double r155765 = r155764 * r155743;
        double r155766 = r155763 ? r155740 : r155765;
        double r155767 = r155752 ? r155761 : r155766;
        double r155768 = r155747 ? r155750 : r155767;
        double r155769 = r155742 ? r155745 : r155768;
        return r155769;
}

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.6
Target11.1
Herbie2.3
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]

Derivation

  1. Split input into 5 regimes
  2. if (/ (* a1 a2) (* b1 b2)) < -9.70902822860593e+269

    1. Initial program 46.1

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

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

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

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

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

    if -9.70902822860593e+269 < (/ (* a1 a2) (* b1 b2)) < -1.354165395452925e-308

    1. Initial program 0.7

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

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

    if -1.354165395452925e-308 < (/ (* a1 a2) (* b1 b2)) < 0.0

    1. Initial program 14.2

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

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

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

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

      \[\leadsto a1 \cdot \color{blue}{\frac{\frac{a2}{b2}}{b1}}\]
    8. Using strategy rm
    9. Applied add-cube-cbrt4.7

      \[\leadsto a1 \cdot \frac{\frac{a2}{b2}}{\color{blue}{\left(\sqrt[3]{b1} \cdot \sqrt[3]{b1}\right) \cdot \sqrt[3]{b1}}}\]
    10. Applied add-cube-cbrt4.7

      \[\leadsto a1 \cdot \frac{\frac{a2}{\color{blue}{\left(\sqrt[3]{b2} \cdot \sqrt[3]{b2}\right) \cdot \sqrt[3]{b2}}}}{\left(\sqrt[3]{b1} \cdot \sqrt[3]{b1}\right) \cdot \sqrt[3]{b1}}\]
    11. Applied *-un-lft-identity4.7

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

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

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

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

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

    if 0.0 < (/ (* a1 a2) (* b1 b2)) < 8.662421594280042e+306

    1. Initial program 4.9

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

    if 8.662421594280042e+306 < (/ (* a1 a2) (* b1 b2))

    1. Initial program 63.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -9.70902822860593018100726549242427629367 \cdot 10^{269}:\\ \;\;\;\;a1 \cdot \frac{\frac{a2}{b2}}{b1}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -1.354165395452925096499840829844842091146 \cdot 10^{-308}:\\ \;\;\;\;\frac{1}{\frac{b1 \cdot b2}{a1 \cdot a2}}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 0.0:\\ \;\;\;\;\frac{a1}{\left(\sqrt[3]{b1} \cdot \sqrt[3]{b1}\right) \cdot \left(\sqrt[3]{b2} \cdot \sqrt[3]{b2}\right)} \cdot \frac{\frac{a2}{\sqrt[3]{b2}}}{\sqrt[3]{b1}}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 8.662421594280041679794721844727974951203 \cdot 10^{306}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \end{array}\]

Reproduce

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

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

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