Quotient of products

Percentage Accurate: 86.2% → 94.7%
Time: 3.3s
Alternatives: 7
Speedup: 1.0×

Specification

?
\[\begin{array}{l} \\ \frac{a1 \cdot a2}{b1 \cdot b2} \end{array} \]
(FPCore (a1 a2 b1 b2) :precision binary64 (/ (* a1 a2) (* b1 b2)))
double code(double a1, double a2, double b1, double b2) {
	return (a1 * a2) / (b1 * b2);
}
real(8) function code(a1, a2, b1, b2)
    real(8), intent (in) :: a1
    real(8), intent (in) :: a2
    real(8), intent (in) :: b1
    real(8), intent (in) :: b2
    code = (a1 * a2) / (b1 * b2)
end function
public static double code(double a1, double a2, double b1, double b2) {
	return (a1 * a2) / (b1 * b2);
}
def code(a1, a2, b1, b2):
	return (a1 * a2) / (b1 * b2)
function code(a1, a2, b1, b2)
	return Float64(Float64(a1 * a2) / Float64(b1 * b2))
end
function tmp = code(a1, a2, b1, b2)
	tmp = (a1 * a2) / (b1 * b2);
end
code[a1_, a2_, b1_, b2_] := N[(N[(a1 * a2), $MachinePrecision] / N[(b1 * b2), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{a1 \cdot a2}{b1 \cdot b2}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 7 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 86.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{a1 \cdot a2}{b1 \cdot b2} \end{array} \]
(FPCore (a1 a2 b1 b2) :precision binary64 (/ (* a1 a2) (* b1 b2)))
double code(double a1, double a2, double b1, double b2) {
	return (a1 * a2) / (b1 * b2);
}
real(8) function code(a1, a2, b1, b2)
    real(8), intent (in) :: a1
    real(8), intent (in) :: a2
    real(8), intent (in) :: b1
    real(8), intent (in) :: b2
    code = (a1 * a2) / (b1 * b2)
end function
public static double code(double a1, double a2, double b1, double b2) {
	return (a1 * a2) / (b1 * b2);
}
def code(a1, a2, b1, b2):
	return (a1 * a2) / (b1 * b2)
function code(a1, a2, b1, b2)
	return Float64(Float64(a1 * a2) / Float64(b1 * b2))
end
function tmp = code(a1, a2, b1, b2)
	tmp = (a1 * a2) / (b1 * b2);
end
code[a1_, a2_, b1_, b2_] := N[(N[(a1 * a2), $MachinePrecision] / N[(b1 * b2), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{a1 \cdot a2}{b1 \cdot b2}
\end{array}

Alternative 1: 94.7% accurate, 0.2× speedup?

\[\begin{array}{l} [a1, a2] = \mathsf{sort}([a1, a2])\\ [b1, b2] = \mathsf{sort}([b1, b2])\\ \\ \begin{array}{l} t_0 := \frac{a1 \cdot a2}{b1 \cdot b2}\\ t_1 := \frac{\frac{a2}{b2}}{\frac{b1}{a1}}\\ \mathbf{if}\;t_0 \leq -1 \cdot 10^{+276}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_0 \leq -5 \cdot 10^{-58}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;t_0 \leq 0:\\ \;\;\;\;\frac{a2}{b1} \cdot \frac{a1}{b2}\\ \mathbf{elif}\;t_0 \leq 4 \cdot 10^{+292}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
NOTE: a1 and a2 should be sorted in increasing order before calling this function.
NOTE: b1 and b2 should be sorted in increasing order before calling this function.
(FPCore (a1 a2 b1 b2)
 :precision binary64
 (let* ((t_0 (/ (* a1 a2) (* b1 b2))) (t_1 (/ (/ a2 b2) (/ b1 a1))))
   (if (<= t_0 -1e+276)
     t_1
     (if (<= t_0 -5e-58)
       t_0
       (if (<= t_0 0.0)
         (* (/ a2 b1) (/ a1 b2))
         (if (<= t_0 4e+292) t_0 t_1))))))
assert(a1 < a2);
assert(b1 < b2);
double code(double a1, double a2, double b1, double b2) {
	double t_0 = (a1 * a2) / (b1 * b2);
	double t_1 = (a2 / b2) / (b1 / a1);
	double tmp;
	if (t_0 <= -1e+276) {
		tmp = t_1;
	} else if (t_0 <= -5e-58) {
		tmp = t_0;
	} else if (t_0 <= 0.0) {
		tmp = (a2 / b1) * (a1 / b2);
	} else if (t_0 <= 4e+292) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
NOTE: a1 and a2 should be sorted in increasing order before calling this function.
NOTE: b1 and b2 should be sorted in increasing order before calling this function.
real(8) function code(a1, a2, b1, b2)
    real(8), intent (in) :: a1
    real(8), intent (in) :: a2
    real(8), intent (in) :: b1
    real(8), intent (in) :: b2
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (a1 * a2) / (b1 * b2)
    t_1 = (a2 / b2) / (b1 / a1)
    if (t_0 <= (-1d+276)) then
        tmp = t_1
    else if (t_0 <= (-5d-58)) then
        tmp = t_0
    else if (t_0 <= 0.0d0) then
        tmp = (a2 / b1) * (a1 / b2)
    else if (t_0 <= 4d+292) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
assert a1 < a2;
assert b1 < b2;
public static double code(double a1, double a2, double b1, double b2) {
	double t_0 = (a1 * a2) / (b1 * b2);
	double t_1 = (a2 / b2) / (b1 / a1);
	double tmp;
	if (t_0 <= -1e+276) {
		tmp = t_1;
	} else if (t_0 <= -5e-58) {
		tmp = t_0;
	} else if (t_0 <= 0.0) {
		tmp = (a2 / b1) * (a1 / b2);
	} else if (t_0 <= 4e+292) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
[a1, a2] = sort([a1, a2])
[b1, b2] = sort([b1, b2])
def code(a1, a2, b1, b2):
	t_0 = (a1 * a2) / (b1 * b2)
	t_1 = (a2 / b2) / (b1 / a1)
	tmp = 0
	if t_0 <= -1e+276:
		tmp = t_1
	elif t_0 <= -5e-58:
		tmp = t_0
	elif t_0 <= 0.0:
		tmp = (a2 / b1) * (a1 / b2)
	elif t_0 <= 4e+292:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
a1, a2 = sort([a1, a2])
b1, b2 = sort([b1, b2])
function code(a1, a2, b1, b2)
	t_0 = Float64(Float64(a1 * a2) / Float64(b1 * b2))
	t_1 = Float64(Float64(a2 / b2) / Float64(b1 / a1))
	tmp = 0.0
	if (t_0 <= -1e+276)
		tmp = t_1;
	elseif (t_0 <= -5e-58)
		tmp = t_0;
	elseif (t_0 <= 0.0)
		tmp = Float64(Float64(a2 / b1) * Float64(a1 / b2));
	elseif (t_0 <= 4e+292)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
a1, a2 = num2cell(sort([a1, a2])){:}
b1, b2 = num2cell(sort([b1, b2])){:}
function tmp_2 = code(a1, a2, b1, b2)
	t_0 = (a1 * a2) / (b1 * b2);
	t_1 = (a2 / b2) / (b1 / a1);
	tmp = 0.0;
	if (t_0 <= -1e+276)
		tmp = t_1;
	elseif (t_0 <= -5e-58)
		tmp = t_0;
	elseif (t_0 <= 0.0)
		tmp = (a2 / b1) * (a1 / b2);
	elseif (t_0 <= 4e+292)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
NOTE: a1 and a2 should be sorted in increasing order before calling this function.
NOTE: b1 and b2 should be sorted in increasing order before calling this function.
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[(a2 / b2), $MachinePrecision] / N[(b1 / a1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1e+276], t$95$1, If[LessEqual[t$95$0, -5e-58], t$95$0, If[LessEqual[t$95$0, 0.0], N[(N[(a2 / b1), $MachinePrecision] * N[(a1 / b2), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 4e+292], t$95$0, t$95$1]]]]]]
\begin{array}{l}
[a1, a2] = \mathsf{sort}([a1, a2])\\
[b1, b2] = \mathsf{sort}([b1, b2])\\
\\
\begin{array}{l}
t_0 := \frac{a1 \cdot a2}{b1 \cdot b2}\\
t_1 := \frac{\frac{a2}{b2}}{\frac{b1}{a1}}\\
\mathbf{if}\;t_0 \leq -1 \cdot 10^{+276}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t_0 \leq -5 \cdot 10^{-58}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;t_0 \leq 4 \cdot 10^{+292}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -1.0000000000000001e276 or 4.0000000000000001e292 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2))

    1. Initial program 57.4%

      \[\frac{a1 \cdot a2}{b1 \cdot b2} \]
    2. Step-by-step derivation
      1. times-frac93.7%

        \[\leadsto \color{blue}{\frac{a1}{b1} \cdot \frac{a2}{b2}} \]
    3. Simplified93.7%

      \[\leadsto \color{blue}{\frac{a1}{b1} \cdot \frac{a2}{b2}} \]
    4. Step-by-step derivation
      1. *-commutative93.7%

        \[\leadsto \color{blue}{\frac{a2}{b2} \cdot \frac{a1}{b1}} \]
      2. clear-num93.7%

        \[\leadsto \frac{a2}{b2} \cdot \color{blue}{\frac{1}{\frac{b1}{a1}}} \]
      3. un-div-inv94.2%

        \[\leadsto \color{blue}{\frac{\frac{a2}{b2}}{\frac{b1}{a1}}} \]
    5. Applied egg-rr94.2%

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

    if -1.0000000000000001e276 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -4.99999999999999977e-58 or 0.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 4.0000000000000001e292

    1. Initial program 98.7%

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

    if -4.99999999999999977e-58 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 0.0

    1. Initial program 86.2%

      \[\frac{a1 \cdot a2}{b1 \cdot b2} \]
    2. Step-by-step derivation
      1. associate-/l*92.5%

        \[\leadsto \color{blue}{\frac{a1}{\frac{b1 \cdot b2}{a2}}} \]
      2. *-commutative92.5%

        \[\leadsto \frac{a1}{\frac{\color{blue}{b2 \cdot b1}}{a2}} \]
      3. associate-/l*90.4%

        \[\leadsto \frac{a1}{\color{blue}{\frac{b2}{\frac{a2}{b1}}}} \]
    3. Simplified90.4%

      \[\leadsto \color{blue}{\frac{a1}{\frac{b2}{\frac{a2}{b1}}}} \]
    4. Step-by-step derivation
      1. associate-/r/91.0%

        \[\leadsto \color{blue}{\frac{a1}{b2} \cdot \frac{a2}{b1}} \]
      2. *-commutative91.0%

        \[\leadsto \color{blue}{\frac{a2}{b1} \cdot \frac{a1}{b2}} \]
    5. Applied egg-rr91.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -1 \cdot 10^{+276}:\\ \;\;\;\;\frac{\frac{a2}{b2}}{\frac{b1}{a1}}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -5 \cdot 10^{-58}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 0:\\ \;\;\;\;\frac{a2}{b1} \cdot \frac{a1}{b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 4 \cdot 10^{+292}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\frac{a2}{b2}}{\frac{b1}{a1}}\\ \end{array} \]

Alternative 2: 95.0% accurate, 0.2× speedup?

\[\begin{array}{l} [a1, a2] = \mathsf{sort}([a1, a2])\\ [b1, b2] = \mathsf{sort}([b1, b2])\\ \\ \begin{array}{l} t_0 := \frac{a1 \cdot a2}{b1 \cdot b2}\\ t_1 := \frac{a2}{b2} \cdot \frac{a1}{b1}\\ \mathbf{if}\;t_0 \leq -1 \cdot 10^{+276}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_0 \leq -2 \cdot 10^{-123}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;t_0 \leq 0:\\ \;\;\;\;\frac{a2}{b1} \cdot \frac{a1}{b2}\\ \mathbf{elif}\;t_0 \leq 5 \cdot 10^{+265}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \end{array} \]
NOTE: a1 and a2 should be sorted in increasing order before calling this function.
NOTE: b1 and b2 should be sorted in increasing order before calling this function.
(FPCore (a1 a2 b1 b2)
 :precision binary64
 (let* ((t_0 (/ (* a1 a2) (* b1 b2))) (t_1 (* (/ a2 b2) (/ a1 b1))))
   (if (<= t_0 -1e+276)
     t_1
     (if (<= t_0 -2e-123)
       t_0
       (if (<= t_0 0.0)
         (* (/ a2 b1) (/ a1 b2))
         (if (<= t_0 5e+265) t_0 t_1))))))
assert(a1 < a2);
assert(b1 < b2);
double code(double a1, double a2, double b1, double b2) {
	double t_0 = (a1 * a2) / (b1 * b2);
	double t_1 = (a2 / b2) * (a1 / b1);
	double tmp;
	if (t_0 <= -1e+276) {
		tmp = t_1;
	} else if (t_0 <= -2e-123) {
		tmp = t_0;
	} else if (t_0 <= 0.0) {
		tmp = (a2 / b1) * (a1 / b2);
	} else if (t_0 <= 5e+265) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
NOTE: a1 and a2 should be sorted in increasing order before calling this function.
NOTE: b1 and b2 should be sorted in increasing order before calling this function.
real(8) function code(a1, a2, b1, b2)
    real(8), intent (in) :: a1
    real(8), intent (in) :: a2
    real(8), intent (in) :: b1
    real(8), intent (in) :: b2
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = (a1 * a2) / (b1 * b2)
    t_1 = (a2 / b2) * (a1 / b1)
    if (t_0 <= (-1d+276)) then
        tmp = t_1
    else if (t_0 <= (-2d-123)) then
        tmp = t_0
    else if (t_0 <= 0.0d0) then
        tmp = (a2 / b1) * (a1 / b2)
    else if (t_0 <= 5d+265) then
        tmp = t_0
    else
        tmp = t_1
    end if
    code = tmp
end function
assert a1 < a2;
assert b1 < b2;
public static double code(double a1, double a2, double b1, double b2) {
	double t_0 = (a1 * a2) / (b1 * b2);
	double t_1 = (a2 / b2) * (a1 / b1);
	double tmp;
	if (t_0 <= -1e+276) {
		tmp = t_1;
	} else if (t_0 <= -2e-123) {
		tmp = t_0;
	} else if (t_0 <= 0.0) {
		tmp = (a2 / b1) * (a1 / b2);
	} else if (t_0 <= 5e+265) {
		tmp = t_0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
[a1, a2] = sort([a1, a2])
[b1, b2] = sort([b1, b2])
def code(a1, a2, b1, b2):
	t_0 = (a1 * a2) / (b1 * b2)
	t_1 = (a2 / b2) * (a1 / b1)
	tmp = 0
	if t_0 <= -1e+276:
		tmp = t_1
	elif t_0 <= -2e-123:
		tmp = t_0
	elif t_0 <= 0.0:
		tmp = (a2 / b1) * (a1 / b2)
	elif t_0 <= 5e+265:
		tmp = t_0
	else:
		tmp = t_1
	return tmp
a1, a2 = sort([a1, a2])
b1, b2 = sort([b1, b2])
function code(a1, a2, b1, b2)
	t_0 = Float64(Float64(a1 * a2) / Float64(b1 * b2))
	t_1 = Float64(Float64(a2 / b2) * Float64(a1 / b1))
	tmp = 0.0
	if (t_0 <= -1e+276)
		tmp = t_1;
	elseif (t_0 <= -2e-123)
		tmp = t_0;
	elseif (t_0 <= 0.0)
		tmp = Float64(Float64(a2 / b1) * Float64(a1 / b2));
	elseif (t_0 <= 5e+265)
		tmp = t_0;
	else
		tmp = t_1;
	end
	return tmp
end
a1, a2 = num2cell(sort([a1, a2])){:}
b1, b2 = num2cell(sort([b1, b2])){:}
function tmp_2 = code(a1, a2, b1, b2)
	t_0 = (a1 * a2) / (b1 * b2);
	t_1 = (a2 / b2) * (a1 / b1);
	tmp = 0.0;
	if (t_0 <= -1e+276)
		tmp = t_1;
	elseif (t_0 <= -2e-123)
		tmp = t_0;
	elseif (t_0 <= 0.0)
		tmp = (a2 / b1) * (a1 / b2);
	elseif (t_0 <= 5e+265)
		tmp = t_0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
NOTE: a1 and a2 should be sorted in increasing order before calling this function.
NOTE: b1 and b2 should be sorted in increasing order before calling this function.
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[(a2 / b2), $MachinePrecision] * N[(a1 / b1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1e+276], t$95$1, If[LessEqual[t$95$0, -2e-123], t$95$0, If[LessEqual[t$95$0, 0.0], N[(N[(a2 / b1), $MachinePrecision] * N[(a1 / b2), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e+265], t$95$0, t$95$1]]]]]]
\begin{array}{l}
[a1, a2] = \mathsf{sort}([a1, a2])\\
[b1, b2] = \mathsf{sort}([b1, b2])\\
\\
\begin{array}{l}
t_0 := \frac{a1 \cdot a2}{b1 \cdot b2}\\
t_1 := \frac{a2}{b2} \cdot \frac{a1}{b1}\\
\mathbf{if}\;t_0 \leq -1 \cdot 10^{+276}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t_0 \leq -2 \cdot 10^{-123}:\\
\;\;\;\;t_0\\

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

\mathbf{elif}\;t_0 \leq 5 \cdot 10^{+265}:\\
\;\;\;\;t_0\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -1.0000000000000001e276 or 5.0000000000000002e265 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2))

    1. Initial program 57.9%

      \[\frac{a1 \cdot a2}{b1 \cdot b2} \]
    2. Step-by-step derivation
      1. times-frac92.6%

        \[\leadsto \color{blue}{\frac{a1}{b1} \cdot \frac{a2}{b2}} \]
    3. Simplified92.6%

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

    if -1.0000000000000001e276 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -2.0000000000000001e-123 or 0.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 5.0000000000000002e265

    1. Initial program 98.7%

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

    if -2.0000000000000001e-123 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 0.0

    1. Initial program 84.9%

      \[\frac{a1 \cdot a2}{b1 \cdot b2} \]
    2. Step-by-step derivation
      1. associate-/l*91.9%

        \[\leadsto \color{blue}{\frac{a1}{\frac{b1 \cdot b2}{a2}}} \]
      2. *-commutative91.9%

        \[\leadsto \frac{a1}{\frac{\color{blue}{b2 \cdot b1}}{a2}} \]
      3. associate-/l*90.7%

        \[\leadsto \frac{a1}{\color{blue}{\frac{b2}{\frac{a2}{b1}}}} \]
    3. Simplified90.7%

      \[\leadsto \color{blue}{\frac{a1}{\frac{b2}{\frac{a2}{b1}}}} \]
    4. Step-by-step derivation
      1. associate-/r/91.3%

        \[\leadsto \color{blue}{\frac{a1}{b2} \cdot \frac{a2}{b1}} \]
      2. *-commutative91.3%

        \[\leadsto \color{blue}{\frac{a2}{b1} \cdot \frac{a1}{b2}} \]
    5. Applied egg-rr91.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -1 \cdot 10^{+276}:\\ \;\;\;\;\frac{a2}{b2} \cdot \frac{a1}{b1}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq -2 \cdot 10^{-123}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 0:\\ \;\;\;\;\frac{a2}{b1} \cdot \frac{a1}{b2}\\ \mathbf{elif}\;\frac{a1 \cdot a2}{b1 \cdot b2} \leq 5 \cdot 10^{+265}:\\ \;\;\;\;\frac{a1 \cdot a2}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{a2}{b2} \cdot \frac{a1}{b1}\\ \end{array} \]

Alternative 3: 93.3% accurate, 0.3× speedup?

\[\begin{array}{l} [a1, a2] = \mathsf{sort}([a1, a2])\\ [b1, b2] = \mathsf{sort}([b1, b2])\\ \\ \begin{array}{l} \mathbf{if}\;b1 \cdot b2 \leq -5 \cdot 10^{+207} \lor \neg \left(b1 \cdot b2 \leq -5 \cdot 10^{-172}\right) \land \left(b1 \cdot b2 \leq 5 \cdot 10^{-132} \lor \neg \left(b1 \cdot b2 \leq 2 \cdot 10^{+158}\right)\right):\\ \;\;\;\;\frac{a2}{b2} \cdot \frac{a1}{b1}\\ \mathbf{else}:\\ \;\;\;\;a2 \cdot \frac{a1}{b1 \cdot b2}\\ \end{array} \end{array} \]
NOTE: a1 and a2 should be sorted in increasing order before calling this function.
NOTE: b1 and b2 should be sorted in increasing order before calling this function.
(FPCore (a1 a2 b1 b2)
 :precision binary64
 (if (or (<= (* b1 b2) -5e+207)
         (and (not (<= (* b1 b2) -5e-172))
              (or (<= (* b1 b2) 5e-132) (not (<= (* b1 b2) 2e+158)))))
   (* (/ a2 b2) (/ a1 b1))
   (* a2 (/ a1 (* b1 b2)))))
assert(a1 < a2);
assert(b1 < b2);
double code(double a1, double a2, double b1, double b2) {
	double tmp;
	if (((b1 * b2) <= -5e+207) || (!((b1 * b2) <= -5e-172) && (((b1 * b2) <= 5e-132) || !((b1 * b2) <= 2e+158)))) {
		tmp = (a2 / b2) * (a1 / b1);
	} else {
		tmp = a2 * (a1 / (b1 * b2));
	}
	return tmp;
}
NOTE: a1 and a2 should be sorted in increasing order before calling this function.
NOTE: b1 and b2 should be sorted in increasing order before calling this function.
real(8) function code(a1, a2, b1, b2)
    real(8), intent (in) :: a1
    real(8), intent (in) :: a2
    real(8), intent (in) :: b1
    real(8), intent (in) :: b2
    real(8) :: tmp
    if (((b1 * b2) <= (-5d+207)) .or. (.not. ((b1 * b2) <= (-5d-172))) .and. ((b1 * b2) <= 5d-132) .or. (.not. ((b1 * b2) <= 2d+158))) then
        tmp = (a2 / b2) * (a1 / b1)
    else
        tmp = a2 * (a1 / (b1 * b2))
    end if
    code = tmp
end function
assert a1 < a2;
assert b1 < b2;
public static double code(double a1, double a2, double b1, double b2) {
	double tmp;
	if (((b1 * b2) <= -5e+207) || (!((b1 * b2) <= -5e-172) && (((b1 * b2) <= 5e-132) || !((b1 * b2) <= 2e+158)))) {
		tmp = (a2 / b2) * (a1 / b1);
	} else {
		tmp = a2 * (a1 / (b1 * b2));
	}
	return tmp;
}
[a1, a2] = sort([a1, a2])
[b1, b2] = sort([b1, b2])
def code(a1, a2, b1, b2):
	tmp = 0
	if ((b1 * b2) <= -5e+207) or (not ((b1 * b2) <= -5e-172) and (((b1 * b2) <= 5e-132) or not ((b1 * b2) <= 2e+158))):
		tmp = (a2 / b2) * (a1 / b1)
	else:
		tmp = a2 * (a1 / (b1 * b2))
	return tmp
a1, a2 = sort([a1, a2])
b1, b2 = sort([b1, b2])
function code(a1, a2, b1, b2)
	tmp = 0.0
	if ((Float64(b1 * b2) <= -5e+207) || (!(Float64(b1 * b2) <= -5e-172) && ((Float64(b1 * b2) <= 5e-132) || !(Float64(b1 * b2) <= 2e+158))))
		tmp = Float64(Float64(a2 / b2) * Float64(a1 / b1));
	else
		tmp = Float64(a2 * Float64(a1 / Float64(b1 * b2)));
	end
	return tmp
end
a1, a2 = num2cell(sort([a1, a2])){:}
b1, b2 = num2cell(sort([b1, b2])){:}
function tmp_2 = code(a1, a2, b1, b2)
	tmp = 0.0;
	if (((b1 * b2) <= -5e+207) || (~(((b1 * b2) <= -5e-172)) && (((b1 * b2) <= 5e-132) || ~(((b1 * b2) <= 2e+158)))))
		tmp = (a2 / b2) * (a1 / b1);
	else
		tmp = a2 * (a1 / (b1 * b2));
	end
	tmp_2 = tmp;
end
NOTE: a1 and a2 should be sorted in increasing order before calling this function.
NOTE: b1 and b2 should be sorted in increasing order before calling this function.
code[a1_, a2_, b1_, b2_] := If[Or[LessEqual[N[(b1 * b2), $MachinePrecision], -5e+207], And[N[Not[LessEqual[N[(b1 * b2), $MachinePrecision], -5e-172]], $MachinePrecision], Or[LessEqual[N[(b1 * b2), $MachinePrecision], 5e-132], N[Not[LessEqual[N[(b1 * b2), $MachinePrecision], 2e+158]], $MachinePrecision]]]], N[(N[(a2 / b2), $MachinePrecision] * N[(a1 / b1), $MachinePrecision]), $MachinePrecision], N[(a2 * N[(a1 / N[(b1 * b2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[a1, a2] = \mathsf{sort}([a1, a2])\\
[b1, b2] = \mathsf{sort}([b1, b2])\\
\\
\begin{array}{l}
\mathbf{if}\;b1 \cdot b2 \leq -5 \cdot 10^{+207} \lor \neg \left(b1 \cdot b2 \leq -5 \cdot 10^{-172}\right) \land \left(b1 \cdot b2 \leq 5 \cdot 10^{-132} \lor \neg \left(b1 \cdot b2 \leq 2 \cdot 10^{+158}\right)\right):\\
\;\;\;\;\frac{a2}{b2} \cdot \frac{a1}{b1}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 b1 b2) < -4.9999999999999999e207 or -4.9999999999999999e-172 < (*.f64 b1 b2) < 4.9999999999999999e-132 or 1.99999999999999991e158 < (*.f64 b1 b2)

    1. Initial program 73.5%

      \[\frac{a1 \cdot a2}{b1 \cdot b2} \]
    2. Step-by-step derivation
      1. times-frac92.0%

        \[\leadsto \color{blue}{\frac{a1}{b1} \cdot \frac{a2}{b2}} \]
    3. Simplified92.0%

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

    if -4.9999999999999999e207 < (*.f64 b1 b2) < -4.9999999999999999e-172 or 4.9999999999999999e-132 < (*.f64 b1 b2) < 1.99999999999999991e158

    1. Initial program 90.2%

      \[\frac{a1 \cdot a2}{b1 \cdot b2} \]
    2. Step-by-step derivation
      1. associate-/l*94.8%

        \[\leadsto \color{blue}{\frac{a1}{\frac{b1 \cdot b2}{a2}}} \]
      2. *-commutative94.8%

        \[\leadsto \frac{a1}{\frac{\color{blue}{b2 \cdot b1}}{a2}} \]
      3. associate-/l*82.6%

        \[\leadsto \frac{a1}{\color{blue}{\frac{b2}{\frac{a2}{b1}}}} \]
    3. Simplified82.6%

      \[\leadsto \color{blue}{\frac{a1}{\frac{b2}{\frac{a2}{b1}}}} \]
    4. Step-by-step derivation
      1. associate-/l*94.8%

        \[\leadsto \frac{a1}{\color{blue}{\frac{b2 \cdot b1}{a2}}} \]
      2. *-commutative94.8%

        \[\leadsto \frac{a1}{\frac{\color{blue}{b1 \cdot b2}}{a2}} \]
      3. associate-/r/94.2%

        \[\leadsto \color{blue}{\frac{a1}{b1 \cdot b2} \cdot a2} \]
    5. Applied egg-rr94.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b1 \cdot b2 \leq -5 \cdot 10^{+207} \lor \neg \left(b1 \cdot b2 \leq -5 \cdot 10^{-172}\right) \land \left(b1 \cdot b2 \leq 5 \cdot 10^{-132} \lor \neg \left(b1 \cdot b2 \leq 2 \cdot 10^{+158}\right)\right):\\ \;\;\;\;\frac{a2}{b2} \cdot \frac{a1}{b1}\\ \mathbf{else}:\\ \;\;\;\;a2 \cdot \frac{a1}{b1 \cdot b2}\\ \end{array} \]

Alternative 4: 92.9% accurate, 0.3× speedup?

\[\begin{array}{l} [a1, a2] = \mathsf{sort}([a1, a2])\\ [b1, b2] = \mathsf{sort}([b1, b2])\\ \\ \begin{array}{l} \mathbf{if}\;b1 \cdot b2 \leq -5 \cdot 10^{+139}:\\ \;\;\;\;\frac{a2}{b1} \cdot \frac{a1}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \leq -5 \cdot 10^{-172} \lor \neg \left(b1 \cdot b2 \leq 5 \cdot 10^{-132}\right) \land b1 \cdot b2 \leq 2 \cdot 10^{+158}:\\ \;\;\;\;a2 \cdot \frac{a1}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{a2}{b2} \cdot \frac{a1}{b1}\\ \end{array} \end{array} \]
NOTE: a1 and a2 should be sorted in increasing order before calling this function.
NOTE: b1 and b2 should be sorted in increasing order before calling this function.
(FPCore (a1 a2 b1 b2)
 :precision binary64
 (if (<= (* b1 b2) -5e+139)
   (* (/ a2 b1) (/ a1 b2))
   (if (or (<= (* b1 b2) -5e-172)
           (and (not (<= (* b1 b2) 5e-132)) (<= (* b1 b2) 2e+158)))
     (* a2 (/ a1 (* b1 b2)))
     (* (/ a2 b2) (/ a1 b1)))))
assert(a1 < a2);
assert(b1 < b2);
double code(double a1, double a2, double b1, double b2) {
	double tmp;
	if ((b1 * b2) <= -5e+139) {
		tmp = (a2 / b1) * (a1 / b2);
	} else if (((b1 * b2) <= -5e-172) || (!((b1 * b2) <= 5e-132) && ((b1 * b2) <= 2e+158))) {
		tmp = a2 * (a1 / (b1 * b2));
	} else {
		tmp = (a2 / b2) * (a1 / b1);
	}
	return tmp;
}
NOTE: a1 and a2 should be sorted in increasing order before calling this function.
NOTE: b1 and b2 should be sorted in increasing order before calling this function.
real(8) function code(a1, a2, b1, b2)
    real(8), intent (in) :: a1
    real(8), intent (in) :: a2
    real(8), intent (in) :: b1
    real(8), intent (in) :: b2
    real(8) :: tmp
    if ((b1 * b2) <= (-5d+139)) then
        tmp = (a2 / b1) * (a1 / b2)
    else if (((b1 * b2) <= (-5d-172)) .or. (.not. ((b1 * b2) <= 5d-132)) .and. ((b1 * b2) <= 2d+158)) then
        tmp = a2 * (a1 / (b1 * b2))
    else
        tmp = (a2 / b2) * (a1 / b1)
    end if
    code = tmp
end function
assert a1 < a2;
assert b1 < b2;
public static double code(double a1, double a2, double b1, double b2) {
	double tmp;
	if ((b1 * b2) <= -5e+139) {
		tmp = (a2 / b1) * (a1 / b2);
	} else if (((b1 * b2) <= -5e-172) || (!((b1 * b2) <= 5e-132) && ((b1 * b2) <= 2e+158))) {
		tmp = a2 * (a1 / (b1 * b2));
	} else {
		tmp = (a2 / b2) * (a1 / b1);
	}
	return tmp;
}
[a1, a2] = sort([a1, a2])
[b1, b2] = sort([b1, b2])
def code(a1, a2, b1, b2):
	tmp = 0
	if (b1 * b2) <= -5e+139:
		tmp = (a2 / b1) * (a1 / b2)
	elif ((b1 * b2) <= -5e-172) or (not ((b1 * b2) <= 5e-132) and ((b1 * b2) <= 2e+158)):
		tmp = a2 * (a1 / (b1 * b2))
	else:
		tmp = (a2 / b2) * (a1 / b1)
	return tmp
a1, a2 = sort([a1, a2])
b1, b2 = sort([b1, b2])
function code(a1, a2, b1, b2)
	tmp = 0.0
	if (Float64(b1 * b2) <= -5e+139)
		tmp = Float64(Float64(a2 / b1) * Float64(a1 / b2));
	elseif ((Float64(b1 * b2) <= -5e-172) || (!(Float64(b1 * b2) <= 5e-132) && (Float64(b1 * b2) <= 2e+158)))
		tmp = Float64(a2 * Float64(a1 / Float64(b1 * b2)));
	else
		tmp = Float64(Float64(a2 / b2) * Float64(a1 / b1));
	end
	return tmp
end
a1, a2 = num2cell(sort([a1, a2])){:}
b1, b2 = num2cell(sort([b1, b2])){:}
function tmp_2 = code(a1, a2, b1, b2)
	tmp = 0.0;
	if ((b1 * b2) <= -5e+139)
		tmp = (a2 / b1) * (a1 / b2);
	elseif (((b1 * b2) <= -5e-172) || (~(((b1 * b2) <= 5e-132)) && ((b1 * b2) <= 2e+158)))
		tmp = a2 * (a1 / (b1 * b2));
	else
		tmp = (a2 / b2) * (a1 / b1);
	end
	tmp_2 = tmp;
end
NOTE: a1 and a2 should be sorted in increasing order before calling this function.
NOTE: b1 and b2 should be sorted in increasing order before calling this function.
code[a1_, a2_, b1_, b2_] := If[LessEqual[N[(b1 * b2), $MachinePrecision], -5e+139], N[(N[(a2 / b1), $MachinePrecision] * N[(a1 / b2), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[N[(b1 * b2), $MachinePrecision], -5e-172], And[N[Not[LessEqual[N[(b1 * b2), $MachinePrecision], 5e-132]], $MachinePrecision], LessEqual[N[(b1 * b2), $MachinePrecision], 2e+158]]], N[(a2 * N[(a1 / N[(b1 * b2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(a2 / b2), $MachinePrecision] * N[(a1 / b1), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[a1, a2] = \mathsf{sort}([a1, a2])\\
[b1, b2] = \mathsf{sort}([b1, b2])\\
\\
\begin{array}{l}
\mathbf{if}\;b1 \cdot b2 \leq -5 \cdot 10^{+139}:\\
\;\;\;\;\frac{a2}{b1} \cdot \frac{a1}{b2}\\

\mathbf{elif}\;b1 \cdot b2 \leq -5 \cdot 10^{-172} \lor \neg \left(b1 \cdot b2 \leq 5 \cdot 10^{-132}\right) \land b1 \cdot b2 \leq 2 \cdot 10^{+158}:\\
\;\;\;\;a2 \cdot \frac{a1}{b1 \cdot b2}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 b1 b2) < -5.0000000000000003e139

    1. Initial program 75.8%

      \[\frac{a1 \cdot a2}{b1 \cdot b2} \]
    2. Step-by-step derivation
      1. associate-/l*71.9%

        \[\leadsto \color{blue}{\frac{a1}{\frac{b1 \cdot b2}{a2}}} \]
      2. *-commutative71.9%

        \[\leadsto \frac{a1}{\frac{\color{blue}{b2 \cdot b1}}{a2}} \]
      3. associate-/l*84.3%

        \[\leadsto \frac{a1}{\color{blue}{\frac{b2}{\frac{a2}{b1}}}} \]
    3. Simplified84.3%

      \[\leadsto \color{blue}{\frac{a1}{\frac{b2}{\frac{a2}{b1}}}} \]
    4. Step-by-step derivation
      1. associate-/r/87.2%

        \[\leadsto \color{blue}{\frac{a1}{b2} \cdot \frac{a2}{b1}} \]
      2. *-commutative87.2%

        \[\leadsto \color{blue}{\frac{a2}{b1} \cdot \frac{a1}{b2}} \]
    5. Applied egg-rr87.2%

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

    if -5.0000000000000003e139 < (*.f64 b1 b2) < -4.9999999999999999e-172 or 4.9999999999999999e-132 < (*.f64 b1 b2) < 1.99999999999999991e158

    1. Initial program 91.1%

      \[\frac{a1 \cdot a2}{b1 \cdot b2} \]
    2. Step-by-step derivation
      1. associate-/l*95.2%

        \[\leadsto \color{blue}{\frac{a1}{\frac{b1 \cdot b2}{a2}}} \]
      2. *-commutative95.2%

        \[\leadsto \frac{a1}{\frac{\color{blue}{b2 \cdot b1}}{a2}} \]
      3. associate-/l*82.9%

        \[\leadsto \frac{a1}{\color{blue}{\frac{b2}{\frac{a2}{b1}}}} \]
    3. Simplified82.9%

      \[\leadsto \color{blue}{\frac{a1}{\frac{b2}{\frac{a2}{b1}}}} \]
    4. Step-by-step derivation
      1. associate-/l*95.2%

        \[\leadsto \frac{a1}{\color{blue}{\frac{b2 \cdot b1}{a2}}} \]
      2. *-commutative95.2%

        \[\leadsto \frac{a1}{\frac{\color{blue}{b1 \cdot b2}}{a2}} \]
      3. associate-/r/96.2%

        \[\leadsto \color{blue}{\frac{a1}{b1 \cdot b2} \cdot a2} \]
    5. Applied egg-rr96.2%

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

    if -4.9999999999999999e-172 < (*.f64 b1 b2) < 4.9999999999999999e-132 or 1.99999999999999991e158 < (*.f64 b1 b2)

    1. Initial program 72.9%

      \[\frac{a1 \cdot a2}{b1 \cdot b2} \]
    2. Step-by-step derivation
      1. times-frac92.5%

        \[\leadsto \color{blue}{\frac{a1}{b1} \cdot \frac{a2}{b2}} \]
    3. Simplified92.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b1 \cdot b2 \leq -5 \cdot 10^{+139}:\\ \;\;\;\;\frac{a2}{b1} \cdot \frac{a1}{b2}\\ \mathbf{elif}\;b1 \cdot b2 \leq -5 \cdot 10^{-172} \lor \neg \left(b1 \cdot b2 \leq 5 \cdot 10^{-132}\right) \land b1 \cdot b2 \leq 2 \cdot 10^{+158}:\\ \;\;\;\;a2 \cdot \frac{a1}{b1 \cdot b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{a2}{b2} \cdot \frac{a1}{b1}\\ \end{array} \]

Alternative 5: 89.7% accurate, 0.4× speedup?

\[\begin{array}{l} [a1, a2] = \mathsf{sort}([a1, a2])\\ [b1, b2] = \mathsf{sort}([b1, b2])\\ \\ \begin{array}{l} t_0 := \frac{a1}{b2 \cdot \frac{b1}{a2}}\\ \mathbf{if}\;b1 \cdot b2 \leq -5 \cdot 10^{+207}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;b1 \cdot b2 \leq -5 \cdot 10^{-201}:\\ \;\;\;\;a2 \cdot \frac{a1}{b1 \cdot b2}\\ \mathbf{elif}\;b1 \cdot b2 \leq 10^{-249}:\\ \;\;\;\;\frac{a2}{b1} \cdot \frac{a1}{b2}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
NOTE: a1 and a2 should be sorted in increasing order before calling this function.
NOTE: b1 and b2 should be sorted in increasing order before calling this function.
(FPCore (a1 a2 b1 b2)
 :precision binary64
 (let* ((t_0 (/ a1 (* b2 (/ b1 a2)))))
   (if (<= (* b1 b2) -5e+207)
     t_0
     (if (<= (* b1 b2) -5e-201)
       (* a2 (/ a1 (* b1 b2)))
       (if (<= (* b1 b2) 1e-249) (* (/ a2 b1) (/ a1 b2)) t_0)))))
assert(a1 < a2);
assert(b1 < b2);
double code(double a1, double a2, double b1, double b2) {
	double t_0 = a1 / (b2 * (b1 / a2));
	double tmp;
	if ((b1 * b2) <= -5e+207) {
		tmp = t_0;
	} else if ((b1 * b2) <= -5e-201) {
		tmp = a2 * (a1 / (b1 * b2));
	} else if ((b1 * b2) <= 1e-249) {
		tmp = (a2 / b1) * (a1 / b2);
	} else {
		tmp = t_0;
	}
	return tmp;
}
NOTE: a1 and a2 should be sorted in increasing order before calling this function.
NOTE: b1 and b2 should be sorted in increasing order before calling this function.
real(8) function code(a1, a2, b1, b2)
    real(8), intent (in) :: a1
    real(8), intent (in) :: a2
    real(8), intent (in) :: b1
    real(8), intent (in) :: b2
    real(8) :: t_0
    real(8) :: tmp
    t_0 = a1 / (b2 * (b1 / a2))
    if ((b1 * b2) <= (-5d+207)) then
        tmp = t_0
    else if ((b1 * b2) <= (-5d-201)) then
        tmp = a2 * (a1 / (b1 * b2))
    else if ((b1 * b2) <= 1d-249) then
        tmp = (a2 / b1) * (a1 / b2)
    else
        tmp = t_0
    end if
    code = tmp
end function
assert a1 < a2;
assert b1 < b2;
public static double code(double a1, double a2, double b1, double b2) {
	double t_0 = a1 / (b2 * (b1 / a2));
	double tmp;
	if ((b1 * b2) <= -5e+207) {
		tmp = t_0;
	} else if ((b1 * b2) <= -5e-201) {
		tmp = a2 * (a1 / (b1 * b2));
	} else if ((b1 * b2) <= 1e-249) {
		tmp = (a2 / b1) * (a1 / b2);
	} else {
		tmp = t_0;
	}
	return tmp;
}
[a1, a2] = sort([a1, a2])
[b1, b2] = sort([b1, b2])
def code(a1, a2, b1, b2):
	t_0 = a1 / (b2 * (b1 / a2))
	tmp = 0
	if (b1 * b2) <= -5e+207:
		tmp = t_0
	elif (b1 * b2) <= -5e-201:
		tmp = a2 * (a1 / (b1 * b2))
	elif (b1 * b2) <= 1e-249:
		tmp = (a2 / b1) * (a1 / b2)
	else:
		tmp = t_0
	return tmp
a1, a2 = sort([a1, a2])
b1, b2 = sort([b1, b2])
function code(a1, a2, b1, b2)
	t_0 = Float64(a1 / Float64(b2 * Float64(b1 / a2)))
	tmp = 0.0
	if (Float64(b1 * b2) <= -5e+207)
		tmp = t_0;
	elseif (Float64(b1 * b2) <= -5e-201)
		tmp = Float64(a2 * Float64(a1 / Float64(b1 * b2)));
	elseif (Float64(b1 * b2) <= 1e-249)
		tmp = Float64(Float64(a2 / b1) * Float64(a1 / b2));
	else
		tmp = t_0;
	end
	return tmp
end
a1, a2 = num2cell(sort([a1, a2])){:}
b1, b2 = num2cell(sort([b1, b2])){:}
function tmp_2 = code(a1, a2, b1, b2)
	t_0 = a1 / (b2 * (b1 / a2));
	tmp = 0.0;
	if ((b1 * b2) <= -5e+207)
		tmp = t_0;
	elseif ((b1 * b2) <= -5e-201)
		tmp = a2 * (a1 / (b1 * b2));
	elseif ((b1 * b2) <= 1e-249)
		tmp = (a2 / b1) * (a1 / b2);
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
NOTE: a1 and a2 should be sorted in increasing order before calling this function.
NOTE: b1 and b2 should be sorted in increasing order before calling this function.
code[a1_, a2_, b1_, b2_] := Block[{t$95$0 = N[(a1 / N[(b2 * N[(b1 / a2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(b1 * b2), $MachinePrecision], -5e+207], t$95$0, If[LessEqual[N[(b1 * b2), $MachinePrecision], -5e-201], N[(a2 * N[(a1 / N[(b1 * b2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(b1 * b2), $MachinePrecision], 1e-249], N[(N[(a2 / b1), $MachinePrecision] * N[(a1 / b2), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
[a1, a2] = \mathsf{sort}([a1, a2])\\
[b1, b2] = \mathsf{sort}([b1, b2])\\
\\
\begin{array}{l}
t_0 := \frac{a1}{b2 \cdot \frac{b1}{a2}}\\
\mathbf{if}\;b1 \cdot b2 \leq -5 \cdot 10^{+207}:\\
\;\;\;\;t_0\\

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

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

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 b1 b2) < -4.9999999999999999e207 or 1.00000000000000005e-249 < (*.f64 b1 b2)

    1. Initial program 86.3%

      \[\frac{a1 \cdot a2}{b1 \cdot b2} \]
    2. Step-by-step derivation
      1. associate-/l*85.8%

        \[\leadsto \color{blue}{\frac{a1}{\frac{b1 \cdot b2}{a2}}} \]
      2. *-commutative85.8%

        \[\leadsto \frac{a1}{\frac{\color{blue}{b2 \cdot b1}}{a2}} \]
      3. associate-/l*86.1%

        \[\leadsto \frac{a1}{\color{blue}{\frac{b2}{\frac{a2}{b1}}}} \]
    3. Simplified86.1%

      \[\leadsto \color{blue}{\frac{a1}{\frac{b2}{\frac{a2}{b1}}}} \]
    4. Step-by-step derivation
      1. clear-num86.1%

        \[\leadsto \frac{a1}{\color{blue}{\frac{1}{\frac{\frac{a2}{b1}}{b2}}}} \]
      2. associate-/r/85.8%

        \[\leadsto \frac{a1}{\color{blue}{\frac{1}{\frac{a2}{b1}} \cdot b2}} \]
      3. clear-num85.8%

        \[\leadsto \frac{a1}{\color{blue}{\frac{b1}{a2}} \cdot b2} \]
    5. Applied egg-rr85.8%

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

    if -4.9999999999999999e207 < (*.f64 b1 b2) < -4.9999999999999999e-201

    1. Initial program 87.6%

      \[\frac{a1 \cdot a2}{b1 \cdot b2} \]
    2. Step-by-step derivation
      1. associate-/l*93.9%

        \[\leadsto \color{blue}{\frac{a1}{\frac{b1 \cdot b2}{a2}}} \]
      2. *-commutative93.9%

        \[\leadsto \frac{a1}{\frac{\color{blue}{b2 \cdot b1}}{a2}} \]
      3. associate-/l*83.5%

        \[\leadsto \frac{a1}{\color{blue}{\frac{b2}{\frac{a2}{b1}}}} \]
    3. Simplified83.5%

      \[\leadsto \color{blue}{\frac{a1}{\frac{b2}{\frac{a2}{b1}}}} \]
    4. Step-by-step derivation
      1. associate-/l*93.9%

        \[\leadsto \frac{a1}{\color{blue}{\frac{b2 \cdot b1}{a2}}} \]
      2. *-commutative93.9%

        \[\leadsto \frac{a1}{\frac{\color{blue}{b1 \cdot b2}}{a2}} \]
      3. associate-/r/90.6%

        \[\leadsto \color{blue}{\frac{a1}{b1 \cdot b2} \cdot a2} \]
    5. Applied egg-rr90.6%

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

    if -4.9999999999999999e-201 < (*.f64 b1 b2) < 1.00000000000000005e-249

    1. Initial program 59.7%

      \[\frac{a1 \cdot a2}{b1 \cdot b2} \]
    2. Step-by-step derivation
      1. associate-/l*64.7%

        \[\leadsto \color{blue}{\frac{a1}{\frac{b1 \cdot b2}{a2}}} \]
      2. *-commutative64.7%

        \[\leadsto \frac{a1}{\frac{\color{blue}{b2 \cdot b1}}{a2}} \]
      3. associate-/l*86.5%

        \[\leadsto \frac{a1}{\color{blue}{\frac{b2}{\frac{a2}{b1}}}} \]
    3. Simplified86.5%

      \[\leadsto \color{blue}{\frac{a1}{\frac{b2}{\frac{a2}{b1}}}} \]
    4. Step-by-step derivation
      1. associate-/r/95.7%

        \[\leadsto \color{blue}{\frac{a1}{b2} \cdot \frac{a2}{b1}} \]
      2. *-commutative95.7%

        \[\leadsto \color{blue}{\frac{a2}{b1} \cdot \frac{a1}{b2}} \]
    5. Applied egg-rr95.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b1 \cdot b2 \leq -5 \cdot 10^{+207}:\\ \;\;\;\;\frac{a1}{b2 \cdot \frac{b1}{a2}}\\ \mathbf{elif}\;b1 \cdot b2 \leq -5 \cdot 10^{-201}:\\ \;\;\;\;a2 \cdot \frac{a1}{b1 \cdot b2}\\ \mathbf{elif}\;b1 \cdot b2 \leq 10^{-249}:\\ \;\;\;\;\frac{a2}{b1} \cdot \frac{a1}{b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1}{b2 \cdot \frac{b1}{a2}}\\ \end{array} \]

Alternative 6: 89.8% accurate, 0.4× speedup?

\[\begin{array}{l} [a1, a2] = \mathsf{sort}([a1, a2])\\ [b1, b2] = \mathsf{sort}([b1, b2])\\ \\ \begin{array}{l} \mathbf{if}\;b1 \cdot b2 \leq -5 \cdot 10^{+207}:\\ \;\;\;\;\frac{a1}{b2 \cdot \frac{b1}{a2}}\\ \mathbf{elif}\;b1 \cdot b2 \leq -5 \cdot 10^{-201}:\\ \;\;\;\;a2 \cdot \frac{a1}{b1 \cdot b2}\\ \mathbf{elif}\;b1 \cdot b2 \leq 10^{-249}:\\ \;\;\;\;\frac{a2}{b1} \cdot \frac{a1}{b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1}{\frac{b2}{\frac{a2}{b1}}}\\ \end{array} \end{array} \]
NOTE: a1 and a2 should be sorted in increasing order before calling this function.
NOTE: b1 and b2 should be sorted in increasing order before calling this function.
(FPCore (a1 a2 b1 b2)
 :precision binary64
 (if (<= (* b1 b2) -5e+207)
   (/ a1 (* b2 (/ b1 a2)))
   (if (<= (* b1 b2) -5e-201)
     (* a2 (/ a1 (* b1 b2)))
     (if (<= (* b1 b2) 1e-249)
       (* (/ a2 b1) (/ a1 b2))
       (/ a1 (/ b2 (/ a2 b1)))))))
assert(a1 < a2);
assert(b1 < b2);
double code(double a1, double a2, double b1, double b2) {
	double tmp;
	if ((b1 * b2) <= -5e+207) {
		tmp = a1 / (b2 * (b1 / a2));
	} else if ((b1 * b2) <= -5e-201) {
		tmp = a2 * (a1 / (b1 * b2));
	} else if ((b1 * b2) <= 1e-249) {
		tmp = (a2 / b1) * (a1 / b2);
	} else {
		tmp = a1 / (b2 / (a2 / b1));
	}
	return tmp;
}
NOTE: a1 and a2 should be sorted in increasing order before calling this function.
NOTE: b1 and b2 should be sorted in increasing order before calling this function.
real(8) function code(a1, a2, b1, b2)
    real(8), intent (in) :: a1
    real(8), intent (in) :: a2
    real(8), intent (in) :: b1
    real(8), intent (in) :: b2
    real(8) :: tmp
    if ((b1 * b2) <= (-5d+207)) then
        tmp = a1 / (b2 * (b1 / a2))
    else if ((b1 * b2) <= (-5d-201)) then
        tmp = a2 * (a1 / (b1 * b2))
    else if ((b1 * b2) <= 1d-249) then
        tmp = (a2 / b1) * (a1 / b2)
    else
        tmp = a1 / (b2 / (a2 / b1))
    end if
    code = tmp
end function
assert a1 < a2;
assert b1 < b2;
public static double code(double a1, double a2, double b1, double b2) {
	double tmp;
	if ((b1 * b2) <= -5e+207) {
		tmp = a1 / (b2 * (b1 / a2));
	} else if ((b1 * b2) <= -5e-201) {
		tmp = a2 * (a1 / (b1 * b2));
	} else if ((b1 * b2) <= 1e-249) {
		tmp = (a2 / b1) * (a1 / b2);
	} else {
		tmp = a1 / (b2 / (a2 / b1));
	}
	return tmp;
}
[a1, a2] = sort([a1, a2])
[b1, b2] = sort([b1, b2])
def code(a1, a2, b1, b2):
	tmp = 0
	if (b1 * b2) <= -5e+207:
		tmp = a1 / (b2 * (b1 / a2))
	elif (b1 * b2) <= -5e-201:
		tmp = a2 * (a1 / (b1 * b2))
	elif (b1 * b2) <= 1e-249:
		tmp = (a2 / b1) * (a1 / b2)
	else:
		tmp = a1 / (b2 / (a2 / b1))
	return tmp
a1, a2 = sort([a1, a2])
b1, b2 = sort([b1, b2])
function code(a1, a2, b1, b2)
	tmp = 0.0
	if (Float64(b1 * b2) <= -5e+207)
		tmp = Float64(a1 / Float64(b2 * Float64(b1 / a2)));
	elseif (Float64(b1 * b2) <= -5e-201)
		tmp = Float64(a2 * Float64(a1 / Float64(b1 * b2)));
	elseif (Float64(b1 * b2) <= 1e-249)
		tmp = Float64(Float64(a2 / b1) * Float64(a1 / b2));
	else
		tmp = Float64(a1 / Float64(b2 / Float64(a2 / b1)));
	end
	return tmp
end
a1, a2 = num2cell(sort([a1, a2])){:}
b1, b2 = num2cell(sort([b1, b2])){:}
function tmp_2 = code(a1, a2, b1, b2)
	tmp = 0.0;
	if ((b1 * b2) <= -5e+207)
		tmp = a1 / (b2 * (b1 / a2));
	elseif ((b1 * b2) <= -5e-201)
		tmp = a2 * (a1 / (b1 * b2));
	elseif ((b1 * b2) <= 1e-249)
		tmp = (a2 / b1) * (a1 / b2);
	else
		tmp = a1 / (b2 / (a2 / b1));
	end
	tmp_2 = tmp;
end
NOTE: a1 and a2 should be sorted in increasing order before calling this function.
NOTE: b1 and b2 should be sorted in increasing order before calling this function.
code[a1_, a2_, b1_, b2_] := If[LessEqual[N[(b1 * b2), $MachinePrecision], -5e+207], N[(a1 / N[(b2 * N[(b1 / a2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(b1 * b2), $MachinePrecision], -5e-201], N[(a2 * N[(a1 / N[(b1 * b2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(b1 * b2), $MachinePrecision], 1e-249], N[(N[(a2 / b1), $MachinePrecision] * N[(a1 / b2), $MachinePrecision]), $MachinePrecision], N[(a1 / N[(b2 / N[(a2 / b1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[a1, a2] = \mathsf{sort}([a1, a2])\\
[b1, b2] = \mathsf{sort}([b1, b2])\\
\\
\begin{array}{l}
\mathbf{if}\;b1 \cdot b2 \leq -5 \cdot 10^{+207}:\\
\;\;\;\;\frac{a1}{b2 \cdot \frac{b1}{a2}}\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (*.f64 b1 b2) < -4.9999999999999999e207

    1. Initial program 75.0%

      \[\frac{a1 \cdot a2}{b1 \cdot b2} \]
    2. Step-by-step derivation
      1. associate-/l*67.5%

        \[\leadsto \color{blue}{\frac{a1}{\frac{b1 \cdot b2}{a2}}} \]
      2. *-commutative67.5%

        \[\leadsto \frac{a1}{\frac{\color{blue}{b2 \cdot b1}}{a2}} \]
      3. associate-/l*85.7%

        \[\leadsto \frac{a1}{\color{blue}{\frac{b2}{\frac{a2}{b1}}}} \]
    3. Simplified85.7%

      \[\leadsto \color{blue}{\frac{a1}{\frac{b2}{\frac{a2}{b1}}}} \]
    4. Step-by-step derivation
      1. clear-num85.6%

        \[\leadsto \frac{a1}{\color{blue}{\frac{1}{\frac{\frac{a2}{b1}}{b2}}}} \]
      2. associate-/r/85.7%

        \[\leadsto \frac{a1}{\color{blue}{\frac{1}{\frac{a2}{b1}} \cdot b2}} \]
      3. clear-num85.6%

        \[\leadsto \frac{a1}{\color{blue}{\frac{b1}{a2}} \cdot b2} \]
    5. Applied egg-rr85.6%

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

    if -4.9999999999999999e207 < (*.f64 b1 b2) < -4.9999999999999999e-201

    1. Initial program 87.6%

      \[\frac{a1 \cdot a2}{b1 \cdot b2} \]
    2. Step-by-step derivation
      1. associate-/l*93.9%

        \[\leadsto \color{blue}{\frac{a1}{\frac{b1 \cdot b2}{a2}}} \]
      2. *-commutative93.9%

        \[\leadsto \frac{a1}{\frac{\color{blue}{b2 \cdot b1}}{a2}} \]
      3. associate-/l*83.5%

        \[\leadsto \frac{a1}{\color{blue}{\frac{b2}{\frac{a2}{b1}}}} \]
    3. Simplified83.5%

      \[\leadsto \color{blue}{\frac{a1}{\frac{b2}{\frac{a2}{b1}}}} \]
    4. Step-by-step derivation
      1. associate-/l*93.9%

        \[\leadsto \frac{a1}{\color{blue}{\frac{b2 \cdot b1}{a2}}} \]
      2. *-commutative93.9%

        \[\leadsto \frac{a1}{\frac{\color{blue}{b1 \cdot b2}}{a2}} \]
      3. associate-/r/90.6%

        \[\leadsto \color{blue}{\frac{a1}{b1 \cdot b2} \cdot a2} \]
    5. Applied egg-rr90.6%

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

    if -4.9999999999999999e-201 < (*.f64 b1 b2) < 1.00000000000000005e-249

    1. Initial program 59.7%

      \[\frac{a1 \cdot a2}{b1 \cdot b2} \]
    2. Step-by-step derivation
      1. associate-/l*64.7%

        \[\leadsto \color{blue}{\frac{a1}{\frac{b1 \cdot b2}{a2}}} \]
      2. *-commutative64.7%

        \[\leadsto \frac{a1}{\frac{\color{blue}{b2 \cdot b1}}{a2}} \]
      3. associate-/l*86.5%

        \[\leadsto \frac{a1}{\color{blue}{\frac{b2}{\frac{a2}{b1}}}} \]
    3. Simplified86.5%

      \[\leadsto \color{blue}{\frac{a1}{\frac{b2}{\frac{a2}{b1}}}} \]
    4. Step-by-step derivation
      1. associate-/r/95.7%

        \[\leadsto \color{blue}{\frac{a1}{b2} \cdot \frac{a2}{b1}} \]
      2. *-commutative95.7%

        \[\leadsto \color{blue}{\frac{a2}{b1} \cdot \frac{a1}{b2}} \]
    5. Applied egg-rr95.7%

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

    if 1.00000000000000005e-249 < (*.f64 b1 b2)

    1. Initial program 90.5%

      \[\frac{a1 \cdot a2}{b1 \cdot b2} \]
    2. Step-by-step derivation
      1. associate-/l*92.6%

        \[\leadsto \color{blue}{\frac{a1}{\frac{b1 \cdot b2}{a2}}} \]
      2. *-commutative92.6%

        \[\leadsto \frac{a1}{\frac{\color{blue}{b2 \cdot b1}}{a2}} \]
      3. associate-/l*86.3%

        \[\leadsto \frac{a1}{\color{blue}{\frac{b2}{\frac{a2}{b1}}}} \]
    3. Simplified86.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b1 \cdot b2 \leq -5 \cdot 10^{+207}:\\ \;\;\;\;\frac{a1}{b2 \cdot \frac{b1}{a2}}\\ \mathbf{elif}\;b1 \cdot b2 \leq -5 \cdot 10^{-201}:\\ \;\;\;\;a2 \cdot \frac{a1}{b1 \cdot b2}\\ \mathbf{elif}\;b1 \cdot b2 \leq 10^{-249}:\\ \;\;\;\;\frac{a2}{b1} \cdot \frac{a1}{b2}\\ \mathbf{else}:\\ \;\;\;\;\frac{a1}{\frac{b2}{\frac{a2}{b1}}}\\ \end{array} \]

Alternative 7: 86.6% accurate, 1.0× speedup?

\[\begin{array}{l} [a1, a2] = \mathsf{sort}([a1, a2])\\ [b1, b2] = \mathsf{sort}([b1, b2])\\ \\ \frac{a2}{b2} \cdot \frac{a1}{b1} \end{array} \]
NOTE: a1 and a2 should be sorted in increasing order before calling this function.
NOTE: b1 and b2 should be sorted in increasing order before calling this function.
(FPCore (a1 a2 b1 b2) :precision binary64 (* (/ a2 b2) (/ a1 b1)))
assert(a1 < a2);
assert(b1 < b2);
double code(double a1, double a2, double b1, double b2) {
	return (a2 / b2) * (a1 / b1);
}
NOTE: a1 and a2 should be sorted in increasing order before calling this function.
NOTE: b1 and b2 should be sorted in increasing order before calling this function.
real(8) function code(a1, a2, b1, b2)
    real(8), intent (in) :: a1
    real(8), intent (in) :: a2
    real(8), intent (in) :: b1
    real(8), intent (in) :: b2
    code = (a2 / b2) * (a1 / b1)
end function
assert a1 < a2;
assert b1 < b2;
public static double code(double a1, double a2, double b1, double b2) {
	return (a2 / b2) * (a1 / b1);
}
[a1, a2] = sort([a1, a2])
[b1, b2] = sort([b1, b2])
def code(a1, a2, b1, b2):
	return (a2 / b2) * (a1 / b1)
a1, a2 = sort([a1, a2])
b1, b2 = sort([b1, b2])
function code(a1, a2, b1, b2)
	return Float64(Float64(a2 / b2) * Float64(a1 / b1))
end
a1, a2 = num2cell(sort([a1, a2])){:}
b1, b2 = num2cell(sort([b1, b2])){:}
function tmp = code(a1, a2, b1, b2)
	tmp = (a2 / b2) * (a1 / b1);
end
NOTE: a1 and a2 should be sorted in increasing order before calling this function.
NOTE: b1 and b2 should be sorted in increasing order before calling this function.
code[a1_, a2_, b1_, b2_] := N[(N[(a2 / b2), $MachinePrecision] * N[(a1 / b1), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[a1, a2] = \mathsf{sort}([a1, a2])\\
[b1, b2] = \mathsf{sort}([b1, b2])\\
\\
\frac{a2}{b2} \cdot \frac{a1}{b1}
\end{array}
Derivation
  1. Initial program 81.8%

    \[\frac{a1 \cdot a2}{b1 \cdot b2} \]
  2. Step-by-step derivation
    1. times-frac87.6%

      \[\leadsto \color{blue}{\frac{a1}{b1} \cdot \frac{a2}{b2}} \]
  3. Simplified87.6%

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

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

Developer target: 86.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{a1}{b1} \cdot \frac{a2}{b2} \end{array} \]
(FPCore (a1 a2 b1 b2) :precision binary64 (* (/ a1 b1) (/ a2 b2)))
double code(double a1, double a2, double b1, double b2) {
	return (a1 / b1) * (a2 / b2);
}
real(8) function code(a1, a2, b1, b2)
    real(8), intent (in) :: a1
    real(8), intent (in) :: a2
    real(8), intent (in) :: b1
    real(8), intent (in) :: b2
    code = (a1 / b1) * (a2 / b2)
end function
public static double code(double a1, double a2, double b1, double b2) {
	return (a1 / b1) * (a2 / b2);
}
def code(a1, a2, b1, b2):
	return (a1 / b1) * (a2 / b2)
function code(a1, a2, b1, b2)
	return Float64(Float64(a1 / b1) * Float64(a2 / b2))
end
function tmp = code(a1, a2, b1, b2)
	tmp = (a1 / b1) * (a2 / b2);
end
code[a1_, a2_, b1_, b2_] := N[(N[(a1 / b1), $MachinePrecision] * N[(a2 / b2), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{a1}{b1} \cdot \frac{a2}{b2}
\end{array}

Reproduce

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

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

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