Average Error: 11.6 → 4.1
Time: 6.4s
Precision: binary64
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;b1 \cdot b2 \leq -7.598920629217912 \cdot 10^{+198}:\\ \;\;\;\;\frac{1}{\frac{b1}{a2}} \cdot \frac{a1}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \leq -9.536629910005653 \cdot 10^{-213}:\\ \;\;\;\;a1 \cdot \frac{a2}{b1 \cdot b2}\\ \mathbf{elif}\;b1 \cdot b2 \leq 5.193948502327851 \cdot 10^{-106} \lor \neg \left(b1 \cdot b2 \leq 8.619819618703962 \cdot 10^{+164}\right):\\ \;\;\;\;\frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{\frac{\sqrt[3]{b1} \cdot \sqrt[3]{b1}}{\sqrt[3]{a2} \cdot \sqrt[3]{a2}}} \cdot \frac{\sqrt[3]{a1}}{\frac{\sqrt[3]{b1}}{\frac{\sqrt[3]{a2}}{b2}}}\\ \mathbf{else}:\\ \;\;\;\;a2 \cdot \frac{a1}{b1 \cdot b2}\\ \end{array}\]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
\mathbf{if}\;b1 \cdot b2 \leq -7.598920629217912 \cdot 10^{+198}:\\
\;\;\;\;\frac{1}{\frac{b1}{a2}} \cdot \frac{a1}{b2}\\

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

\mathbf{elif}\;b1 \cdot b2 \leq 5.193948502327851 \cdot 10^{-106} \lor \neg \left(b1 \cdot b2 \leq 8.619819618703962 \cdot 10^{+164}\right):\\
\;\;\;\;\frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{\frac{\sqrt[3]{b1} \cdot \sqrt[3]{b1}}{\sqrt[3]{a2} \cdot \sqrt[3]{a2}}} \cdot \frac{\sqrt[3]{a1}}{\frac{\sqrt[3]{b1}}{\frac{\sqrt[3]{a2}}{b2}}}\\

\mathbf{else}:\\
\;\;\;\;a2 \cdot \frac{a1}{b1 \cdot b2}\\

\end{array}
(FPCore (a1 a2 b1 b2) :precision binary64 (/ (* a1 a2) (* b1 b2)))
(FPCore (a1 a2 b1 b2)
 :precision binary64
 (if (<= (* b1 b2) -7.598920629217912e+198)
   (* (/ 1.0 (/ b1 a2)) (/ a1 b2))
   (if (<= (* b1 b2) -9.536629910005653e-213)
     (* a1 (/ a2 (* b1 b2)))
     (if (or (<= (* b1 b2) 5.193948502327851e-106)
             (not (<= (* b1 b2) 8.619819618703962e+164)))
       (*
        (/
         (* (cbrt a1) (cbrt a1))
         (/ (* (cbrt b1) (cbrt b1)) (* (cbrt a2) (cbrt a2))))
        (/ (cbrt a1) (/ (cbrt b1) (/ (cbrt a2) b2))))
       (* a2 (/ a1 (* b1 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 ((b1 * b2) <= -7.598920629217912e+198) {
		tmp = (1.0 / (b1 / a2)) * (a1 / b2);
	} else if ((b1 * b2) <= -9.536629910005653e-213) {
		tmp = a1 * (a2 / (b1 * b2));
	} else if (((b1 * b2) <= 5.193948502327851e-106) || !((b1 * b2) <= 8.619819618703962e+164)) {
		tmp = ((cbrt(a1) * cbrt(a1)) / ((cbrt(b1) * cbrt(b1)) / (cbrt(a2) * cbrt(a2)))) * (cbrt(a1) / (cbrt(b1) / (cbrt(a2) / b2)));
	} else {
		tmp = a2 * (a1 / (b1 * 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.0
Herbie4.1
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]

Derivation

  1. Split input into 4 regimes
  2. if (*.f64 b1 b2) < -7.5989206292179123e198

    1. Initial program 15.8

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

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

      \[\leadsto \frac{a1}{\color{blue}{\frac{b1}{\frac{a2}{b2}}}}\]
    5. Using strategy rm
    6. Applied associate-/r/_binary64_37758.6

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

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

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

    if -7.5989206292179123e198 < (*.f64 b1 b2) < -9.53662991000565299e-213

    1. Initial program 5.1

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

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

      \[\leadsto \frac{a1}{\color{blue}{\frac{b1}{\frac{a2}{b2}}}}\]
    5. Using strategy rm
    6. Applied div-inv_binary64_382610.7

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

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

    if -9.53662991000565299e-213 < (*.f64 b1 b2) < 5.1939485023278511e-106 or 8.6198196187039622e164 < (*.f64 b1 b2)

    1. Initial program 19.8

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

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

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

      \[\leadsto \frac{a1}{\frac{b1}{\frac{a2}{\color{blue}{1 \cdot b2}}}}\]
    7. Applied add-cube-cbrt_binary64_386412.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_binary64_383512.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_binary64_386412.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}}{1} \cdot \frac{\sqrt[3]{a2}}{b2}}}\]
    10. Applied times-frac_binary64_383511.0

      \[\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 add-cube-cbrt_binary64_386411.1

      \[\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{\sqrt[3]{a2} \cdot \sqrt[3]{a2}}{1}} \cdot \frac{\sqrt[3]{b1}}{\frac{\sqrt[3]{a2}}{b2}}}\]
    12. Applied times-frac_binary64_38354.3

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

    if 5.1939485023278511e-106 < (*.f64 b1 b2) < 8.6198196187039622e164

    1. Initial program 3.8

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

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

      \[\leadsto \frac{a1}{\color{blue}{\frac{b1}{\frac{a2}{b2}}}}\]
    5. Using strategy rm
    6. Applied div-inv_binary64_382610.9

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{\frac{1}{a2}} \cdot \frac{a1}{\frac{b1}{\frac{1}{b2}}}}\]
    11. Simplified3.5

      \[\leadsto \color{blue}{a2} \cdot \frac{a1}{\frac{b1}{\frac{1}{b2}}}\]
    12. Simplified3.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b1 \cdot b2 \leq -7.598920629217912 \cdot 10^{+198}:\\ \;\;\;\;\frac{1}{\frac{b1}{a2}} \cdot \frac{a1}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \leq -9.536629910005653 \cdot 10^{-213}:\\ \;\;\;\;a1 \cdot \frac{a2}{b1 \cdot b2}\\ \mathbf{elif}\;b1 \cdot b2 \leq 5.193948502327851 \cdot 10^{-106} \lor \neg \left(b1 \cdot b2 \leq 8.619819618703962 \cdot 10^{+164}\right):\\ \;\;\;\;\frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{\frac{\sqrt[3]{b1} \cdot \sqrt[3]{b1}}{\sqrt[3]{a2} \cdot \sqrt[3]{a2}}} \cdot \frac{\sqrt[3]{a1}}{\frac{\sqrt[3]{b1}}{\frac{\sqrt[3]{a2}}{b2}}}\\ \mathbf{else}:\\ \;\;\;\;a2 \cdot \frac{a1}{b1 \cdot b2}\\ \end{array}\]

Reproduce

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

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

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