Average Error: 11.4 → 2.4
Time: 5.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} t_0 := \sqrt[3]{b1} \cdot \sqrt[3]{b1}\\ t_1 := \sqrt[3]{b2} \cdot \sqrt[3]{b2}\\ t_2 := \frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;\frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{t_0 \cdot t_1} \cdot \frac{\sqrt[3]{a1}}{\frac{\sqrt[3]{b1}}{\frac{a2}{\sqrt[3]{b2}}}}\\ \mathbf{elif}\;t_2 \leq -2.653892108765896 \cdot 10^{-209}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\sqrt[3]{a2} \cdot \sqrt[3]{a2}}{t_1}}{t_0} \cdot \frac{a1}{\frac{\sqrt[3]{b1}}{\frac{\sqrt[3]{a2}}{\sqrt[3]{b2}}}}\\ \end{array} \]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
t_0 := \sqrt[3]{b1} \cdot \sqrt[3]{b1}\\
t_1 := \sqrt[3]{b2} \cdot \sqrt[3]{b2}\\
t_2 := \frac{a1 \cdot a2}{b1 \cdot b2}\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;\frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{t_0 \cdot t_1} \cdot \frac{\sqrt[3]{a1}}{\frac{\sqrt[3]{b1}}{\frac{a2}{\sqrt[3]{b2}}}}\\

\mathbf{elif}\;t_2 \leq -2.653892108765896 \cdot 10^{-209}:\\
\;\;\;\;t_2\\

\mathbf{else}:\\
\;\;\;\;\frac{\frac{\sqrt[3]{a2} \cdot \sqrt[3]{a2}}{t_1}}{t_0} \cdot \frac{a1}{\frac{\sqrt[3]{b1}}{\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
 (let* ((t_0 (* (cbrt b1) (cbrt b1)))
        (t_1 (* (cbrt b2) (cbrt b2)))
        (t_2 (/ (* a1 a2) (* b1 b2))))
   (if (<= t_2 (- INFINITY))
     (*
      (/ (* (cbrt a1) (cbrt a1)) (* t_0 t_1))
      (/ (cbrt a1) (/ (cbrt b1) (/ a2 (cbrt b2)))))
     (if (<= t_2 -2.653892108765896e-209)
       t_2
       (*
        (/ (/ (* (cbrt a2) (cbrt a2)) t_1) t_0)
        (/ a1 (/ (cbrt b1) (/ (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 t_0 = cbrt(b1) * cbrt(b1);
	double t_1 = cbrt(b2) * cbrt(b2);
	double t_2 = (a1 * a2) / (b1 * b2);
	double tmp;
	if (t_2 <= -((double) INFINITY)) {
		tmp = ((cbrt(a1) * cbrt(a1)) / (t_0 * t_1)) * (cbrt(a1) / (cbrt(b1) / (a2 / cbrt(b2))));
	} else if (t_2 <= -2.653892108765896e-209) {
		tmp = t_2;
	} else {
		tmp = (((cbrt(a2) * cbrt(a2)) / t_1) / t_0) * (a1 / (cbrt(b1) / (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

Original11.4
Target11.6
Herbie2.4
\[\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. Applied associate-/l*_binary6429.1

      \[\leadsto \color{blue}{\frac{a1}{\frac{b1 \cdot b2}{a2}}} \]
    3. Simplified16.2

      \[\leadsto \frac{a1}{\color{blue}{\frac{b1}{\frac{a2}{b2}}}} \]
    4. Applied add-cube-cbrt_binary6417.0

      \[\leadsto \frac{a1}{\frac{b1}{\frac{a2}{\color{blue}{\left(\sqrt[3]{b2} \cdot \sqrt[3]{b2}\right) \cdot \sqrt[3]{b2}}}}} \]
    5. Applied *-un-lft-identity_binary6417.0

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

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

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

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

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

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

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

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

    1. Initial program 0.8

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

    if -2.6538921087658958e-209 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2))

    1. Initial program 12.8

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

      \[\leadsto \color{blue}{\frac{a1}{\frac{b1 \cdot b2}{a2}}} \]
    3. Simplified9.7

      \[\leadsto \frac{a1}{\color{blue}{\frac{b1}{\frac{a2}{b2}}}} \]
    4. Applied add-cube-cbrt_binary6410.2

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

      \[\leadsto \frac{a1}{\frac{b1}{\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}}}} \]
    6. Applied times-frac_binary6410.3

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -\infty:\\ \;\;\;\;\frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{\left(\sqrt[3]{b1} \cdot \sqrt[3]{b1}\right) \cdot \left(\sqrt[3]{b2} \cdot \sqrt[3]{b2}\right)} \cdot \frac{\sqrt[3]{a1}}{\frac{\sqrt[3]{b1}}{\frac{a2}{\sqrt[3]{b2}}}}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -2.653892108765896 \cdot 10^{-209}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{\sqrt[3]{a2} \cdot \sqrt[3]{a2}}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}}}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \frac{a1}{\frac{\sqrt[3]{b1}}{\frac{\sqrt[3]{a2}}{\sqrt[3]{b2}}}}\\ \end{array} \]

Reproduce

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

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

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