Average Error: 11.8 → 3.9
Time: 11.9s
Precision: 64
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} = -\infty:\\ \;\;\;\;\frac{a1}{\frac{b1 \cdot b2}{a2}}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -6.70415471086550637493707435050808693496 \cdot 10^{-315}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -0.0:\\ \;\;\;\;\left(\left(\sqrt[3]{\frac{a2}{b2}} \cdot \sqrt[3]{\frac{a2}{b2}}\right) \cdot a1\right) \cdot \frac{\sqrt[3]{\frac{a2}{b2}}}{b1}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 3.55240378150326106810509497578384630044 \cdot 10^{307}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{a1}{b1} \cdot a2\right) \cdot \frac{1}{b2}\\ \end{array}\]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
\mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} = -\infty:\\
\;\;\;\;\frac{a1}{\frac{b1 \cdot b2}{a2}}\\

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

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

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

\mathbf{else}:\\
\;\;\;\;\left(\frac{a1}{b1} \cdot a2\right) \cdot \frac{1}{b2}\\

\end{array}
double f(double a1, double a2, double b1, double b2) {
        double r109794 = a1;
        double r109795 = a2;
        double r109796 = r109794 * r109795;
        double r109797 = b1;
        double r109798 = b2;
        double r109799 = r109797 * r109798;
        double r109800 = r109796 / r109799;
        return r109800;
}

double f(double a1, double a2, double b1, double b2) {
        double r109801 = a1;
        double r109802 = a2;
        double r109803 = r109801 * r109802;
        double r109804 = b1;
        double r109805 = b2;
        double r109806 = r109804 * r109805;
        double r109807 = r109803 / r109806;
        double r109808 = -inf.0;
        bool r109809 = r109807 <= r109808;
        double r109810 = r109806 / r109802;
        double r109811 = r109801 / r109810;
        double r109812 = -6.7041547108655e-315;
        bool r109813 = r109807 <= r109812;
        double r109814 = -0.0;
        bool r109815 = r109807 <= r109814;
        double r109816 = r109802 / r109805;
        double r109817 = cbrt(r109816);
        double r109818 = r109817 * r109817;
        double r109819 = r109818 * r109801;
        double r109820 = r109817 / r109804;
        double r109821 = r109819 * r109820;
        double r109822 = 3.552403781503261e+307;
        bool r109823 = r109807 <= r109822;
        double r109824 = r109801 / r109804;
        double r109825 = r109824 * r109802;
        double r109826 = 1.0;
        double r109827 = r109826 / r109805;
        double r109828 = r109825 * r109827;
        double r109829 = r109823 ? r109807 : r109828;
        double r109830 = r109815 ? r109821 : r109829;
        double r109831 = r109813 ? r109807 : r109830;
        double r109832 = r109809 ? r109811 : r109831;
        return r109832;
}

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

Derivation

  1. Split input into 4 regimes
  2. if (/ (* a1 a2) (* b1 b2)) < -inf.0

    1. Initial program 64.0

      \[\frac{a1 \cdot a2}{b1 \cdot b2}\]
    2. Using strategy rm
    3. Applied associate-/l*32.2

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

    if -inf.0 < (/ (* a1 a2) (* b1 b2)) < -6.7041547108655e-315 or -0.0 < (/ (* a1 a2) (* b1 b2)) < 3.552403781503261e+307

    1. Initial program 3.6

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

    if -6.7041547108655e-315 < (/ (* a1 a2) (* b1 b2)) < -0.0

    1. Initial program 14.6

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

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

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

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

      \[\leadsto a1 \cdot \color{blue}{\frac{\frac{a2}{b2}}{b1}}\]
    8. Using strategy rm
    9. Applied *-un-lft-identity4.3

      \[\leadsto a1 \cdot \frac{\frac{a2}{b2}}{\color{blue}{1 \cdot b1}}\]
    10. Applied add-cube-cbrt4.5

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

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

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

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

    if 3.552403781503261e+307 < (/ (* a1 a2) (* b1 b2))

    1. Initial program 63.7

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} = -\infty:\\ \;\;\;\;\frac{a1}{\frac{b1 \cdot b2}{a2}}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -6.70415471086550637493707435050808693496 \cdot 10^{-315}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -0.0:\\ \;\;\;\;\left(\left(\sqrt[3]{\frac{a2}{b2}} \cdot \sqrt[3]{\frac{a2}{b2}}\right) \cdot a1\right) \cdot \frac{\sqrt[3]{\frac{a2}{b2}}}{b1}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 3.55240378150326106810509497578384630044 \cdot 10^{307}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{a1}{b1} \cdot a2\right) \cdot \frac{1}{b2}\\ \end{array}\]

Reproduce

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

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

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