Average Error: 11.3 → 2.6
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:\\ \;\;\;\;\left(\frac{1}{b2} \cdot \frac{a2}{b1}\right) \cdot a1\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -1.859026544525180769940658588695383877197 \cdot 10^{-313}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -0.0:\\ \;\;\;\;\frac{1}{b2} \cdot \left(\frac{a2}{b1} \cdot a1\right)\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 1.990908588070363276139871141296651621269 \cdot 10^{287}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{a2}{b2} \cdot \frac{a1}{b1}\\ \end{array}\]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
\mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} = -\infty:\\
\;\;\;\;\left(\frac{1}{b2} \cdot \frac{a2}{b1}\right) \cdot a1\\

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

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

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

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

\end{array}
double f(double a1, double a2, double b1, double b2) {
        double r5696412 = a1;
        double r5696413 = a2;
        double r5696414 = r5696412 * r5696413;
        double r5696415 = b1;
        double r5696416 = b2;
        double r5696417 = r5696415 * r5696416;
        double r5696418 = r5696414 / r5696417;
        return r5696418;
}

double f(double a1, double a2, double b1, double b2) {
        double r5696419 = a1;
        double r5696420 = a2;
        double r5696421 = r5696419 * r5696420;
        double r5696422 = b1;
        double r5696423 = b2;
        double r5696424 = r5696422 * r5696423;
        double r5696425 = r5696421 / r5696424;
        double r5696426 = -inf.0;
        bool r5696427 = r5696425 <= r5696426;
        double r5696428 = 1.0;
        double r5696429 = r5696428 / r5696423;
        double r5696430 = r5696420 / r5696422;
        double r5696431 = r5696429 * r5696430;
        double r5696432 = r5696431 * r5696419;
        double r5696433 = -1.8590265445252e-313;
        bool r5696434 = r5696425 <= r5696433;
        double r5696435 = -0.0;
        bool r5696436 = r5696425 <= r5696435;
        double r5696437 = r5696430 * r5696419;
        double r5696438 = r5696429 * r5696437;
        double r5696439 = 1.9909085880703633e+287;
        bool r5696440 = r5696425 <= r5696439;
        double r5696441 = r5696420 / r5696423;
        double r5696442 = r5696419 / r5696422;
        double r5696443 = r5696441 * r5696442;
        double r5696444 = r5696440 ? r5696425 : r5696443;
        double r5696445 = r5696436 ? r5696438 : r5696444;
        double r5696446 = r5696434 ? r5696425 : r5696445;
        double r5696447 = r5696427 ? r5696432 : r5696446;
        return r5696447;
}

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.3
Target11.4
Herbie2.6
\[\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*28.6

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

      \[\leadsto \color{blue}{a1 \cdot \frac{1}{\frac{b1 \cdot b2}{a2}}}\]
    6. Simplified14.0

      \[\leadsto a1 \cdot \color{blue}{\frac{\frac{a2}{b1}}{b2}}\]
    7. Using strategy rm
    8. Applied div-inv14.1

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

    if -inf.0 < (/ (* a1 a2) (* b1 b2)) < -1.8590265445252e-313 or -0.0 < (/ (* a1 a2) (* b1 b2)) < 1.9909085880703633e+287

    1. Initial program 0.8

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

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

      \[\leadsto \color{blue}{a1 \cdot \frac{1}{\frac{b1 \cdot b2}{a2}}}\]
    6. Simplified14.2

      \[\leadsto a1 \cdot \color{blue}{\frac{\frac{a2}{b1}}{b2}}\]
    7. Using strategy rm
    8. Applied div-inv14.3

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

      \[\leadsto \color{blue}{\left(a1 \cdot \frac{a2}{b1}\right) \cdot \frac{1}{b2}}\]
    10. Using strategy rm
    11. Applied associate-*r/7.9

      \[\leadsto \color{blue}{\frac{a1 \cdot a2}{b1}} \cdot \frac{1}{b2}\]
    12. Applied frac-times0.8

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

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

    if -1.8590265445252e-313 < (/ (* a1 a2) (* b1 b2)) < -0.0

    1. Initial program 12.9

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

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

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

      \[\leadsto a1 \cdot \color{blue}{\frac{\frac{a2}{b1}}{b2}}\]
    7. Using strategy rm
    8. Applied div-inv3.1

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

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

    if 1.9909085880703633e+287 < (/ (* a1 a2) (* b1 b2))

    1. Initial program 58.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} = -\infty:\\ \;\;\;\;\left(\frac{1}{b2} \cdot \frac{a2}{b1}\right) \cdot a1\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -1.859026544525180769940658588695383877197 \cdot 10^{-313}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -0.0:\\ \;\;\;\;\frac{1}{b2} \cdot \left(\frac{a2}{b1} \cdot a1\right)\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 1.990908588070363276139871141296651621269 \cdot 10^{287}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{a2}{b2} \cdot \frac{a1}{b1}\\ \end{array}\]

Reproduce

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

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

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