Average Error: 10.9 → 1.5
Time: 9.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} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -\infty:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -7.087500967058436 \cdot 10^{-296} \lor \neg \left(\frac{a1 \cdot a2}{b1 \cdot b2} \leq 0\right) \land \frac{a1 \cdot a2}{b1 \cdot b2} \leq 2.4483889177719666 \cdot 10^{+305}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\left(\frac{a1}{b1} \cdot \frac{\sqrt[3]{a2} \cdot \sqrt[3]{a2}}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}}\right) \cdot \frac{\sqrt[3]{a2}}{\sqrt[3]{b2}}\\ \end{array}\]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
\mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -\infty:\\
\;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\

\mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -7.087500967058436 \cdot 10^{-296} \lor \neg \left(\frac{a1 \cdot a2}{b1 \cdot b2} \leq 0\right) \land \frac{a1 \cdot a2}{b1 \cdot b2} \leq 2.4483889177719666 \cdot 10^{+305}:\\
\;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\

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

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

Original10.9
Target11.7
Herbie1.5
\[\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. Using strategy rm
    3. Applied times-frac_binary64_588110.8

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

    if -inf.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -7.08750096705843556e-296 or -0.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 2.4483889177719666e305

    1. Initial program 0.7

      \[\frac{a1 \cdot a2}{b1 \cdot b2}\]
    2. Using strategy rm
    3. Applied *-un-lft-identity_binary64_58750.7

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

    if -7.08750096705843556e-296 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -0.0 or 2.4483889177719666e305 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2))

    1. Initial program 21.9

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

      \[\leadsto \color{blue}{\frac{a1}{b1} \cdot \frac{a2}{b2}}\]
    4. Using strategy rm
    5. Applied add-cube-cbrt_binary64_59103.2

      \[\leadsto \frac{a1}{b1} \cdot \frac{a2}{\color{blue}{\left(\sqrt[3]{b2} \cdot \sqrt[3]{b2}\right) \cdot \sqrt[3]{b2}}}\]
    6. Applied add-cube-cbrt_binary64_59103.3

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

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

      \[\leadsto \color{blue}{\left(\frac{a1}{b1} \cdot \frac{\sqrt[3]{a2} \cdot \sqrt[3]{a2}}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}}\right) \cdot \frac{\sqrt[3]{a2}}{\sqrt[3]{b2}}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification1.5

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

Reproduce

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

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

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