Average Error: 10.9 → 2.9
Time: 3.1s
Precision: 64
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} = -\infty:\\ \;\;\;\;\frac{\frac{a1}{b1}}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}} \cdot \frac{a2}{\sqrt[3]{b2}}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -2.111168099783512 \cdot 10^{-309}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -0.0:\\ \;\;\;\;\frac{\frac{a1}{b1}}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}} \cdot \frac{a2}{\sqrt[3]{b2}}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 1.99364642502751304 \cdot 10^{245}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \end{array}\]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
\mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} = -\infty:\\
\;\;\;\;\frac{\frac{a1}{b1}}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}} \cdot \frac{a2}{\sqrt[3]{b2}}\\

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

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

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

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

\end{array}
double code(double a1, double a2, double b1, double b2) {
	return ((a1 * a2) / (b1 * b2));
}
double code(double a1, double a2, double b1, double b2) {
	double VAR;
	if ((((a1 * a2) / (b1 * b2)) <= -inf.0)) {
		VAR = (((a1 / b1) / (cbrt(b2) * cbrt(b2))) * (a2 / cbrt(b2)));
	} else {
		double VAR_1;
		if ((((a1 * a2) / (b1 * b2)) <= -2.11116809978351e-309)) {
			VAR_1 = ((a1 * a2) / (b1 * b2));
		} else {
			double VAR_2;
			if ((((a1 * a2) / (b1 * b2)) <= -0.0)) {
				VAR_2 = (((a1 / b1) / (cbrt(b2) * cbrt(b2))) * (a2 / cbrt(b2)));
			} else {
				double VAR_3;
				if ((((a1 * a2) / (b1 * b2)) <= 1.993646425027513e+245)) {
					VAR_3 = ((a1 * a2) / (b1 * b2));
				} else {
					VAR_3 = ((a1 / b1) * (a2 / b2));
				}
				VAR_2 = VAR_3;
			}
			VAR_1 = VAR_2;
		}
		VAR = VAR_1;
	}
	return VAR;
}

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

Derivation

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

    1. Initial program 17.5

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

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

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

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

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

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

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

    if -inf.0 < (/ (* a1 a2) (* b1 b2)) < -2.11116809978351e-309 or -0.0 < (/ (* a1 a2) (* b1 b2)) < 1.993646425027513e+245

    1. Initial program 0.8

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

    if 1.993646425027513e+245 < (/ (* a1 a2) (* b1 b2))

    1. Initial program 49.1

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} = -\infty:\\ \;\;\;\;\frac{\frac{a1}{b1}}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}} \cdot \frac{a2}{\sqrt[3]{b2}}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -2.111168099783512 \cdot 10^{-309}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le -0.0:\\ \;\;\;\;\frac{\frac{a1}{b1}}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}} \cdot \frac{a2}{\sqrt[3]{b2}}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \le 1.99364642502751304 \cdot 10^{245}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \end{array}\]

Reproduce

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

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

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