Average Error: 10.9 → 5.0
Time: 52.0s
Precision: 64
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;b1 \cdot b2 \le -6.770256909762417 \cdot 10^{+247}:\\ \;\;\;\;\frac{a2}{\frac{b1}{a1}} \cdot \frac{1}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \le -2.5972175215851213 \cdot 10^{-303}:\\ \;\;\;\;\frac{a1}{\frac{b1 \cdot b2}{a2}}\\ \mathbf{elif}\;b1 \cdot b2 \le 1.089678327652975 \cdot 10^{-177}:\\ \;\;\;\;\frac{a2}{\frac{b1}{a1}} \cdot \frac{1}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \le 2.3504500220205782 \cdot 10^{+185}:\\ \;\;\;\;\frac{a1}{\frac{b1 \cdot b2}{a2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{a2}{\frac{b1}{a1}} \cdot \frac{1}{b2}\\ \end{array}\]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
\mathbf{if}\;b1 \cdot b2 \le -6.770256909762417 \cdot 10^{+247}:\\
\;\;\;\;\frac{a2}{\frac{b1}{a1}} \cdot \frac{1}{b2}\\

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

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

\mathbf{elif}\;b1 \cdot b2 \le 2.3504500220205782 \cdot 10^{+185}:\\
\;\;\;\;\frac{a1}{\frac{b1 \cdot b2}{a2}}\\

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

\end{array}
double f(double a1, double a2, double b1, double b2) {
        double r7277788 = a1;
        double r7277789 = a2;
        double r7277790 = r7277788 * r7277789;
        double r7277791 = b1;
        double r7277792 = b2;
        double r7277793 = r7277791 * r7277792;
        double r7277794 = r7277790 / r7277793;
        return r7277794;
}

double f(double a1, double a2, double b1, double b2) {
        double r7277795 = b1;
        double r7277796 = b2;
        double r7277797 = r7277795 * r7277796;
        double r7277798 = -6.770256909762417e+247;
        bool r7277799 = r7277797 <= r7277798;
        double r7277800 = a2;
        double r7277801 = a1;
        double r7277802 = r7277795 / r7277801;
        double r7277803 = r7277800 / r7277802;
        double r7277804 = 1.0;
        double r7277805 = r7277804 / r7277796;
        double r7277806 = r7277803 * r7277805;
        double r7277807 = -2.5972175215851213e-303;
        bool r7277808 = r7277797 <= r7277807;
        double r7277809 = r7277797 / r7277800;
        double r7277810 = r7277801 / r7277809;
        double r7277811 = 1.089678327652975e-177;
        bool r7277812 = r7277797 <= r7277811;
        double r7277813 = 2.3504500220205782e+185;
        bool r7277814 = r7277797 <= r7277813;
        double r7277815 = r7277814 ? r7277810 : r7277806;
        double r7277816 = r7277812 ? r7277806 : r7277815;
        double r7277817 = r7277808 ? r7277810 : r7277816;
        double r7277818 = r7277799 ? r7277806 : r7277817;
        return r7277818;
}

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

Derivation

  1. Split input into 2 regimes
  2. if (* b1 b2) < -6.770256909762417e+247 or -2.5972175215851213e-303 < (* b1 b2) < 1.089678327652975e-177 or 2.3504500220205782e+185 < (* b1 b2)

    1. Initial program 21.4

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{a2}{\frac{b1}{a1}}}}{b2}\]
    8. Using strategy rm
    9. Applied div-inv6.2

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

    if -6.770256909762417e+247 < (* b1 b2) < -2.5972175215851213e-303 or 1.089678327652975e-177 < (* b1 b2) < 2.3504500220205782e+185

    1. Initial program 4.8

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b1 \cdot b2 \le -6.770256909762417 \cdot 10^{+247}:\\ \;\;\;\;\frac{a2}{\frac{b1}{a1}} \cdot \frac{1}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \le -2.5972175215851213 \cdot 10^{-303}:\\ \;\;\;\;\frac{a1}{\frac{b1 \cdot b2}{a2}}\\ \mathbf{elif}\;b1 \cdot b2 \le 1.089678327652975 \cdot 10^{-177}:\\ \;\;\;\;\frac{a2}{\frac{b1}{a1}} \cdot \frac{1}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \le 2.3504500220205782 \cdot 10^{+185}:\\ \;\;\;\;\frac{a1}{\frac{b1 \cdot b2}{a2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{a2}{\frac{b1}{a1}} \cdot \frac{1}{b2}\\ \end{array}\]

Reproduce

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

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

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