Average Error: 11.4 → 2.6
Time: 12.4s
Precision: binary64
\[[a1, a2]=\mathsf{sort}([a1, a2])\]
\[\frac{a1 \cdot a2}{b1 \cdot b2} \]
\[\begin{array}{l} t_0 := \frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{if}\;t_0 \leq -\infty:\\ \;\;\;\;a1 \cdot \frac{1}{\frac{b1}{\frac{a2}{b2}}}\\ \mathbf{elif}\;t_0 \leq -1.3142776653186078 \cdot 10^{-294}:\\ \;\;\;\;\left(a1 \cdot a2\right) \cdot \frac{1}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\begin{array}{l} t_1 := \sqrt[3]{a1} \cdot \sqrt[3]{a1}\\ \mathbf{if}\;t_0 \leq 0:\\ \;\;\;\;\left(a2 \cdot \frac{t_1}{b1}\right) \cdot \frac{\sqrt[3]{a1}}{b2}\\ \mathbf{elif}\;t_0 \leq 5.037792537121833 \cdot 10^{+183}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{t_1}{\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}\\ \end{array} \]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
t_0 := \frac{a1 \cdot a2}{b1 \cdot b2}\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;a1 \cdot \frac{1}{\frac{b1}{\frac{a2}{b2}}}\\

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

\mathbf{else}:\\
\;\;\;\;\begin{array}{l}
t_1 := \sqrt[3]{a1} \cdot \sqrt[3]{a1}\\
\mathbf{if}\;t_0 \leq 0:\\
\;\;\;\;\left(a2 \cdot \frac{t_1}{b1}\right) \cdot \frac{\sqrt[3]{a1}}{b2}\\

\mathbf{elif}\;t_0 \leq 5.037792537121833 \cdot 10^{+183}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;\frac{t_1}{\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}\\


\end{array}
(FPCore (a1 a2 b1 b2) :precision binary64 (/ (* a1 a2) (* b1 b2)))
(FPCore (a1 a2 b1 b2)
 :precision binary64
 (let* ((t_0 (/ (* a1 a2) (* b1 b2))))
   (if (<= t_0 (- INFINITY))
     (* a1 (/ 1.0 (/ b1 (/ a2 b2))))
     (if (<= t_0 -1.3142776653186078e-294)
       (* (* a1 a2) (/ 1.0 (* b1 b2)))
       (let* ((t_1 (* (cbrt a1) (cbrt a1))))
         (if (<= t_0 0.0)
           (* (* a2 (/ t_1 b1)) (/ (cbrt a1) b2))
           (if (<= t_0 5.037792537121833e+183)
             t_0
             (*
              (/
               t_1
               (/
                (* (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 t_0 = (a1 * a2) / (b1 * b2);
	double tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = a1 * (1.0 / (b1 / (a2 / b2)));
	} else if (t_0 <= -1.3142776653186078e-294) {
		tmp = (a1 * a2) * (1.0 / (b1 * b2));
	} else {
		double t_1 = cbrt(a1) * cbrt(a1);
		double tmp_1;
		if (t_0 <= 0.0) {
			tmp_1 = (a2 * (t_1 / b1)) * (cbrt(a1) / b2);
		} else if (t_0 <= 5.037792537121833e+183) {
			tmp_1 = t_0;
		} else {
			tmp_1 = (t_1 / ((cbrt(b1) * cbrt(b1)) / ((cbrt(a2) * cbrt(a2)) / (cbrt(b2) * cbrt(b2))))) * (cbrt(a1) / (cbrt(b1) / (cbrt(a2) / cbrt(b2))));
		}
		tmp = tmp_1;
	}
	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.6
Herbie2.6
\[\frac{a1}{b1} \cdot \frac{a2}{b2} \]

Derivation

  1. Split input into 5 regimes
  2. if (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -inf.0

    1. Initial program 64.0

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

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

      \[\leadsto \frac{a1}{\color{blue}{\frac{b1}{\frac{a2}{b2}}}} \]
    5. Using strategy rm
    6. Applied div-inv_binary6417.1

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

    if -inf.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -1.3142776653186078e-294

    1. Initial program 0.7

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

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

    if -1.3142776653186078e-294 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -0.0

    1. Initial program 13.4

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

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

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

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

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

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

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

    if -0.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 5.0377925371218328e183

    1. Initial program 0.6

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

    if 5.0377925371218328e183 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2))

    1. Initial program 40.2

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

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

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

      \[\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_binary6416.2

      \[\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_binary6416.2

      \[\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_binary6416.3

      \[\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_binary6413.9

      \[\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_binary6414.1

      \[\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_binary644.8

      \[\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 5 regimes into one program.
  4. Final simplification2.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -\infty:\\ \;\;\;\;a1 \cdot \frac{1}{\frac{b1}{\frac{a2}{b2}}}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -1.3142776653186078 \cdot 10^{-294}:\\ \;\;\;\;\left(a1 \cdot a2\right) \cdot \frac{1}{b1 \cdot b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 0:\\ \;\;\;\;\left(a2 \cdot \frac{\sqrt[3]{a1} \cdot \sqrt[3]{a1}}{b1}\right) \cdot \frac{\sqrt[3]{a1}}{b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 5.037792537121833 \cdot 10^{+183}:\\ \;\;\;\;\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 2021190 
(FPCore (a1 a2 b1 b2)
  :name "Quotient of products"
  :precision binary64

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

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