Average Error: 11.4 → 2.3
Time: 5.6s
Precision: binary64
\[[a1, a2]=\mathsf{sort}([a1, a2])\]
\[[b1, b2]=\mathsf{sort}([b1, b2])\]
\[\frac{a1 \cdot a2}{b1 \cdot b2} \]
\[\begin{array}{l} t_0 := \frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{if}\;t_0 \leq -\infty:\\ \;\;\;\;\frac{a1}{\frac{b1}{\frac{a2}{b2}}}\\ \mathbf{elif}\;t_0 \leq -3.44917 \cdot 10^{-319} \lor \neg \left(t_0 \leq 0\right) \land t_0 \leq 4.0160797858835715 \cdot 10^{+299}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{a2}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}}}{\frac{b2}{\frac{a1}{\sqrt[3]{b1}}}}\\ \end{array} \]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
t_0 := \frac{a1 \cdot a2}{b1 \cdot b2}\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;\frac{a1}{\frac{b1}{\frac{a2}{b2}}}\\

\mathbf{elif}\;t_0 \leq -3.44917 \cdot 10^{-319} \lor \neg \left(t_0 \leq 0\right) \land t_0 \leq 4.0160797858835715 \cdot 10^{+299}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{a2}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}}}{\frac{b2}{\frac{a1}{\sqrt[3]{b1}}}}\\


\end{array}
(FPCore (a1 a2 b1 b2) :precision binary64 (/ (* a1 a2) (* b1 b2)))
(FPCore (a1 a2 b1 b2)
 :precision binary64
 (let* ((t_0 (/ (* a1 a2) (* b1 b2))))
   (if (<= t_0 (- INFINITY))
     (/ a1 (/ b1 (/ a2 b2)))
     (if (or (<= t_0 -3.44917e-319)
             (and (not (<= t_0 0.0)) (<= t_0 4.0160797858835715e+299)))
       t_0
       (/ (/ a2 (* (cbrt b1) (cbrt b1))) (/ b2 (/ a1 (cbrt b1))))))))
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 t_0 = (a1 * a2) / (b1 * b2);
	double tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = a1 / (b1 / (a2 / b2));
	} else if ((t_0 <= -3.44917e-319) || (!(t_0 <= 0.0) && (t_0 <= 4.0160797858835715e+299))) {
		tmp = t_0;
	} else {
		tmp = (a2 / (cbrt(b1) * cbrt(b1))) / (b2 / (a1 / cbrt(b1)));
	}
	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.4
Herbie2.3
\[\frac{a1}{b1} \cdot \frac{a2}{b2} \]

Derivation

  1. Split input into 3 regimes
  2. if (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -inf.0

    1. Initial program 64.0

      \[\frac{a1 \cdot a2}{b1 \cdot b2} \]
    2. Applied associate-/l*_binary6434.6

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

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

    if -inf.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -3.44917e-319 or -0.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 4.01607978588357146e299

    1. Initial program 0.7

      \[\frac{a1 \cdot a2}{b1 \cdot b2} \]

    if -3.44917e-319 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -0.0 or 4.01607978588357146e299 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2))

    1. Initial program 23.2

      \[\frac{a1 \cdot a2}{b1 \cdot b2} \]
    2. Applied associate-/r*_binary6414.5

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

      \[\leadsto \frac{\color{blue}{a2 \cdot \frac{a1}{b1}}}{b2} \]
    4. Applied associate-/l*_binary645.8

      \[\leadsto \color{blue}{\frac{a2}{\frac{b2}{\frac{a1}{b1}}}} \]
    5. Applied add-cube-cbrt_binary646.0

      \[\leadsto \frac{a2}{\frac{b2}{\frac{a1}{\color{blue}{\left(\sqrt[3]{b1} \cdot \sqrt[3]{b1}\right) \cdot \sqrt[3]{b1}}}}} \]
    6. Applied *-un-lft-identity_binary646.0

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

      \[\leadsto \frac{a2}{\frac{b2}{\color{blue}{\frac{1}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \frac{a1}{\sqrt[3]{b1}}}}} \]
    8. Applied *-un-lft-identity_binary646.0

      \[\leadsto \frac{a2}{\frac{\color{blue}{1 \cdot b2}}{\frac{1}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \frac{a1}{\sqrt[3]{b1}}}} \]
    9. Applied times-frac_binary645.7

      \[\leadsto \frac{a2}{\color{blue}{\frac{1}{\frac{1}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}}} \cdot \frac{b2}{\frac{a1}{\sqrt[3]{b1}}}}} \]
    10. Applied associate-/r*_binary643.3

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -\infty:\\ \;\;\;\;\frac{a1}{\frac{b1}{\frac{a2}{b2}}}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -3.44917 \cdot 10^{-319} \lor \neg \left(\frac{a1 \cdot a2}{b1 \cdot b2} \leq 0\right) \land \frac{a1 \cdot a2}{b1 \cdot b2} \leq 4.0160797858835715 \cdot 10^{+299}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{a2}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}}}{\frac{b2}{\frac{a1}{\sqrt[3]{b1}}}}\\ \end{array} \]

Reproduce

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

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

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