Average Error: 11.5 → 5.3
Time: 3.6s
Precision: binary64
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;b1 \cdot b2 \leq -4.193834960798578 \cdot 10^{+261}:\\ \;\;\;\;\left(\frac{a1}{b1} \cdot \left(\sqrt[3]{a2} \cdot \sqrt[3]{a2}\right)\right) \cdot \frac{\sqrt[3]{a2}}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \leq -3.9728237755663456 \cdot 10^{-292}:\\ \;\;\;\;a1 \cdot \frac{a2}{b1 \cdot b2}\\ \mathbf{elif}\;b1 \cdot b2 \leq 1.4607986041132002 \cdot 10^{-243}:\\ \;\;\;\;\frac{\frac{a1}{b1} \cdot a2}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \leq 6.036554690463631 \cdot 10^{+287}:\\ \;\;\;\;a1 \cdot \frac{a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{a1}{b1} \cdot \left(\sqrt[3]{a2} \cdot \sqrt[3]{a2}\right)\right) \cdot \frac{\sqrt[3]{a2}}{b2}\\ \end{array}\]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
\mathbf{if}\;b1 \cdot b2 \leq -4.193834960798578 \cdot 10^{+261}:\\
\;\;\;\;\left(\frac{a1}{b1} \cdot \left(\sqrt[3]{a2} \cdot \sqrt[3]{a2}\right)\right) \cdot \frac{\sqrt[3]{a2}}{b2}\\

\mathbf{elif}\;b1 \cdot b2 \leq -3.9728237755663456 \cdot 10^{-292}:\\
\;\;\;\;a1 \cdot \frac{a2}{b1 \cdot b2}\\

\mathbf{elif}\;b1 \cdot b2 \leq 1.4607986041132002 \cdot 10^{-243}:\\
\;\;\;\;\frac{\frac{a1}{b1} \cdot a2}{b2}\\

\mathbf{elif}\;b1 \cdot b2 \leq 6.036554690463631 \cdot 10^{+287}:\\
\;\;\;\;a1 \cdot \frac{a2}{b1 \cdot b2}\\

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

\end{array}
(FPCore (a1 a2 b1 b2) :precision binary64 (/ (* a1 a2) (* b1 b2)))
(FPCore (a1 a2 b1 b2)
 :precision binary64
 (if (<= (* b1 b2) -4.193834960798578e+261)
   (* (* (/ a1 b1) (* (cbrt a2) (cbrt a2))) (/ (cbrt a2) b2))
   (if (<= (* b1 b2) -3.9728237755663456e-292)
     (* a1 (/ a2 (* b1 b2)))
     (if (<= (* b1 b2) 1.4607986041132002e-243)
       (/ (* (/ a1 b1) a2) b2)
       (if (<= (* b1 b2) 6.036554690463631e+287)
         (* a1 (/ a2 (* b1 b2)))
         (* (* (/ a1 b1) (* (cbrt a2) (cbrt a2))) (/ (cbrt a2) 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 tmp;
	if ((b1 * b2) <= -4.193834960798578e+261) {
		tmp = ((a1 / b1) * (cbrt(a2) * cbrt(a2))) * (cbrt(a2) / b2);
	} else if ((b1 * b2) <= -3.9728237755663456e-292) {
		tmp = a1 * (a2 / (b1 * b2));
	} else if ((b1 * b2) <= 1.4607986041132002e-243) {
		tmp = ((a1 / b1) * a2) / b2;
	} else if ((b1 * b2) <= 6.036554690463631e+287) {
		tmp = a1 * (a2 / (b1 * b2));
	} else {
		tmp = ((a1 / b1) * (cbrt(a2) * cbrt(a2))) * (cbrt(a2) / 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.9
Herbie5.3
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]

Derivation

  1. Split input into 3 regimes
  2. if (*.f64 b1 b2) < -4.19383496079857828e261 or 6.03655469046363111e287 < (*.f64 b1 b2)

    1. Initial program 20.4

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

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

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

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

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

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

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

    if -4.19383496079857828e261 < (*.f64 b1 b2) < -3.97282377556634561e-292 or 1.4607986041132002e-243 < (*.f64 b1 b2) < 6.03655469046363111e287

    1. Initial program 5.3

      \[\frac{a1 \cdot a2}{b1 \cdot b2}\]
    2. Using strategy rm
    3. Applied times-frac_binary6414.5

      \[\leadsto \color{blue}{\frac{a1}{b1} \cdot \frac{a2}{b2}}\]
    4. Using strategy rm
    5. Applied div-inv_binary6414.6

      \[\leadsto \color{blue}{\left(a1 \cdot \frac{1}{b1}\right)} \cdot \frac{a2}{b2}\]
    6. Applied associate-*l*_binary6412.0

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

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

    if -3.97282377556634561e-292 < (*.f64 b1 b2) < 1.4607986041132002e-243

    1. Initial program 46.2

      \[\frac{a1 \cdot a2}{b1 \cdot b2}\]
    2. Using strategy rm
    3. Applied associate-/r*_binary6417.5

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b1 \cdot b2 \leq -4.193834960798578 \cdot 10^{+261}:\\ \;\;\;\;\left(\frac{a1}{b1} \cdot \left(\sqrt[3]{a2} \cdot \sqrt[3]{a2}\right)\right) \cdot \frac{\sqrt[3]{a2}}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \leq -3.9728237755663456 \cdot 10^{-292}:\\ \;\;\;\;a1 \cdot \frac{a2}{b1 \cdot b2}\\ \mathbf{elif}\;b1 \cdot b2 \leq 1.4607986041132002 \cdot 10^{-243}:\\ \;\;\;\;\frac{\frac{a1}{b1} \cdot a2}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \leq 6.036554690463631 \cdot 10^{+287}:\\ \;\;\;\;a1 \cdot \frac{a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{a1}{b1} \cdot \left(\sqrt[3]{a2} \cdot \sqrt[3]{a2}\right)\right) \cdot \frac{\sqrt[3]{a2}}{b2}\\ \end{array}\]

Reproduce

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

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

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