
(FPCore (a b c d) :precision binary64 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = ((b * c) - (a * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((b * c) - (a * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c d) :precision binary64 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = ((b * c) - (a * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((b * c) - (a * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\end{array}
(FPCore (a b c d) :precision binary64 (fma (/ 1.0 (hypot c d)) (/ b (/ (hypot c d) c)) (/ (* (/ a (hypot c d)) (- d)) (hypot c d))))
double code(double a, double b, double c, double d) {
return fma((1.0 / hypot(c, d)), (b / (hypot(c, d) / c)), (((a / hypot(c, d)) * -d) / hypot(c, d)));
}
function code(a, b, c, d) return fma(Float64(1.0 / hypot(c, d)), Float64(b / Float64(hypot(c, d) / c)), Float64(Float64(Float64(a / hypot(c, d)) * Float64(-d)) / hypot(c, d))) end
code[a_, b_, c_, d_] := N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] + N[(N[(N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * (-d)), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}, \frac{\frac{a}{\mathsf{hypot}\left(c, d\right)} \cdot \left(-d\right)}{\mathsf{hypot}\left(c, d\right)}\right)
\end{array}
Initial program 69.1%
div-sub67.0%
sub-neg67.0%
*-un-lft-identity67.0%
add-sqr-sqrt67.0%
times-frac66.9%
fma-def66.9%
hypot-def66.9%
hypot-def72.9%
associate-/l*74.8%
add-sqr-sqrt74.8%
pow274.8%
hypot-def74.8%
Applied egg-rr74.8%
associate-/l*85.1%
distribute-neg-frac85.1%
Simplified85.1%
unpow285.1%
*-un-lft-identity85.1%
times-frac98.3%
Applied egg-rr98.3%
/-rgt-identity98.3%
neg-mul-198.3%
times-frac98.9%
Applied egg-rr98.9%
associate-*l/99.0%
mul-1-neg99.0%
associate-/r/98.3%
Simplified98.3%
Final simplification98.3%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ 1.0 (hypot c d))) (t_1 (- (* c b) (* d a))))
(if (<= (/ t_1 (+ (* c c) (* d d))) INFINITY)
(* t_0 (/ t_1 (hypot c d)))
(-
(* t_0 (/ c (/ (hypot c d) b)))
(* d (/ (/ a (hypot c d)) (hypot c d)))))))
double code(double a, double b, double c, double d) {
double t_0 = 1.0 / hypot(c, d);
double t_1 = (c * b) - (d * a);
double tmp;
if ((t_1 / ((c * c) + (d * d))) <= ((double) INFINITY)) {
tmp = t_0 * (t_1 / hypot(c, d));
} else {
tmp = (t_0 * (c / (hypot(c, d) / b))) - (d * ((a / hypot(c, d)) / hypot(c, d)));
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = 1.0 / Math.hypot(c, d);
double t_1 = (c * b) - (d * a);
double tmp;
if ((t_1 / ((c * c) + (d * d))) <= Double.POSITIVE_INFINITY) {
tmp = t_0 * (t_1 / Math.hypot(c, d));
} else {
tmp = (t_0 * (c / (Math.hypot(c, d) / b))) - (d * ((a / Math.hypot(c, d)) / Math.hypot(c, d)));
}
return tmp;
}
def code(a, b, c, d): t_0 = 1.0 / math.hypot(c, d) t_1 = (c * b) - (d * a) tmp = 0 if (t_1 / ((c * c) + (d * d))) <= math.inf: tmp = t_0 * (t_1 / math.hypot(c, d)) else: tmp = (t_0 * (c / (math.hypot(c, d) / b))) - (d * ((a / math.hypot(c, d)) / math.hypot(c, d))) return tmp
function code(a, b, c, d) t_0 = Float64(1.0 / hypot(c, d)) t_1 = Float64(Float64(c * b) - Float64(d * a)) tmp = 0.0 if (Float64(t_1 / Float64(Float64(c * c) + Float64(d * d))) <= Inf) tmp = Float64(t_0 * Float64(t_1 / hypot(c, d))); else tmp = Float64(Float64(t_0 * Float64(c / Float64(hypot(c, d) / b))) - Float64(d * Float64(Float64(a / hypot(c, d)) / hypot(c, d)))); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = 1.0 / hypot(c, d); t_1 = (c * b) - (d * a); tmp = 0.0; if ((t_1 / ((c * c) + (d * d))) <= Inf) tmp = t_0 * (t_1 / hypot(c, d)); else tmp = (t_0 * (c / (hypot(c, d) / b))) - (d * ((a / hypot(c, d)) / hypot(c, d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$1 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(t$95$0 * N[(t$95$1 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 * N[(c / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(d * N[(N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\mathsf{hypot}\left(c, d\right)}\\
t_1 := c \cdot b - d \cdot a\\
\mathbf{if}\;\frac{t_1}{c \cdot c + d \cdot d} \leq \infty:\\
\;\;\;\;t_0 \cdot \frac{t_1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{b}} - d \cdot \frac{\frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < +inf.0Initial program 84.2%
*-un-lft-identity84.2%
add-sqr-sqrt84.2%
times-frac84.2%
hypot-def84.2%
hypot-def95.9%
Applied egg-rr95.9%
if +inf.0 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 0.0%
div-sub0.0%
sub-neg0.0%
*-un-lft-identity0.0%
add-sqr-sqrt0.0%
times-frac0.0%
fma-def0.0%
hypot-def0.0%
hypot-def1.4%
associate-/l*3.1%
add-sqr-sqrt3.1%
pow23.1%
hypot-def3.1%
Applied egg-rr3.1%
fma-neg3.1%
*-commutative3.1%
associate-/l*55.7%
associate-/r/55.7%
*-commutative55.7%
Simplified55.7%
*-un-lft-identity55.7%
unpow255.7%
times-frac78.8%
Applied egg-rr78.8%
associate-*l/78.8%
*-lft-identity78.8%
Simplified78.8%
Final simplification92.9%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* c b) (* d a))))
(if (<= (/ t_0 (+ (* c c) (* d d))) INFINITY)
(* (/ 1.0 (hypot c d)) (/ t_0 (hypot c d)))
(- (/ b c) (/ a (* c (/ c d)))))))
double code(double a, double b, double c, double d) {
double t_0 = (c * b) - (d * a);
double tmp;
if ((t_0 / ((c * c) + (d * d))) <= ((double) INFINITY)) {
tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
} else {
tmp = (b / c) - (a / (c * (c / d)));
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = (c * b) - (d * a);
double tmp;
if ((t_0 / ((c * c) + (d * d))) <= Double.POSITIVE_INFINITY) {
tmp = (1.0 / Math.hypot(c, d)) * (t_0 / Math.hypot(c, d));
} else {
tmp = (b / c) - (a / (c * (c / d)));
}
return tmp;
}
def code(a, b, c, d): t_0 = (c * b) - (d * a) tmp = 0 if (t_0 / ((c * c) + (d * d))) <= math.inf: tmp = (1.0 / math.hypot(c, d)) * (t_0 / math.hypot(c, d)) else: tmp = (b / c) - (a / (c * (c / d))) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(c * b) - Float64(d * a)) tmp = 0.0 if (Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))) <= Inf) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(t_0 / hypot(c, d))); else tmp = Float64(Float64(b / c) - Float64(a / Float64(c * Float64(c / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (c * b) - (d * a); tmp = 0.0; if ((t_0 / ((c * c) + (d * d))) <= Inf) tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d)); else tmp = (b / c) - (a / (c * (c / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b / c), $MachinePrecision] - N[(a / N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot b - d \cdot a\\
\mathbf{if}\;\frac{t_0}{c \cdot c + d \cdot d} \leq \infty:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t_0}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c} - \frac{a}{c \cdot \frac{c}{d}}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < +inf.0Initial program 84.2%
*-un-lft-identity84.2%
add-sqr-sqrt84.2%
times-frac84.2%
hypot-def84.2%
hypot-def95.9%
Applied egg-rr95.9%
if +inf.0 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 0.0%
div-sub0.0%
sub-neg0.0%
*-un-lft-identity0.0%
add-sqr-sqrt0.0%
times-frac0.0%
fma-def0.0%
hypot-def0.0%
hypot-def1.4%
associate-/l*3.1%
add-sqr-sqrt3.1%
pow23.1%
hypot-def3.1%
Applied egg-rr3.1%
associate-/l*55.8%
distribute-neg-frac55.8%
Simplified55.8%
Taylor expanded in c around inf 44.6%
+-commutative44.6%
mul-1-neg44.6%
sub-neg44.6%
associate-/l*47.7%
Simplified47.7%
unpow247.7%
*-un-lft-identity47.7%
times-frac61.6%
Applied egg-rr61.6%
Final simplification89.8%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- a) d)) (t_1 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
(if (<= d -7.5e+76)
(fma (/ -1.0 d) (/ b (/ (hypot c d) c)) t_0)
(if (<= d -1.2e-88)
t_1
(if (<= d 3.8e-171)
(- (/ b c) (/ a (* c (/ c d))))
(if (<= d 6.2e+143)
t_1
(fma (/ 1.0 (hypot c d)) (/ b (/ d c)) t_0)))))))
double code(double a, double b, double c, double d) {
double t_0 = -a / d;
double t_1 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double tmp;
if (d <= -7.5e+76) {
tmp = fma((-1.0 / d), (b / (hypot(c, d) / c)), t_0);
} else if (d <= -1.2e-88) {
tmp = t_1;
} else if (d <= 3.8e-171) {
tmp = (b / c) - (a / (c * (c / d)));
} else if (d <= 6.2e+143) {
tmp = t_1;
} else {
tmp = fma((1.0 / hypot(c, d)), (b / (d / c)), t_0);
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(-a) / d) t_1 = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (d <= -7.5e+76) tmp = fma(Float64(-1.0 / d), Float64(b / Float64(hypot(c, d) / c)), t_0); elseif (d <= -1.2e-88) tmp = t_1; elseif (d <= 3.8e-171) tmp = Float64(Float64(b / c) - Float64(a / Float64(c * Float64(c / d)))); elseif (d <= 6.2e+143) tmp = t_1; else tmp = fma(Float64(1.0 / hypot(c, d)), Float64(b / Float64(d / c)), t_0); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[((-a) / d), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -7.5e+76], N[(N[(-1.0 / d), $MachinePrecision] * N[(b / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision], If[LessEqual[d, -1.2e-88], t$95$1, If[LessEqual[d, 3.8e-171], N[(N[(b / c), $MachinePrecision] - N[(a / N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 6.2e+143], t$95$1, N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-a}{d}\\
t_1 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -7.5 \cdot 10^{+76}:\\
\;\;\;\;\mathsf{fma}\left(\frac{-1}{d}, \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}, t_0\right)\\
\mathbf{elif}\;d \leq -1.2 \cdot 10^{-88}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d \leq 3.8 \cdot 10^{-171}:\\
\;\;\;\;\frac{b}{c} - \frac{a}{c \cdot \frac{c}{d}}\\
\mathbf{elif}\;d \leq 6.2 \cdot 10^{+143}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{1}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\frac{d}{c}}, t_0\right)\\
\end{array}
\end{array}
if d < -7.4999999999999995e76Initial program 46.5%
div-sub46.5%
sub-neg46.5%
*-un-lft-identity46.5%
add-sqr-sqrt46.5%
times-frac46.5%
fma-def46.5%
hypot-def46.5%
hypot-def58.4%
associate-/l*61.3%
add-sqr-sqrt61.3%
pow261.3%
hypot-def61.3%
Applied egg-rr61.3%
associate-/l*78.3%
distribute-neg-frac78.3%
Simplified78.3%
Taylor expanded in c around 0 87.9%
Taylor expanded in d around -inf 85.7%
if -7.4999999999999995e76 < d < -1.2e-88 or 3.80000000000000021e-171 < d < 6.1999999999999998e143Initial program 89.2%
if -1.2e-88 < d < 3.80000000000000021e-171Initial program 67.8%
div-sub62.3%
sub-neg62.3%
*-un-lft-identity62.3%
add-sqr-sqrt62.3%
times-frac62.2%
fma-def62.2%
hypot-def62.2%
hypot-def68.7%
associate-/l*70.0%
add-sqr-sqrt70.0%
pow270.0%
hypot-def70.0%
Applied egg-rr70.0%
associate-/l*82.3%
distribute-neg-frac82.3%
Simplified82.3%
Taylor expanded in c around inf 80.0%
+-commutative80.0%
mul-1-neg80.0%
sub-neg80.0%
associate-/l*80.3%
Simplified80.3%
unpow280.3%
*-un-lft-identity80.3%
times-frac92.3%
Applied egg-rr92.3%
if 6.1999999999999998e143 < d Initial program 30.6%
div-sub30.6%
sub-neg30.6%
*-un-lft-identity30.6%
add-sqr-sqrt30.6%
times-frac30.6%
fma-def30.6%
hypot-def30.6%
hypot-def34.4%
associate-/l*39.0%
add-sqr-sqrt39.0%
pow239.0%
hypot-def39.0%
Applied egg-rr39.0%
associate-/l*55.2%
distribute-neg-frac55.2%
Simplified55.2%
Taylor expanded in c around 0 87.3%
Taylor expanded in c around 0 81.2%
Final simplification88.7%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* c b) (* d a))) (t_1 (- (/ b c) (/ a (* c (/ c d))))))
(if (<= c -1.2e+113)
t_1
(if (<= c -3.6e-155)
(* t_0 (pow (hypot c d) -2.0))
(if (<= c 1.75e-149)
(- (/ b (/ (pow d 2.0) c)) (/ a d))
(if (<= c 9.5e+111) (/ t_0 (+ (* c c) (* d d))) t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = (c * b) - (d * a);
double t_1 = (b / c) - (a / (c * (c / d)));
double tmp;
if (c <= -1.2e+113) {
tmp = t_1;
} else if (c <= -3.6e-155) {
tmp = t_0 * pow(hypot(c, d), -2.0);
} else if (c <= 1.75e-149) {
tmp = (b / (pow(d, 2.0) / c)) - (a / d);
} else if (c <= 9.5e+111) {
tmp = t_0 / ((c * c) + (d * d));
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = (c * b) - (d * a);
double t_1 = (b / c) - (a / (c * (c / d)));
double tmp;
if (c <= -1.2e+113) {
tmp = t_1;
} else if (c <= -3.6e-155) {
tmp = t_0 * Math.pow(Math.hypot(c, d), -2.0);
} else if (c <= 1.75e-149) {
tmp = (b / (Math.pow(d, 2.0) / c)) - (a / d);
} else if (c <= 9.5e+111) {
tmp = t_0 / ((c * c) + (d * d));
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = (c * b) - (d * a) t_1 = (b / c) - (a / (c * (c / d))) tmp = 0 if c <= -1.2e+113: tmp = t_1 elif c <= -3.6e-155: tmp = t_0 * math.pow(math.hypot(c, d), -2.0) elif c <= 1.75e-149: tmp = (b / (math.pow(d, 2.0) / c)) - (a / d) elif c <= 9.5e+111: tmp = t_0 / ((c * c) + (d * d)) else: tmp = t_1 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(c * b) - Float64(d * a)) t_1 = Float64(Float64(b / c) - Float64(a / Float64(c * Float64(c / d)))) tmp = 0.0 if (c <= -1.2e+113) tmp = t_1; elseif (c <= -3.6e-155) tmp = Float64(t_0 * (hypot(c, d) ^ -2.0)); elseif (c <= 1.75e-149) tmp = Float64(Float64(b / Float64((d ^ 2.0) / c)) - Float64(a / d)); elseif (c <= 9.5e+111) tmp = Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))); else tmp = t_1; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (c * b) - (d * a); t_1 = (b / c) - (a / (c * (c / d))); tmp = 0.0; if (c <= -1.2e+113) tmp = t_1; elseif (c <= -3.6e-155) tmp = t_0 * (hypot(c, d) ^ -2.0); elseif (c <= 1.75e-149) tmp = (b / ((d ^ 2.0) / c)) - (a / d); elseif (c <= 9.5e+111) tmp = t_0 / ((c * c) + (d * d)); else tmp = t_1; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(b / c), $MachinePrecision] - N[(a / N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -1.2e+113], t$95$1, If[LessEqual[c, -3.6e-155], N[(t$95$0 * N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.75e-149], N[(N[(b / N[(N[Power[d, 2.0], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 9.5e+111], N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot b - d \cdot a\\
t_1 := \frac{b}{c} - \frac{a}{c \cdot \frac{c}{d}}\\
\mathbf{if}\;c \leq -1.2 \cdot 10^{+113}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \leq -3.6 \cdot 10^{-155}:\\
\;\;\;\;t_0 \cdot {\left(\mathsf{hypot}\left(c, d\right)\right)}^{-2}\\
\mathbf{elif}\;c \leq 1.75 \cdot 10^{-149}:\\
\;\;\;\;\frac{b}{\frac{{d}^{2}}{c}} - \frac{a}{d}\\
\mathbf{elif}\;c \leq 9.5 \cdot 10^{+111}:\\
\;\;\;\;\frac{t_0}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if c < -1.19999999999999992e113 or 9.50000000000000019e111 < c Initial program 35.0%
div-sub35.0%
sub-neg35.0%
*-un-lft-identity35.0%
add-sqr-sqrt35.0%
times-frac35.0%
fma-def35.0%
hypot-def35.0%
hypot-def51.0%
associate-/l*51.4%
add-sqr-sqrt51.4%
pow251.4%
hypot-def51.4%
Applied egg-rr51.4%
associate-/l*90.2%
distribute-neg-frac90.2%
Simplified90.2%
Taylor expanded in c around inf 78.6%
+-commutative78.6%
mul-1-neg78.6%
sub-neg78.6%
associate-/l*80.3%
Simplified80.3%
unpow280.3%
*-un-lft-identity80.3%
times-frac83.2%
Applied egg-rr83.2%
if -1.19999999999999992e113 < c < -3.59999999999999989e-155Initial program 89.5%
clear-num89.4%
associate-/r/89.5%
add-sqr-sqrt89.5%
pow289.5%
hypot-def89.5%
Applied egg-rr89.5%
expm1-log1p-u87.6%
expm1-udef38.7%
pow-flip38.7%
metadata-eval38.7%
Applied egg-rr38.7%
expm1-def88.9%
expm1-log1p90.8%
Simplified90.8%
if -3.59999999999999989e-155 < c < 1.75e-149Initial program 70.2%
Taylor expanded in c around 0 83.9%
+-commutative83.9%
mul-1-neg83.9%
unsub-neg83.9%
associate-/l*81.9%
Simplified81.9%
if 1.75e-149 < c < 9.50000000000000019e111Initial program 91.7%
Final simplification86.1%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
(if (<= d -3e+76)
(fma (/ -1.0 d) (/ b (/ (hypot c d) c)) (/ (- a) d))
(if (<= d -4.2e-88)
t_0
(if (<= d 5.5e-172)
(- (/ b c) (/ a (* c (/ c d))))
(if (<= d 3.3e+143) t_0 (- (/ b (/ (pow d 2.0) c)) (/ a d))))))))
double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double tmp;
if (d <= -3e+76) {
tmp = fma((-1.0 / d), (b / (hypot(c, d) / c)), (-a / d));
} else if (d <= -4.2e-88) {
tmp = t_0;
} else if (d <= 5.5e-172) {
tmp = (b / c) - (a / (c * (c / d)));
} else if (d <= 3.3e+143) {
tmp = t_0;
} else {
tmp = (b / (pow(d, 2.0) / c)) - (a / d);
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (d <= -3e+76) tmp = fma(Float64(-1.0 / d), Float64(b / Float64(hypot(c, d) / c)), Float64(Float64(-a) / d)); elseif (d <= -4.2e-88) tmp = t_0; elseif (d <= 5.5e-172) tmp = Float64(Float64(b / c) - Float64(a / Float64(c * Float64(c / d)))); elseif (d <= 3.3e+143) tmp = t_0; else tmp = Float64(Float64(b / Float64((d ^ 2.0) / c)) - Float64(a / d)); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -3e+76], N[(N[(-1.0 / d), $MachinePrecision] * N[(b / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] + N[((-a) / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -4.2e-88], t$95$0, If[LessEqual[d, 5.5e-172], N[(N[(b / c), $MachinePrecision] - N[(a / N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.3e+143], t$95$0, N[(N[(b / N[(N[Power[d, 2.0], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -3 \cdot 10^{+76}:\\
\;\;\;\;\mathsf{fma}\left(\frac{-1}{d}, \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}}, \frac{-a}{d}\right)\\
\mathbf{elif}\;d \leq -4.2 \cdot 10^{-88}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 5.5 \cdot 10^{-172}:\\
\;\;\;\;\frac{b}{c} - \frac{a}{c \cdot \frac{c}{d}}\\
\mathbf{elif}\;d \leq 3.3 \cdot 10^{+143}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{\frac{{d}^{2}}{c}} - \frac{a}{d}\\
\end{array}
\end{array}
if d < -2.9999999999999998e76Initial program 46.5%
div-sub46.5%
sub-neg46.5%
*-un-lft-identity46.5%
add-sqr-sqrt46.5%
times-frac46.5%
fma-def46.5%
hypot-def46.5%
hypot-def58.4%
associate-/l*61.3%
add-sqr-sqrt61.3%
pow261.3%
hypot-def61.3%
Applied egg-rr61.3%
associate-/l*78.3%
distribute-neg-frac78.3%
Simplified78.3%
Taylor expanded in c around 0 87.9%
Taylor expanded in d around -inf 85.7%
if -2.9999999999999998e76 < d < -4.1999999999999999e-88 or 5.5000000000000004e-172 < d < 3.3e143Initial program 89.2%
if -4.1999999999999999e-88 < d < 5.5000000000000004e-172Initial program 67.8%
div-sub62.3%
sub-neg62.3%
*-un-lft-identity62.3%
add-sqr-sqrt62.3%
times-frac62.2%
fma-def62.2%
hypot-def62.2%
hypot-def68.7%
associate-/l*70.0%
add-sqr-sqrt70.0%
pow270.0%
hypot-def70.0%
Applied egg-rr70.0%
associate-/l*82.3%
distribute-neg-frac82.3%
Simplified82.3%
Taylor expanded in c around inf 80.0%
+-commutative80.0%
mul-1-neg80.0%
sub-neg80.0%
associate-/l*80.3%
Simplified80.3%
unpow280.3%
*-un-lft-identity80.3%
times-frac92.3%
Applied egg-rr92.3%
if 3.3e143 < d Initial program 30.6%
Taylor expanded in c around 0 70.2%
+-commutative70.2%
mul-1-neg70.2%
unsub-neg70.2%
associate-/l*71.1%
Simplified71.1%
Final simplification87.5%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* c b) (* d a)))
(t_1 (- (/ b c) (/ a (* c (/ c d)))))
(t_2 (+ (* c c) (* d d))))
(if (<= c -9.5e+111)
t_1
(if (<= c -5.8e-156)
(/ (+ t_0 (* 2.0 (fma a (- d) (* d a)))) t_2)
(if (<= c 1.35e-149)
(- (/ b (/ (pow d 2.0) c)) (/ a d))
(if (<= c 1.08e+111) (/ t_0 t_2) t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = (c * b) - (d * a);
double t_1 = (b / c) - (a / (c * (c / d)));
double t_2 = (c * c) + (d * d);
double tmp;
if (c <= -9.5e+111) {
tmp = t_1;
} else if (c <= -5.8e-156) {
tmp = (t_0 + (2.0 * fma(a, -d, (d * a)))) / t_2;
} else if (c <= 1.35e-149) {
tmp = (b / (pow(d, 2.0) / c)) - (a / d);
} else if (c <= 1.08e+111) {
tmp = t_0 / t_2;
} else {
tmp = t_1;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(c * b) - Float64(d * a)) t_1 = Float64(Float64(b / c) - Float64(a / Float64(c * Float64(c / d)))) t_2 = Float64(Float64(c * c) + Float64(d * d)) tmp = 0.0 if (c <= -9.5e+111) tmp = t_1; elseif (c <= -5.8e-156) tmp = Float64(Float64(t_0 + Float64(2.0 * fma(a, Float64(-d), Float64(d * a)))) / t_2); elseif (c <= 1.35e-149) tmp = Float64(Float64(b / Float64((d ^ 2.0) / c)) - Float64(a / d)); elseif (c <= 1.08e+111) tmp = Float64(t_0 / t_2); else tmp = t_1; end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(b / c), $MachinePrecision] - N[(a / N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -9.5e+111], t$95$1, If[LessEqual[c, -5.8e-156], N[(N[(t$95$0 + N[(2.0 * N[(a * (-d) + N[(d * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$2), $MachinePrecision], If[LessEqual[c, 1.35e-149], N[(N[(b / N[(N[Power[d, 2.0], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.08e+111], N[(t$95$0 / t$95$2), $MachinePrecision], t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot b - d \cdot a\\
t_1 := \frac{b}{c} - \frac{a}{c \cdot \frac{c}{d}}\\
t_2 := c \cdot c + d \cdot d\\
\mathbf{if}\;c \leq -9.5 \cdot 10^{+111}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \leq -5.8 \cdot 10^{-156}:\\
\;\;\;\;\frac{t_0 + 2 \cdot \mathsf{fma}\left(a, -d, d \cdot a\right)}{t_2}\\
\mathbf{elif}\;c \leq 1.35 \cdot 10^{-149}:\\
\;\;\;\;\frac{b}{\frac{{d}^{2}}{c}} - \frac{a}{d}\\
\mathbf{elif}\;c \leq 1.08 \cdot 10^{+111}:\\
\;\;\;\;\frac{t_0}{t_2}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if c < -9.50000000000000019e111 or 1.08000000000000004e111 < c Initial program 35.0%
div-sub35.0%
sub-neg35.0%
*-un-lft-identity35.0%
add-sqr-sqrt35.0%
times-frac35.0%
fma-def35.0%
hypot-def35.0%
hypot-def51.0%
associate-/l*51.4%
add-sqr-sqrt51.4%
pow251.4%
hypot-def51.4%
Applied egg-rr51.4%
associate-/l*90.2%
distribute-neg-frac90.2%
Simplified90.2%
Taylor expanded in c around inf 78.6%
+-commutative78.6%
mul-1-neg78.6%
sub-neg78.6%
associate-/l*80.3%
Simplified80.3%
unpow280.3%
*-un-lft-identity80.3%
times-frac83.2%
Applied egg-rr83.2%
if -9.50000000000000019e111 < c < -5.80000000000000041e-156Initial program 89.5%
prod-diff89.4%
*-commutative89.4%
fma-neg89.4%
prod-diff89.4%
*-commutative89.4%
fma-neg89.4%
associate-+l+89.5%
*-commutative89.5%
fma-udef89.4%
distribute-lft-neg-in89.4%
*-commutative89.4%
distribute-rgt-neg-in89.4%
fma-def89.5%
*-commutative89.5%
fma-udef89.4%
distribute-lft-neg-in89.4%
*-commutative89.4%
distribute-rgt-neg-in89.4%
fma-def89.5%
Applied egg-rr89.5%
*-commutative89.5%
count-289.5%
Simplified89.5%
if -5.80000000000000041e-156 < c < 1.35000000000000007e-149Initial program 70.2%
Taylor expanded in c around 0 83.9%
+-commutative83.9%
mul-1-neg83.9%
unsub-neg83.9%
associate-/l*81.9%
Simplified81.9%
if 1.35000000000000007e-149 < c < 1.08000000000000004e111Initial program 91.7%
Final simplification85.8%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d))))
(t_1 (- (/ b c) (/ a (* c (/ c d))))))
(if (<= c -8e+111)
t_1
(if (<= c -3.6e-156)
t_0
(if (<= c 1.55e-149)
(- (/ b (/ (pow d 2.0) c)) (/ a d))
(if (<= c 1.25e+116) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double t_1 = (b / c) - (a / (c * (c / d)));
double tmp;
if (c <= -8e+111) {
tmp = t_1;
} else if (c <= -3.6e-156) {
tmp = t_0;
} else if (c <= 1.55e-149) {
tmp = (b / (pow(d, 2.0) / c)) - (a / d);
} else if (c <= 1.25e+116) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d))
t_1 = (b / c) - (a / (c * (c / d)))
if (c <= (-8d+111)) then
tmp = t_1
else if (c <= (-3.6d-156)) then
tmp = t_0
else if (c <= 1.55d-149) then
tmp = (b / ((d ** 2.0d0) / c)) - (a / d)
else if (c <= 1.25d+116) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double t_1 = (b / c) - (a / (c * (c / d)));
double tmp;
if (c <= -8e+111) {
tmp = t_1;
} else if (c <= -3.6e-156) {
tmp = t_0;
} else if (c <= 1.55e-149) {
tmp = (b / (Math.pow(d, 2.0) / c)) - (a / d);
} else if (c <= 1.25e+116) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)) t_1 = (b / c) - (a / (c * (c / d))) tmp = 0 if c <= -8e+111: tmp = t_1 elif c <= -3.6e-156: tmp = t_0 elif c <= 1.55e-149: tmp = (b / (math.pow(d, 2.0) / c)) - (a / d) elif c <= 1.25e+116: tmp = t_0 else: tmp = t_1 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))) t_1 = Float64(Float64(b / c) - Float64(a / Float64(c * Float64(c / d)))) tmp = 0.0 if (c <= -8e+111) tmp = t_1; elseif (c <= -3.6e-156) tmp = t_0; elseif (c <= 1.55e-149) tmp = Float64(Float64(b / Float64((d ^ 2.0) / c)) - Float64(a / d)); elseif (c <= 1.25e+116) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)); t_1 = (b / c) - (a / (c * (c / d))); tmp = 0.0; if (c <= -8e+111) tmp = t_1; elseif (c <= -3.6e-156) tmp = t_0; elseif (c <= 1.55e-149) tmp = (b / ((d ^ 2.0) / c)) - (a / d); elseif (c <= 1.25e+116) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(b / c), $MachinePrecision] - N[(a / N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -8e+111], t$95$1, If[LessEqual[c, -3.6e-156], t$95$0, If[LessEqual[c, 1.55e-149], N[(N[(b / N[(N[Power[d, 2.0], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.25e+116], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
t_1 := \frac{b}{c} - \frac{a}{c \cdot \frac{c}{d}}\\
\mathbf{if}\;c \leq -8 \cdot 10^{+111}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \leq -3.6 \cdot 10^{-156}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 1.55 \cdot 10^{-149}:\\
\;\;\;\;\frac{b}{\frac{{d}^{2}}{c}} - \frac{a}{d}\\
\mathbf{elif}\;c \leq 1.25 \cdot 10^{+116}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if c < -7.99999999999999965e111 or 1.25000000000000006e116 < c Initial program 35.0%
div-sub35.0%
sub-neg35.0%
*-un-lft-identity35.0%
add-sqr-sqrt35.0%
times-frac35.0%
fma-def35.0%
hypot-def35.0%
hypot-def51.0%
associate-/l*51.4%
add-sqr-sqrt51.4%
pow251.4%
hypot-def51.4%
Applied egg-rr51.4%
associate-/l*90.2%
distribute-neg-frac90.2%
Simplified90.2%
Taylor expanded in c around inf 78.6%
+-commutative78.6%
mul-1-neg78.6%
sub-neg78.6%
associate-/l*80.3%
Simplified80.3%
unpow280.3%
*-un-lft-identity80.3%
times-frac83.2%
Applied egg-rr83.2%
if -7.99999999999999965e111 < c < -3.59999999999999999e-156 or 1.54999999999999994e-149 < c < 1.25000000000000006e116Initial program 90.5%
if -3.59999999999999999e-156 < c < 1.54999999999999994e-149Initial program 70.2%
Taylor expanded in c around 0 83.9%
+-commutative83.9%
mul-1-neg83.9%
unsub-neg83.9%
associate-/l*81.9%
Simplified81.9%
Final simplification85.8%
(FPCore (a b c d) :precision binary64 (let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d))))) (if (<= t_0 1e+244) t_0 (- (/ b c) (/ a (* c (/ c d)))))))
double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double tmp;
if (t_0 <= 1e+244) {
tmp = t_0;
} else {
tmp = (b / c) - (a / (c * (c / d)));
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d))
if (t_0 <= 1d+244) then
tmp = t_0
else
tmp = (b / c) - (a / (c * (c / d)))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double tmp;
if (t_0 <= 1e+244) {
tmp = t_0;
} else {
tmp = (b / c) - (a / (c * (c / d)));
}
return tmp;
}
def code(a, b, c, d): t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)) tmp = 0 if t_0 <= 1e+244: tmp = t_0 else: tmp = (b / c) - (a / (c * (c / d))) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (t_0 <= 1e+244) tmp = t_0; else tmp = Float64(Float64(b / c) - Float64(a / Float64(c * Float64(c / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)); tmp = 0.0; if (t_0 <= 1e+244) tmp = t_0; else tmp = (b / c) - (a / (c * (c / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 1e+244], t$95$0, N[(N[(b / c), $MachinePrecision] - N[(a / N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{if}\;t_0 \leq 10^{+244}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c} - \frac{a}{c \cdot \frac{c}{d}}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 1.00000000000000007e244Initial program 86.2%
if 1.00000000000000007e244 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 17.7%
div-sub12.7%
sub-neg12.7%
*-un-lft-identity12.7%
add-sqr-sqrt12.7%
times-frac12.7%
fma-def12.7%
hypot-def12.7%
hypot-def15.4%
associate-/l*18.1%
add-sqr-sqrt18.1%
pow218.1%
hypot-def18.1%
Applied egg-rr18.1%
associate-/l*60.4%
distribute-neg-frac60.4%
Simplified60.4%
Taylor expanded in c around inf 48.0%
+-commutative48.0%
mul-1-neg48.0%
sub-neg48.0%
associate-/l*50.2%
Simplified50.2%
unpow250.2%
*-un-lft-identity50.2%
times-frac65.0%
Applied egg-rr65.0%
Final simplification80.9%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (+ (* c c) (* d d))) (t_1 (/ (* c b) t_0)) (t_2 (/ (- a) d)))
(if (<= c -2.8e+82)
(/ b c)
(if (<= c -4.8e+33)
(/ (* d (- a)) t_0)
(if (<= c -5.6e+17)
t_1
(if (<= c -4.6e-30)
t_2
(if (<= c -4.2e-132)
t_1
(if (<= c 1.45e-98) t_2 (if (<= c 2.8e+108) t_1 (/ b c))))))))))
double code(double a, double b, double c, double d) {
double t_0 = (c * c) + (d * d);
double t_1 = (c * b) / t_0;
double t_2 = -a / d;
double tmp;
if (c <= -2.8e+82) {
tmp = b / c;
} else if (c <= -4.8e+33) {
tmp = (d * -a) / t_0;
} else if (c <= -5.6e+17) {
tmp = t_1;
} else if (c <= -4.6e-30) {
tmp = t_2;
} else if (c <= -4.2e-132) {
tmp = t_1;
} else if (c <= 1.45e-98) {
tmp = t_2;
} else if (c <= 2.8e+108) {
tmp = t_1;
} else {
tmp = b / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = (c * c) + (d * d)
t_1 = (c * b) / t_0
t_2 = -a / d
if (c <= (-2.8d+82)) then
tmp = b / c
else if (c <= (-4.8d+33)) then
tmp = (d * -a) / t_0
else if (c <= (-5.6d+17)) then
tmp = t_1
else if (c <= (-4.6d-30)) then
tmp = t_2
else if (c <= (-4.2d-132)) then
tmp = t_1
else if (c <= 1.45d-98) then
tmp = t_2
else if (c <= 2.8d+108) then
tmp = t_1
else
tmp = b / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = (c * c) + (d * d);
double t_1 = (c * b) / t_0;
double t_2 = -a / d;
double tmp;
if (c <= -2.8e+82) {
tmp = b / c;
} else if (c <= -4.8e+33) {
tmp = (d * -a) / t_0;
} else if (c <= -5.6e+17) {
tmp = t_1;
} else if (c <= -4.6e-30) {
tmp = t_2;
} else if (c <= -4.2e-132) {
tmp = t_1;
} else if (c <= 1.45e-98) {
tmp = t_2;
} else if (c <= 2.8e+108) {
tmp = t_1;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): t_0 = (c * c) + (d * d) t_1 = (c * b) / t_0 t_2 = -a / d tmp = 0 if c <= -2.8e+82: tmp = b / c elif c <= -4.8e+33: tmp = (d * -a) / t_0 elif c <= -5.6e+17: tmp = t_1 elif c <= -4.6e-30: tmp = t_2 elif c <= -4.2e-132: tmp = t_1 elif c <= 1.45e-98: tmp = t_2 elif c <= 2.8e+108: tmp = t_1 else: tmp = b / c return tmp
function code(a, b, c, d) t_0 = Float64(Float64(c * c) + Float64(d * d)) t_1 = Float64(Float64(c * b) / t_0) t_2 = Float64(Float64(-a) / d) tmp = 0.0 if (c <= -2.8e+82) tmp = Float64(b / c); elseif (c <= -4.8e+33) tmp = Float64(Float64(d * Float64(-a)) / t_0); elseif (c <= -5.6e+17) tmp = t_1; elseif (c <= -4.6e-30) tmp = t_2; elseif (c <= -4.2e-132) tmp = t_1; elseif (c <= 1.45e-98) tmp = t_2; elseif (c <= 2.8e+108) tmp = t_1; else tmp = Float64(b / c); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (c * c) + (d * d); t_1 = (c * b) / t_0; t_2 = -a / d; tmp = 0.0; if (c <= -2.8e+82) tmp = b / c; elseif (c <= -4.8e+33) tmp = (d * -a) / t_0; elseif (c <= -5.6e+17) tmp = t_1; elseif (c <= -4.6e-30) tmp = t_2; elseif (c <= -4.2e-132) tmp = t_1; elseif (c <= 1.45e-98) tmp = t_2; elseif (c <= 2.8e+108) tmp = t_1; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(c * b), $MachinePrecision] / t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[((-a) / d), $MachinePrecision]}, If[LessEqual[c, -2.8e+82], N[(b / c), $MachinePrecision], If[LessEqual[c, -4.8e+33], N[(N[(d * (-a)), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[c, -5.6e+17], t$95$1, If[LessEqual[c, -4.6e-30], t$95$2, If[LessEqual[c, -4.2e-132], t$95$1, If[LessEqual[c, 1.45e-98], t$95$2, If[LessEqual[c, 2.8e+108], t$95$1, N[(b / c), $MachinePrecision]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot c + d \cdot d\\
t_1 := \frac{c \cdot b}{t_0}\\
t_2 := \frac{-a}{d}\\
\mathbf{if}\;c \leq -2.8 \cdot 10^{+82}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq -4.8 \cdot 10^{+33}:\\
\;\;\;\;\frac{d \cdot \left(-a\right)}{t_0}\\
\mathbf{elif}\;c \leq -5.6 \cdot 10^{+17}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \leq -4.6 \cdot 10^{-30}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;c \leq -4.2 \cdot 10^{-132}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;c \leq 1.45 \cdot 10^{-98}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;c \leq 2.8 \cdot 10^{+108}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -2.8e82 or 2.7999999999999998e108 < c Initial program 42.3%
Taylor expanded in c around inf 80.4%
if -2.8e82 < c < -4.8e33Initial program 99.4%
Taylor expanded in b around 0 89.9%
associate-*r*89.9%
neg-mul-189.9%
*-commutative89.9%
Simplified89.9%
if -4.8e33 < c < -5.6e17 or -4.59999999999999968e-30 < c < -4.2000000000000002e-132 or 1.45e-98 < c < 2.7999999999999998e108Initial program 86.6%
Taylor expanded in b around inf 64.5%
*-commutative64.5%
Simplified64.5%
if -5.6e17 < c < -4.59999999999999968e-30 or -4.2000000000000002e-132 < c < 1.45e-98Initial program 75.3%
Taylor expanded in c around 0 72.8%
associate-*r/72.8%
neg-mul-172.8%
Simplified72.8%
Final simplification73.7%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (* c b) (+ (* c c) (* d d)))))
(if (<= c -8.5e+111)
(/ b c)
(if (<= c -1.02e-131)
t_0
(if (<= c 1.4e-98) (/ (- a) d) (if (<= c 5.2e+107) t_0 (/ b c)))))))
double code(double a, double b, double c, double d) {
double t_0 = (c * b) / ((c * c) + (d * d));
double tmp;
if (c <= -8.5e+111) {
tmp = b / c;
} else if (c <= -1.02e-131) {
tmp = t_0;
} else if (c <= 1.4e-98) {
tmp = -a / d;
} else if (c <= 5.2e+107) {
tmp = t_0;
} else {
tmp = b / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = (c * b) / ((c * c) + (d * d))
if (c <= (-8.5d+111)) then
tmp = b / c
else if (c <= (-1.02d-131)) then
tmp = t_0
else if (c <= 1.4d-98) then
tmp = -a / d
else if (c <= 5.2d+107) then
tmp = t_0
else
tmp = b / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = (c * b) / ((c * c) + (d * d));
double tmp;
if (c <= -8.5e+111) {
tmp = b / c;
} else if (c <= -1.02e-131) {
tmp = t_0;
} else if (c <= 1.4e-98) {
tmp = -a / d;
} else if (c <= 5.2e+107) {
tmp = t_0;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): t_0 = (c * b) / ((c * c) + (d * d)) tmp = 0 if c <= -8.5e+111: tmp = b / c elif c <= -1.02e-131: tmp = t_0 elif c <= 1.4e-98: tmp = -a / d elif c <= 5.2e+107: tmp = t_0 else: tmp = b / c return tmp
function code(a, b, c, d) t_0 = Float64(Float64(c * b) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (c <= -8.5e+111) tmp = Float64(b / c); elseif (c <= -1.02e-131) tmp = t_0; elseif (c <= 1.4e-98) tmp = Float64(Float64(-a) / d); elseif (c <= 5.2e+107) tmp = t_0; else tmp = Float64(b / c); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (c * b) / ((c * c) + (d * d)); tmp = 0.0; if (c <= -8.5e+111) tmp = b / c; elseif (c <= -1.02e-131) tmp = t_0; elseif (c <= 1.4e-98) tmp = -a / d; elseif (c <= 5.2e+107) tmp = t_0; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * b), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[c, -8.5e+111], N[(b / c), $MachinePrecision], If[LessEqual[c, -1.02e-131], t$95$0, If[LessEqual[c, 1.4e-98], N[((-a) / d), $MachinePrecision], If[LessEqual[c, 5.2e+107], t$95$0, N[(b / c), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot b}{c \cdot c + d \cdot d}\\
\mathbf{if}\;c \leq -8.5 \cdot 10^{+111}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq -1.02 \cdot 10^{-131}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;c \leq 1.4 \cdot 10^{-98}:\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{elif}\;c \leq 5.2 \cdot 10^{+107}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -8.49999999999999983e111 or 5.2000000000000002e107 < c Initial program 35.0%
Taylor expanded in c around inf 79.2%
if -8.49999999999999983e111 < c < -1.02000000000000001e-131 or 1.3999999999999999e-98 < c < 5.2000000000000002e107Initial program 89.6%
Taylor expanded in b around inf 65.6%
*-commutative65.6%
Simplified65.6%
if -1.02000000000000001e-131 < c < 1.3999999999999999e-98Initial program 73.5%
Taylor expanded in c around 0 72.7%
associate-*r/72.7%
neg-mul-172.7%
Simplified72.7%
Final simplification71.8%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- a) d)))
(if (<= d -4.8e+89)
t_0
(if (<= d -2.55e-33)
(/ (* d (- a)) (+ (* c c) (* d d)))
(if (<= d 6.1e+38) (- (/ b c) (/ a (* c (/ c d)))) t_0)))))
double code(double a, double b, double c, double d) {
double t_0 = -a / d;
double tmp;
if (d <= -4.8e+89) {
tmp = t_0;
} else if (d <= -2.55e-33) {
tmp = (d * -a) / ((c * c) + (d * d));
} else if (d <= 6.1e+38) {
tmp = (b / c) - (a / (c * (c / d)));
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = -a / d
if (d <= (-4.8d+89)) then
tmp = t_0
else if (d <= (-2.55d-33)) then
tmp = (d * -a) / ((c * c) + (d * d))
else if (d <= 6.1d+38) then
tmp = (b / c) - (a / (c * (c / d)))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = -a / d;
double tmp;
if (d <= -4.8e+89) {
tmp = t_0;
} else if (d <= -2.55e-33) {
tmp = (d * -a) / ((c * c) + (d * d));
} else if (d <= 6.1e+38) {
tmp = (b / c) - (a / (c * (c / d)));
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = -a / d tmp = 0 if d <= -4.8e+89: tmp = t_0 elif d <= -2.55e-33: tmp = (d * -a) / ((c * c) + (d * d)) elif d <= 6.1e+38: tmp = (b / c) - (a / (c * (c / d))) else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(-a) / d) tmp = 0.0 if (d <= -4.8e+89) tmp = t_0; elseif (d <= -2.55e-33) tmp = Float64(Float64(d * Float64(-a)) / Float64(Float64(c * c) + Float64(d * d))); elseif (d <= 6.1e+38) tmp = Float64(Float64(b / c) - Float64(a / Float64(c * Float64(c / d)))); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = -a / d; tmp = 0.0; if (d <= -4.8e+89) tmp = t_0; elseif (d <= -2.55e-33) tmp = (d * -a) / ((c * c) + (d * d)); elseif (d <= 6.1e+38) tmp = (b / c) - (a / (c * (c / d))); else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[((-a) / d), $MachinePrecision]}, If[LessEqual[d, -4.8e+89], t$95$0, If[LessEqual[d, -2.55e-33], N[(N[(d * (-a)), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 6.1e+38], N[(N[(b / c), $MachinePrecision] - N[(a / N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-a}{d}\\
\mathbf{if}\;d \leq -4.8 \cdot 10^{+89}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq -2.55 \cdot 10^{-33}:\\
\;\;\;\;\frac{d \cdot \left(-a\right)}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 6.1 \cdot 10^{+38}:\\
\;\;\;\;\frac{b}{c} - \frac{a}{c \cdot \frac{c}{d}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if d < -4.80000000000000009e89 or 6.0999999999999999e38 < d Initial program 53.1%
Taylor expanded in c around 0 67.7%
associate-*r/67.7%
neg-mul-167.7%
Simplified67.7%
if -4.80000000000000009e89 < d < -2.55000000000000004e-33Initial program 86.6%
Taylor expanded in b around 0 64.3%
associate-*r*64.3%
neg-mul-164.3%
*-commutative64.3%
Simplified64.3%
if -2.55000000000000004e-33 < d < 6.0999999999999999e38Initial program 75.0%
div-sub71.1%
sub-neg71.1%
*-un-lft-identity71.1%
add-sqr-sqrt71.1%
times-frac71.0%
fma-def71.0%
hypot-def71.0%
hypot-def77.0%
associate-/l*78.5%
add-sqr-sqrt78.5%
pow278.5%
hypot-def78.5%
Applied egg-rr78.5%
associate-/l*89.7%
distribute-neg-frac89.7%
Simplified89.7%
Taylor expanded in c around inf 71.6%
+-commutative71.6%
mul-1-neg71.6%
sub-neg71.6%
associate-/l*72.5%
Simplified72.5%
unpow272.5%
*-un-lft-identity72.5%
times-frac79.4%
Applied egg-rr79.4%
Final simplification73.5%
(FPCore (a b c d) :precision binary64 (if (or (<= d -3.4e-40) (not (<= d 4000000.0))) (/ (- a) d) (/ b c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -3.4e-40) || !(d <= 4000000.0)) {
tmp = -a / d;
} else {
tmp = b / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if ((d <= (-3.4d-40)) .or. (.not. (d <= 4000000.0d0))) then
tmp = -a / d
else
tmp = b / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -3.4e-40) || !(d <= 4000000.0)) {
tmp = -a / d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -3.4e-40) or not (d <= 4000000.0): tmp = -a / d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -3.4e-40) || !(d <= 4000000.0)) tmp = Float64(Float64(-a) / d); else tmp = Float64(b / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -3.4e-40) || ~((d <= 4000000.0))) tmp = -a / d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -3.4e-40], N[Not[LessEqual[d, 4000000.0]], $MachinePrecision]], N[((-a) / d), $MachinePrecision], N[(b / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -3.4 \cdot 10^{-40} \lor \neg \left(d \leq 4000000\right):\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if d < -3.39999999999999984e-40 or 4e6 < d Initial program 62.7%
Taylor expanded in c around 0 59.2%
associate-*r/59.2%
neg-mul-159.2%
Simplified59.2%
if -3.39999999999999984e-40 < d < 4e6Initial program 75.1%
Taylor expanded in c around inf 69.1%
Final simplification64.3%
(FPCore (a b c d) :precision binary64 (/ b c))
double code(double a, double b, double c, double d) {
return b / c;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = b / c
end function
public static double code(double a, double b, double c, double d) {
return b / c;
}
def code(a, b, c, d): return b / c
function code(a, b, c, d) return Float64(b / c) end
function tmp = code(a, b, c, d) tmp = b / c; end
code[a_, b_, c_, d_] := N[(b / c), $MachinePrecision]
\begin{array}{l}
\\
\frac{b}{c}
\end{array}
Initial program 69.1%
Taylor expanded in c around inf 45.4%
Final simplification45.4%
(FPCore (a b c d) :precision binary64 (if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if (fabs(d) < fabs(c)) {
tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if (abs(d) < abs(c)) then
tmp = (b - (a * (d / c))) / (c + (d * (d / c)))
else
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (Math.abs(d) < Math.abs(c)) {
tmp = (b - (a * (d / c))) / (c + (d * (d / c)));
} else {
tmp = (-a + (b * (c / d))) / (d + (c * (c / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if math.fabs(d) < math.fabs(c): tmp = (b - (a * (d / c))) / (c + (d * (d / c))) else: tmp = (-a + (b * (c / d))) / (d + (c * (c / d))) return tmp
function code(a, b, c, d) tmp = 0.0 if (abs(d) < abs(c)) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / Float64(c + Float64(d * Float64(d / c)))); else tmp = Float64(Float64(Float64(-a) + Float64(b * Float64(c / d))) / Float64(d + Float64(c * Float64(c / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (abs(d) < abs(c)) tmp = (b - (a * (d / c))) / (c + (d * (d / c))); else tmp = (-a + (b * (c / d))) / (d + (c * (c / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Less[N[Abs[d], $MachinePrecision], N[Abs[c], $MachinePrecision]], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(c + N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[((-a) + N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(d + N[(c * N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\left|d\right| < \left|c\right|:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c + d \cdot \frac{d}{c}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(-a\right) + b \cdot \frac{c}{d}}{d + c \cdot \frac{c}{d}}\\
\end{array}
\end{array}
herbie shell --seed 2023339
(FPCore (a b c d)
:name "Complex division, imag part"
:precision binary64
:herbie-target
(if (< (fabs d) (fabs c)) (/ (- b (* a (/ d c))) (+ c (* d (/ d c)))) (/ (+ (- a) (* b (/ c d))) (+ d (* c (/ c d)))))
(/ (- (* b c) (* a d)) (+ (* c c) (* d d))))