(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 -4e+273)
(/ a1 (* b1 (/ b2 a2)))
(if (<= t_0 -2e-290)
t_0
(if (<= t_0 0.0)
(* (/ a2 b2) (/ a1 b1))
(if (<= t_0 2e+299) t_0 (pow (* (/ b2 a2) (/ b1 a1)) -1.0)))))))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 <= -4e+273) {
tmp = a1 / (b1 * (b2 / a2));
} else if (t_0 <= -2e-290) {
tmp = t_0;
} else if (t_0 <= 0.0) {
tmp = (a2 / b2) * (a1 / b1);
} else if (t_0 <= 2e+299) {
tmp = t_0;
} else {
tmp = pow(((b2 / a2) * (b1 / a1)), -1.0);
}
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
code = (a1 * a2) / (b1 * b2)
end 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 * a2) / (b1 * b2)
if (t_0 <= (-4d+273)) then
tmp = a1 / (b1 * (b2 / a2))
else if (t_0 <= (-2d-290)) then
tmp = t_0
else if (t_0 <= 0.0d0) then
tmp = (a2 / b2) * (a1 / b1)
else if (t_0 <= 2d+299) then
tmp = t_0
else
tmp = ((b2 / a2) * (b1 / a1)) ** (-1.0d0)
end if
code = tmp
end function
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 <= -4e+273) {
tmp = a1 / (b1 * (b2 / a2));
} else if (t_0 <= -2e-290) {
tmp = t_0;
} else if (t_0 <= 0.0) {
tmp = (a2 / b2) * (a1 / b1);
} else if (t_0 <= 2e+299) {
tmp = t_0;
} else {
tmp = Math.pow(((b2 / a2) * (b1 / a1)), -1.0);
}
return tmp;
}
def code(a1, a2, b1, b2): return (a1 * a2) / (b1 * b2)
def code(a1, a2, b1, b2): t_0 = (a1 * a2) / (b1 * b2) tmp = 0 if t_0 <= -4e+273: tmp = a1 / (b1 * (b2 / a2)) elif t_0 <= -2e-290: tmp = t_0 elif t_0 <= 0.0: tmp = (a2 / b2) * (a1 / b1) elif t_0 <= 2e+299: tmp = t_0 else: tmp = math.pow(((b2 / a2) * (b1 / a1)), -1.0) 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 <= -4e+273) tmp = Float64(a1 / Float64(b1 * Float64(b2 / a2))); elseif (t_0 <= -2e-290) tmp = t_0; elseif (t_0 <= 0.0) tmp = Float64(Float64(a2 / b2) * Float64(a1 / b1)); elseif (t_0 <= 2e+299) tmp = t_0; else tmp = Float64(Float64(b2 / a2) * Float64(b1 / a1)) ^ -1.0; end return tmp end
function tmp = code(a1, a2, b1, b2) tmp = (a1 * a2) / (b1 * b2); end
function tmp_2 = code(a1, a2, b1, b2) t_0 = (a1 * a2) / (b1 * b2); tmp = 0.0; if (t_0 <= -4e+273) tmp = a1 / (b1 * (b2 / a2)); elseif (t_0 <= -2e-290) tmp = t_0; elseif (t_0 <= 0.0) tmp = (a2 / b2) * (a1 / b1); elseif (t_0 <= 2e+299) tmp = t_0; else tmp = ((b2 / a2) * (b1 / a1)) ^ -1.0; end tmp_2 = 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, -4e+273], N[(a1 / N[(b1 * N[(b2 / a2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, -2e-290], t$95$0, If[LessEqual[t$95$0, 0.0], N[(N[(a2 / b2), $MachinePrecision] * N[(a1 / b1), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2e+299], t$95$0, N[Power[N[(N[(b2 / a2), $MachinePrecision] * N[(b1 / a1), $MachinePrecision]), $MachinePrecision], -1.0], $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 -4 \cdot 10^{+273}:\\
\;\;\;\;\frac{a1}{b1 \cdot \frac{b2}{a2}}\\
\mathbf{elif}\;t_0 \leq -2 \cdot 10^{-290}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;t_0 \leq 0:\\
\;\;\;\;\frac{a2}{b2} \cdot \frac{a1}{b1}\\
\mathbf{elif}\;t_0 \leq 2 \cdot 10^{+299}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;{\left(\frac{b2}{a2} \cdot \frac{b1}{a1}\right)}^{-1}\\
\end{array}
Results
| Original | 11.4 |
|---|---|
| Target | 11.6 |
| Herbie | 2.7 |
if (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -3.99999999999999978e273Initial program 46.0
Applied egg-rr27.9
Applied egg-rr19.4
if -3.99999999999999978e273 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < -2.0000000000000001e-290 or 0.0 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 2.0000000000000001e299Initial program 0.8
if -2.0000000000000001e-290 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) < 0.0Initial program 14.2
Applied egg-rr3.0
if 2.0000000000000001e299 < (/.f64 (*.f64 a1 a2) (*.f64 b1 b2)) Initial program 61.2
Applied egg-rr6.3
Final simplification2.7
herbie shell --seed 2022210
(FPCore (a1 a2 b1 b2)
:name "Quotient of products"
:precision binary64
:herbie-target
(* (/ a1 b1) (/ a2 b2))
(/ (* a1 a2) (* b1 b2)))