Average Error: 11.5 → 5.0
Time: 6.0s
Precision: binary64
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;b1 \cdot b2 \leq -1.0027776074466395 \cdot 10^{+199}:\\ \;\;\;\;\frac{a2 \cdot \frac{a1}{b1}}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \leq -4.3641756399046666 \cdot 10^{-273}:\\ \;\;\;\;\left(a2 \cdot a1\right) \cdot \frac{1}{b1 \cdot b2}\\ \mathbf{elif}\;b1 \cdot b2 \leq 2.773549446951285 \cdot 10^{-114}:\\ \;\;\;\;\frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \frac{\sqrt[3]{a1}}{\frac{\sqrt[3]{b1}}{\frac{a2}{b2}}}\\ \mathbf{elif}\;b1 \cdot b2 \leq 1.1283613478007406 \cdot 10^{+221}:\\ \;\;\;\;a2 \cdot \frac{a1}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{a2 \cdot \frac{a1}{b1}}{b2}\\ \end{array}\]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
\mathbf{if}\;b1 \cdot b2 \leq -1.0027776074466395 \cdot 10^{+199}:\\
\;\;\;\;\frac{a2 \cdot \frac{a1}{b1}}{b2}\\

\mathbf{elif}\;b1 \cdot b2 \leq -4.3641756399046666 \cdot 10^{-273}:\\
\;\;\;\;\left(a2 \cdot a1\right) \cdot \frac{1}{b1 \cdot b2}\\

\mathbf{elif}\;b1 \cdot b2 \leq 2.773549446951285 \cdot 10^{-114}:\\
\;\;\;\;\frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \frac{\sqrt[3]{a1}}{\frac{\sqrt[3]{b1}}{\frac{a2}{b2}}}\\

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

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

\end{array}
(FPCore (a1 a2 b1 b2) :precision binary64 (/ (* a1 a2) (* b1 b2)))
(FPCore (a1 a2 b1 b2)
 :precision binary64
 (if (<= (* b1 b2) -1.0027776074466395e+199)
   (/ (* a2 (/ a1 b1)) b2)
   (if (<= (* b1 b2) -4.3641756399046666e-273)
     (* (* a2 a1) (/ 1.0 (* b1 b2)))
     (if (<= (* b1 b2) 2.773549446951285e-114)
       (*
        (/ (* (cbrt a1) (cbrt a1)) (* (cbrt b1) (cbrt b1)))
        (/ (cbrt a1) (/ (cbrt b1) (/ a2 b2))))
       (if (<= (* b1 b2) 1.1283613478007406e+221)
         (* a2 (/ a1 (* b1 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) <= -1.0027776074466395e+199) {
		tmp = (a2 * (a1 / b1)) / b2;
	} else if ((b1 * b2) <= -4.3641756399046666e-273) {
		tmp = (a2 * a1) * (1.0 / (b1 * b2));
	} else if ((b1 * b2) <= 2.773549446951285e-114) {
		tmp = ((cbrt(a1) * cbrt(a1)) / (cbrt(b1) * cbrt(b1))) * (cbrt(a1) / (cbrt(b1) / (a2 / b2)));
	} else if ((b1 * b2) <= 1.1283613478007406e+221) {
		tmp = a2 * (a1 / (b1 * 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.5
Target10.7
Herbie5.0
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]

Derivation

  1. Split input into 4 regimes
  2. if (*.f64 b1 b2) < -1.0027776074466395e199 or 1.1283613478007406e221 < (*.f64 b1 b2)

    1. Initial program 16.3

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

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

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

    if -1.0027776074466395e199 < (*.f64 b1 b2) < -4.3641756399046666e-273

    1. Initial program 4.9

      \[\frac{a1 \cdot a2}{b1 \cdot b2}\]
    2. Using strategy rm
    3. Applied div-inv_binary645.0

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

    if -4.3641756399046666e-273 < (*.f64 b1 b2) < 2.77354944695128514e-114

    1. Initial program 30.1

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

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

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

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

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

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

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

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

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

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

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

    if 2.77354944695128514e-114 < (*.f64 b1 b2) < 1.1283613478007406e221

    1. Initial program 3.4

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b1 \cdot b2 \leq -1.0027776074466395 \cdot 10^{+199}:\\ \;\;\;\;\frac{a2 \cdot \frac{a1}{b1}}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \leq -4.3641756399046666 \cdot 10^{-273}:\\ \;\;\;\;\left(a2 \cdot a1\right) \cdot \frac{1}{b1 \cdot b2}\\ \mathbf{elif}\;b1 \cdot b2 \leq 2.773549446951285 \cdot 10^{-114}:\\ \;\;\;\;\frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \frac{\sqrt[3]{a1}}{\frac{\sqrt[3]{b1}}{\frac{a2}{b2}}}\\ \mathbf{elif}\;b1 \cdot b2 \leq 1.1283613478007406 \cdot 10^{+221}:\\ \;\;\;\;a2 \cdot \frac{a1}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{a2 \cdot \frac{a1}{b1}}{b2}\\ \end{array}\]

Reproduce

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

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

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