Average Error: 11.1 → 2.9
Time: 13.3s
Precision: 64
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} = -\infty:\\ \;\;\;\;\frac{a1 \cdot \frac{a2}{b2}}{b1}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -2.424333575784733165640312865210186090398 \cdot 10^{-300}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 0.0:\\ \;\;\;\;\frac{a1}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}} \cdot \frac{\frac{a2}{\sqrt[3]{b2}}}{b1}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 1.173306201668288734588760971486902423604 \cdot 10^{275}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;a1 \cdot \frac{\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{a1 \cdot \frac{a2}{b2}}{b1}\\

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

\mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 0.0:\\
\;\;\;\;\frac{a1}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}} \cdot \frac{\frac{a2}{\sqrt[3]{b2}}}{b1}\\

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

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

\end{array}
double f(double a1, double a2, double b1, double b2) {
        double r82402 = a1;
        double r82403 = a2;
        double r82404 = r82402 * r82403;
        double r82405 = b1;
        double r82406 = b2;
        double r82407 = r82405 * r82406;
        double r82408 = r82404 / r82407;
        return r82408;
}

double f(double a1, double a2, double b1, double b2) {
        double r82409 = a1;
        double r82410 = a2;
        double r82411 = r82409 * r82410;
        double r82412 = b1;
        double r82413 = b2;
        double r82414 = r82412 * r82413;
        double r82415 = r82411 / r82414;
        double r82416 = -inf.0;
        bool r82417 = r82415 <= r82416;
        double r82418 = r82410 / r82413;
        double r82419 = r82409 * r82418;
        double r82420 = r82419 / r82412;
        double r82421 = -2.424333575784733e-300;
        bool r82422 = r82415 <= r82421;
        double r82423 = 0.0;
        bool r82424 = r82415 <= r82423;
        double r82425 = cbrt(r82413);
        double r82426 = r82425 * r82425;
        double r82427 = r82409 / r82426;
        double r82428 = r82410 / r82425;
        double r82429 = r82428 / r82412;
        double r82430 = r82427 * r82429;
        double r82431 = 1.1733062016682887e+275;
        bool r82432 = r82415 <= r82431;
        double r82433 = r82418 / r82412;
        double r82434 = r82409 * r82433;
        double r82435 = r82432 ? r82415 : r82434;
        double r82436 = r82424 ? r82430 : r82435;
        double r82437 = r82422 ? r82415 : r82436;
        double r82438 = r82417 ? r82420 : r82437;
        return r82438;
}

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.1
Target11.3
Herbie2.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 times-frac13.1

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

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

    if -inf.0 < (/ (* a1 a2) (* b1 b2)) < -2.424333575784733e-300 or 0.0 < (/ (* a1 a2) (* b1 b2)) < 1.1733062016682887e+275

    1. Initial program 3.5

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

    if -2.424333575784733e-300 < (/ (* a1 a2) (* b1 b2)) < 0.0

    1. Initial program 12.5

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

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

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

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

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

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

      \[\leadsto a1 \cdot \frac{\frac{a2}{\color{blue}{\left(\sqrt[3]{b2} \cdot \sqrt[3]{b2}\right) \cdot \sqrt[3]{b2}}}}{1 \cdot b1}\]
    11. Applied *-un-lft-identity4.3

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

      \[\leadsto a1 \cdot \frac{\color{blue}{\frac{1}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}} \cdot \frac{a2}{\sqrt[3]{b2}}}}{1 \cdot b1}\]
    13. Applied times-frac4.2

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

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

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

    if 1.1733062016682887e+275 < (/ (* a1 a2) (* b1 b2))

    1. Initial program 54.5

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} = -\infty:\\ \;\;\;\;\frac{a1 \cdot \frac{a2}{b2}}{b1}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -2.424333575784733165640312865210186090398 \cdot 10^{-300}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 0.0:\\ \;\;\;\;\frac{a1}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}} \cdot \frac{\frac{a2}{\sqrt[3]{b2}}}{b1}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 1.173306201668288734588760971486902423604 \cdot 10^{275}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;a1 \cdot \frac{\frac{a2}{b2}}{b1}\\ \end{array}\]

Reproduce

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

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

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