Average Error: 11.3 → 2.0
Time: 10.8s
Precision: binary64
\[\frac{a1 \cdot a2}{b1 \cdot b2}\]
\[\begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -3.417901669555667 \cdot 10^{+301}:\\ \;\;\;\;\frac{\frac{a1}{b2}}{\frac{b1}{a2}}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -2.542552855874417 \cdot 10^{-297}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 0:\\ \;\;\;\;\frac{1}{\frac{\sqrt[3]{b1} \cdot \sqrt[3]{b1}}{\frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}}} \cdot \frac{\sqrt[3]{b1}}{\frac{\sqrt[3]{a1}}{\frac{\sqrt[3]{b2}}{a2}}}}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 1.7044719015567174 \cdot 10^{+305}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{a1}{b2}}{\frac{b1}{a2}}\\ \end{array}\]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
\mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -3.417901669555667 \cdot 10^{+301}:\\
\;\;\;\;\frac{\frac{a1}{b2}}{\frac{b1}{a2}}\\

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

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

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

\mathbf{else}:\\
\;\;\;\;\frac{\frac{a1}{b2}}{\frac{b1}{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)) -3.417901669555667e+301)
   (/ (/ a1 b2) (/ b1 a2))
   (if (<= (/ (* a1 a2) (* b1 b2)) -2.542552855874417e-297)
     (/ (* a1 a2) (* b1 b2))
     (if (<= (/ (* a1 a2) (* b1 b2)) 0.0)
       (/
        1.0
        (*
         (/
          (* (cbrt b1) (cbrt b1))
          (/ (* (cbrt a1) (cbrt a1)) (* (cbrt b2) (cbrt b2))))
         (/ (cbrt b1) (/ (cbrt a1) (/ (cbrt b2) a2)))))
       (if (<= (/ (* a1 a2) (* b1 b2)) 1.7044719015567174e+305)
         (/ (* a1 a2) (* b1 b2))
         (/ (/ a1 b2) (/ b1 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)) <= -3.417901669555667e+301) {
		tmp = (a1 / b2) / (b1 / a2);
	} else if (((a1 * a2) / (b1 * b2)) <= -2.542552855874417e-297) {
		tmp = (a1 * a2) / (b1 * b2);
	} else if (((a1 * a2) / (b1 * b2)) <= 0.0) {
		tmp = 1.0 / (((cbrt(b1) * cbrt(b1)) / ((cbrt(a1) * cbrt(a1)) / (cbrt(b2) * cbrt(b2)))) * (cbrt(b1) / (cbrt(a1) / (cbrt(b2) / a2))));
	} else if (((a1 * a2) / (b1 * b2)) <= 1.7044719015567174e+305) {
		tmp = (a1 * a2) / (b1 * b2);
	} else {
		tmp = (a1 / b2) / (b1 / 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.3
Target11.5
Herbie2.0
\[\frac{a1}{b1} \cdot \frac{a2}{b2}\]

Derivation

  1. Split input into 3 regimes
  2. if (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -3.41790166955566683e301 or 1.7044719015567174e305 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2))

    1. Initial program 63.0

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

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

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

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

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

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

      \[\leadsto \frac{1}{\color{blue}{\frac{1}{\frac{a1}{b2}} \cdot \frac{b1}{a2}}}\]
    11. Applied associate-/r*_binary64_27507.2

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

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

    if -3.41790166955566683e301 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -2.5425528558744169e-297 or 0.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 1.7044719015567174e305

    1. Initial program 0.8

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

    if -2.5425528558744169e-297 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 0.0

    1. Initial program 13.3

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

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

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

      \[\leadsto \frac{1}{\frac{b1}{\color{blue}{\frac{a1}{\frac{b2}{a2}}}}}\]
    7. Using strategy rm
    8. Applied *-un-lft-identity_binary64_28064.5

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

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

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

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

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

      \[\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{\sqrt[3]{b2} \cdot \sqrt[3]{b2}}{1}} \cdot \frac{\sqrt[3]{a1}}{\frac{\sqrt[3]{b2}}{a2}}}}\]
    14. Applied times-frac_binary64_28122.7

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -3.417901669555667 \cdot 10^{+301}:\\ \;\;\;\;\frac{\frac{a1}{b2}}{\frac{b1}{a2}}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -2.542552855874417 \cdot 10^{-297}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 0:\\ \;\;\;\;\frac{1}{\frac{\sqrt[3]{b1} \cdot \sqrt[3]{b1}}{\frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{\sqrt[3]{b2} \cdot \sqrt[3]{b2}}} \cdot \frac{\sqrt[3]{b1}}{\frac{\sqrt[3]{a1}}{\frac{\sqrt[3]{b2}}{a2}}}}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 1.7044719015567174 \cdot 10^{+305}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{a1}{b2}}{\frac{b1}{a2}}\\ \end{array}\]

Reproduce

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

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

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