
(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:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(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}
(FPCore (a1 a2 b1 b2)
:precision binary64
(let* ((t_0 (/ (* a1 a2) (* b1 b2))))
(if (<= t_0 (- INFINITY))
(* (/ a1 b1) (/ a2 b2))
(if (<= t_0 -2e-281)
t_0
(if (<= t_0 0.0)
(/ (/ a2 b2) (/ b1 a1))
(if (<= t_0 5e+250) t_0 (/ (/ a1 b2) (/ b1 a2))))))))
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 / b1) * (a2 / b2);
} else if (t_0 <= -2e-281) {
tmp = t_0;
} else if (t_0 <= 0.0) {
tmp = (a2 / b2) / (b1 / a1);
} else if (t_0 <= 5e+250) {
tmp = t_0;
} else {
tmp = (a1 / b2) / (b1 / a2);
}
return tmp;
}
public static double code(double a1, double a2, double b1, double b2) {
double t_0 = (a1 * a2) / (b1 * b2);
double tmp;
if (t_0 <= -Double.POSITIVE_INFINITY) {
tmp = (a1 / b1) * (a2 / b2);
} else if (t_0 <= -2e-281) {
tmp = t_0;
} else if (t_0 <= 0.0) {
tmp = (a2 / b2) / (b1 / a1);
} else if (t_0 <= 5e+250) {
tmp = t_0;
} else {
tmp = (a1 / b2) / (b1 / a2);
}
return tmp;
}
def code(a1, a2, b1, b2): t_0 = (a1 * a2) / (b1 * b2) tmp = 0 if t_0 <= -math.inf: tmp = (a1 / b1) * (a2 / b2) elif t_0 <= -2e-281: tmp = t_0 elif t_0 <= 0.0: tmp = (a2 / b2) / (b1 / a1) elif t_0 <= 5e+250: tmp = t_0 else: tmp = (a1 / b2) / (b1 / a2) return tmp
function code(a1, a2, b1, b2) t_0 = Float64(Float64(a1 * a2) / Float64(b1 * b2)) tmp = 0.0 if (t_0 <= Float64(-Inf)) tmp = Float64(Float64(a1 / b1) * Float64(a2 / b2)); elseif (t_0 <= -2e-281) tmp = t_0; elseif (t_0 <= 0.0) tmp = Float64(Float64(a2 / b2) / Float64(b1 / a1)); elseif (t_0 <= 5e+250) tmp = t_0; else tmp = Float64(Float64(a1 / b2) / Float64(b1 / a2)); end return tmp end
function tmp_2 = code(a1, a2, b1, b2) t_0 = (a1 * a2) / (b1 * b2); tmp = 0.0; if (t_0 <= -Inf) tmp = (a1 / b1) * (a2 / b2); elseif (t_0 <= -2e-281) tmp = t_0; elseif (t_0 <= 0.0) tmp = (a2 / b2) / (b1 / a1); elseif (t_0 <= 5e+250) tmp = t_0; else tmp = (a1 / b2) / (b1 / a2); end tmp_2 = tmp; end
code[a1_, a2_, b1_, b2_] := Block[{t$95$0 = N[(N[(a1 * a2), $MachinePrecision] / N[(b1 * b2), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, (-Infinity)], N[(N[(a1 / b1), $MachinePrecision] * N[(a2 / b2), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -2e-281], t$95$0, If[LessEqual[t$95$0, 0.0], N[(N[(a2 / b2), $MachinePrecision] / N[(b1 / a1), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 5e+250], t$95$0, N[(N[(a1 / b2), $MachinePrecision] / N[(b1 / a2), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a1 \cdot a2}{b1 \cdot b2}\\
\mathbf{if}\;t_0 \leq -\infty:\\
\;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\
\mathbf{elif}\;t_0 \leq -2 \cdot 10^{-281}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;t_0 \leq 0:\\
\;\;\;\;\frac{\frac{a2}{b2}}{\frac{b1}{a1}}\\
\mathbf{elif}\;t_0 \leq 5 \cdot 10^{+250}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{a1}{b2}}{\frac{b1}{a2}}\\
\end{array}
\end{array}
if (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -inf.0Initial program 72.8%
times-frac93.3%
Simplified93.3%
if -inf.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -2e-281 or -0.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 5.0000000000000002e250Initial program 98.9%
if -2e-281 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -0.0Initial program 69.1%
times-frac96.3%
Simplified96.3%
*-commutative96.3%
clear-num96.3%
un-div-inv96.4%
Applied egg-rr96.4%
if 5.0000000000000002e250 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) Initial program 75.1%
times-frac96.8%
Simplified96.8%
frac-times75.1%
*-commutative75.1%
frac-times96.9%
clear-num96.8%
un-div-inv99.3%
Applied egg-rr99.3%
Final simplification97.3%
(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 -2e-281)
t_0
(if (<= t_0 0.0)
t_1
(if (<= t_0 5e+250) t_0 (* (/ a1 b2) (/ a2 b1))))))))
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 <= -2e-281) {
tmp = t_0;
} else if (t_0 <= 0.0) {
tmp = t_1;
} else if (t_0 <= 5e+250) {
tmp = t_0;
} else {
tmp = (a1 / b2) * (a2 / b1);
}
return tmp;
}
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 <= -2e-281) {
tmp = t_0;
} else if (t_0 <= 0.0) {
tmp = t_1;
} else if (t_0 <= 5e+250) {
tmp = t_0;
} else {
tmp = (a1 / b2) * (a2 / b1);
}
return tmp;
}
def code(a1, a2, b1, b2): t_0 = (a1 * a2) / (b1 * b2) t_1 = (a1 / b1) * (a2 / b2) tmp = 0 if t_0 <= -math.inf: tmp = t_1 elif t_0 <= -2e-281: tmp = t_0 elif t_0 <= 0.0: tmp = t_1 elif t_0 <= 5e+250: tmp = t_0 else: tmp = (a1 / b2) * (a2 / b1) return tmp
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 <= -2e-281) tmp = t_0; elseif (t_0 <= 0.0) tmp = t_1; elseif (t_0 <= 5e+250) tmp = t_0; else tmp = Float64(Float64(a1 / b2) * Float64(a2 / b1)); end return tmp end
function tmp_2 = code(a1, a2, b1, b2) t_0 = (a1 * a2) / (b1 * b2); t_1 = (a1 / b1) * (a2 / b2); tmp = 0.0; if (t_0 <= -Inf) tmp = t_1; elseif (t_0 <= -2e-281) tmp = t_0; elseif (t_0 <= 0.0) tmp = t_1; elseif (t_0 <= 5e+250) tmp = t_0; else tmp = (a1 / b2) * (a2 / b1); end tmp_2 = tmp; end
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, -2e-281], t$95$0, If[LessEqual[t$95$0, 0.0], t$95$1, If[LessEqual[t$95$0, 5e+250], t$95$0, N[(N[(a1 / b2), $MachinePrecision] * N[(a2 / b1), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\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 -2 \cdot 10^{-281}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;t_0 \leq 0:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_0 \leq 5 \cdot 10^{+250}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{a1}{b2} \cdot \frac{a2}{b1}\\
\end{array}
\end{array}
if (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -inf.0 or -2e-281 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -0.0Initial program 70.4%
times-frac95.3%
Simplified95.3%
if -inf.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -2e-281 or -0.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 5.0000000000000002e250Initial program 98.9%
if 5.0000000000000002e250 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) Initial program 75.1%
associate-/l*81.4%
*-commutative81.4%
associate-/l*93.9%
Simplified93.9%
associate-/r/96.9%
*-commutative96.9%
Applied egg-rr96.9%
Final simplification97.0%
(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 -2e-281)
t_0
(if (<= t_0 0.0)
t_1
(if (<= t_0 5e+250) t_0 (/ (/ a1 b2) (/ b1 a2))))))))
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 <= -2e-281) {
tmp = t_0;
} else if (t_0 <= 0.0) {
tmp = t_1;
} else if (t_0 <= 5e+250) {
tmp = t_0;
} else {
tmp = (a1 / b2) / (b1 / a2);
}
return tmp;
}
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 <= -2e-281) {
tmp = t_0;
} else if (t_0 <= 0.0) {
tmp = t_1;
} else if (t_0 <= 5e+250) {
tmp = t_0;
} else {
tmp = (a1 / b2) / (b1 / a2);
}
return tmp;
}
def code(a1, a2, b1, b2): t_0 = (a1 * a2) / (b1 * b2) t_1 = (a1 / b1) * (a2 / b2) tmp = 0 if t_0 <= -math.inf: tmp = t_1 elif t_0 <= -2e-281: tmp = t_0 elif t_0 <= 0.0: tmp = t_1 elif t_0 <= 5e+250: tmp = t_0 else: tmp = (a1 / b2) / (b1 / a2) return tmp
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 <= -2e-281) tmp = t_0; elseif (t_0 <= 0.0) tmp = t_1; elseif (t_0 <= 5e+250) tmp = t_0; else tmp = Float64(Float64(a1 / b2) / Float64(b1 / a2)); end return tmp end
function tmp_2 = code(a1, a2, b1, b2) t_0 = (a1 * a2) / (b1 * b2); t_1 = (a1 / b1) * (a2 / b2); tmp = 0.0; if (t_0 <= -Inf) tmp = t_1; elseif (t_0 <= -2e-281) tmp = t_0; elseif (t_0 <= 0.0) tmp = t_1; elseif (t_0 <= 5e+250) tmp = t_0; else tmp = (a1 / b2) / (b1 / a2); end tmp_2 = tmp; end
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, -2e-281], t$95$0, If[LessEqual[t$95$0, 0.0], t$95$1, If[LessEqual[t$95$0, 5e+250], t$95$0, N[(N[(a1 / b2), $MachinePrecision] / N[(b1 / a2), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\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 -2 \cdot 10^{-281}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;t_0 \leq 0:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_0 \leq 5 \cdot 10^{+250}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{a1}{b2}}{\frac{b1}{a2}}\\
\end{array}
\end{array}
if (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -inf.0 or -2e-281 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -0.0Initial program 70.4%
times-frac95.3%
Simplified95.3%
if -inf.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -2e-281 or -0.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 5.0000000000000002e250Initial program 98.9%
if 5.0000000000000002e250 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) Initial program 75.1%
times-frac96.8%
Simplified96.8%
frac-times75.1%
*-commutative75.1%
frac-times96.9%
clear-num96.8%
un-div-inv99.3%
Applied egg-rr99.3%
Final simplification97.3%
(FPCore (a1 a2 b1 b2)
:precision binary64
(let* ((t_0 (* (/ a1 b2) (/ a2 b1))))
(if (<= (* b1 b2) -2e+127)
t_0
(if (<= (* b1 b2) -2e-180)
(* a1 (/ a2 (* b1 b2)))
(if (<= (* b1 b2) 2e-284) t_0 (* a2 (/ a1 (* b1 b2))))))))
double code(double a1, double a2, double b1, double b2) {
double t_0 = (a1 / b2) * (a2 / b1);
double tmp;
if ((b1 * b2) <= -2e+127) {
tmp = t_0;
} else if ((b1 * b2) <= -2e-180) {
tmp = a1 * (a2 / (b1 * b2));
} else if ((b1 * b2) <= 2e-284) {
tmp = t_0;
} else {
tmp = a2 * (a1 / (b1 * b2));
}
return tmp;
}
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) * (a2 / b1)
if ((b1 * b2) <= (-2d+127)) then
tmp = t_0
else if ((b1 * b2) <= (-2d-180)) then
tmp = a1 * (a2 / (b1 * b2))
else if ((b1 * b2) <= 2d-284) then
tmp = t_0
else
tmp = a2 * (a1 / (b1 * b2))
end if
code = tmp
end function
public static double code(double a1, double a2, double b1, double b2) {
double t_0 = (a1 / b2) * (a2 / b1);
double tmp;
if ((b1 * b2) <= -2e+127) {
tmp = t_0;
} else if ((b1 * b2) <= -2e-180) {
tmp = a1 * (a2 / (b1 * b2));
} else if ((b1 * b2) <= 2e-284) {
tmp = t_0;
} else {
tmp = a2 * (a1 / (b1 * b2));
}
return tmp;
}
def code(a1, a2, b1, b2): t_0 = (a1 / b2) * (a2 / b1) tmp = 0 if (b1 * b2) <= -2e+127: tmp = t_0 elif (b1 * b2) <= -2e-180: tmp = a1 * (a2 / (b1 * b2)) elif (b1 * b2) <= 2e-284: tmp = t_0 else: tmp = a2 * (a1 / (b1 * b2)) return tmp
function code(a1, a2, b1, b2) t_0 = Float64(Float64(a1 / b2) * Float64(a2 / b1)) tmp = 0.0 if (Float64(b1 * b2) <= -2e+127) tmp = t_0; elseif (Float64(b1 * b2) <= -2e-180) tmp = Float64(a1 * Float64(a2 / Float64(b1 * b2))); elseif (Float64(b1 * b2) <= 2e-284) tmp = t_0; else tmp = Float64(a2 * Float64(a1 / Float64(b1 * b2))); end return tmp end
function tmp_2 = code(a1, a2, b1, b2) t_0 = (a1 / b2) * (a2 / b1); tmp = 0.0; if ((b1 * b2) <= -2e+127) tmp = t_0; elseif ((b1 * b2) <= -2e-180) tmp = a1 * (a2 / (b1 * b2)); elseif ((b1 * b2) <= 2e-284) tmp = t_0; else tmp = a2 * (a1 / (b1 * b2)); end tmp_2 = tmp; end
code[a1_, a2_, b1_, b2_] := Block[{t$95$0 = N[(N[(a1 / b2), $MachinePrecision] * N[(a2 / b1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(b1 * b2), $MachinePrecision], -2e+127], t$95$0, If[LessEqual[N[(b1 * b2), $MachinePrecision], -2e-180], N[(a1 * N[(a2 / N[(b1 * b2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(b1 * b2), $MachinePrecision], 2e-284], t$95$0, N[(a2 * N[(a1 / N[(b1 * b2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a1}{b2} \cdot \frac{a2}{b1}\\
\mathbf{if}\;b1 \cdot b2 \leq -2 \cdot 10^{+127}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;b1 \cdot b2 \leq -2 \cdot 10^{-180}:\\
\;\;\;\;a1 \cdot \frac{a2}{b1 \cdot b2}\\
\mathbf{elif}\;b1 \cdot b2 \leq 2 \cdot 10^{-284}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;a2 \cdot \frac{a1}{b1 \cdot b2}\\
\end{array}
\end{array}
if (*.f64 b1 b2) < -1.99999999999999991e127 or -2e-180 < (*.f64 b1 b2) < 2.00000000000000007e-284Initial program 75.7%
associate-/l*80.1%
*-commutative80.1%
associate-/l*87.5%
Simplified87.5%
associate-/r/95.2%
*-commutative95.2%
Applied egg-rr95.2%
if -1.99999999999999991e127 < (*.f64 b1 b2) < -2e-180Initial program 92.7%
associate-/l*97.8%
*-commutative97.8%
associate-/l*77.8%
Simplified77.8%
clear-num77.7%
associate-/r/77.8%
clear-num78.0%
associate-/l/97.8%
*-commutative97.8%
Applied egg-rr97.8%
if 2.00000000000000007e-284 < (*.f64 b1 b2) Initial program 85.2%
associate-/l*90.3%
*-commutative90.3%
associate-/l*84.4%
Simplified84.4%
associate-/l*90.3%
*-commutative90.3%
associate-/r/93.2%
Applied egg-rr93.2%
Final simplification94.9%
(FPCore (a1 a2 b1 b2) :precision binary64 (if (<= (* b1 b2) -2e+266) (* (/ a1 b1) (/ a2 b2)) (* a2 (/ a1 (* b1 b2)))))
double code(double a1, double a2, double b1, double b2) {
double tmp;
if ((b1 * b2) <= -2e+266) {
tmp = (a1 / b1) * (a2 / b2);
} else {
tmp = a2 * (a1 / (b1 * b2));
}
return tmp;
}
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) <= (-2d+266)) then
tmp = (a1 / b1) * (a2 / b2)
else
tmp = a2 * (a1 / (b1 * b2))
end if
code = tmp
end function
public static double code(double a1, double a2, double b1, double b2) {
double tmp;
if ((b1 * b2) <= -2e+266) {
tmp = (a1 / b1) * (a2 / b2);
} else {
tmp = a2 * (a1 / (b1 * b2));
}
return tmp;
}
def code(a1, a2, b1, b2): tmp = 0 if (b1 * b2) <= -2e+266: tmp = (a1 / b1) * (a2 / b2) else: tmp = a2 * (a1 / (b1 * b2)) return tmp
function code(a1, a2, b1, b2) tmp = 0.0 if (Float64(b1 * b2) <= -2e+266) tmp = Float64(Float64(a1 / b1) * Float64(a2 / b2)); else tmp = Float64(a2 * Float64(a1 / Float64(b1 * b2))); end return tmp end
function tmp_2 = code(a1, a2, b1, b2) tmp = 0.0; if ((b1 * b2) <= -2e+266) tmp = (a1 / b1) * (a2 / b2); else tmp = a2 * (a1 / (b1 * b2)); end tmp_2 = tmp; end
code[a1_, a2_, b1_, b2_] := If[LessEqual[N[(b1 * b2), $MachinePrecision], -2e+266], N[(N[(a1 / b1), $MachinePrecision] * N[(a2 / b2), $MachinePrecision]), $MachinePrecision], N[(a2 * N[(a1 / N[(b1 * b2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b1 \cdot b2 \leq -2 \cdot 10^{+266}:\\
\;\;\;\;\frac{a1}{b1} \cdot \frac{a2}{b2}\\
\mathbf{else}:\\
\;\;\;\;a2 \cdot \frac{a1}{b1 \cdot b2}\\
\end{array}
\end{array}
if (*.f64 b1 b2) < -2.0000000000000001e266Initial program 62.3%
times-frac93.2%
Simplified93.2%
if -2.0000000000000001e266 < (*.f64 b1 b2) Initial program 85.5%
associate-/l*90.0%
*-commutative90.0%
associate-/l*83.2%
Simplified83.2%
associate-/l*90.0%
*-commutative90.0%
associate-/r/92.3%
Applied egg-rr92.3%
Final simplification92.4%
(FPCore (a1 a2 b1 b2) :precision binary64 (if (<= (* b1 b2) -5e+154) (* (/ a1 b2) (/ a2 b1)) (* a2 (/ a1 (* b1 b2)))))
double code(double a1, double a2, double b1, double b2) {
double tmp;
if ((b1 * b2) <= -5e+154) {
tmp = (a1 / b2) * (a2 / b1);
} else {
tmp = a2 * (a1 / (b1 * b2));
}
return tmp;
}
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+154)) then
tmp = (a1 / b2) * (a2 / b1)
else
tmp = a2 * (a1 / (b1 * b2))
end if
code = tmp
end function
public static double code(double a1, double a2, double b1, double b2) {
double tmp;
if ((b1 * b2) <= -5e+154) {
tmp = (a1 / b2) * (a2 / b1);
} else {
tmp = a2 * (a1 / (b1 * b2));
}
return tmp;
}
def code(a1, a2, b1, b2): tmp = 0 if (b1 * b2) <= -5e+154: tmp = (a1 / b2) * (a2 / b1) else: tmp = a2 * (a1 / (b1 * b2)) return tmp
function code(a1, a2, b1, b2) tmp = 0.0 if (Float64(b1 * b2) <= -5e+154) tmp = Float64(Float64(a1 / b2) * Float64(a2 / b1)); else tmp = Float64(a2 * Float64(a1 / Float64(b1 * b2))); end return tmp end
function tmp_2 = code(a1, a2, b1, b2) tmp = 0.0; if ((b1 * b2) <= -5e+154) tmp = (a1 / b2) * (a2 / b1); else tmp = a2 * (a1 / (b1 * b2)); end tmp_2 = tmp; end
code[a1_, a2_, b1_, b2_] := If[LessEqual[N[(b1 * b2), $MachinePrecision], -5e+154], N[(N[(a1 / b2), $MachinePrecision] * N[(a2 / b1), $MachinePrecision]), $MachinePrecision], N[(a2 * N[(a1 / N[(b1 * b2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;b1 \cdot b2 \leq -5 \cdot 10^{+154}:\\
\;\;\;\;\frac{a1}{b2} \cdot \frac{a2}{b1}\\
\mathbf{else}:\\
\;\;\;\;a2 \cdot \frac{a1}{b1 \cdot b2}\\
\end{array}
\end{array}
if (*.f64 b1 b2) < -5.00000000000000004e154Initial program 73.4%
associate-/l*78.6%
*-commutative78.6%
associate-/l*90.9%
Simplified90.9%
associate-/r/95.8%
*-commutative95.8%
Applied egg-rr95.8%
if -5.00000000000000004e154 < (*.f64 b1 b2) Initial program 85.1%
associate-/l*89.8%
*-commutative89.8%
associate-/l*82.8%
Simplified82.8%
associate-/l*89.8%
*-commutative89.8%
associate-/r/92.5%
Applied egg-rr92.5%
Final simplification93.1%
(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}
Initial program 83.0%
times-frac85.7%
Simplified85.7%
Final simplification85.7%
(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}
herbie shell --seed 2023217
(FPCore (a1 a2 b1 b2)
:name "Quotient of products"
:precision binary64
:herbie-target
(* (/ a1 b1) (/ a2 b2))
(/ (* a1 a2) (* b1 b2)))