Average Error: 11.6 → 4.8
Time: 4.4s
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 := \frac{\left(a2 \cdot \frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}}\right) \cdot \frac{\sqrt[3]{a1}}{\sqrt[3]{b1}}}{b2}\\ \mathbf{if}\;b1 \cdot b2 \leq -2.3720194052494554 \cdot 10^{+232}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;b1 \cdot b2 \leq -5.062919740973674 \cdot 10^{-112}:\\ \;\;\;\;\frac{a2 \cdot a1}{b1 \cdot b2}\\ \mathbf{elif}\;b1 \cdot b2 \leq 0:\\ \;\;\;\;t_0\\ \mathbf{elif}\;b1 \cdot b2 \leq 7.40266575556476 \cdot 10^{+200}:\\ \;\;\;\;a2 \cdot \frac{a1}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{a2}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}} \cdot \frac{\frac{a1}{b1}}{\sqrt[3]{b2}}\\ \end{array} \]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
t_0 := \frac{\left(a2 \cdot \frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}}\right) \cdot \frac{\sqrt[3]{a1}}{\sqrt[3]{b1}}}{b2}\\
\mathbf{if}\;b1 \cdot b2 \leq -2.3720194052494554 \cdot 10^{+232}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;b1 \cdot b2 \leq 0:\\
\;\;\;\;t_0\\

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

\mathbf{else}:\\
\;\;\;\;\frac{a2}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}} \cdot \frac{\frac{a1}{b1}}{\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
         (/
          (*
           (* a2 (/ (* (cbrt a1) (cbrt a1)) (* (cbrt b1) (cbrt b1))))
           (/ (cbrt a1) (cbrt b1)))
          b2)))
   (if (<= (* b1 b2) -2.3720194052494554e+232)
     t_0
     (if (<= (* b1 b2) -5.062919740973674e-112)
       (/ (* a2 a1) (* b1 b2))
       (if (<= (* b1 b2) 0.0)
         t_0
         (if (<= (* b1 b2) 7.40266575556476e+200)
           (* a2 (/ a1 (* b1 b2)))
           (* (/ a2 (* (cbrt b2) (cbrt b2))) (/ (/ a1 b1) (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 = ((a2 * ((cbrt(a1) * cbrt(a1)) / (cbrt(b1) * cbrt(b1)))) * (cbrt(a1) / cbrt(b1))) / b2;
	double tmp;
	if ((b1 * b2) <= -2.3720194052494554e+232) {
		tmp = t_0;
	} else if ((b1 * b2) <= -5.062919740973674e-112) {
		tmp = (a2 * a1) / (b1 * b2);
	} else if ((b1 * b2) <= 0.0) {
		tmp = t_0;
	} else if ((b1 * b2) <= 7.40266575556476e+200) {
		tmp = a2 * (a1 / (b1 * b2));
	} else {
		tmp = (a2 / (cbrt(b2) * cbrt(b2))) * ((a1 / b1) / 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.6
Target11.1
Herbie4.8
\[\frac{a1}{b1} \cdot \frac{a2}{b2} \]

Derivation

  1. Split input into 4 regimes
  2. if (*.f64 b1 b2) < -2.3720194052494554e232 or -5.06291974097367404e-112 < (*.f64 b1 b2) < -0.0

    1. Initial program 24.8

      \[\frac{a1 \cdot a2}{b1 \cdot b2} \]
    2. Using strategy rm
    3. Applied associate-/r*_binary6412.9

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

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

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

      \[\leadsto \frac{a2 \cdot \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}}}{b2} \]
    8. Applied times-frac_binary648.9

      \[\leadsto \frac{a2 \cdot \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)}}{b2} \]
    9. Applied associate-*r*_binary645.8

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

    if -2.3720194052494554e232 < (*.f64 b1 b2) < -5.06291974097367404e-112

    1. Initial program 3.8

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

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

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

      \[\leadsto \frac{a2 \cdot \frac{a1}{b1}}{\color{blue}{1 \cdot b2}} \]
    7. Applied times-frac_binary6410.6

      \[\leadsto \color{blue}{\frac{a2}{1} \cdot \frac{\frac{a1}{b1}}{b2}} \]
    8. Simplified10.6

      \[\leadsto \color{blue}{a2} \cdot \frac{\frac{a1}{b1}}{b2} \]
    9. Simplified3.6

      \[\leadsto a2 \cdot \color{blue}{\frac{a1}{b2 \cdot b1}} \]
    10. Taylor expanded around 0 3.8

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

    if -0.0 < (*.f64 b1 b2) < 7.40266575556476003e200

    1. Initial program 5.7

      \[\frac{a1 \cdot a2}{b1 \cdot b2} \]
    2. Using strategy rm
    3. Applied associate-/r*_binary6412.5

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

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

      \[\leadsto \frac{a2 \cdot \frac{a1}{b1}}{\color{blue}{1 \cdot b2}} \]
    7. Applied times-frac_binary6411.8

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

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

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

    if 7.40266575556476003e200 < (*.f64 b1 b2)

    1. Initial program 15.6

      \[\frac{a1 \cdot a2}{b1 \cdot b2} \]
    2. Using strategy rm
    3. Applied associate-/r*_binary647.7

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b1 \cdot b2 \leq -2.3720194052494554 \cdot 10^{+232}:\\ \;\;\;\;\frac{\left(a2 \cdot \frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}}\right) \cdot \frac{\sqrt[3]{a1}}{\sqrt[3]{b1}}}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \leq -5.062919740973674 \cdot 10^{-112}:\\ \;\;\;\;\frac{a2 \cdot a1}{b1 \cdot b2}\\ \mathbf{elif}\;b1 \cdot b2 \leq 0:\\ \;\;\;\;\frac{\left(a2 \cdot \frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}}\right) \cdot \frac{\sqrt[3]{a1}}{\sqrt[3]{b1}}}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \leq 7.40266575556476 \cdot 10^{+200}:\\ \;\;\;\;a2 \cdot \frac{a1}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{a2}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}} \cdot \frac{\frac{a1}{b1}}{\sqrt[3]{b2}}\\ \end{array} \]

Reproduce

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

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

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