Average Error: 11.3 → 3.1
Time: 2.9s
Precision: binary64
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -1.282096742419842 \cdot 10^{+229}:\\ \;\;\;\;\frac{a2}{\frac{b2}{\frac{a1}{b1}}}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -3.478366537771996 \cdot 10^{-297}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 0:\\ \;\;\;\;\frac{a2}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \frac{\frac{a1}{\sqrt[3]{b1}}}{b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 1.988148331797139 \cdot 10^{+259}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \end{array}\]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
\mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -1.282096742419842 \cdot 10^{+229}:\\
\;\;\;\;\frac{a2}{\frac{b2}{\frac{a1}{b1}}}\\

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

\mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 0:\\
\;\;\;\;\frac{a2}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \frac{\frac{a1}{\sqrt[3]{b1}}}{b2}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{a1}{b1} \cdot \frac{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)) -1.282096742419842e+229)
   (/ a2 (/ b2 (/ a1 b1)))
   (if (<= (/ (* a1 a2) (* b1 b2)) -3.478366537771996e-297)
     (/ (* a1 a2) (* b1 b2))
     (if (<= (/ (* a1 a2) (* b1 b2)) 0.0)
       (* (/ a2 (* (cbrt b1) (cbrt b1))) (/ (/ a1 (cbrt b1)) b2))
       (if (<= (/ (* a1 a2) (* b1 b2)) 1.988148331797139e+259)
         (/ (* a1 a2) (* b1 b2))
         (* (/ a1 b1) (/ 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)) <= -1.282096742419842e+229) {
		tmp = a2 / (b2 / (a1 / b1));
	} else if (((a1 * a2) / (b1 * b2)) <= -3.478366537771996e-297) {
		tmp = (a1 * a2) / (b1 * b2);
	} else if (((a1 * a2) / (b1 * b2)) <= 0.0) {
		tmp = (a2 / (cbrt(b1) * cbrt(b1))) * ((a1 / cbrt(b1)) / b2);
	} else if (((a1 * a2) / (b1 * b2)) <= 1.988148331797139e+259) {
		tmp = (a1 * a2) / (b1 * b2);
	} else {
		tmp = (a1 / b1) * (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

Original11.3
Target11.0
Herbie3.1
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]

Derivation

  1. Split input into 4 regimes
  2. if (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -1.2820967424198419e229

    1. Initial program 37.5

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

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

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

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

    if -1.2820967424198419e229 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -3.4783665377719959e-297 or 0.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 1.9881483317971391e259

    1. Initial program 0.9

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

    if -3.4783665377719959e-297 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 0.0

    1. Initial program 13.0

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

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

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

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

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

      \[\leadsto \color{blue}{a2} \cdot \frac{\frac{a1}{b1}}{b2}\]
    9. Using strategy rm
    10. Applied *-un-lft-identity_binary64_65574.0

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

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

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

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

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

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

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

    if 1.9881483317971391e259 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2))

    1. Initial program 53.7

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -1.282096742419842 \cdot 10^{+229}:\\ \;\;\;\;\frac{a2}{\frac{b2}{\frac{a1}{b1}}}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -3.478366537771996 \cdot 10^{-297}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 0:\\ \;\;\;\;\frac{a2}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \frac{\frac{a1}{\sqrt[3]{b1}}}{b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 1.988148331797139 \cdot 10^{+259}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \end{array}\]

Reproduce

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

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

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