Average Error: 11.4 → 4.4
Time: 8.3s
Precision: binary64
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;a1 \cdot a2 \leq -4.803948692560538 \cdot 10^{+168}:\\ \;\;\;\;\frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{\frac{\sqrt[3]{b1} \cdot \sqrt[3]{b1}}{\frac{1}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}}}} \cdot \frac{\sqrt[3]{a1}}{\frac{\sqrt[3]{b1}}{\frac{a2}{\sqrt[3]{b2}}}}\\ \mathbf{elif}\;a1 \cdot a2 \leq -6.737766217048404 \cdot 10^{-162}:\\ \;\;\;\;\left(a1 \cdot a2\right) \cdot \frac{1}{b1 \cdot b2}\\ \mathbf{elif}\;a1 \cdot a2 \leq 6.83775354817476 \cdot 10^{-84}:\\ \;\;\;\;\frac{\sqrt[3]{a1}}{\frac{\sqrt[3]{b1}}{\frac{a2}{\sqrt[3]{b2}}}} \cdot \frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{\left(\sqrt[3]{b1} \cdot \sqrt[3]{b1}\right) \cdot \left(\sqrt[3]{b2} \cdot \sqrt[3]{b2}\right)}\\ \mathbf{elif}\;a1 \cdot a2 \leq 2.6529840764464326 \cdot 10^{+141}:\\ \;\;\;\;\frac{\frac{a1 \cdot a2}{b1}}{b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1}{\frac{b1}{\frac{a2}{b2}}}\\ \end{array}\]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
\mathbf{if}\;a1 \cdot a2 \leq -4.803948692560538 \cdot 10^{+168}:\\
\;\;\;\;\frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{\frac{\sqrt[3]{b1} \cdot \sqrt[3]{b1}}{\frac{1}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}}}} \cdot \frac{\sqrt[3]{a1}}{\frac{\sqrt[3]{b1}}{\frac{a2}{\sqrt[3]{b2}}}}\\

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

\mathbf{elif}\;a1 \cdot a2 \leq 6.83775354817476 \cdot 10^{-84}:\\
\;\;\;\;\frac{\sqrt[3]{a1}}{\frac{\sqrt[3]{b1}}{\frac{a2}{\sqrt[3]{b2}}}} \cdot \frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{\left(\sqrt[3]{b1} \cdot \sqrt[3]{b1}\right) \cdot \left(\sqrt[3]{b2} \cdot \sqrt[3]{b2}\right)}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{a1}{\frac{b1}{\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) -4.803948692560538e+168)
   (*
    (/
     (* (cbrt a1) (cbrt a1))
     (/ (* (cbrt b1) (cbrt b1)) (/ 1.0 (* (cbrt b2) (cbrt b2)))))
    (/ (cbrt a1) (/ (cbrt b1) (/ a2 (cbrt b2)))))
   (if (<= (* a1 a2) -6.737766217048404e-162)
     (* (* a1 a2) (/ 1.0 (* b1 b2)))
     (if (<= (* a1 a2) 6.83775354817476e-84)
       (*
        (/ (cbrt a1) (/ (cbrt b1) (/ a2 (cbrt b2))))
        (/
         (* (cbrt a1) (cbrt a1))
         (* (* (cbrt b1) (cbrt b1)) (* (cbrt b2) (cbrt b2)))))
       (if (<= (* a1 a2) 2.6529840764464326e+141)
         (/ (/ (* 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) <= -4.803948692560538e+168) {
		tmp = ((cbrt(a1) * cbrt(a1)) / ((cbrt(b1) * cbrt(b1)) / (1.0 / (cbrt(b2) * cbrt(b2))))) * (cbrt(a1) / (cbrt(b1) / (a2 / cbrt(b2))));
	} else if ((a1 * a2) <= -6.737766217048404e-162) {
		tmp = (a1 * a2) * (1.0 / (b1 * b2));
	} else if ((a1 * a2) <= 6.83775354817476e-84) {
		tmp = (cbrt(a1) / (cbrt(b1) / (a2 / cbrt(b2)))) * ((cbrt(a1) * cbrt(a1)) / ((cbrt(b1) * cbrt(b1)) * (cbrt(b2) * cbrt(b2))));
	} else if ((a1 * a2) <= 2.6529840764464326e+141) {
		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.4
Target11.0
Herbie4.4
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]

Derivation

  1. Split input into 5 regimes
  2. if (*.f64 a1 a2) < -4.8039486925605376e168

    1. Initial program 30.5

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

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

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

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

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

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

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

      \[\leadsto \frac{a1}{\color{blue}{\frac{\sqrt[3]{b1} \cdot \sqrt[3]{b1}}{\frac{1}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}}} \cdot \frac{\sqrt[3]{b1}}{\frac{a2}{\sqrt[3]{b2}}}}}\]
    11. Applied add-cube-cbrt_binary64_35239.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}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}}} \cdot \frac{\sqrt[3]{b1}}{\frac{a2}{\sqrt[3]{b2}}}}\]
    12. Applied times-frac_binary64_34946.6

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

    if -4.8039486925605376e168 < (*.f64 a1 a2) < -6.7377662170484036e-162

    1. Initial program 4.0

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

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

    if -6.7377662170484036e-162 < (*.f64 a1 a2) < 6.8377535481747603e-84

    1. Initial program 12.3

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

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

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

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

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

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

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

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

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

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

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

    if 6.8377535481747603e-84 < (*.f64 a1 a2) < 2.6529840764464326e141

    1. Initial program 3.2

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

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

    if 2.6529840764464326e141 < (*.f64 a1 a2)

    1. Initial program 27.2

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a1 \cdot a2 \leq -4.803948692560538 \cdot 10^{+168}:\\ \;\;\;\;\frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{\frac{\sqrt[3]{b1} \cdot \sqrt[3]{b1}}{\frac{1}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}}}} \cdot \frac{\sqrt[3]{a1}}{\frac{\sqrt[3]{b1}}{\frac{a2}{\sqrt[3]{b2}}}}\\ \mathbf{elif}\;a1 \cdot a2 \leq -6.737766217048404 \cdot 10^{-162}:\\ \;\;\;\;\left(a1 \cdot a2\right) \cdot \frac{1}{b1 \cdot b2}\\ \mathbf{elif}\;a1 \cdot a2 \leq 6.83775354817476 \cdot 10^{-84}:\\ \;\;\;\;\frac{\sqrt[3]{a1}}{\frac{\sqrt[3]{b1}}{\frac{a2}{\sqrt[3]{b2}}}} \cdot \frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{\left(\sqrt[3]{b1} \cdot \sqrt[3]{b1}\right) \cdot \left(\sqrt[3]{b2} \cdot \sqrt[3]{b2}\right)}\\ \mathbf{elif}\;a1 \cdot a2 \leq 2.6529840764464326 \cdot 10^{+141}:\\ \;\;\;\;\frac{\frac{a1 \cdot a2}{b1}}{b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1}{\frac{b1}{\frac{a2}{b2}}}\\ \end{array}\]

Reproduce

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

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

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