Average Error: 11.1 → 2.9
Time: 14.0s
Precision: 64
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} = -\infty:\\ \;\;\;\;\frac{a1 \cdot \frac{a2}{b2}}{b1}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -2.424333575784733165640312865210186090398 \cdot 10^{-300}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 0.0:\\ \;\;\;\;\frac{a1}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}} \cdot \frac{\frac{a2}{\sqrt[3]{b2}}}{b1}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 1.173306201668288734588760971486902423604 \cdot 10^{275}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;a1 \cdot \frac{\frac{a2}{b2}}{b1}\\ \end{array}\]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
\mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} = -\infty:\\
\;\;\;\;\frac{a1 \cdot \frac{a2}{b2}}{b1}\\

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

\mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 0.0:\\
\;\;\;\;\frac{a1}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}} \cdot \frac{\frac{a2}{\sqrt[3]{b2}}}{b1}\\

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

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

\end{array}
double f(double a1, double a2, double b1, double b2) {
        double r112705 = a1;
        double r112706 = a2;
        double r112707 = r112705 * r112706;
        double r112708 = b1;
        double r112709 = b2;
        double r112710 = r112708 * r112709;
        double r112711 = r112707 / r112710;
        return r112711;
}

double f(double a1, double a2, double b1, double b2) {
        double r112712 = a1;
        double r112713 = a2;
        double r112714 = r112712 * r112713;
        double r112715 = b1;
        double r112716 = b2;
        double r112717 = r112715 * r112716;
        double r112718 = r112714 / r112717;
        double r112719 = -inf.0;
        bool r112720 = r112718 <= r112719;
        double r112721 = r112713 / r112716;
        double r112722 = r112712 * r112721;
        double r112723 = r112722 / r112715;
        double r112724 = -2.424333575784733e-300;
        bool r112725 = r112718 <= r112724;
        double r112726 = 0.0;
        bool r112727 = r112718 <= r112726;
        double r112728 = cbrt(r112716);
        double r112729 = r112728 * r112728;
        double r112730 = r112712 / r112729;
        double r112731 = r112713 / r112728;
        double r112732 = r112731 / r112715;
        double r112733 = r112730 * r112732;
        double r112734 = 1.1733062016682887e+275;
        bool r112735 = r112718 <= r112734;
        double r112736 = r112721 / r112715;
        double r112737 = r112712 * r112736;
        double r112738 = r112735 ? r112718 : r112737;
        double r112739 = r112727 ? r112733 : r112738;
        double r112740 = r112725 ? r112718 : r112739;
        double r112741 = r112720 ? r112723 : r112740;
        return r112741;
}

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

Derivation

  1. Split input into 4 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 times-frac13.1

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

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

    if -inf.0 < (/ (* a1 a2) (* b1 b2)) < -2.424333575784733e-300 or 0.0 < (/ (* a1 a2) (* b1 b2)) < 1.1733062016682887e+275

    1. Initial program 3.5

      \[\frac{a1 \cdot a2}{b1 \cdot b2}\]

    if -2.424333575784733e-300 < (/ (* a1 a2) (* b1 b2)) < 0.0

    1. Initial program 12.5

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

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

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

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

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

      \[\leadsto a1 \cdot \frac{\frac{a2}{b2}}{\color{blue}{1 \cdot b1}}\]
    10. Applied add-cube-cbrt4.3

      \[\leadsto a1 \cdot \frac{\frac{a2}{\color{blue}{\left(\sqrt[3]{b2} \cdot \sqrt[3]{b2}\right) \cdot \sqrt[3]{b2}}}}{1 \cdot b1}\]
    11. Applied *-un-lft-identity4.3

      \[\leadsto a1 \cdot \frac{\frac{\color{blue}{1 \cdot a2}}{\left(\sqrt[3]{b2} \cdot \sqrt[3]{b2}\right) \cdot \sqrt[3]{b2}}}{1 \cdot b1}\]
    12. Applied times-frac4.3

      \[\leadsto a1 \cdot \frac{\color{blue}{\frac{1}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}} \cdot \frac{a2}{\sqrt[3]{b2}}}}{1 \cdot b1}\]
    13. Applied times-frac4.2

      \[\leadsto a1 \cdot \color{blue}{\left(\frac{\frac{1}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}}}{1} \cdot \frac{\frac{a2}{\sqrt[3]{b2}}}{b1}\right)}\]
    14. Applied associate-*r*2.7

      \[\leadsto \color{blue}{\left(a1 \cdot \frac{\frac{1}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}}}{1}\right) \cdot \frac{\frac{a2}{\sqrt[3]{b2}}}{b1}}\]
    15. Simplified2.7

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

    if 1.1733062016682887e+275 < (/ (* a1 a2) (* b1 b2))

    1. Initial program 54.5

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} = -\infty:\\ \;\;\;\;\frac{a1 \cdot \frac{a2}{b2}}{b1}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -2.424333575784733165640312865210186090398 \cdot 10^{-300}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 0.0:\\ \;\;\;\;\frac{a1}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}} \cdot \frac{\frac{a2}{\sqrt[3]{b2}}}{b1}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 1.173306201668288734588760971486902423604 \cdot 10^{275}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;a1 \cdot \frac{\frac{a2}{b2}}{b1}\\ \end{array}\]

Reproduce

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

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

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