Average Error: 11.7 → 5.3
Time: 3.2s
Precision: binary64
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;b1 \cdot b2 \le -1.1847928602155 \cdot 10^{222} \lor \neg \left(b1 \cdot b2 \le -2.65012901835582308 \cdot 10^{-171} \lor \neg \left(b1 \cdot b2 \le 1.9618991491095908 \cdot 10^{-204} \lor \neg \left(b1 \cdot b2 \le 4.8487651961466998 \cdot 10^{178}\right)\right)\right):\\ \;\;\;\;\left(\frac{a1}{b1} \cdot a2\right) \cdot \frac{1}{b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1}{\frac{b1 \cdot b2}{a2}}\\ \end{array}\]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
\mathbf{if}\;b1 \cdot b2 \le -1.1847928602155 \cdot 10^{222} \lor \neg \left(b1 \cdot b2 \le -2.65012901835582308 \cdot 10^{-171} \lor \neg \left(b1 \cdot b2 \le 1.9618991491095908 \cdot 10^{-204} \lor \neg \left(b1 \cdot b2 \le 4.8487651961466998 \cdot 10^{178}\right)\right)\right):\\
\;\;\;\;\left(\frac{a1}{b1} \cdot a2\right) \cdot \frac{1}{b2}\\

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

\end{array}
double code(double a1, double a2, double b1, double b2) {
	return ((double) (((double) (a1 * a2)) / ((double) (b1 * b2))));
}
double code(double a1, double a2, double b1, double b2) {
	double VAR;
	if (((((double) (b1 * b2)) <= -1.1847928602155e+222) || !((((double) (b1 * b2)) <= -2.650129018355823e-171) || !((((double) (b1 * b2)) <= 1.9618991491095908e-204) || !(((double) (b1 * b2)) <= 4.8487651961467e+178))))) {
		VAR = ((double) (((double) (((double) (a1 / b1)) * a2)) * ((double) (1.0 / b2))));
	} else {
		VAR = ((double) (a1 / ((double) (((double) (b1 * b2)) / a2))));
	}
	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.7
Target11.0
Herbie5.3
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]

Derivation

  1. Split input into 2 regimes
  2. if (* b1 b2) < -1.1847928602155e222 or -2.65012901835582308e-171 < (* b1 b2) < 1.9618991491095908e-204 or 4.8487651961466998e178 < (* b1 b2)

    1. Initial program 21.3

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

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

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

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

    if -1.1847928602155e222 < (* b1 b2) < -2.65012901835582308e-171 or 1.9618991491095908e-204 < (* b1 b2) < 4.8487651961466998e178

    1. Initial program 4.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b1 \cdot b2 \le -1.1847928602155 \cdot 10^{222} \lor \neg \left(b1 \cdot b2 \le -2.65012901835582308 \cdot 10^{-171} \lor \neg \left(b1 \cdot b2 \le 1.9618991491095908 \cdot 10^{-204} \lor \neg \left(b1 \cdot b2 \le 4.8487651961466998 \cdot 10^{178}\right)\right)\right):\\ \;\;\;\;\left(\frac{a1}{b1} \cdot a2\right) \cdot \frac{1}{b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1}{\frac{b1 \cdot b2}{a2}}\\ \end{array}\]

Reproduce

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

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

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