Average Error: 11.2 → 6.2
Time: 3.0s
Precision: binary64
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;b1 \cdot b2 \le -6.68668093917740342 \cdot 10^{275}:\\ \;\;\;\;\frac{a2}{b1} \cdot \frac{a1}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \le -2.08718180476195655 \cdot 10^{-263}:\\ \;\;\;\;a2 \cdot \frac{a1}{b1 \cdot b2}\\ \mathbf{elif}\;b1 \cdot b2 \le 3.1382336163668068 \cdot 10^{-212}:\\ \;\;\;\;\frac{1}{b2 \cdot \frac{b1}{a2 \cdot a1}}\\ \mathbf{elif}\;b1 \cdot b2 \le 9.24251358724885461 \cdot 10^{126}:\\ \;\;\;\;a2 \cdot \frac{a1}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{a2}{b1} \cdot \frac{a1}{b2}\\ \end{array}\]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
\mathbf{if}\;b1 \cdot b2 \le -6.68668093917740342 \cdot 10^{275}:\\
\;\;\;\;\frac{a2}{b1} \cdot \frac{a1}{b2}\\

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

\mathbf{elif}\;b1 \cdot b2 \le 3.1382336163668068 \cdot 10^{-212}:\\
\;\;\;\;\frac{1}{b2 \cdot \frac{b1}{a2 \cdot a1}}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{a2}{b1} \cdot \frac{a1}{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)) <= -6.686680939177403e+275)) {
		VAR = ((double) ((a2 / b1) * (a1 / b2)));
	} else {
		double VAR_1;
		if ((((double) (b1 * b2)) <= -2.0871818047619565e-263)) {
			VAR_1 = ((double) (a2 * (a1 / ((double) (b1 * b2)))));
		} else {
			double VAR_2;
			if ((((double) (b1 * b2)) <= 3.138233616366807e-212)) {
				VAR_2 = (1.0 / ((double) (b2 * (b1 / ((double) (a2 * a1))))));
			} else {
				double VAR_3;
				if ((((double) (b1 * b2)) <= 9.242513587248855e+126)) {
					VAR_3 = ((double) (a2 * (a1 / ((double) (b1 * b2)))));
				} else {
					VAR_3 = ((double) ((a2 / b1) * (a1 / 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.2
Target11.0
Herbie6.2
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]

Derivation

  1. Split input into 3 regimes
  2. if (* b1 b2) < -6.68668093917740342e275 or 9.24251358724885461e126 < (* b1 b2)

    1. Initial program 15.8

      \[\frac{a1 \cdot a2}{b1 \cdot b2}\]
    2. Taylor expanded around 0 15.8

      \[\leadsto \color{blue}{\frac{a1 \cdot a2}{b1 \cdot b2}}\]
    3. Simplified15.5

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

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

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

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

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

    if -6.68668093917740342e275 < (* b1 b2) < -2.08718180476195655e-263 or 3.1382336163668068e-212 < (* b1 b2) < 9.24251358724885461e126

    1. Initial program 4.8

      \[\frac{a1 \cdot a2}{b1 \cdot b2}\]
    2. Taylor expanded around 0 4.8

      \[\leadsto \color{blue}{\frac{a1 \cdot a2}{b1 \cdot b2}}\]
    3. Simplified4.8

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

    if -2.08718180476195655e-263 < (* b1 b2) < 3.1382336163668068e-212

    1. Initial program 37.1

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b1 \cdot b2 \le -6.68668093917740342 \cdot 10^{275}:\\ \;\;\;\;\frac{a2}{b1} \cdot \frac{a1}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \le -2.08718180476195655 \cdot 10^{-263}:\\ \;\;\;\;a2 \cdot \frac{a1}{b1 \cdot b2}\\ \mathbf{elif}\;b1 \cdot b2 \le 3.1382336163668068 \cdot 10^{-212}:\\ \;\;\;\;\frac{1}{b2 \cdot \frac{b1}{a2 \cdot a1}}\\ \mathbf{elif}\;b1 \cdot b2 \le 9.24251358724885461 \cdot 10^{126}:\\ \;\;\;\;a2 \cdot \frac{a1}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{a2}{b1} \cdot \frac{a1}{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)))