Average Error: 11.3 → 5.0
Time: 3.3s
Precision: 64
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;a1 \cdot a2 \le -6.08712058696868874 \cdot 10^{188}:\\ \;\;\;\;a1 \cdot \frac{\frac{a2}{b2}}{b1}\\ \mathbf{elif}\;a1 \cdot a2 \le -3.0178565167744215 \cdot 10^{-307}:\\ \;\;\;\;\left(a2 \cdot a1\right) \cdot \frac{\frac{1}{b2}}{b1}\\ \mathbf{elif}\;a1 \cdot a2 \le 5.3291942180717 \cdot 10^{-313}:\\ \;\;\;\;\frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{1} \cdot \left(\frac{\sqrt[3]{a1}}{b1} \cdot \frac{a2}{b2}\right)\\ \mathbf{elif}\;a1 \cdot a2 \le 4.48816418979761226 \cdot 10^{154}:\\ \;\;\;\;\left(a2 \cdot a1\right) \cdot \frac{\frac{1}{b2}}{b1}\\ \mathbf{else}:\\ \;\;\;\;a1 \cdot \frac{\frac{a2}{b2}}{b1}\\ \end{array}\]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
\mathbf{if}\;a1 \cdot a2 \le -6.08712058696868874 \cdot 10^{188}:\\
\;\;\;\;a1 \cdot \frac{\frac{a2}{b2}}{b1}\\

\mathbf{elif}\;a1 \cdot a2 \le -3.0178565167744215 \cdot 10^{-307}:\\
\;\;\;\;\left(a2 \cdot a1\right) \cdot \frac{\frac{1}{b2}}{b1}\\

\mathbf{elif}\;a1 \cdot a2 \le 5.3291942180717 \cdot 10^{-313}:\\
\;\;\;\;\frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{1} \cdot \left(\frac{\sqrt[3]{a1}}{b1} \cdot \frac{a2}{b2}\right)\\

\mathbf{elif}\;a1 \cdot a2 \le 4.48816418979761226 \cdot 10^{154}:\\
\;\;\;\;\left(a2 \cdot a1\right) \cdot \frac{\frac{1}{b2}}{b1}\\

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

\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 (((a1 * a2) <= -6.087120586968689e+188)) {
		temp = (a1 * ((a2 / b2) / b1));
	} else {
		double temp_1;
		if (((a1 * a2) <= -3.0178565167744215e-307)) {
			temp_1 = ((a2 * a1) * ((1.0 / b2) / b1));
		} else {
			double temp_2;
			if (((a1 * a2) <= 5.3291942180717e-313)) {
				temp_2 = (((cbrt(a1) * cbrt(a1)) / 1.0) * ((cbrt(a1) / b1) * (a2 / b2)));
			} else {
				double temp_3;
				if (((a1 * a2) <= 4.488164189797612e+154)) {
					temp_3 = ((a2 * a1) * ((1.0 / b2) / b1));
				} else {
					temp_3 = (a1 * ((a2 / b2) / b1));
				}
				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.3
Target11.7
Herbie5.0
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]

Derivation

  1. Split input into 3 regimes
  2. if (* a1 a2) < -6.087120586968689e+188 or 4.488164189797612e+154 < (* a1 a2)

    1. Initial program 31.5

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

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

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

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

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

    if -6.087120586968689e+188 < (* a1 a2) < -3.0178565167744215e-307 or 5.3291942180717e-313 < (* a1 a2) < 4.488164189797612e+154

    1. Initial program 4.5

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

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

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

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

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

      \[\leadsto a1 \cdot \frac{\frac{a2}{b2}}{\color{blue}{1 \cdot b1}}\]
    10. Applied div-inv13.6

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

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

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

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

    if -3.0178565167744215e-307 < (* a1 a2) < 5.3291942180717e-313

    1. Initial program 21.6

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

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

      \[\leadsto \frac{a1}{\color{blue}{1 \cdot b1}} \cdot \frac{a2}{b2}\]
    6. Applied add-cube-cbrt3.2

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a1 \cdot a2 \le -6.08712058696868874 \cdot 10^{188}:\\ \;\;\;\;a1 \cdot \frac{\frac{a2}{b2}}{b1}\\ \mathbf{elif}\;a1 \cdot a2 \le -3.0178565167744215 \cdot 10^{-307}:\\ \;\;\;\;\left(a2 \cdot a1\right) \cdot \frac{\frac{1}{b2}}{b1}\\ \mathbf{elif}\;a1 \cdot a2 \le 5.3291942180717 \cdot 10^{-313}:\\ \;\;\;\;\frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{1} \cdot \left(\frac{\sqrt[3]{a1}}{b1} \cdot \frac{a2}{b2}\right)\\ \mathbf{elif}\;a1 \cdot a2 \le 4.48816418979761226 \cdot 10^{154}:\\ \;\;\;\;\left(a2 \cdot a1\right) \cdot \frac{\frac{1}{b2}}{b1}\\ \mathbf{else}:\\ \;\;\;\;a1 \cdot \frac{\frac{a2}{b2}}{b1}\\ \end{array}\]

Reproduce

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

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

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