Average Error: 11.1 → 5.0
Time: 20.0s
Precision: 64
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;b1 \cdot b2 \le -5.98446143373493 \cdot 10^{+245}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \le -1.0084599578011689 \cdot 10^{-263}:\\ \;\;\;\;a2 \cdot \frac{a1}{b1 \cdot b2}\\ \mathbf{elif}\;b1 \cdot b2 \le 3.019673003289364 \cdot 10^{-116}:\\ \;\;\;\;\frac{\frac{a1}{\frac{b1}{a2}}}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \le 8.38868406756228 \cdot 10^{+184}:\\ \;\;\;\;\frac{a1}{\frac{b1 \cdot b2}{a2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{a1}{\frac{b1}{a2}}}{b2}\\ \end{array}\]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
\mathbf{if}\;b1 \cdot b2 \le -5.98446143373493 \cdot 10^{+245}:\\
\;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\

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

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

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

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

\end{array}
double f(double a1, double a2, double b1, double b2) {
        double r6042929 = a1;
        double r6042930 = a2;
        double r6042931 = r6042929 * r6042930;
        double r6042932 = b1;
        double r6042933 = b2;
        double r6042934 = r6042932 * r6042933;
        double r6042935 = r6042931 / r6042934;
        return r6042935;
}

double f(double a1, double a2, double b1, double b2) {
        double r6042936 = b1;
        double r6042937 = b2;
        double r6042938 = r6042936 * r6042937;
        double r6042939 = -5.98446143373493e+245;
        bool r6042940 = r6042938 <= r6042939;
        double r6042941 = a1;
        double r6042942 = r6042941 / r6042936;
        double r6042943 = a2;
        double r6042944 = r6042943 / r6042937;
        double r6042945 = r6042942 * r6042944;
        double r6042946 = -1.0084599578011689e-263;
        bool r6042947 = r6042938 <= r6042946;
        double r6042948 = r6042941 / r6042938;
        double r6042949 = r6042943 * r6042948;
        double r6042950 = 3.019673003289364e-116;
        bool r6042951 = r6042938 <= r6042950;
        double r6042952 = r6042936 / r6042943;
        double r6042953 = r6042941 / r6042952;
        double r6042954 = r6042953 / r6042937;
        double r6042955 = 8.38868406756228e+184;
        bool r6042956 = r6042938 <= r6042955;
        double r6042957 = r6042938 / r6042943;
        double r6042958 = r6042941 / r6042957;
        double r6042959 = r6042956 ? r6042958 : r6042954;
        double r6042960 = r6042951 ? r6042954 : r6042959;
        double r6042961 = r6042947 ? r6042949 : r6042960;
        double r6042962 = r6042940 ? r6042945 : r6042961;
        return r6042962;
}

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

Derivation

  1. Split input into 4 regimes
  2. if (* b1 b2) < -5.98446143373493e+245

    1. Initial program 18.0

      \[\frac{a1 \cdot a2}{b1 \cdot b2}\]
    2. Using strategy rm
    3. Applied times-frac3.4

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

    if -5.98446143373493e+245 < (* b1 b2) < -1.0084599578011689e-263

    1. Initial program 4.8

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

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

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

      \[\leadsto \color{blue}{\left(1 \cdot \frac{a1 \cdot a2}{b1}\right)} \cdot \frac{1}{b2}\]
    8. Applied associate-*l*11.1

      \[\leadsto \color{blue}{1 \cdot \left(\frac{a1 \cdot a2}{b1} \cdot \frac{1}{b2}\right)}\]
    9. Simplified4.6

      \[\leadsto 1 \cdot \color{blue}{\left(\frac{a1}{b1 \cdot b2} \cdot a2\right)}\]

    if -1.0084599578011689e-263 < (* b1 b2) < 3.019673003289364e-116 or 8.38868406756228e+184 < (* b1 b2)

    1. Initial program 21.6

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

      \[\leadsto \color{blue}{\frac{\frac{a1 \cdot a2}{b1}}{b2}}\]
    4. Using strategy rm
    5. Applied associate-/l*7.2

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

    if 3.019673003289364e-116 < (* b1 b2) < 8.38868406756228e+184

    1. Initial program 3.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b1 \cdot b2 \le -5.98446143373493 \cdot 10^{+245}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \le -1.0084599578011689 \cdot 10^{-263}:\\ \;\;\;\;a2 \cdot \frac{a1}{b1 \cdot b2}\\ \mathbf{elif}\;b1 \cdot b2 \le 3.019673003289364 \cdot 10^{-116}:\\ \;\;\;\;\frac{\frac{a1}{\frac{b1}{a2}}}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \le 8.38868406756228 \cdot 10^{+184}:\\ \;\;\;\;\frac{a1}{\frac{b1 \cdot b2}{a2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{a1}{\frac{b1}{a2}}}{b2}\\ \end{array}\]

Reproduce

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

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

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