Average Error: 11.0 → 2.5
Time: 3.2s
Precision: binary64
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -\infty:\\ \;\;\;\;\frac{\frac{a2}{\frac{b1}{a1}}}{b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -8.266987820202985 \cdot 10^{-304}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 0:\\ \;\;\;\;\frac{\frac{a2}{\frac{b1}{a1}}}{b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 4.126127910155212 \cdot 10^{+297}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{\frac{\sqrt[3]{b1} \cdot \sqrt[3]{b1}}{\frac{\sqrt[3]{a2} \cdot \sqrt[3]{a2}}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}}}} \cdot \frac{\sqrt[3]{a1}}{\frac{\sqrt[3]{b1}}{\frac{\sqrt[3]{a2}}{\sqrt[3]{b2}}}}\\ \end{array}\]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
\mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -\infty:\\
\;\;\;\;\frac{\frac{a2}{\frac{b1}{a1}}}{b2}\\

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

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

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

\mathbf{else}:\\
\;\;\;\;\frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{\frac{\sqrt[3]{b1} \cdot \sqrt[3]{b1}}{\frac{\sqrt[3]{a2} \cdot \sqrt[3]{a2}}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}}}} \cdot \frac{\sqrt[3]{a1}}{\frac{\sqrt[3]{b1}}{\frac{\sqrt[3]{a2}}{\sqrt[3]{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)) (- INFINITY))
   (/ (/ a2 (/ b1 a1)) b2)
   (if (<= (/ (* a1 a2) (* b1 b2)) -8.266987820202985e-304)
     (/ (* a1 a2) (* b1 b2))
     (if (<= (/ (* a1 a2) (* b1 b2)) 0.0)
       (/ (/ a2 (/ b1 a1)) b2)
       (if (<= (/ (* a1 a2) (* b1 b2)) 4.126127910155212e+297)
         (/ (* a1 a2) (* b1 b2))
         (*
          (/
           (* (cbrt a1) (cbrt a1))
           (/
            (* (cbrt b1) (cbrt b1))
            (/ (* (cbrt a2) (cbrt a2)) (* (cbrt b2) (cbrt b2)))))
          (/ (cbrt a1) (/ (cbrt b1) (/ (cbrt a2) (cbrt 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)) <= -((double) INFINITY)) {
		tmp = (a2 / (b1 / a1)) / b2;
	} else if (((a1 * a2) / (b1 * b2)) <= -8.266987820202985e-304) {
		tmp = (a1 * a2) / (b1 * b2);
	} else if (((a1 * a2) / (b1 * b2)) <= 0.0) {
		tmp = (a2 / (b1 / a1)) / b2;
	} else if (((a1 * a2) / (b1 * b2)) <= 4.126127910155212e+297) {
		tmp = (a1 * a2) / (b1 * b2);
	} else {
		tmp = ((cbrt(a1) * cbrt(a1)) / ((cbrt(b1) * cbrt(b1)) / ((cbrt(a2) * cbrt(a2)) / (cbrt(b2) * cbrt(b2))))) * (cbrt(a1) / (cbrt(b1) / (cbrt(a2) / cbrt(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.0
Target11.5
Herbie2.5
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]

Derivation

  1. Split input into 3 regimes
  2. if (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -inf.0 or -8.266987820202985e-304 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 0.0

    1. Initial program 17.9

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

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

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

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

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

    if -inf.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -8.266987820202985e-304 or 0.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 4.1261279101552118e297

    1. Initial program 0.8

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

    if 4.1261279101552118e297 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2))

    1. Initial program 61.4

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

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

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

      \[\leadsto \frac{a1}{\frac{b1}{\frac{a2}{\color{blue}{\left(\sqrt[3]{b2} \cdot \sqrt[3]{b2}\right) \cdot \sqrt[3]{b2}}}}}\]
    7. Applied add-cube-cbrt_binary64_250013.5

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

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

      \[\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}}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}} \cdot \frac{\sqrt[3]{a2}}{\sqrt[3]{b2}}}}\]
    10. Applied times-frac_binary64_247112.4

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

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

      \[\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}}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}}}} \cdot \frac{\sqrt[3]{a1}}{\frac{\sqrt[3]{b1}}{\frac{\sqrt[3]{a2}}{\sqrt[3]{b2}}}}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification2.5

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -\infty:\\ \;\;\;\;\frac{\frac{a2}{\frac{b1}{a1}}}{b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -8.266987820202985 \cdot 10^{-304}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 0:\\ \;\;\;\;\frac{\frac{a2}{\frac{b1}{a1}}}{b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 4.126127910155212 \cdot 10^{+297}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{\frac{\sqrt[3]{b1} \cdot \sqrt[3]{b1}}{\frac{\sqrt[3]{a2} \cdot \sqrt[3]{a2}}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}}}} \cdot \frac{\sqrt[3]{a1}}{\frac{\sqrt[3]{b1}}{\frac{\sqrt[3]{a2}}{\sqrt[3]{b2}}}}\\ \end{array}\]

Reproduce

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

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

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