Average Error: 11.2 → 3.7
Time: 7.0s
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}\\ t_1 := \frac{\frac{a1}{b1}}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}} \cdot \frac{a2}{\sqrt[3]{b2}}\\ \mathbf{if}\;t_0 \leq -\infty:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_0 \leq -6.916235610315 \cdot 10^{-312}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;t_0 \leq 5.041403853359531 \cdot 10^{-289}:\\ \;\;\;\;\frac{a1 \cdot \frac{a2}{b2}}{b1}\\ \mathbf{elif}\;t_0 \leq 7.488614284566524 \cdot 10^{+190}:\\ \;\;\;\;\left(a1 \cdot a2\right) \cdot \frac{\frac{1}{b1}}{b2}\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
t_0 := \frac{a1 \cdot a2}{b1 \cdot b2}\\
t_1 := \frac{\frac{a1}{b1}}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}} \cdot \frac{a2}{\sqrt[3]{b2}}\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t_0 \leq -6.916235610315 \cdot 10^{-312}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;t_0 \leq 5.041403853359531 \cdot 10^{-289}:\\
\;\;\;\;\frac{a1 \cdot \frac{a2}{b2}}{b1}\\

\mathbf{elif}\;t_0 \leq 7.488614284566524 \cdot 10^{+190}:\\
\;\;\;\;\left(a1 \cdot a2\right) \cdot \frac{\frac{1}{b1}}{b2}\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\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)))
        (t_1 (* (/ (/ a1 b1) (* (cbrt b2) (cbrt b2))) (/ a2 (cbrt b2)))))
   (if (<= t_0 (- INFINITY))
     t_1
     (if (<= t_0 -6.916235610315e-312)
       t_0
       (if (<= t_0 5.041403853359531e-289)
         (/ (* a1 (/ a2 b2)) b1)
         (if (<= t_0 7.488614284566524e+190)
           (* (* a1 a2) (/ (/ 1.0 b1) b2))
           t_1))))))
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 t_1 = ((a1 / b1) / (cbrt(b2) * cbrt(b2))) * (a2 / cbrt(b2));
	double tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = t_1;
	} else if (t_0 <= -6.916235610315e-312) {
		tmp = t_0;
	} else if (t_0 <= 5.041403853359531e-289) {
		tmp = (a1 * (a2 / b2)) / b1;
	} else if (t_0 <= 7.488614284566524e+190) {
		tmp = (a1 * a2) * ((1.0 / b1) / b2);
	} else {
		tmp = t_1;
	}
	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.2
Target11.4
Herbie3.7
\[\frac{a1}{b1} \cdot \frac{a2}{b2} \]

Derivation

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

    1. Initial program 46.1

      \[\frac{a1 \cdot a2}{b1 \cdot b2} \]
    2. Applied times-frac_binary6411.7

      \[\leadsto \color{blue}{\frac{a1}{b1} \cdot \frac{a2}{b2}} \]
    3. Applied add-cube-cbrt_binary6412.5

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

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

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

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

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

    if -inf.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -6.9162356103149e-312

    1. Initial program 0.8

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

    if -6.9162356103149e-312 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 5.0414038533595308e-289

    1. Initial program 12.5

      \[\frac{a1 \cdot a2}{b1 \cdot b2} \]
    2. Applied times-frac_binary642.3

      \[\leadsto \color{blue}{\frac{a1}{b1} \cdot \frac{a2}{b2}} \]
    3. Applied associate-*l/_binary643.7

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

    if 5.0414038533595308e-289 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 7.48861428456652416e190

    1. Initial program 0.8

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

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

      \[\leadsto \frac{\frac{a1 \cdot a2}{b1}}{\color{blue}{1 \cdot b2}} \]
    4. Applied div-inv_binary646.7

      \[\leadsto \frac{\color{blue}{\left(a1 \cdot a2\right) \cdot \frac{1}{b1}}}{1 \cdot b2} \]
    5. Applied times-frac_binary641.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -\infty:\\ \;\;\;\;\frac{\frac{a1}{b1}}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}} \cdot \frac{a2}{\sqrt[3]{b2}}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -6.916235610315 \cdot 10^{-312}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 5.041403853359531 \cdot 10^{-289}:\\ \;\;\;\;\frac{a1 \cdot \frac{a2}{b2}}{b1}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 7.488614284566524 \cdot 10^{+190}:\\ \;\;\;\;\left(a1 \cdot a2\right) \cdot \frac{\frac{1}{b1}}{b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{a1}{b1}}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}} \cdot \frac{a2}{\sqrt[3]{b2}}\\ \end{array} \]

Reproduce

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

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

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