Average Error: 11.8 → 3.9
Time: 13.2s
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 r87163 = a1;
        double r87164 = a2;
        double r87165 = r87163 * r87164;
        double r87166 = b1;
        double r87167 = b2;
        double r87168 = r87166 * r87167;
        double r87169 = r87165 / r87168;
        return r87169;
}

double f(double a1, double a2, double b1, double b2) {
        double r87170 = a1;
        double r87171 = a2;
        double r87172 = r87170 * r87171;
        double r87173 = b1;
        double r87174 = b2;
        double r87175 = r87173 * r87174;
        double r87176 = r87172 / r87175;
        double r87177 = -inf.0;
        bool r87178 = r87176 <= r87177;
        double r87179 = r87175 / r87171;
        double r87180 = r87170 / r87179;
        double r87181 = -6.7041547108655e-315;
        bool r87182 = r87176 <= r87181;
        double r87183 = -0.0;
        bool r87184 = r87176 <= r87183;
        double r87185 = r87171 / r87174;
        double r87186 = cbrt(r87185);
        double r87187 = r87186 * r87186;
        double r87188 = r87187 * r87170;
        double r87189 = r87186 / r87173;
        double r87190 = r87188 * r87189;
        double r87191 = 3.552403781503261e+307;
        bool r87192 = r87176 <= r87191;
        double r87193 = r87170 / r87173;
        double r87194 = r87193 * r87171;
        double r87195 = 1.0;
        double r87196 = r87195 / r87174;
        double r87197 = r87194 * r87196;
        double r87198 = r87192 ? r87176 : r87197;
        double r87199 = r87184 ? r87190 : r87198;
        double r87200 = r87182 ? r87176 : r87199;
        double r87201 = r87178 ? r87180 : r87200;
        return r87201;
}

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