Average Error: 11.1 → 5.1
Time: 2.7s
Precision: 64
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;b1 \cdot b2 \le -9.2690769035523702 \cdot 10^{292}:\\ \;\;\;\;\left(a1 \cdot \frac{\sqrt[3]{a2} \cdot \sqrt[3]{a2}}{b1}\right) \cdot \frac{\sqrt[3]{a2}}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \le -8.2523225915956471 \cdot 10^{-278}:\\ \;\;\;\;a1 \cdot \frac{a2}{b1 \cdot b2}\\ \mathbf{elif}\;b1 \cdot b2 \le 8.28170983261853465 \cdot 10^{-276}:\\ \;\;\;\;\frac{\frac{a1}{b1}}{\frac{b2}{a2}}\\ \mathbf{elif}\;b1 \cdot b2 \le 2.7030945419074493 \cdot 10^{228}:\\ \;\;\;\;a1 \cdot \frac{a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\left(a1 \cdot \frac{\sqrt[3]{a2} \cdot \sqrt[3]{a2}}{b1}\right) \cdot \frac{\sqrt[3]{a2}}{b2}\\ \end{array}\]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
\mathbf{if}\;b1 \cdot b2 \le -9.2690769035523702 \cdot 10^{292}:\\
\;\;\;\;\left(a1 \cdot \frac{\sqrt[3]{a2} \cdot \sqrt[3]{a2}}{b1}\right) \cdot \frac{\sqrt[3]{a2}}{b2}\\

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

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

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

\mathbf{else}:\\
\;\;\;\;\left(a1 \cdot \frac{\sqrt[3]{a2} \cdot \sqrt[3]{a2}}{b1}\right) \cdot \frac{\sqrt[3]{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 temp;
	if (((b1 * b2) <= -9.26907690355237e+292)) {
		temp = ((a1 * ((cbrt(a2) * cbrt(a2)) / b1)) * (cbrt(a2) / b2));
	} else {
		double temp_1;
		if (((b1 * b2) <= -8.252322591595647e-278)) {
			temp_1 = (a1 * (a2 / (b1 * b2)));
		} else {
			double temp_2;
			if (((b1 * b2) <= 8.281709832618535e-276)) {
				temp_2 = ((a1 / b1) / (b2 / a2));
			} else {
				double temp_3;
				if (((b1 * b2) <= 2.7030945419074493e+228)) {
					temp_3 = (a1 * (a2 / (b1 * b2)));
				} else {
					temp_3 = ((a1 * ((cbrt(a2) * cbrt(a2)) / b1)) * (cbrt(a2) / b2));
				}
				temp_2 = temp_3;
			}
			temp_1 = temp_2;
		}
		temp = temp_1;
	}
	return temp;
}

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

Derivation

  1. Split input into 3 regimes
  2. if (* b1 b2) < -9.26907690355237e+292 or 2.7030945419074493e+228 < (* b1 b2)

    1. Initial program 19.3

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

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

      \[\leadsto \color{blue}{a1 \cdot \frac{1}{\frac{b1 \cdot b2}{a2}}}\]
    6. Simplified18.8

      \[\leadsto a1 \cdot \color{blue}{\frac{a2}{b1 \cdot b2}}\]
    7. Using strategy rm
    8. Applied add-cube-cbrt18.9

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

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

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

    if -9.26907690355237e+292 < (* b1 b2) < -8.252322591595647e-278 or 8.281709832618535e-276 < (* b1 b2) < 2.7030945419074493e+228

    1. Initial program 5.2

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

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

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

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

    if -8.252322591595647e-278 < (* b1 b2) < 8.281709832618535e-276

    1. Initial program 47.3

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

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

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

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

      \[\leadsto \color{blue}{\frac{\frac{a1}{\frac{b1}{1}}}{\frac{b2}{a2}}}\]
    8. Simplified8.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b1 \cdot b2 \le -9.2690769035523702 \cdot 10^{292}:\\ \;\;\;\;\left(a1 \cdot \frac{\sqrt[3]{a2} \cdot \sqrt[3]{a2}}{b1}\right) \cdot \frac{\sqrt[3]{a2}}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \le -8.2523225915956471 \cdot 10^{-278}:\\ \;\;\;\;a1 \cdot \frac{a2}{b1 \cdot b2}\\ \mathbf{elif}\;b1 \cdot b2 \le 8.28170983261853465 \cdot 10^{-276}:\\ \;\;\;\;\frac{\frac{a1}{b1}}{\frac{b2}{a2}}\\ \mathbf{elif}\;b1 \cdot b2 \le 2.7030945419074493 \cdot 10^{228}:\\ \;\;\;\;a1 \cdot \frac{a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\left(a1 \cdot \frac{\sqrt[3]{a2} \cdot \sqrt[3]{a2}}{b1}\right) \cdot \frac{\sqrt[3]{a2}}{b2}\\ \end{array}\]

Reproduce

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

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

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