Average Error: 10.7 → 5.0
Time: 14.8s
Precision: 64
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;b1 \cdot b2 \le -2.776996541214902 \cdot 10^{+242}:\\ \;\;\;\;\frac{\frac{a1}{b1}}{\frac{b2}{a2}}\\ \mathbf{elif}\;b1 \cdot b2 \le -1.2620149532156769 \cdot 10^{-221}:\\ \;\;\;\;\frac{a1}{\frac{1}{\frac{a2}{b1 \cdot b2}}}\\ \mathbf{elif}\;b1 \cdot b2 \le -0.0:\\ \;\;\;\;\frac{\frac{a1}{b1}}{\frac{b2}{a2}}\\ \mathbf{elif}\;b1 \cdot b2 \le 5.0652006343350663 \cdot 10^{+179}:\\ \;\;\;\;\frac{1}{\frac{\frac{b1 \cdot b2}{a2}}{a1}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{a1}{b1}}{\frac{b2}{a2}}\\ \end{array}\]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
\mathbf{if}\;b1 \cdot b2 \le -2.776996541214902 \cdot 10^{+242}:\\
\;\;\;\;\frac{\frac{a1}{b1}}{\frac{b2}{a2}}\\

\mathbf{elif}\;b1 \cdot b2 \le -1.2620149532156769 \cdot 10^{-221}:\\
\;\;\;\;\frac{a1}{\frac{1}{\frac{a2}{b1 \cdot b2}}}\\

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

\mathbf{elif}\;b1 \cdot b2 \le 5.0652006343350663 \cdot 10^{+179}:\\
\;\;\;\;\frac{1}{\frac{\frac{b1 \cdot b2}{a2}}{a1}}\\

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

\end{array}
double f(double a1, double a2, double b1, double b2) {
        double r6338005 = a1;
        double r6338006 = a2;
        double r6338007 = r6338005 * r6338006;
        double r6338008 = b1;
        double r6338009 = b2;
        double r6338010 = r6338008 * r6338009;
        double r6338011 = r6338007 / r6338010;
        return r6338011;
}

double f(double a1, double a2, double b1, double b2) {
        double r6338012 = b1;
        double r6338013 = b2;
        double r6338014 = r6338012 * r6338013;
        double r6338015 = -2.776996541214902e+242;
        bool r6338016 = r6338014 <= r6338015;
        double r6338017 = a1;
        double r6338018 = r6338017 / r6338012;
        double r6338019 = a2;
        double r6338020 = r6338013 / r6338019;
        double r6338021 = r6338018 / r6338020;
        double r6338022 = -1.2620149532156769e-221;
        bool r6338023 = r6338014 <= r6338022;
        double r6338024 = 1.0;
        double r6338025 = r6338019 / r6338014;
        double r6338026 = r6338024 / r6338025;
        double r6338027 = r6338017 / r6338026;
        double r6338028 = -0.0;
        bool r6338029 = r6338014 <= r6338028;
        double r6338030 = 5.0652006343350663e+179;
        bool r6338031 = r6338014 <= r6338030;
        double r6338032 = r6338014 / r6338019;
        double r6338033 = r6338032 / r6338017;
        double r6338034 = r6338024 / r6338033;
        double r6338035 = r6338031 ? r6338034 : r6338021;
        double r6338036 = r6338029 ? r6338021 : r6338035;
        double r6338037 = r6338023 ? r6338027 : r6338036;
        double r6338038 = r6338016 ? r6338021 : r6338037;
        return r6338038;
}

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

Original10.7
Target10.8
Herbie5.0
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]

Derivation

  1. Split input into 3 regimes
  2. if (* b1 b2) < -2.776996541214902e+242 or -1.2620149532156769e-221 < (* b1 b2) < -0.0 or 5.0652006343350663e+179 < (* b1 b2)

    1. Initial program 21.5

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

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

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

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

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

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

    if -2.776996541214902e+242 < (* b1 b2) < -1.2620149532156769e-221

    1. Initial program 4.6

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

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

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

    if -0.0 < (* b1 b2) < 5.0652006343350663e+179

    1. Initial program 5.1

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

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

      \[\leadsto \frac{\color{blue}{1 \cdot a1}}{\frac{b1 \cdot b2}{a2}}\]
    6. Applied associate-/l*5.7

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b1 \cdot b2 \le -2.776996541214902 \cdot 10^{+242}:\\ \;\;\;\;\frac{\frac{a1}{b1}}{\frac{b2}{a2}}\\ \mathbf{elif}\;b1 \cdot b2 \le -1.2620149532156769 \cdot 10^{-221}:\\ \;\;\;\;\frac{a1}{\frac{1}{\frac{a2}{b1 \cdot b2}}}\\ \mathbf{elif}\;b1 \cdot b2 \le -0.0:\\ \;\;\;\;\frac{\frac{a1}{b1}}{\frac{b2}{a2}}\\ \mathbf{elif}\;b1 \cdot b2 \le 5.0652006343350663 \cdot 10^{+179}:\\ \;\;\;\;\frac{1}{\frac{\frac{b1 \cdot b2}{a2}}{a1}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{a1}{b1}}{\frac{b2}{a2}}\\ \end{array}\]

Reproduce

herbie shell --seed 2019141 +o rules:numerics
(FPCore (a1 a2 b1 b2)
  :name "Quotient of products"

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

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