Average Error: 11.4 → 2.5
Time: 6.6s
Precision: binary64
\[[a1, a2] = \mathsf{sort}([a1, a2]) \\]
\[\frac{a1 \cdot a2}{b1 \cdot b2} \]
\[\begin{array}{l} t_0 := \frac{a1 \cdot a2}{b1 \cdot b2}\\ t_1 := \frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{if}\;t_0 \leq -\infty:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_0 \leq -8.400079601776277 \cdot 10^{-290}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;t_0 \leq 0:\\ \;\;\;\;\left(\sqrt[3]{a1} \cdot \sqrt[3]{a1}\right) \cdot \left(\left(\frac{\sqrt[3]{a1}}{b1} \cdot \left(\sqrt[3]{a2} \cdot \sqrt[3]{a2}\right)\right) \cdot \frac{\sqrt[3]{a2}}{b2}\right)\\ \mathbf{elif}\;t_0 \leq 3.589237135653206 \cdot 10^{+299}:\\ \;\;\;\;t_0\\ \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{a1}{b1} \cdot \frac{a2}{b2}\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t_0 \leq -8.400079601776277 \cdot 10^{-290}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;t_0 \leq 3.589237135653206 \cdot 10^{+299}:\\
\;\;\;\;t_0\\

\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) (/ a2 b2))))
   (if (<= t_0 (- INFINITY))
     t_1
     (if (<= t_0 -8.400079601776277e-290)
       t_0
       (if (<= t_0 0.0)
         (*
          (* (cbrt a1) (cbrt a1))
          (* (* (/ (cbrt a1) b1) (* (cbrt a2) (cbrt a2))) (/ (cbrt a2) b2)))
         (if (<= t_0 3.589237135653206e+299) t_0 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) * (a2 / b2);
	double tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = t_1;
	} else if (t_0 <= -8.400079601776277e-290) {
		tmp = t_0;
	} else if (t_0 <= 0.0) {
		tmp = (cbrt(a1) * cbrt(a1)) * (((cbrt(a1) / b1) * (cbrt(a2) * cbrt(a2))) * (cbrt(a2) / b2));
	} else if (t_0 <= 3.589237135653206e+299) {
		tmp = t_0;
	} 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.4
Target11.6
Herbie2.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 or 3.58923713565320618e299 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2))

    1. Initial program 62.5

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

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

    if -inf.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -8.4000796017762771e-290 or -0.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 3.58923713565320618e299

    1. Initial program 0.9

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

    if -8.4000796017762771e-290 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -0.0

    1. Initial program 13.1

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{1} \cdot \left(\frac{\sqrt[3]{a1}}{b1} \cdot \frac{a2}{b2}\right)} \]
    7. Applied *-un-lft-identity_binary643.8

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

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

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

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

      \[\leadsto \frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{1} \cdot \left(\color{blue}{\left(\frac{\sqrt[3]{a1}}{b1} \cdot \left(\sqrt[3]{a2} \cdot \sqrt[3]{a2}\right)\right)} \cdot \frac{\sqrt[3]{a2}}{b2}\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification2.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 -8.400079601776277 \cdot 10^{-290}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 0:\\ \;\;\;\;\left(\sqrt[3]{a1} \cdot \sqrt[3]{a1}\right) \cdot \left(\left(\frac{\sqrt[3]{a1}}{b1} \cdot \left(\sqrt[3]{a2} \cdot \sqrt[3]{a2}\right)\right) \cdot \frac{\sqrt[3]{a2}}{b2}\right)\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 3.589237135653206 \cdot 10^{+299}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \end{array} \]

Reproduce

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

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

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