Average Error: 11.5 → 3.8
Time: 20.0s
Precision: 64
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;\frac{a2 \cdot a1}{b2 \cdot b1} = -\infty:\\ \;\;\;\;\frac{\frac{a1}{b1}}{\frac{b2}{a2}}\\ \mathbf{elif}\;\frac{a2 \cdot a1}{b2 \cdot b1} \le -8.689229871317468393658322463867604866085 \cdot 10^{-264}:\\ \;\;\;\;\frac{a2 \cdot a1}{b2 \cdot b1}\\ \mathbf{elif}\;\frac{a2 \cdot a1}{b2 \cdot b1} \le -0.0:\\ \;\;\;\;a1 \cdot \frac{\frac{a2}{b1}}{b2}\\ \mathbf{elif}\;\frac{a2 \cdot a1}{b2 \cdot b1} \le 9.000995610168164344108674672461018222846 \cdot 10^{241}:\\ \;\;\;\;\frac{a2 \cdot a1}{b2 \cdot b1}\\ \mathbf{else}:\\ \;\;\;\;a1 \cdot \frac{\frac{a2}{b1}}{b2}\\ \end{array}\]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
\mathbf{if}\;\frac{a2 \cdot a1}{b2 \cdot b1} = -\infty:\\
\;\;\;\;\frac{\frac{a1}{b1}}{\frac{b2}{a2}}\\

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

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

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

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

\end{array}
double f(double a1, double a2, double b1, double b2) {
        double r5672996 = a1;
        double r5672997 = a2;
        double r5672998 = r5672996 * r5672997;
        double r5672999 = b1;
        double r5673000 = b2;
        double r5673001 = r5672999 * r5673000;
        double r5673002 = r5672998 / r5673001;
        return r5673002;
}

double f(double a1, double a2, double b1, double b2) {
        double r5673003 = a2;
        double r5673004 = a1;
        double r5673005 = r5673003 * r5673004;
        double r5673006 = b2;
        double r5673007 = b1;
        double r5673008 = r5673006 * r5673007;
        double r5673009 = r5673005 / r5673008;
        double r5673010 = -inf.0;
        bool r5673011 = r5673009 <= r5673010;
        double r5673012 = r5673004 / r5673007;
        double r5673013 = r5673006 / r5673003;
        double r5673014 = r5673012 / r5673013;
        double r5673015 = -8.689229871317468e-264;
        bool r5673016 = r5673009 <= r5673015;
        double r5673017 = -0.0;
        bool r5673018 = r5673009 <= r5673017;
        double r5673019 = r5673003 / r5673007;
        double r5673020 = r5673019 / r5673006;
        double r5673021 = r5673004 * r5673020;
        double r5673022 = 9.000995610168164e+241;
        bool r5673023 = r5673009 <= r5673022;
        double r5673024 = r5673023 ? r5673009 : r5673021;
        double r5673025 = r5673018 ? r5673021 : r5673024;
        double r5673026 = r5673016 ? r5673009 : r5673025;
        double r5673027 = r5673011 ? r5673014 : r5673026;
        return r5673027;
}

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

Derivation

  1. Split input into 3 regimes
  2. if (/ (* a1 a2) (* b1 b2)) < -inf.0

    1. Initial program 64.0

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

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

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

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

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

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

    if -inf.0 < (/ (* a1 a2) (* b1 b2)) < -8.689229871317468e-264 or -0.0 < (/ (* a1 a2) (* b1 b2)) < 9.000995610168164e+241

    1. Initial program 0.9

      \[\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. Taylor expanded around 0 0.9

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

    if -8.689229871317468e-264 < (/ (* a1 a2) (* b1 b2)) < -0.0 or 9.000995610168164e+241 < (/ (* a1 a2) (* b1 b2))

    1. Initial program 20.9

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{a2 \cdot a1}{b2 \cdot b1} = -\infty:\\ \;\;\;\;\frac{\frac{a1}{b1}}{\frac{b2}{a2}}\\ \mathbf{elif}\;\frac{a2 \cdot a1}{b2 \cdot b1} \le -8.689229871317468393658322463867604866085 \cdot 10^{-264}:\\ \;\;\;\;\frac{a2 \cdot a1}{b2 \cdot b1}\\ \mathbf{elif}\;\frac{a2 \cdot a1}{b2 \cdot b1} \le -0.0:\\ \;\;\;\;a1 \cdot \frac{\frac{a2}{b1}}{b2}\\ \mathbf{elif}\;\frac{a2 \cdot a1}{b2 \cdot b1} \le 9.000995610168164344108674672461018222846 \cdot 10^{241}:\\ \;\;\;\;\frac{a2 \cdot a1}{b2 \cdot b1}\\ \mathbf{else}:\\ \;\;\;\;a1 \cdot \frac{\frac{a2}{b1}}{b2}\\ \end{array}\]

Reproduce

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

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

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