Average Error: 11.5 → 3.2
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 -9.417758774108464 \cdot 10^{+253}:\\ \;\;\;\;\frac{a2 \cdot \frac{a1}{b1}}{b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -1.2921792901332 \cdot 10^{-319}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 0:\\ \;\;\;\;\frac{a2}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}} \cdot \frac{\frac{a1}{b1}}{\sqrt[3]{b2}}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 4.5122744546889826 \cdot 10^{+247}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \end{array}\]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
\mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -9.417758774108464 \cdot 10^{+253}:\\
\;\;\;\;\frac{a2 \cdot \frac{a1}{b1}}{b2}\\

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

\mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 0:\\
\;\;\;\;\frac{a2}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}} \cdot \frac{\frac{a1}{b1}}{\sqrt[3]{b2}}\\

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

\mathbf{else}:\\
\;\;\;\;\frac{a1}{b1} \cdot \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) (* b1 b2)) -9.417758774108464e+253)
   (/ (* a2 (/ a1 b1)) b2)
   (if (<= (/ (* a1 a2) (* b1 b2)) -1.2921792901332e-319)
     (/ (* a1 a2) (* b1 b2))
     (if (<= (/ (* a1 a2) (* b1 b2)) 0.0)
       (* (/ a2 (* (cbrt b2) (cbrt b2))) (/ (/ a1 b1) (cbrt b2)))
       (if (<= (/ (* a1 a2) (* b1 b2)) 4.5122744546889826e+247)
         (/ (* 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) / (b1 * b2)) <= -9.417758774108464e+253) {
		tmp = (a2 * (a1 / b1)) / b2;
	} else if (((a1 * a2) / (b1 * b2)) <= -1.2921792901332e-319) {
		tmp = (a1 * a2) / (b1 * b2);
	} else if (((a1 * a2) / (b1 * b2)) <= 0.0) {
		tmp = (a2 / (cbrt(b2) * cbrt(b2))) * ((a1 / b1) / cbrt(b2));
	} else if (((a1 * a2) / (b1 * b2)) <= 4.5122744546889826e+247) {
		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.5
Target11.1
Herbie3.2
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]

Derivation

  1. Split input into 4 regimes
  2. if (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -9.4177587741084635e253

    1. Initial program 41.7

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

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

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

    if -9.4177587741084635e253 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -1.29218e-319 or 0.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 4.51227445468898261e247

    1. Initial program 0.9

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

    if -1.29218e-319 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 0.0

    1. Initial program 14.0

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

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

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

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

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

    if 4.51227445468898261e247 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2))

    1. Initial program 49.8

      \[\frac{a1 \cdot a2}{b1 \cdot b2}\]
    2. Using strategy rm
    3. Applied times-frac_binary64_178910.8

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -9.417758774108464 \cdot 10^{+253}:\\ \;\;\;\;\frac{a2 \cdot \frac{a1}{b1}}{b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -1.2921792901332 \cdot 10^{-319}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 0:\\ \;\;\;\;\frac{a2}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}} \cdot \frac{\frac{a1}{b1}}{\sqrt[3]{b2}}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 4.5122744546889826 \cdot 10^{+247}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \end{array}\]

Reproduce

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

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

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