Average Error: 11.2 → 5.7
Time: 4.9s
Precision: binary64
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;b1 \cdot b2 = -inf.0:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \le -2.08718180476195655 \cdot 10^{-263}:\\ \;\;\;\;\frac{a1}{b2 \cdot b1} \cdot a2\\ \mathbf{elif}\;b1 \cdot b2 \le 0.0 \lor \neg \left(b1 \cdot b2 \le 6.20077002672593022 \cdot 10^{229}\right):\\ \;\;\;\;\frac{\sqrt[3]{a2} \cdot \sqrt[3]{a2}}{b1} \cdot \left(\left(\sqrt[3]{a2} \cdot a1\right) \cdot \frac{1}{b2}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(a1 \cdot a2\right) \cdot \frac{1}{b1 \cdot b2}\\ \end{array}\]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
\mathbf{if}\;b1 \cdot b2 = -inf.0:\\
\;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\

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

\mathbf{elif}\;b1 \cdot b2 \le 0.0 \lor \neg \left(b1 \cdot b2 \le 6.20077002672593022 \cdot 10^{229}\right):\\
\;\;\;\;\frac{\sqrt[3]{a2} \cdot \sqrt[3]{a2}}{b1} \cdot \left(\left(\sqrt[3]{a2} \cdot a1\right) \cdot \frac{1}{b2}\right)\\

\mathbf{else}:\\
\;\;\;\;\left(a1 \cdot a2\right) \cdot \frac{1}{b1 \cdot b2}\\

\end{array}
double code(double a1, double a2, double b1, double b2) {
	return (((double) (a1 * a2)) / ((double) (b1 * b2)));
}
double code(double a1, double a2, double b1, double b2) {
	double VAR;
	if ((((double) (b1 * b2)) <= -inf.0)) {
		VAR = ((double) ((a1 / b1) * (a2 / b2)));
	} else {
		double VAR_1;
		if ((((double) (b1 * b2)) <= -2.0871818047619565e-263)) {
			VAR_1 = ((double) ((a1 / ((double) (b2 * b1))) * a2));
		} else {
			double VAR_2;
			if (((((double) (b1 * b2)) <= 0.0) || !(((double) (b1 * b2)) <= 6.20077002672593e+229))) {
				VAR_2 = ((double) ((((double) (((double) cbrt(a2)) * ((double) cbrt(a2)))) / b1) * ((double) (((double) (((double) cbrt(a2)) * a1)) * (1.0 / b2)))));
			} else {
				VAR_2 = ((double) (((double) (a1 * a2)) * (1.0 / ((double) (b1 * b2)))));
			}
			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.2
Target11.0
Herbie5.7
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]

Derivation

  1. Split input into 4 regimes
  2. if (* b1 b2) < -inf.0

    1. Initial program 23.4

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

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

    if -inf.0 < (* b1 b2) < -2.08718180476195655e-263

    1. Initial program 5.4

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

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

      \[\leadsto \frac{1}{\color{blue}{\frac{\frac{b1 \cdot b2}{a1}}{a2}}}\]
    6. Using strategy rm
    7. Applied div-inv5.9

      \[\leadsto \frac{1}{\color{blue}{\frac{b1 \cdot b2}{a1} \cdot \frac{1}{a2}}}\]
    8. Applied add-cube-cbrt5.9

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

      \[\leadsto \color{blue}{\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\frac{b1 \cdot b2}{a1}} \cdot \frac{\sqrt[3]{1}}{\frac{1}{a2}}}\]
    10. Simplified5.4

      \[\leadsto \color{blue}{\frac{a1}{b2 \cdot b1}} \cdot \frac{\sqrt[3]{1}}{\frac{1}{a2}}\]
    11. Simplified5.4

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

    if -2.08718180476195655e-263 < (* b1 b2) < 0.0 or 6.20077002672593022e229 < (* b1 b2)

    1. Initial program 28.3

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

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

      \[\leadsto \frac{1}{\color{blue}{\frac{\frac{b1 \cdot b2}{a1}}{a2}}}\]
    6. Using strategy rm
    7. Applied add-cube-cbrt28.4

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

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

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

      \[\leadsto \frac{1}{\color{blue}{\frac{\frac{b1}{1}}{\sqrt[3]{a2} \cdot \sqrt[3]{a2}} \cdot \frac{\frac{b2}{a1}}{\sqrt[3]{a2}}}}\]
    11. Applied add-cube-cbrt5.8

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

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

      \[\leadsto \color{blue}{\frac{\sqrt[3]{a2} \cdot \sqrt[3]{a2}}{b1}} \cdot \frac{\sqrt[3]{1}}{\frac{\frac{b2}{a1}}{\sqrt[3]{a2}}}\]
    14. Simplified7.4

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

    if 0.0 < (* b1 b2) < 6.20077002672593022e229

    1. Initial program 5.6

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b1 \cdot b2 = -inf.0:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \le -2.08718180476195655 \cdot 10^{-263}:\\ \;\;\;\;\frac{a1}{b2 \cdot b1} \cdot a2\\ \mathbf{elif}\;b1 \cdot b2 \le 0.0 \lor \neg \left(b1 \cdot b2 \le 6.20077002672593022 \cdot 10^{229}\right):\\ \;\;\;\;\frac{\sqrt[3]{a2} \cdot \sqrt[3]{a2}}{b1} \cdot \left(\left(\sqrt[3]{a2} \cdot a1\right) \cdot \frac{1}{b2}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(a1 \cdot a2\right) \cdot \frac{1}{b1 \cdot b2}\\ \end{array}\]

Reproduce

herbie shell --seed 2020182 
(FPCore (a1 a2 b1 b2)
  :name "Quotient of products"
  :precision binary64

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

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