Average Error: 11.4 → 4.7
Time: 4.9s
Precision: binary64
\[[b1, b2] = \mathsf{sort}([b1, b2]) \\]
\[\frac{a1 \cdot a2}{b1 \cdot b2} \]
\[\begin{array}{l} t_0 := \frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{if}\;t_0 \leq -2.428659076582579 \cdot 10^{-287}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;t_0 \leq 1.6417374084 \cdot 10^{-314}:\\ \;\;\;\;\frac{\frac{a2 \cdot \frac{a1}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}}}{\sqrt[3]{b1}}}{b2}\\ \mathbf{elif}\;t_0 \leq 9.12141700165575 \cdot 10^{+273}:\\ \;\;\;\;\frac{1}{\frac{b1 \cdot b2}{a1 \cdot a2}}\\ \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
 (let* ((t_0 (/ (* a1 a2) (* b1 b2))))
   (if (<= t_0 -2.428659076582579e-287)
     t_0
     (if (<= t_0 1.6417374084e-314)
       (/ (/ (* a2 (/ a1 (* (cbrt b1) (cbrt b1)))) (cbrt b1)) b2)
       (if (<= t_0 9.12141700165575e+273)
         (/ 1.0 (/ (* b1 b2) (* a1 a2)))
         (* (/ 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 t_0 = (a1 * a2) / (b1 * b2);
	double tmp;
	if (t_0 <= -2.428659076582579e-287) {
		tmp = t_0;
	} else if (t_0 <= 1.6417374084e-314) {
		tmp = ((a2 * (a1 / (cbrt(b1) * cbrt(b1)))) / cbrt(b1)) / b2;
	} else if (t_0 <= 9.12141700165575e+273) {
		tmp = 1.0 / ((b1 * b2) / (a1 * a2));
	} else {
		tmp = (a1 / b1) * (a2 / b2);
	}
	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 tmp;
	if (t_0 <= -2.428659076582579e-287) {
		tmp = t_0;
	} else if (t_0 <= 1.6417374084e-314) {
		tmp = ((a2 * (a1 / (Math.cbrt(b1) * Math.cbrt(b1)))) / Math.cbrt(b1)) / b2;
	} else if (t_0 <= 9.12141700165575e+273) {
		tmp = 1.0 / ((b1 * b2) / (a1 * a2));
	} else {
		tmp = (a1 / b1) * (a2 / b2);
	}
	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))
	tmp = 0.0
	if (t_0 <= -2.428659076582579e-287)
		tmp = t_0;
	elseif (t_0 <= 1.6417374084e-314)
		tmp = Float64(Float64(Float64(a2 * Float64(a1 / Float64(cbrt(b1) * cbrt(b1)))) / cbrt(b1)) / b2);
	elseif (t_0 <= 9.12141700165575e+273)
		tmp = Float64(1.0 / Float64(Float64(b1 * b2) / Float64(a1 * a2)));
	else
		tmp = Float64(Float64(a1 / b1) * Float64(a2 / b2));
	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]}, If[LessEqual[t$95$0, -2.428659076582579e-287], t$95$0, If[LessEqual[t$95$0, 1.6417374084e-314], N[(N[(N[(a2 * N[(a1 / N[(N[Power[b1, 1/3], $MachinePrecision] * N[Power[b1, 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[b1, 1/3], $MachinePrecision]), $MachinePrecision] / b2), $MachinePrecision], If[LessEqual[t$95$0, 9.12141700165575e+273], N[(1.0 / N[(N[(b1 * b2), $MachinePrecision] / N[(a1 * a2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a1 / b1), $MachinePrecision] * N[(a2 / b2), $MachinePrecision]), $MachinePrecision]]]]]
\frac{a1 \cdot a2}{b1 \cdot b2}
\begin{array}{l}
t_0 := \frac{a1 \cdot a2}{b1 \cdot b2}\\
\mathbf{if}\;t_0 \leq -2.428659076582579 \cdot 10^{-287}:\\
\;\;\;\;t_0\\

\mathbf{elif}\;t_0 \leq 1.6417374084 \cdot 10^{-314}:\\
\;\;\;\;\frac{\frac{a2 \cdot \frac{a1}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}}}{\sqrt[3]{b1}}}{b2}\\

\mathbf{elif}\;t_0 \leq 9.12141700165575 \cdot 10^{+273}:\\
\;\;\;\;\frac{1}{\frac{b1 \cdot b2}{a1 \cdot a2}}\\

\mathbf{else}:\\
\;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\


\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.4
Target11.0
Herbie4.7
\[\frac{a1}{b1} \cdot \frac{a2}{b2} \]

Derivation

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

    1. Initial program 7.8

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

    if -2.42865907658257895e-287 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 1.6417374084e-314

    1. Initial program 13.0

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

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

      \[\leadsto \frac{\frac{a1 \cdot a2}{\color{blue}{\left(\sqrt[3]{b1} \cdot \sqrt[3]{b1}\right) \cdot \sqrt[3]{b1}}}}{b2} \]
    4. Applied associate-/r*_binary646.6

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

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

    if 1.6417374084e-314 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 9.1214170016557509e273

    1. Initial program 0.9

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

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

    if 9.1214170016557509e273 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2))

    1. Initial program 55.4

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -2.428659076582579 \cdot 10^{-287}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 1.6417374084 \cdot 10^{-314}:\\ \;\;\;\;\frac{\frac{a2 \cdot \frac{a1}{\sqrt[3]{b1} \cdot \sqrt[3]{b1}}}{\sqrt[3]{b1}}}{b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 9.12141700165575 \cdot 10^{+273}:\\ \;\;\;\;\frac{1}{\frac{b1 \cdot b2}{a1 \cdot a2}}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\ \end{array} \]

Reproduce

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

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

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