Average Error: 11.2 → 2.2
Time: 4.9s
Precision: binary64
\[ \begin{array}{c}[a1, a2] = \mathsf{sort}([a1, a2])\\ [b1, b2] = \mathsf{sort}([b1, b2])\\ \end{array} \]
\[\frac{a1 \cdot a2}{b1 \cdot b2} \]
\[\begin{array}{l} t_0 := \frac{a1 \cdot a2}{b1 \cdot b2}\\ t_1 := \frac{a1}{b1} \cdot \frac{a2}{b2}\\ \mathbf{if}\;t_0 \leq -\infty:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_0 \leq -1.117539720539455 \cdot 10^{-304}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;t_0 \leq 0:\\ \;\;\;\;\frac{a1}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \frac{\frac{a2}{\sqrt[3]{b1}}}{b2}\\ \mathbf{elif}\;t_0 \leq 9.809131235010281 \cdot 10^{+288}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \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))) (t_1 (* (/ a1 b1) (/ a2 b2))))
   (if (<= t_0 (- INFINITY))
     t_1
     (if (<= t_0 -1.117539720539455e-304)
       t_0
       (if (<= t_0 0.0)
         (* (/ a1 (* (cbrt b1) (cbrt b1))) (/ (/ a2 (cbrt b1)) b2))
         (if (<= t_0 9.809131235010281e+288) t_0 t_1))))))
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 t_1 = (a1 / b1) * (a2 / b2);
	double tmp;
	if (t_0 <= -((double) INFINITY)) {
		tmp = t_1;
	} else if (t_0 <= -1.117539720539455e-304) {
		tmp = t_0;
	} else if (t_0 <= 0.0) {
		tmp = (a1 / (cbrt(b1) * cbrt(b1))) * ((a2 / cbrt(b1)) / b2);
	} else if (t_0 <= 9.809131235010281e+288) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
public static double code(double a1, double a2, double b1, double b2) {
	return (a1 * a2) / (b1 * b2);
}
public static double code(double a1, double a2, double b1, double b2) {
	double t_0 = (a1 * a2) / (b1 * b2);
	double t_1 = (a1 / b1) * (a2 / b2);
	double tmp;
	if (t_0 <= -Double.POSITIVE_INFINITY) {
		tmp = t_1;
	} else if (t_0 <= -1.117539720539455e-304) {
		tmp = t_0;
	} else if (t_0 <= 0.0) {
		tmp = (a1 / (Math.cbrt(b1) * Math.cbrt(b1))) * ((a2 / Math.cbrt(b1)) / b2);
	} else if (t_0 <= 9.809131235010281e+288) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(a1, a2, b1, b2)
	return Float64(Float64(a1 * a2) / Float64(b1 * b2))
end
function code(a1, a2, b1, b2)
	t_0 = Float64(Float64(a1 * a2) / Float64(b1 * b2))
	t_1 = Float64(Float64(a1 / b1) * Float64(a2 / b2))
	tmp = 0.0
	if (t_0 <= Float64(-Inf))
		tmp = t_1;
	elseif (t_0 <= -1.117539720539455e-304)
		tmp = t_0;
	elseif (t_0 <= 0.0)
		tmp = Float64(Float64(a1 / Float64(cbrt(b1) * cbrt(b1))) * Float64(Float64(a2 / cbrt(b1)) / b2));
	elseif (t_0 <= 9.809131235010281e+288)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
code[a1_, a2_, b1_, b2_] := N[(N[(a1 * a2), $MachinePrecision] / N[(b1 * b2), $MachinePrecision]), $MachinePrecision]
code[a1_, a2_, b1_, b2_] := Block[{t$95$0 = N[(N[(a1 * a2), $MachinePrecision] / N[(b1 * b2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(a1 / b1), $MachinePrecision] * N[(a2 / b2), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], t$95$1, If[LessEqual[t$95$0, -1.117539720539455e-304], t$95$0, If[LessEqual[t$95$0, 0.0], N[(N[(a1 / N[(N[Power[b1, 1/3], $MachinePrecision] * N[Power[b1, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[(a2 / N[Power[b1, 1/3], $MachinePrecision]), $MachinePrecision] / b2), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 9.809131235010281e+288], t$95$0, t$95$1]]]]]]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
t_0 := \frac{a1 \cdot a2}{b1 \cdot b2}\\
t_1 := \frac{a1}{b1} \cdot \frac{a2}{b2}\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t_0 \leq -1.117539720539455 \cdot 10^{-304}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;t_0 \leq 9.809131235010281 \cdot 10^{+288}:\\
\;\;\;\;t_0\\

\mathbf{else}:\\
\;\;\;\;t_1\\


\end{array}

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.2
Target11.2
Herbie2.2
\[\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 9.80913123501028139e288 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2))

    1. Initial program 61.4

      \[\frac{a1 \cdot a2}{b1 \cdot b2} \]
    2. Applied times-frac_binary649.0

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

    if -inf.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -1.11753972053945503e-304 or 0.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 9.80913123501028139e288

    1. Initial program 0.8

      \[\frac{a1 \cdot a2}{b1 \cdot b2} \]
    2. Applied associate-/r*_binary648.4

      \[\leadsto \color{blue}{\frac{\frac{a1 \cdot a2}{b1}}{b2}} \]
    3. Applied *-un-lft-identity_binary648.4

      \[\leadsto \frac{\frac{a1 \cdot a2}{b1}}{\color{blue}{1 \cdot b2}} \]
    4. Applied div-inv_binary648.4

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

      \[\leadsto \color{blue}{\frac{a1 \cdot a2}{1} \cdot \frac{\frac{1}{b1}}{b2}} \]
    6. Applied associate-*l/_binary641.2

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

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

    if -1.11753972053945503e-304 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 0.0

    1. Initial program 13.4

      \[\frac{a1 \cdot a2}{b1 \cdot b2} \]
    2. Applied associate-/r*_binary646.1

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{a1}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}} \cdot \frac{a2}{\sqrt[3]{b1}}}}{1 \cdot b2} \]
    6. Applied times-frac_binary642.4

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

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

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

Reproduce

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

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

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