Average Error: 11.5 → 6.3
Time: 8.2s
Precision: 64
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;b1 \cdot b2 \le -3.879073760322599450066672914765923053393 \cdot 10^{110}:\\ \;\;\;\;\frac{\frac{a1}{b1}}{\frac{b2}{a2}}\\ \mathbf{elif}\;b1 \cdot b2 \le -7.378249179097892230367951646605555713051 \cdot 10^{-128}:\\ \;\;\;\;\frac{a1}{\frac{b1 \cdot b2}{a2}}\\ \mathbf{elif}\;b1 \cdot b2 \le 4.490723890911153990498532039302970574827 \cdot 10^{-250}:\\ \;\;\;\;\frac{\frac{a1}{b1}}{\frac{b2}{a2}}\\ \mathbf{elif}\;b1 \cdot b2 \le 1.150194457634113342149620175619745181399 \cdot 10^{213}:\\ \;\;\;\;\frac{a1}{\frac{b1 \cdot b2}{a2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{a1 \cdot a2}{b1}}{b2}\\ \end{array}\]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
\mathbf{if}\;b1 \cdot b2 \le -3.879073760322599450066672914765923053393 \cdot 10^{110}:\\
\;\;\;\;\frac{\frac{a1}{b1}}{\frac{b2}{a2}}\\

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

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

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

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

\end{array}
double f(double a1, double a2, double b1, double b2) {
        double r118991 = a1;
        double r118992 = a2;
        double r118993 = r118991 * r118992;
        double r118994 = b1;
        double r118995 = b2;
        double r118996 = r118994 * r118995;
        double r118997 = r118993 / r118996;
        return r118997;
}

double f(double a1, double a2, double b1, double b2) {
        double r118998 = b1;
        double r118999 = b2;
        double r119000 = r118998 * r118999;
        double r119001 = -3.8790737603225995e+110;
        bool r119002 = r119000 <= r119001;
        double r119003 = a1;
        double r119004 = r119003 / r118998;
        double r119005 = a2;
        double r119006 = r118999 / r119005;
        double r119007 = r119004 / r119006;
        double r119008 = -7.378249179097892e-128;
        bool r119009 = r119000 <= r119008;
        double r119010 = r119000 / r119005;
        double r119011 = r119003 / r119010;
        double r119012 = 4.490723890911154e-250;
        bool r119013 = r119000 <= r119012;
        double r119014 = 1.1501944576341133e+213;
        bool r119015 = r119000 <= r119014;
        double r119016 = r119003 * r119005;
        double r119017 = r119016 / r118998;
        double r119018 = r119017 / r118999;
        double r119019 = r119015 ? r119011 : r119018;
        double r119020 = r119013 ? r119007 : r119019;
        double r119021 = r119009 ? r119011 : r119020;
        double r119022 = r119002 ? r119007 : r119021;
        return r119022;
}

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

Derivation

  1. Split input into 3 regimes
  2. if (* b1 b2) < -3.8790737603225995e+110 or -7.378249179097892e-128 < (* b1 b2) < 4.490723890911154e-250

    1. Initial program 19.9

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

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

      \[\leadsto \frac{a1}{\frac{b1 \cdot b2}{\color{blue}{1 \cdot a2}}}\]
    6. Applied times-frac12.5

      \[\leadsto \frac{a1}{\color{blue}{\frac{b1}{1} \cdot \frac{b2}{a2}}}\]
    7. Applied associate-/r*8.5

      \[\leadsto \color{blue}{\frac{\frac{a1}{\frac{b1}{1}}}{\frac{b2}{a2}}}\]
    8. Simplified8.5

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

    if -3.8790737603225995e+110 < (* b1 b2) < -7.378249179097892e-128 or 4.490723890911154e-250 < (* b1 b2) < 1.1501944576341133e+213

    1. Initial program 4.3

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

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

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

    if 1.1501944576341133e+213 < (* b1 b2)

    1. Initial program 17.0

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b1 \cdot b2 \le -3.879073760322599450066672914765923053393 \cdot 10^{110}:\\ \;\;\;\;\frac{\frac{a1}{b1}}{\frac{b2}{a2}}\\ \mathbf{elif}\;b1 \cdot b2 \le -7.378249179097892230367951646605555713051 \cdot 10^{-128}:\\ \;\;\;\;\frac{a1}{\frac{b1 \cdot b2}{a2}}\\ \mathbf{elif}\;b1 \cdot b2 \le 4.490723890911153990498532039302970574827 \cdot 10^{-250}:\\ \;\;\;\;\frac{\frac{a1}{b1}}{\frac{b2}{a2}}\\ \mathbf{elif}\;b1 \cdot b2 \le 1.150194457634113342149620175619745181399 \cdot 10^{213}:\\ \;\;\;\;\frac{a1}{\frac{b1 \cdot b2}{a2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{a1 \cdot a2}{b1}}{b2}\\ \end{array}\]

Reproduce

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

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

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