Average Error: 11.2 → 5.3
Time: 2.1s
Precision: 64
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;b1 \cdot b2 \le -3.83139257688113893 \cdot 10^{179} \lor \neg \left(b1 \cdot b2 \le -1.85368990459426914 \cdot 10^{-182} \lor \neg \left(b1 \cdot b2 \le 1.4192384906235271 \cdot 10^{-201} \lor \neg \left(b1 \cdot b2 \le 1.8190010618023067 \cdot 10^{202}\right)\right)\right):\\ \;\;\;\;\frac{\frac{a1}{b1}}{\frac{b2}{a2}}\\ \mathbf{else}:\\ \;\;\;\;a2 \cdot \frac{a1}{b1 \cdot b2}\\ \end{array}\]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
\mathbf{if}\;b1 \cdot b2 \le -3.83139257688113893 \cdot 10^{179} \lor \neg \left(b1 \cdot b2 \le -1.85368990459426914 \cdot 10^{-182} \lor \neg \left(b1 \cdot b2 \le 1.4192384906235271 \cdot 10^{-201} \lor \neg \left(b1 \cdot b2 \le 1.8190010618023067 \cdot 10^{202}\right)\right)\right):\\
\;\;\;\;\frac{\frac{a1}{b1}}{\frac{b2}{a2}}\\

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

\end{array}
double f(double a1, double a2, double b1, double b2) {
        double r139147 = a1;
        double r139148 = a2;
        double r139149 = r139147 * r139148;
        double r139150 = b1;
        double r139151 = b2;
        double r139152 = r139150 * r139151;
        double r139153 = r139149 / r139152;
        return r139153;
}

double f(double a1, double a2, double b1, double b2) {
        double r139154 = b1;
        double r139155 = b2;
        double r139156 = r139154 * r139155;
        double r139157 = -3.831392576881139e+179;
        bool r139158 = r139156 <= r139157;
        double r139159 = -1.853689904594269e-182;
        bool r139160 = r139156 <= r139159;
        double r139161 = 1.4192384906235271e-201;
        bool r139162 = r139156 <= r139161;
        double r139163 = 1.8190010618023067e+202;
        bool r139164 = r139156 <= r139163;
        double r139165 = !r139164;
        bool r139166 = r139162 || r139165;
        double r139167 = !r139166;
        bool r139168 = r139160 || r139167;
        double r139169 = !r139168;
        bool r139170 = r139158 || r139169;
        double r139171 = a1;
        double r139172 = r139171 / r139154;
        double r139173 = a2;
        double r139174 = r139155 / r139173;
        double r139175 = r139172 / r139174;
        double r139176 = r139171 / r139156;
        double r139177 = r139173 * r139176;
        double r139178 = r139170 ? r139175 : r139177;
        return r139178;
}

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.2
Target11.0
Herbie5.3
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]

Derivation

  1. Split input into 2 regimes
  2. if (* b1 b2) < -3.831392576881139e+179 or -1.853689904594269e-182 < (* b1 b2) < 1.4192384906235271e-201 or 1.8190010618023067e+202 < (* b1 b2)

    1. Initial program 20.1

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

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

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

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

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

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

    if -3.831392576881139e+179 < (* b1 b2) < -1.853689904594269e-182 or 1.4192384906235271e-201 < (* b1 b2) < 1.8190010618023067e+202

    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 associate-/r/4.3

      \[\leadsto \color{blue}{\frac{a1}{b1 \cdot b2} \cdot a2}\]
    6. Using strategy rm
    7. Applied *-commutative4.3

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b1 \cdot b2 \le -3.83139257688113893 \cdot 10^{179} \lor \neg \left(b1 \cdot b2 \le -1.85368990459426914 \cdot 10^{-182} \lor \neg \left(b1 \cdot b2 \le 1.4192384906235271 \cdot 10^{-201} \lor \neg \left(b1 \cdot b2 \le 1.8190010618023067 \cdot 10^{202}\right)\right)\right):\\ \;\;\;\;\frac{\frac{a1}{b1}}{\frac{b2}{a2}}\\ \mathbf{else}:\\ \;\;\;\;a2 \cdot \frac{a1}{b1 \cdot b2}\\ \end{array}\]

Reproduce

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

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

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