Average Error: 10.8 → 2.9
Time: 10.3s
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 0:\\ \;\;\;\;\frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{\frac{1}{\frac{\sqrt[3]{a2} \cdot \sqrt[3]{a2}}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}}}} \cdot \frac{\sqrt[3]{a1}}{\frac{b1}{\frac{\sqrt[3]{a2}}{\sqrt[3]{b2}}}}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 3.5261378074277998 \cdot 10^{+292}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt[3]{a2} \cdot \sqrt[3]{a2}}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \frac{a1}{\frac{\sqrt[3]{b1}}{\frac{\sqrt[3]{a2}}{b2}}}\\ \end{array}\]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
\mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 0:\\
\;\;\;\;\frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{\frac{1}{\frac{\sqrt[3]{a2} \cdot \sqrt[3]{a2}}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}}}} \cdot \frac{\sqrt[3]{a1}}{\frac{b1}{\frac{\sqrt[3]{a2}}{\sqrt[3]{b2}}}}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{\sqrt[3]{a2} \cdot \sqrt[3]{a2}}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \frac{a1}{\frac{\sqrt[3]{b1}}{\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 (<= (/ (* a1 a2) (* b1 b2)) 0.0)
   (*
    (/
     (* (cbrt a1) (cbrt a1))
     (/ 1.0 (/ (* (cbrt a2) (cbrt a2)) (* (cbrt b2) (cbrt b2)))))
    (/ (cbrt a1) (/ b1 (/ (cbrt a2) (cbrt b2)))))
   (if (<= (/ (* a1 a2) (* b1 b2)) 3.5261378074277998e+292)
     (/ (* a1 a2) (* b1 b2))
     (*
      (/ (* (cbrt a2) (cbrt a2)) (* (cbrt b1) (cbrt b1)))
      (/ a1 (/ (cbrt b1) (/ (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 (((a1 * a2) / (b1 * b2)) <= 0.0) {
		tmp = ((cbrt(a1) * cbrt(a1)) / (1.0 / ((cbrt(a2) * cbrt(a2)) / (cbrt(b2) * cbrt(b2))))) * (cbrt(a1) / (b1 / (cbrt(a2) / cbrt(b2))));
	} else if (((a1 * a2) / (b1 * b2)) <= 3.5261378074277998e+292) {
		tmp = (a1 * a2) / (b1 * b2);
	} else {
		tmp = ((cbrt(a2) * cbrt(a2)) / (cbrt(b1) * cbrt(b1))) * (a1 / (cbrt(b1) / (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

Original10.8
Target11.4
Herbie2.9
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]

Derivation

  1. Split input into 3 regimes
  2. if (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 0.0

    1. Initial program 9.9

      \[\frac{a1 \cdot a2}{b1 \cdot b2}\]
    2. Using strategy rm
    3. Applied associate-/l*_binary649.0

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

      \[\leadsto \frac{a1}{\color{blue}{\frac{b1}{\frac{a2}{b2}}}}\]
    5. Using strategy rm
    6. Applied add-cube-cbrt_binary6410.1

      \[\leadsto \frac{a1}{\frac{b1}{\frac{a2}{\color{blue}{\left(\sqrt[3]{b2} \cdot \sqrt[3]{b2}\right) \cdot \sqrt[3]{b2}}}}}\]
    7. 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}}}}\]
    8. 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}}}}}\]
    9. Applied *-un-lft-identity_binary6410.3

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

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

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

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

    if 0.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 3.52613780742779975e292

    1. Initial program 0.7

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

    if 3.52613780742779975e292 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2))

    1. Initial program 60.5

      \[\frac{a1 \cdot a2}{b1 \cdot b2}\]
    2. Using strategy rm
    3. Applied associate-/l*_binary6444.8

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

      \[\leadsto \frac{a1}{\color{blue}{\frac{b1}{\frac{a2}{b2}}}}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity_binary6413.5

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

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

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

      \[\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}}{1} \cdot \frac{\sqrt[3]{a2}}{b2}}}\]
    10. Applied times-frac_binary6412.8

      \[\leadsto \frac{a1}{\color{blue}{\frac{\sqrt[3]{b1} \cdot \sqrt[3]{b1}}{\frac{\sqrt[3]{a2} \cdot \sqrt[3]{a2}}{1}} \cdot \frac{\sqrt[3]{b1}}{\frac{\sqrt[3]{a2}}{b2}}}}\]
    11. Applied *-un-lft-identity_binary6412.8

      \[\leadsto \frac{\color{blue}{1 \cdot a1}}{\frac{\sqrt[3]{b1} \cdot \sqrt[3]{b1}}{\frac{\sqrt[3]{a2} \cdot \sqrt[3]{a2}}{1}} \cdot \frac{\sqrt[3]{b1}}{\frac{\sqrt[3]{a2}}{b2}}}\]
    12. Applied times-frac_binary646.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 0:\\ \;\;\;\;\frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{\frac{1}{\frac{\sqrt[3]{a2} \cdot \sqrt[3]{a2}}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}}}} \cdot \frac{\sqrt[3]{a1}}{\frac{b1}{\frac{\sqrt[3]{a2}}{\sqrt[3]{b2}}}}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 3.5261378074277998 \cdot 10^{+292}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt[3]{a2} \cdot \sqrt[3]{a2}}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \frac{a1}{\frac{\sqrt[3]{b1}}{\frac{\sqrt[3]{a2}}{b2}}}\\ \end{array}\]

Reproduce

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

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

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