Average Error: 11.0 → 3.4
Time: 2.9s
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}:\\ \;\;\;\;1 \cdot \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 9.506032662109647035241797532004526510017 \cdot 10^{254}:\\ \;\;\;\;1 \cdot \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} = -\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}:\\
\;\;\;\;1 \cdot \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 9.506032662109647035241797532004526510017 \cdot 10^{254}:\\
\;\;\;\;1 \cdot \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 r145349 = a1;
        double r145350 = a2;
        double r145351 = r145349 * r145350;
        double r145352 = b1;
        double r145353 = b2;
        double r145354 = r145352 * r145353;
        double r145355 = r145351 / r145354;
        return r145355;
}

double f(double a1, double a2, double b1, double b2) {
        double r145356 = a1;
        double r145357 = a2;
        double r145358 = r145356 * r145357;
        double r145359 = b1;
        double r145360 = b2;
        double r145361 = r145359 * r145360;
        double r145362 = r145358 / r145361;
        double r145363 = -inf.0;
        bool r145364 = r145362 <= r145363;
        double r145365 = r145356 / r145359;
        double r145366 = cbrt(r145360);
        double r145367 = r145366 * r145366;
        double r145368 = r145365 / r145367;
        double r145369 = r145357 / r145366;
        double r145370 = r145368 * r145369;
        double r145371 = -3.85046370192055e-260;
        bool r145372 = r145362 <= r145371;
        double r145373 = 1.0;
        double r145374 = r145373 * r145362;
        double r145375 = 0.0;
        bool r145376 = r145362 <= r145375;
        double r145377 = 9.506032662109647e+254;
        bool r145378 = r145362 <= r145377;
        double r145379 = r145357 / r145360;
        double r145380 = r145356 * r145379;
        double r145381 = r145380 / r145359;
        double r145382 = r145378 ? r145374 : r145381;
        double r145383 = r145376 ? r145370 : r145382;
        double r145384 = r145372 ? r145374 : r145383;
        double r145385 = r145364 ? r145370 : r145384;
        return r145385;
}

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 *-un-lft-identity13.0

      \[\leadsto \frac{a1}{\color{blue}{1 \cdot b1}} \cdot \frac{a2}{b2}\]
    6. Applied *-un-lft-identity13.0

      \[\leadsto \frac{\color{blue}{1 \cdot a1}}{1 \cdot b1} \cdot \frac{a2}{b2}\]
    7. Applied times-frac13.0

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

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

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

    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}:\\ \;\;\;\;1 \cdot \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 9.506032662109647035241797532004526510017 \cdot 10^{254}:\\ \;\;\;\;1 \cdot \frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1 \cdot \frac{a2}{b2}}{b1}\\ \end{array}\]

Reproduce

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

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

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