Average Error: 11.5 → 3.1
Time: 5.0s
Precision: binary64
\[[b1, b2]=\mathsf{sort}([b1, b2])\]
\[\frac{a1 \cdot a2}{b1 \cdot b2} \]
\[\begin{array}{l} t_0 := \frac{a2}{\sqrt[3]{b1}}\\ t_1 := \frac{a1 \cdot a2}{b1 \cdot b2}\\ t_2 := \frac{a1}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}}\\ t_3 := \frac{t_2 \cdot t_0}{b2}\\ \mathbf{if}\;t_1 \leq -\infty:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t_1 \leq -7.610924163598907 \cdot 10^{-298}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_1 \leq 0:\\ \;\;\;\;t_3\\ \mathbf{elif}\;t_1 \leq 1.947699555580729 \cdot 10^{+288}:\\ \;\;\;\;\left(a1 \cdot a2\right) \cdot \frac{\frac{1}{b1}}{b2}\\ \mathbf{else}:\\ \;\;\;\;t_2 \cdot \frac{t_0}{b2}\\ \end{array} \]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
t_0 := \frac{a2}{\sqrt[3]{b1}}\\
t_1 := \frac{a1 \cdot a2}{b1 \cdot b2}\\
t_2 := \frac{a1}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}}\\
t_3 := \frac{t_2 \cdot t_0}{b2}\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;t_3\\

\mathbf{elif}\;t_1 \leq -7.610924163598907 \cdot 10^{-298}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t_1 \leq 0:\\
\;\;\;\;t_3\\

\mathbf{elif}\;t_1 \leq 1.947699555580729 \cdot 10^{+288}:\\
\;\;\;\;\left(a1 \cdot a2\right) \cdot \frac{\frac{1}{b1}}{b2}\\

\mathbf{else}:\\
\;\;\;\;t_2 \cdot \frac{t_0}{b2}\\


\end{array}
(FPCore (a1 a2 b1 b2) :precision binary64 (/ (* a1 a2) (* b1 b2)))
(FPCore (a1 a2 b1 b2)
 :precision binary64
 (let* ((t_0 (/ a2 (cbrt b1)))
        (t_1 (/ (* a1 a2) (* b1 b2)))
        (t_2 (/ a1 (* (cbrt b1) (cbrt b1))))
        (t_3 (/ (* t_2 t_0) b2)))
   (if (<= t_1 (- INFINITY))
     t_3
     (if (<= t_1 -7.610924163598907e-298)
       t_1
       (if (<= t_1 0.0)
         t_3
         (if (<= t_1 1.947699555580729e+288)
           (* (* a1 a2) (/ (/ 1.0 b1) b2))
           (* t_2 (/ t_0 b2))))))))
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 = a2 / cbrt(b1);
	double t_1 = (a1 * a2) / (b1 * b2);
	double t_2 = a1 / (cbrt(b1) * cbrt(b1));
	double t_3 = (t_2 * t_0) / b2;
	double tmp;
	if (t_1 <= -((double) INFINITY)) {
		tmp = t_3;
	} else if (t_1 <= -7.610924163598907e-298) {
		tmp = t_1;
	} else if (t_1 <= 0.0) {
		tmp = t_3;
	} else if (t_1 <= 1.947699555580729e+288) {
		tmp = (a1 * a2) * ((1.0 / b1) / b2);
	} else {
		tmp = t_2 * (t_0 / 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.5
Target11.7
Herbie3.1
\[\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.61092416359890659e-298 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -0.0

    1. Initial program 18.8

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

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

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

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

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

    1. Initial program 0.9

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

    if -0.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 1.94769955558072912e288

    1. Initial program 1.0

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

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

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

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

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

    if 1.94769955558072912e288 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2))

    1. Initial program 58.6

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

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

      \[\leadsto \frac{\frac{a1 \cdot a2}{b1}}{\color{blue}{1 \cdot b2}} \]
    4. Applied add-cube-cbrt_binary6447.8

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

      \[\leadsto \frac{\color{blue}{\frac{a1}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \frac{a2}{\sqrt[3]{b1}}}}{1 \cdot b2} \]
    6. Applied times-frac_binary646.8

      \[\leadsto \color{blue}{\frac{\frac{a1}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}}}{1} \cdot \frac{\frac{a2}{\sqrt[3]{b1}}}{b2}} \]
    7. Simplified6.8

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -\infty:\\ \;\;\;\;\frac{\frac{a1}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \frac{a2}{\sqrt[3]{b1}}}{b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -7.610924163598907 \cdot 10^{-298}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 0:\\ \;\;\;\;\frac{\frac{a1}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \frac{a2}{\sqrt[3]{b1}}}{b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 1.947699555580729 \cdot 10^{+288}:\\ \;\;\;\;\left(a1 \cdot a2\right) \cdot \frac{\frac{1}{b1}}{b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \frac{\frac{a2}{\sqrt[3]{b1}}}{b2}\\ \end{array} \]

Reproduce

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

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

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