Average Error: 11.5 → 5.0
Time: 3.7s
Precision: binary64
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -2.8142638068678418 \cdot 10^{-179}:\\ \;\;\;\;\frac{1}{\frac{\sqrt[3]{b1} \cdot \sqrt[3]{b1}}{\left(\sqrt[3]{a1} \cdot \sqrt[3]{a1}\right) \cdot \left(\sqrt[3]{a2} \cdot \sqrt[3]{a2}\right)} \cdot \frac{\sqrt[3]{b1}}{\frac{\sqrt[3]{a1}}{\frac{b2}{\sqrt[3]{a2}}}}}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 0:\\ \;\;\;\;\frac{\frac{a1}{b1}}{\frac{b2}{a2}}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 3.479436261727929 \cdot 10^{+303}:\\ \;\;\;\;\frac{1}{\frac{b1 \cdot b2}{a1 \cdot a2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{\sqrt[3]{b1} \cdot \sqrt[3]{b1}}{\left(\sqrt[3]{a1} \cdot \sqrt[3]{a1}\right) \cdot \left(\sqrt[3]{a2} \cdot \sqrt[3]{a2}\right)} \cdot \frac{\sqrt[3]{b1}}{\frac{\sqrt[3]{a1}}{\frac{b2}{\sqrt[3]{a2}}}}}\\ \end{array}\]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
\mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -2.8142638068678418 \cdot 10^{-179}:\\
\;\;\;\;\frac{1}{\frac{\sqrt[3]{b1} \cdot \sqrt[3]{b1}}{\left(\sqrt[3]{a1} \cdot \sqrt[3]{a1}\right) \cdot \left(\sqrt[3]{a2} \cdot \sqrt[3]{a2}\right)} \cdot \frac{\sqrt[3]{b1}}{\frac{\sqrt[3]{a1}}{\frac{b2}{\sqrt[3]{a2}}}}}\\

\mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 0:\\
\;\;\;\;\frac{\frac{a1}{b1}}{\frac{b2}{a2}}\\

\mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 3.479436261727929 \cdot 10^{+303}:\\
\;\;\;\;\frac{1}{\frac{b1 \cdot b2}{a1 \cdot a2}}\\

\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{\sqrt[3]{b1} \cdot \sqrt[3]{b1}}{\left(\sqrt[3]{a1} \cdot \sqrt[3]{a1}\right) \cdot \left(\sqrt[3]{a2} \cdot \sqrt[3]{a2}\right)} \cdot \frac{\sqrt[3]{b1}}{\frac{\sqrt[3]{a1}}{\frac{b2}{\sqrt[3]{a2}}}}}\\

\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)) -2.8142638068678418e-179)
   (/
    1.0
    (*
     (/
      (* (cbrt b1) (cbrt b1))
      (* (* (cbrt a1) (cbrt a1)) (* (cbrt a2) (cbrt a2))))
     (/ (cbrt b1) (/ (cbrt a1) (/ b2 (cbrt a2))))))
   (if (<= (/ (* a1 a2) (* b1 b2)) 0.0)
     (/ (/ a1 b1) (/ b2 a2))
     (if (<= (/ (* a1 a2) (* b1 b2)) 3.479436261727929e+303)
       (/ 1.0 (/ (* b1 b2) (* a1 a2)))
       (/
        1.0
        (*
         (/
          (* (cbrt b1) (cbrt b1))
          (* (* (cbrt a1) (cbrt a1)) (* (cbrt a2) (cbrt a2))))
         (/ (cbrt b1) (/ (cbrt a1) (/ b2 (cbrt a2))))))))))
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)) <= -2.8142638068678418e-179) {
		tmp = 1.0 / (((cbrt(b1) * cbrt(b1)) / ((cbrt(a1) * cbrt(a1)) * (cbrt(a2) * cbrt(a2)))) * (cbrt(b1) / (cbrt(a1) / (b2 / cbrt(a2)))));
	} else if (((a1 * a2) / (b1 * b2)) <= 0.0) {
		tmp = (a1 / b1) / (b2 / a2);
	} else if (((a1 * a2) / (b1 * b2)) <= 3.479436261727929e+303) {
		tmp = 1.0 / ((b1 * b2) / (a1 * a2));
	} else {
		tmp = 1.0 / (((cbrt(b1) * cbrt(b1)) / ((cbrt(a1) * cbrt(a1)) * (cbrt(a2) * cbrt(a2)))) * (cbrt(b1) / (cbrt(a1) / (b2 / cbrt(a2)))));
	}
	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
Target11.7
Herbie5.0
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]

Derivation

  1. Split input into 3 regimes
  2. if (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -2.8142638068678418e-179 or 3.47943626172792874e303 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2))

    1. Initial program 20.0

      \[\frac{a1 \cdot a2}{b1 \cdot b2}\]
    2. Using strategy rm
    3. Applied clear-num_binary6420.1

      \[\leadsto \color{blue}{\frac{1}{\frac{b1 \cdot b2}{a1 \cdot a2}}}\]
    4. Using strategy rm
    5. Applied associate-/l*_binary6418.2

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

      \[\leadsto \frac{1}{\frac{b1}{\color{blue}{\frac{a1}{\frac{b2}{a2}}}}}\]
    7. Using strategy rm
    8. Applied add-cube-cbrt_binary6415.0

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

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

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

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

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

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

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

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

    if -2.8142638068678418e-179 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -0.0

    1. Initial program 11.7

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

      \[\leadsto \color{blue}{\frac{1}{\frac{b1 \cdot b2}{a1 \cdot a2}}}\]
    4. Using strategy rm
    5. Applied times-frac_binary646.3

      \[\leadsto \frac{1}{\color{blue}{\frac{b1}{a1} \cdot \frac{b2}{a2}}}\]
    6. Applied associate-/r*_binary645.8

      \[\leadsto \color{blue}{\frac{\frac{1}{\frac{b1}{a1}}}{\frac{b2}{a2}}}\]
    7. Simplified5.5

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

    if -0.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 3.47943626172792874e303

    1. Initial program 0.9

      \[\frac{a1 \cdot a2}{b1 \cdot b2}\]
    2. Using strategy rm
    3. Applied clear-num_binary641.4

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -2.8142638068678418 \cdot 10^{-179}:\\ \;\;\;\;\frac{1}{\frac{\sqrt[3]{b1} \cdot \sqrt[3]{b1}}{\left(\sqrt[3]{a1} \cdot \sqrt[3]{a1}\right) \cdot \left(\sqrt[3]{a2} \cdot \sqrt[3]{a2}\right)} \cdot \frac{\sqrt[3]{b1}}{\frac{\sqrt[3]{a1}}{\frac{b2}{\sqrt[3]{a2}}}}}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 0:\\ \;\;\;\;\frac{\frac{a1}{b1}}{\frac{b2}{a2}}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 3.479436261727929 \cdot 10^{+303}:\\ \;\;\;\;\frac{1}{\frac{b1 \cdot b2}{a1 \cdot a2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{\frac{\sqrt[3]{b1} \cdot \sqrt[3]{b1}}{\left(\sqrt[3]{a1} \cdot \sqrt[3]{a1}\right) \cdot \left(\sqrt[3]{a2} \cdot \sqrt[3]{a2}\right)} \cdot \frac{\sqrt[3]{b1}}{\frac{\sqrt[3]{a1}}{\frac{b2}{\sqrt[3]{a2}}}}}\\ \end{array}\]

Reproduce

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

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

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