Average Error: 11.8 → 2.1
Time: 3.4s
Precision: binary64
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -\infty:\\ \;\;\;\;\left(a1 \cdot \frac{a2}{b2}\right) \cdot \frac{1}{b1}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -1.3109376793505 \cdot 10^{-312}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 0:\\ \;\;\;\;\frac{a2}{b2} \cdot \frac{a1}{b1}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 8.994764357597508 \cdot 10^{+307}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \left(\frac{a2}{b2} \cdot \frac{\sqrt[3]{a1}}{\sqrt[3]{b1}}\right)\\ \end{array}\]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
\mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -\infty:\\
\;\;\;\;\left(a1 \cdot \frac{a2}{b2}\right) \cdot \frac{1}{b1}\\

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

\mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 0:\\
\;\;\;\;\frac{a2}{b2} \cdot \frac{a1}{b1}\\

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

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

\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 (/ a2 b2)) (/ 1.0 b1))
   (if (<= (/ (* a1 a2) (* b1 b2)) -1.3109376793505e-312)
     (/ (* a1 a2) (* b1 b2))
     (if (<= (/ (* a1 a2) (* b1 b2)) 0.0)
       (* (/ a2 b2) (/ a1 b1))
       (if (<= (/ (* a1 a2) (* b1 b2)) 8.994764357597508e+307)
         (/ (* a1 a2) (* b1 b2))
         (*
          (/ (* (cbrt a1) (cbrt a1)) (* (cbrt b1) (cbrt b1)))
          (* (/ a2 b2) (/ (cbrt 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 tmp;
	if (((a1 * a2) / (b1 * b2)) <= -((double) INFINITY)) {
		tmp = (a1 * (a2 / b2)) * (1.0 / b1);
	} else if (((a1 * a2) / (b1 * b2)) <= -1.3109376793505e-312) {
		tmp = (a1 * a2) / (b1 * b2);
	} else if (((a1 * a2) / (b1 * b2)) <= 0.0) {
		tmp = (a2 / b2) * (a1 / b1);
	} else if (((a1 * a2) / (b1 * b2)) <= 8.994764357597508e+307) {
		tmp = (a1 * a2) / (b1 * b2);
	} else {
		tmp = ((cbrt(a1) * cbrt(a1)) / (cbrt(b1) * cbrt(b1))) * ((a2 / b2) * (cbrt(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.8
Target11.3
Herbie2.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

    1. Initial program 64.0

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

      \[\leadsto \color{blue}{\frac{a1}{b1} \cdot \frac{a2}{b2}}\]
    4. Using strategy rm
    5. Applied associate-*l/_binary6419.5

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

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

    if -inf.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -1.3109376793505e-312 or 0.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 8.9947643575975084e307

    1. Initial program 0.7

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

    if -1.3109376793505e-312 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 0.0

    1. Initial program 12.9

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

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

    if 8.9947643575975084e307 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2))

    1. Initial program 63.9

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

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

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

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

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

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

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

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

Reproduce

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

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

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