Average Error: 11.4 → 3.4
Time: 2.1s
Precision: 64
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -1.68280036335944034 \cdot 10^{301}:\\ \;\;\;\;\left(a1 \cdot \frac{a2}{b1}\right) \cdot \frac{1}{b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -4.5204447990899316 \cdot 10^{-307}:\\ \;\;\;\;{\left(\frac{a1 \cdot a2}{b1 \cdot b2}\right)}^{1}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 0.0:\\ \;\;\;\;\frac{a1}{\frac{b1}{\frac{a2}{b2}}}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 4.51733405101081216 \cdot 10^{288}:\\ \;\;\;\;{\left(\frac{a1 \cdot a2}{b1 \cdot b2}\right)}^{1}\\ \mathbf{else}:\\ \;\;\;\;\left(a1 \cdot \frac{a2}{b1}\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} \le -1.68280036335944034 \cdot 10^{301}:\\
\;\;\;\;\left(a1 \cdot \frac{a2}{b1}\right) \cdot \frac{1}{b2}\\

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

\mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 0.0:\\
\;\;\;\;\frac{a1}{\frac{b1}{\frac{a2}{b2}}}\\

\mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 4.51733405101081216 \cdot 10^{288}:\\
\;\;\;\;{\left(\frac{a1 \cdot a2}{b1 \cdot b2}\right)}^{1}\\

\mathbf{else}:\\
\;\;\;\;\left(a1 \cdot \frac{a2}{b1}\right) \cdot \frac{1}{b2}\\

\end{array}
double f(double a1, double a2, double b1, double b2) {
        double r173620 = a1;
        double r173621 = a2;
        double r173622 = r173620 * r173621;
        double r173623 = b1;
        double r173624 = b2;
        double r173625 = r173623 * r173624;
        double r173626 = r173622 / r173625;
        return r173626;
}

double f(double a1, double a2, double b1, double b2) {
        double r173627 = a1;
        double r173628 = a2;
        double r173629 = r173627 * r173628;
        double r173630 = b1;
        double r173631 = b2;
        double r173632 = r173630 * r173631;
        double r173633 = r173629 / r173632;
        double r173634 = -1.6828003633594403e+301;
        bool r173635 = r173633 <= r173634;
        double r173636 = r173628 / r173630;
        double r173637 = r173627 * r173636;
        double r173638 = 1.0;
        double r173639 = r173638 / r173631;
        double r173640 = r173637 * r173639;
        double r173641 = -4.520444799089932e-307;
        bool r173642 = r173633 <= r173641;
        double r173643 = pow(r173633, r173638);
        double r173644 = 0.0;
        bool r173645 = r173633 <= r173644;
        double r173646 = r173628 / r173631;
        double r173647 = r173630 / r173646;
        double r173648 = r173627 / r173647;
        double r173649 = 4.517334051010812e+288;
        bool r173650 = r173633 <= r173649;
        double r173651 = r173650 ? r173643 : r173640;
        double r173652 = r173645 ? r173648 : r173651;
        double r173653 = r173642 ? r173643 : r173652;
        double r173654 = r173635 ? r173640 : r173653;
        return r173654;
}

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.4
Target11.5
Herbie3.4
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]

Derivation

  1. Split input into 3 regimes
  2. if (/ (* a1 a2) (* b1 b2)) < -1.6828003633594403e+301 or 4.517334051010812e+288 < (/ (* a1 a2) (* b1 b2))

    1. Initial program 59.3

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

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

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

      \[\leadsto a1 \cdot \color{blue}{\frac{a2}{b1 \cdot b2}}\]
    7. Using strategy rm
    8. Applied associate-/r*15.2

      \[\leadsto a1 \cdot \color{blue}{\frac{\frac{a2}{b1}}{b2}}\]
    9. Using strategy rm
    10. Applied div-inv15.3

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

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

    if -1.6828003633594403e+301 < (/ (* a1 a2) (* b1 b2)) < -4.520444799089932e-307 or 0.0 < (/ (* a1 a2) (* b1 b2)) < 4.517334051010812e+288

    1. Initial program 0.8

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

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

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

      \[\leadsto a1 \cdot \color{blue}{\frac{a2}{b1 \cdot b2}}\]
    7. Using strategy rm
    8. Applied associate-/r*13.7

      \[\leadsto a1 \cdot \color{blue}{\frac{\frac{a2}{b1}}{b2}}\]
    9. Using strategy rm
    10. Applied pow113.7

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

      \[\leadsto \color{blue}{{a1}^{1}} \cdot {\left(\frac{\frac{a2}{b1}}{b2}\right)}^{1}\]
    12. Applied pow-prod-down13.7

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

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

    if -4.520444799089932e-307 < (/ (* a1 a2) (* b1 b2)) < 0.0

    1. Initial program 13.1

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -1.68280036335944034 \cdot 10^{301}:\\ \;\;\;\;\left(a1 \cdot \frac{a2}{b1}\right) \cdot \frac{1}{b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -4.5204447990899316 \cdot 10^{-307}:\\ \;\;\;\;{\left(\frac{a1 \cdot a2}{b1 \cdot b2}\right)}^{1}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 0.0:\\ \;\;\;\;\frac{a1}{\frac{b1}{\frac{a2}{b2}}}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 4.51733405101081216 \cdot 10^{288}:\\ \;\;\;\;{\left(\frac{a1 \cdot a2}{b1 \cdot b2}\right)}^{1}\\ \mathbf{else}:\\ \;\;\;\;\left(a1 \cdot \frac{a2}{b1}\right) \cdot \frac{1}{b2}\\ \end{array}\]

Reproduce

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

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

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