Average Error: 11.7 → 3.2
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 -1.72595112384748723 \cdot 10^{296}:\\ \;\;\;\;a1 \cdot \frac{\frac{a2}{b2}}{b1}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -3.5493029940074664 \cdot 10^{-307}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 0.0:\\ \;\;\;\;\frac{\frac{a1}{b1}}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}} \cdot \frac{a2}{\sqrt[3]{b2}}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 8.09671095346136017 \cdot 10^{300}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1 \cdot \frac{a2}{b2}}{b1}\\ \end{array}\]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
\mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -1.72595112384748723 \cdot 10^{296}:\\
\;\;\;\;a1 \cdot \frac{\frac{a2}{b2}}{b1}\\

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

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

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

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

\end{array}
double f(double a1, double a2, double b1, double b2) {
        double r156775 = a1;
        double r156776 = a2;
        double r156777 = r156775 * r156776;
        double r156778 = b1;
        double r156779 = b2;
        double r156780 = r156778 * r156779;
        double r156781 = r156777 / r156780;
        return r156781;
}

double f(double a1, double a2, double b1, double b2) {
        double r156782 = a1;
        double r156783 = a2;
        double r156784 = r156782 * r156783;
        double r156785 = b1;
        double r156786 = b2;
        double r156787 = r156785 * r156786;
        double r156788 = r156784 / r156787;
        double r156789 = -1.7259511238474872e+296;
        bool r156790 = r156788 <= r156789;
        double r156791 = r156783 / r156786;
        double r156792 = r156791 / r156785;
        double r156793 = r156782 * r156792;
        double r156794 = -3.5493029940074664e-307;
        bool r156795 = r156788 <= r156794;
        double r156796 = 0.0;
        bool r156797 = r156788 <= r156796;
        double r156798 = r156782 / r156785;
        double r156799 = cbrt(r156786);
        double r156800 = r156799 * r156799;
        double r156801 = r156798 / r156800;
        double r156802 = r156783 / r156799;
        double r156803 = r156801 * r156802;
        double r156804 = 8.09671095346136e+300;
        bool r156805 = r156788 <= r156804;
        double r156806 = r156782 * r156791;
        double r156807 = r156806 / r156785;
        double r156808 = r156805 ? r156788 : r156807;
        double r156809 = r156797 ? r156803 : r156808;
        double r156810 = r156795 ? r156788 : r156809;
        double r156811 = r156790 ? r156793 : r156810;
        return r156811;
}

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

Derivation

  1. Split input into 4 regimes
  2. if (/ (* a1 a2) (* b1 b2)) < -1.7259511238474872e+296

    1. Initial program 57.8

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

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

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

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

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

    if -1.7259511238474872e+296 < (/ (* a1 a2) (* b1 b2)) < -3.5493029940074664e-307 or 0.0 < (/ (* a1 a2) (* b1 b2)) < 8.09671095346136e+300

    1. Initial program 0.9

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

    if -3.5493029940074664e-307 < (/ (* a1 a2) (* b1 b2)) < 0.0

    1. Initial program 13.7

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

      \[\leadsto \color{blue}{\frac{a1}{b1} \cdot \frac{a2}{b2}}\]
    4. Using strategy rm
    5. Applied add-cube-cbrt2.4

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

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

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

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

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

    if 8.09671095346136e+300 < (/ (* a1 a2) (* b1 b2))

    1. Initial program 61.3

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -1.72595112384748723 \cdot 10^{296}:\\ \;\;\;\;a1 \cdot \frac{\frac{a2}{b2}}{b1}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -3.5493029940074664 \cdot 10^{-307}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 0.0:\\ \;\;\;\;\frac{\frac{a1}{b1}}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}} \cdot \frac{a2}{\sqrt[3]{b2}}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 8.09671095346136017 \cdot 10^{300}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1 \cdot \frac{a2}{b2}}{b1}\\ \end{array}\]

Reproduce

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

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

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