Average Error: 11.8 → 3.9
Time: 12.5s
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 r106433 = a1;
        double r106434 = a2;
        double r106435 = r106433 * r106434;
        double r106436 = b1;
        double r106437 = b2;
        double r106438 = r106436 * r106437;
        double r106439 = r106435 / r106438;
        return r106439;
}

double f(double a1, double a2, double b1, double b2) {
        double r106440 = a1;
        double r106441 = a2;
        double r106442 = r106440 * r106441;
        double r106443 = b1;
        double r106444 = b2;
        double r106445 = r106443 * r106444;
        double r106446 = r106442 / r106445;
        double r106447 = -inf.0;
        bool r106448 = r106446 <= r106447;
        double r106449 = r106445 / r106441;
        double r106450 = r106440 / r106449;
        double r106451 = -6.7041547108655e-315;
        bool r106452 = r106446 <= r106451;
        double r106453 = -0.0;
        bool r106454 = r106446 <= r106453;
        double r106455 = r106441 / r106444;
        double r106456 = cbrt(r106455);
        double r106457 = r106456 * r106456;
        double r106458 = r106457 * r106440;
        double r106459 = r106456 / r106443;
        double r106460 = r106458 * r106459;
        double r106461 = 3.552403781503261e+307;
        bool r106462 = r106446 <= r106461;
        double r106463 = r106440 / r106443;
        double r106464 = r106463 * r106441;
        double r106465 = 1.0;
        double r106466 = r106465 / r106444;
        double r106467 = r106464 * r106466;
        double r106468 = r106462 ? r106446 : r106467;
        double r106469 = r106454 ? r106460 : r106468;
        double r106470 = r106452 ? r106446 : r106469;
        double r106471 = r106448 ? r106450 : r106470;
        return r106471;
}

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 
(FPCore (a1 a2 b1 b2)
  :name "Quotient of products"
  :precision binary64

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

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