Average Error: 11.7 → 3.2
Time: 3.0s
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 r120786 = a1;
        double r120787 = a2;
        double r120788 = r120786 * r120787;
        double r120789 = b1;
        double r120790 = b2;
        double r120791 = r120789 * r120790;
        double r120792 = r120788 / r120791;
        return r120792;
}

double f(double a1, double a2, double b1, double b2) {
        double r120793 = a1;
        double r120794 = a2;
        double r120795 = r120793 * r120794;
        double r120796 = b1;
        double r120797 = b2;
        double r120798 = r120796 * r120797;
        double r120799 = r120795 / r120798;
        double r120800 = -1.7259511238474872e+296;
        bool r120801 = r120799 <= r120800;
        double r120802 = r120794 / r120797;
        double r120803 = r120802 / r120796;
        double r120804 = r120793 * r120803;
        double r120805 = -3.5493029940074664e-307;
        bool r120806 = r120799 <= r120805;
        double r120807 = 0.0;
        bool r120808 = r120799 <= r120807;
        double r120809 = r120793 / r120796;
        double r120810 = cbrt(r120797);
        double r120811 = r120810 * r120810;
        double r120812 = r120809 / r120811;
        double r120813 = r120794 / r120810;
        double r120814 = r120812 * r120813;
        double r120815 = 8.09671095346136e+300;
        bool r120816 = r120799 <= r120815;
        double r120817 = r120793 * r120802;
        double r120818 = r120817 / r120796;
        double r120819 = r120816 ? r120799 : r120818;
        double r120820 = r120808 ? r120814 : r120819;
        double r120821 = r120806 ? r120799 : r120820;
        double r120822 = r120801 ? r120804 : r120821;
        return r120822;
}

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 
(FPCore (a1 a2 b1 b2)
  :name "Quotient of products"
  :precision binary64

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

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