Average Error: 11.4 → 2.3
Time: 4.4s
Precision: binary64
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -\infty \lor \neg \left(\frac{a1 \cdot a2}{b1 \cdot b2} \leq -2.51091043835428 \cdot 10^{-309} \lor \neg \left(\frac{a1 \cdot a2}{b1 \cdot b2} \leq -0\right) \land \frac{a1 \cdot a2}{b1 \cdot b2} \leq 6.934790209617415 \cdot 10^{+271}\right):\\ \;\;\;\;\frac{a2}{b1} \cdot \frac{a1}{b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \end{array}\]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
\mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -\infty \lor \neg \left(\frac{a1 \cdot a2}{b1 \cdot b2} \leq -2.51091043835428 \cdot 10^{-309} \lor \neg \left(\frac{a1 \cdot a2}{b1 \cdot b2} \leq -0\right) \land \frac{a1 \cdot a2}{b1 \cdot b2} \leq 6.934790209617415 \cdot 10^{+271}\right):\\
\;\;\;\;\frac{a2}{b1} \cdot \frac{a1}{b2}\\

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

\end{array}
(FPCore (a1 a2 b1 b2) :precision binary64 (/ (* a1 a2) (* b1 b2)))
(FPCore (a1 a2 b1 b2)
 :precision binary64
 (if (or (<= (/ (* a1 a2) (* b1 b2)) (- INFINITY))
         (not
          (or (<= (/ (* a1 a2) (* b1 b2)) -2.51091043835428e-309)
              (and (not (<= (/ (* a1 a2) (* b1 b2)) -0.0))
                   (<= (/ (* a1 a2) (* b1 b2)) 6.934790209617415e+271)))))
   (* (/ a2 b1) (/ a1 b2))
   (/ (* a1 a2) (* b1 b2))))
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 tmp;
	if ((((((double) (a1 * a2)) / ((double) (b1 * b2))) <= ((double) -(((double) INFINITY)))) || !(((((double) (a1 * a2)) / ((double) (b1 * b2))) <= -2.51091043835428e-309) || (!((((double) (a1 * a2)) / ((double) (b1 * b2))) <= -0.0) && ((((double) (a1 * a2)) / ((double) (b1 * b2))) <= 6.934790209617415e+271))))) {
		tmp = ((double) ((a2 / b1) * (a1 / b2)));
	} else {
		tmp = (((double) (a1 * a2)) / ((double) (b1 * b2)));
	}
	return tmp;
}

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.4
Target11.3
Herbie2.3
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]

Derivation

  1. Split input into 2 regimes
  2. if (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -inf.0 or -2.5109104383542784e-309 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -0.0 or 6.9347902096174153e271 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2))

    1. Initial program 24.8

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

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

      \[\leadsto \frac{a1}{\color{blue}{\frac{b1}{\frac{a2}{b2}}}}\]
    5. Using strategy rm
    6. Applied associate-/r/_binary647.0

      \[\leadsto \frac{a1}{\color{blue}{\frac{b1}{a2} \cdot b2}}\]
    7. Applied *-un-lft-identity_binary647.0

      \[\leadsto \frac{\color{blue}{1 \cdot a1}}{\frac{b1}{a2} \cdot b2}\]
    8. Applied times-frac_binary644.2

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

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

    if -inf.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -2.5109104383542784e-309 or -0.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 6.9347902096174153e271

    1. Initial program 0.9

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -\infty \lor \neg \left(\frac{a1 \cdot a2}{b1 \cdot b2} \leq -2.51091043835428 \cdot 10^{-309} \lor \neg \left(\frac{a1 \cdot a2}{b1 \cdot b2} \leq -0\right) \land \frac{a1 \cdot a2}{b1 \cdot b2} \leq 6.934790209617415 \cdot 10^{+271}\right):\\ \;\;\;\;\frac{a2}{b1} \cdot \frac{a1}{b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \end{array}\]

Reproduce

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

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

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