Average Error: 11.0 → 3.4
Time: 3.0s
Precision: 64
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} = -\infty:\\ \;\;\;\;\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 -3.850463701920550132787004998763800105824 \cdot 10^{-260}:\\ \;\;\;\;\frac{a1 \cdot a2}{b2 \cdot b1}\\ \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 9.506032662109647035241797532004526510017 \cdot 10^{254}:\\ \;\;\;\;\frac{a1 \cdot a2}{b2 \cdot b1}\\ \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} = -\infty:\\
\;\;\;\;\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 -3.850463701920550132787004998763800105824 \cdot 10^{-260}:\\
\;\;\;\;\frac{a1 \cdot a2}{b2 \cdot b1}\\

\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 9.506032662109647035241797532004526510017 \cdot 10^{254}:\\
\;\;\;\;\frac{a1 \cdot a2}{b2 \cdot b1}\\

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

\end{array}
double f(double a1, double a2, double b1, double b2) {
        double r141719 = a1;
        double r141720 = a2;
        double r141721 = r141719 * r141720;
        double r141722 = b1;
        double r141723 = b2;
        double r141724 = r141722 * r141723;
        double r141725 = r141721 / r141724;
        return r141725;
}

double f(double a1, double a2, double b1, double b2) {
        double r141726 = a1;
        double r141727 = a2;
        double r141728 = r141726 * r141727;
        double r141729 = b1;
        double r141730 = b2;
        double r141731 = r141729 * r141730;
        double r141732 = r141728 / r141731;
        double r141733 = -inf.0;
        bool r141734 = r141732 <= r141733;
        double r141735 = r141726 / r141729;
        double r141736 = cbrt(r141730);
        double r141737 = r141736 * r141736;
        double r141738 = r141735 / r141737;
        double r141739 = r141727 / r141736;
        double r141740 = r141738 * r141739;
        double r141741 = -3.85046370192055e-260;
        bool r141742 = r141732 <= r141741;
        double r141743 = r141730 * r141729;
        double r141744 = r141728 / r141743;
        double r141745 = 0.0;
        bool r141746 = r141732 <= r141745;
        double r141747 = 9.506032662109647e+254;
        bool r141748 = r141732 <= r141747;
        double r141749 = r141727 / r141730;
        double r141750 = r141726 * r141749;
        double r141751 = r141750 / r141729;
        double r141752 = r141748 ? r141744 : r141751;
        double r141753 = r141746 ? r141740 : r141752;
        double r141754 = r141742 ? r141744 : r141753;
        double r141755 = r141734 ? r141740 : r141754;
        return r141755;
}

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

Derivation

  1. Split input into 3 regimes
  2. if (/ (* a1 a2) (* b1 b2)) < -inf.0 or -3.85046370192055e-260 < (/ (* a1 a2) (* b1 b2)) < 0.0

    1. Initial program 20.7

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

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

      \[\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-identity5.7

      \[\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-frac5.7

      \[\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*6.5

      \[\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. Simplified6.5

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

    if -inf.0 < (/ (* a1 a2) (* b1 b2)) < -3.85046370192055e-260 or 0.0 < (/ (* a1 a2) (* b1 b2)) < 9.506032662109647e+254

    1. Initial program 3.4

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

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

      \[\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-identity13.6

      \[\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-frac13.6

      \[\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*11.6

      \[\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. Simplified11.6

      \[\leadsto \color{blue}{\frac{\frac{a1}{b1}}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}}} \cdot \frac{a2}{\sqrt[3]{b2}}\]
    10. Using strategy rm
    11. Applied frac-times12.1

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

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

      \[\leadsto \frac{\color{blue}{\frac{a1 \cdot a2}{b1}}}{b2}\]
    15. Applied associate-/l/3.4

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

    if 9.506032662109647e+254 < (/ (* a1 a2) (* b1 b2))

    1. Initial program 51.1

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} = -\infty:\\ \;\;\;\;\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 -3.850463701920550132787004998763800105824 \cdot 10^{-260}:\\ \;\;\;\;\frac{a1 \cdot a2}{b2 \cdot b1}\\ \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 9.506032662109647035241797532004526510017 \cdot 10^{254}:\\ \;\;\;\;\frac{a1 \cdot a2}{b2 \cdot b1}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1 \cdot \frac{a2}{b2}}{b1}\\ \end{array}\]

Reproduce

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

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

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