Average Error: 11.1 → 2.9
Time: 1.9s
Precision: 64
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} = -\infty \lor \neg \left(\frac{a1 \cdot a2}{b1 \cdot b2} \le -6.28254 \cdot 10^{-319} \lor \neg \left(\frac{a1 \cdot a2}{b1 \cdot b2} \le 1.16422584143949291 \cdot 10^{-290} \lor \neg \left(\frac{a1 \cdot a2}{b1 \cdot b2} \le 6.1160527718578736 \cdot 10^{209}\right)\right)\right):\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \end{array}\]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
\mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} = -\infty \lor \neg \left(\frac{a1 \cdot a2}{b1 \cdot b2} \le -6.28254 \cdot 10^{-319} \lor \neg \left(\frac{a1 \cdot a2}{b1 \cdot b2} \le 1.16422584143949291 \cdot 10^{-290} \lor \neg \left(\frac{a1 \cdot a2}{b1 \cdot b2} \le 6.1160527718578736 \cdot 10^{209}\right)\right)\right):\\
\;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\

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

\end{array}
double f(double a1, double a2, double b1, double b2) {
        double r274556 = a1;
        double r274557 = a2;
        double r274558 = r274556 * r274557;
        double r274559 = b1;
        double r274560 = b2;
        double r274561 = r274559 * r274560;
        double r274562 = r274558 / r274561;
        return r274562;
}

double f(double a1, double a2, double b1, double b2) {
        double r274563 = a1;
        double r274564 = a2;
        double r274565 = r274563 * r274564;
        double r274566 = b1;
        double r274567 = b2;
        double r274568 = r274566 * r274567;
        double r274569 = r274565 / r274568;
        double r274570 = -inf.0;
        bool r274571 = r274569 <= r274570;
        double r274572 = -6.2825387525173e-319;
        bool r274573 = r274569 <= r274572;
        double r274574 = 1.1642258414394929e-290;
        bool r274575 = r274569 <= r274574;
        double r274576 = 6.1160527718578736e+209;
        bool r274577 = r274569 <= r274576;
        double r274578 = !r274577;
        bool r274579 = r274575 || r274578;
        double r274580 = !r274579;
        bool r274581 = r274573 || r274580;
        double r274582 = !r274581;
        bool r274583 = r274571 || r274582;
        double r274584 = r274563 / r274566;
        double r274585 = r274564 / r274567;
        double r274586 = r274584 * r274585;
        double r274587 = r274583 ? r274586 : r274569;
        return r274587;
}

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.6
Herbie2.9
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]

Derivation

  1. Split input into 2 regimes
  2. if (/ (* a1 a2) (* b1 b2)) < -inf.0 or -6.2825387525173e-319 < (/ (* a1 a2) (* b1 b2)) < 1.1642258414394929e-290 or 6.1160527718578736e+209 < (/ (* a1 a2) (* b1 b2))

    1. Initial program 23.1

      \[\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}}\]

    if -inf.0 < (/ (* a1 a2) (* b1 b2)) < -6.2825387525173e-319 or 1.1642258414394929e-290 < (/ (* a1 a2) (* b1 b2)) < 6.1160527718578736e+209

    1. Initial program 0.8

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

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

      \[\leadsto \color{blue}{\frac{a1}{b1 \cdot b2} \cdot a2}\]
    6. Using strategy rm
    7. Applied pow18.1

      \[\leadsto \frac{a1}{b1 \cdot b2} \cdot \color{blue}{{a2}^{1}}\]
    8. Applied pow18.1

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

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

      \[\leadsto {\color{blue}{\left(\frac{a1 \cdot a2}{b1 \cdot b2}\right)}}^{1}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification2.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} = -\infty \lor \neg \left(\frac{a1 \cdot a2}{b1 \cdot b2} \le -6.28254 \cdot 10^{-319} \lor \neg \left(\frac{a1 \cdot a2}{b1 \cdot b2} \le 1.16422584143949291 \cdot 10^{-290} \lor \neg \left(\frac{a1 \cdot a2}{b1 \cdot b2} \le 6.1160527718578736 \cdot 10^{209}\right)\right)\right):\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \end{array}\]

Reproduce

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

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

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