Average Error: 11.3 → 5.3
Time: 2.8s
Precision: 64
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;b1 \cdot b2 \le -3.04526068195676964 \cdot 10^{263}:\\ \;\;\;\;\frac{\frac{a1}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \frac{a2}{\sqrt[3]{b1}}}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \le -1.87498651142310365 \cdot 10^{-123}:\\ \;\;\;\;\frac{a1}{\frac{b1 \cdot b2}{a2}}\\ \mathbf{elif}\;b1 \cdot b2 \le 2.56914 \cdot 10^{-322}:\\ \;\;\;\;\frac{a1 \cdot \frac{a2}{b1}}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \le 5.5368306551194035 \cdot 10^{179}:\\ \;\;\;\;\frac{a1}{\frac{b1 \cdot b2}{a2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{a1}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \frac{a2}{\sqrt[3]{b1}}}{b2}\\ \end{array}\]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
\mathbf{if}\;b1 \cdot b2 \le -3.04526068195676964 \cdot 10^{263}:\\
\;\;\;\;\frac{\frac{a1}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \frac{a2}{\sqrt[3]{b1}}}{b2}\\

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

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

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{a1}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \frac{a2}{\sqrt[3]{b1}}}{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 (((b1 * b2) <= -3.0452606819567696e+263)) {
		VAR = (((a1 / (cbrt(b1) * cbrt(b1))) * (a2 / cbrt(b1))) / b2);
	} else {
		double VAR_1;
		if (((b1 * b2) <= -1.8749865114231037e-123)) {
			VAR_1 = (a1 / ((b1 * b2) / a2));
		} else {
			double VAR_2;
			if (((b1 * b2) <= 2.5691413583745e-322)) {
				VAR_2 = ((a1 * (a2 / b1)) / b2);
			} else {
				double VAR_3;
				if (((b1 * b2) <= 5.536830655119404e+179)) {
					VAR_3 = (a1 / ((b1 * b2) / a2));
				} else {
					VAR_3 = (((a1 / (cbrt(b1) * cbrt(b1))) * (a2 / cbrt(b1))) / 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

Original11.3
Target11.6
Herbie5.3
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]

Derivation

  1. Split input into 3 regimes
  2. if (* b1 b2) < -3.0452606819567696e+263 or 5.536830655119404e+179 < (* b1 b2)

    1. Initial program 16.5

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

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

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

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

    if -3.0452606819567696e+263 < (* b1 b2) < -1.8749865114231037e-123 or 2.5691413583745e-322 < (* b1 b2) < 5.536830655119404e+179

    1. Initial program 4.9

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

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

    if -1.8749865114231037e-123 < (* b1 b2) < 2.5691413583745e-322

    1. Initial program 30.5

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b1 \cdot b2 \le -3.04526068195676964 \cdot 10^{263}:\\ \;\;\;\;\frac{\frac{a1}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \frac{a2}{\sqrt[3]{b1}}}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \le -1.87498651142310365 \cdot 10^{-123}:\\ \;\;\;\;\frac{a1}{\frac{b1 \cdot b2}{a2}}\\ \mathbf{elif}\;b1 \cdot b2 \le 2.56914 \cdot 10^{-322}:\\ \;\;\;\;\frac{a1 \cdot \frac{a2}{b1}}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \le 5.5368306551194035 \cdot 10^{179}:\\ \;\;\;\;\frac{a1}{\frac{b1 \cdot b2}{a2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{a1}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \frac{a2}{\sqrt[3]{b1}}}{b2}\\ \end{array}\]

Reproduce

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

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

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