Average Error: 11.6 → 2.3
Time: 3.2s
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 r147802 = a1;
        double r147803 = a2;
        double r147804 = r147802 * r147803;
        double r147805 = b1;
        double r147806 = b2;
        double r147807 = r147805 * r147806;
        double r147808 = r147804 / r147807;
        return r147808;
}

double f(double a1, double a2, double b1, double b2) {
        double r147809 = a1;
        double r147810 = a2;
        double r147811 = r147809 * r147810;
        double r147812 = b1;
        double r147813 = b2;
        double r147814 = r147812 * r147813;
        double r147815 = r147811 / r147814;
        double r147816 = -9.70902822860593e+269;
        bool r147817 = r147815 <= r147816;
        double r147818 = r147810 / r147813;
        double r147819 = r147818 / r147812;
        double r147820 = r147809 * r147819;
        double r147821 = -1.354165395452925e-308;
        bool r147822 = r147815 <= r147821;
        double r147823 = 1.0;
        double r147824 = r147814 / r147811;
        double r147825 = r147823 / r147824;
        double r147826 = 0.0;
        bool r147827 = r147815 <= r147826;
        double r147828 = cbrt(r147812);
        double r147829 = r147828 * r147828;
        double r147830 = cbrt(r147813);
        double r147831 = r147830 * r147830;
        double r147832 = r147829 * r147831;
        double r147833 = r147809 / r147832;
        double r147834 = r147810 / r147830;
        double r147835 = r147834 / r147828;
        double r147836 = r147833 * r147835;
        double r147837 = 8.662421594280042e+306;
        bool r147838 = r147815 <= r147837;
        double r147839 = r147809 / r147812;
        double r147840 = r147839 * r147818;
        double r147841 = r147838 ? r147815 : r147840;
        double r147842 = r147827 ? r147836 : r147841;
        double r147843 = r147822 ? r147825 : r147842;
        double r147844 = r147817 ? r147820 : r147843;
        return r147844;
}

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)))