
(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
(let* ((t_0
(fma
(/ c (hypot c d))
(/ b (hypot c d))
(/ (* d (- a)) (pow (hypot c d) 2.0)))))
(if (<= d -3.5e+137)
(/ (- a (/ (* b c) d)) (hypot c d))
(if (<= d -2.35e-151)
t_0
(if (<= d 8.6e-214)
(* (/ 1.0 c) (- b (/ a (/ c d))))
(if (<= d 1.14e+167) t_0 (/ (- (/ b (/ d c)) a) (hypot c d))))))))
double code(double a, double b, double c, double d) {
double t_0 = fma((c / hypot(c, d)), (b / hypot(c, d)), ((d * -a) / pow(hypot(c, d), 2.0)));
double tmp;
if (d <= -3.5e+137) {
tmp = (a - ((b * c) / d)) / hypot(c, d);
} else if (d <= -2.35e-151) {
tmp = t_0;
} else if (d <= 8.6e-214) {
tmp = (1.0 / c) * (b - (a / (c / d)));
} else if (d <= 1.14e+167) {
tmp = t_0;
} else {
tmp = ((b / (d / c)) - a) / hypot(c, d);
}
return tmp;
}
function code(a, b, c, d) t_0 = fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(Float64(d * Float64(-a)) / (hypot(c, d) ^ 2.0))) tmp = 0.0 if (d <= -3.5e+137) tmp = Float64(Float64(a - Float64(Float64(b * c) / d)) / hypot(c, d)); elseif (d <= -2.35e-151) tmp = t_0; elseif (d <= 8.6e-214) tmp = Float64(Float64(1.0 / c) * Float64(b - Float64(a / Float64(c / d)))); elseif (d <= 1.14e+167) tmp = t_0; else tmp = Float64(Float64(Float64(b / Float64(d / c)) - a) / hypot(c, d)); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] + N[(N[(d * (-a)), $MachinePrecision] / N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -3.5e+137], N[(N[(a - N[(N[(b * c), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -2.35e-151], t$95$0, If[LessEqual[d, 8.6e-214], N[(N[(1.0 / c), $MachinePrecision] * N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.14e+167], t$95$0, N[(N[(N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{d \cdot \left(-a\right)}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right)\\
\mathbf{if}\;d \leq -3.5 \cdot 10^{+137}:\\
\;\;\;\;\frac{a - \frac{b \cdot c}{d}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq -2.35 \cdot 10^{-151}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 8.6 \cdot 10^{-214}:\\
\;\;\;\;\frac{1}{c} \cdot \left(b - \frac{a}{\frac{c}{d}}\right)\\
\mathbf{elif}\;d \leq 1.14 \cdot 10^{+167}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{b}{\frac{d}{c}} - a}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if d < -3.5000000000000001e137Initial program 36.6%
fma-def36.6%
*-un-lft-identity36.6%
add-sqr-sqrt36.6%
times-frac36.7%
fma-def36.7%
hypot-def36.7%
fma-def36.7%
hypot-def61.7%
Applied egg-rr61.7%
*-commutative61.7%
associate-*l/61.7%
div-inv61.8%
fma-neg61.8%
distribute-rgt-neg-in61.8%
Applied egg-rr61.8%
Taylor expanded in d around -inf 85.9%
if -3.5000000000000001e137 < d < -2.35000000000000014e-151 or 8.5999999999999999e-214 < d < 1.13999999999999995e167Initial program 75.3%
div-sub74.6%
sub-neg74.6%
*-commutative74.6%
fma-def74.6%
add-sqr-sqrt74.6%
times-frac78.2%
fma-def78.2%
fma-def78.2%
hypot-def78.2%
fma-def78.2%
hypot-def94.4%
fma-def94.4%
add-sqr-sqrt94.4%
pow294.4%
Applied egg-rr94.4%
if -2.35000000000000014e-151 < d < 8.5999999999999999e-214Initial program 73.4%
fma-def73.4%
*-un-lft-identity73.4%
add-sqr-sqrt73.4%
times-frac73.4%
fma-def73.4%
hypot-def73.4%
fma-def73.4%
hypot-def86.1%
Applied egg-rr86.1%
Taylor expanded in c around inf 53.9%
mul-1-neg53.9%
unsub-neg53.9%
associate-/l*55.7%
Simplified55.7%
Taylor expanded in c around inf 96.7%
if 1.13999999999999995e167 < d Initial program 12.1%
fma-def12.1%
*-un-lft-identity12.1%
add-sqr-sqrt12.1%
times-frac12.1%
fma-def12.1%
hypot-def12.1%
fma-def12.1%
hypot-def48.0%
Applied egg-rr48.0%
*-commutative48.0%
associate-*l/48.0%
div-inv48.1%
fma-neg48.1%
distribute-rgt-neg-in48.1%
Applied egg-rr48.1%
Taylor expanded in c around 0 83.9%
+-commutative83.9%
neg-mul-183.9%
unsub-neg83.9%
associate-/l*93.6%
Simplified93.6%
Final simplification93.7%
(FPCore (a b c d) :precision binary64 (if (<= (/ (- (* b c) (* d a)) (+ (* c c) (* d d))) 1e+260) (/ (/ (fma b c (* d (- a))) (hypot c d)) (hypot c d)) (* (/ 1.0 c) (- b (/ a (/ c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if ((((b * c) - (d * a)) / ((c * c) + (d * d))) <= 1e+260) {
tmp = (fma(b, c, (d * -a)) / hypot(c, d)) / hypot(c, d);
} else {
tmp = (1.0 / c) * (b - (a / (c / d)));
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (Float64(Float64(Float64(b * c) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))) <= 1e+260) tmp = Float64(Float64(fma(b, c, Float64(d * Float64(-a))) / hypot(c, d)) / hypot(c, d)); else tmp = Float64(Float64(1.0 / c) * Float64(b - Float64(a / Float64(c / d)))); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[N[(N[(N[(b * c), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e+260], N[(N[(N[(b * c + N[(d * (-a)), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / c), $MachinePrecision] * N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{b \cdot c - d \cdot a}{c \cdot c + d \cdot d} \leq 10^{+260}:\\
\;\;\;\;\frac{\frac{\mathsf{fma}\left(b, c, d \cdot \left(-a\right)\right)}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{c} \cdot \left(b - \frac{a}{\frac{c}{d}}\right)\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 1.00000000000000007e260Initial program 78.9%
fma-def78.9%
*-un-lft-identity78.9%
add-sqr-sqrt78.9%
times-frac78.8%
fma-def78.8%
hypot-def78.9%
fma-def78.9%
hypot-def96.8%
Applied egg-rr96.8%
*-commutative96.8%
associate-*l/96.9%
div-inv97.1%
fma-neg97.1%
distribute-rgt-neg-in97.1%
Applied egg-rr97.1%
if 1.00000000000000007e260 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 14.5%
fma-def14.5%
*-un-lft-identity14.5%
add-sqr-sqrt14.5%
times-frac14.5%
fma-def14.5%
hypot-def14.5%
fma-def14.5%
hypot-def21.9%
Applied egg-rr21.9%
Taylor expanded in c around inf 31.8%
mul-1-neg31.8%
unsub-neg31.8%
associate-/l*38.2%
Simplified38.2%
Taylor expanded in c around inf 64.7%
Final simplification88.8%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* b c) (* d a))))
(if (<= (/ t_0 (+ (* c c) (* d d))) 1e+260)
(* (/ 1.0 (hypot c d)) (/ t_0 (hypot c d)))
(* (/ 1.0 c) (- b (/ a (/ c d)))))))
double code(double a, double b, double c, double d) {
double t_0 = (b * c) - (d * a);
double tmp;
if ((t_0 / ((c * c) + (d * d))) <= 1e+260) {
tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
} else {
tmp = (1.0 / c) * (b - (a / (c / d)));
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = (b * c) - (d * a);
double tmp;
if ((t_0 / ((c * c) + (d * d))) <= 1e+260) {
tmp = (1.0 / Math.hypot(c, d)) * (t_0 / Math.hypot(c, d));
} else {
tmp = (1.0 / c) * (b - (a / (c / d)));
}
return tmp;
}
def code(a, b, c, d): t_0 = (b * c) - (d * a) tmp = 0 if (t_0 / ((c * c) + (d * d))) <= 1e+260: tmp = (1.0 / math.hypot(c, d)) * (t_0 / math.hypot(c, d)) else: tmp = (1.0 / c) * (b - (a / (c / d))) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(b * c) - Float64(d * a)) tmp = 0.0 if (Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))) <= 1e+260) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(t_0 / hypot(c, d))); else tmp = Float64(Float64(1.0 / c) * Float64(b - Float64(a / Float64(c / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (b * c) - (d * a); tmp = 0.0; if ((t_0 / ((c * c) + (d * d))) <= 1e+260) tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d)); else tmp = (1.0 / c) * (b - (a / (c / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b * c), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e+260], 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[(1.0 / c), $MachinePrecision] * N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := b \cdot c - d \cdot a\\
\mathbf{if}\;\frac{t_0}{c \cdot c + d \cdot d} \leq 10^{+260}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t_0}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{c} \cdot \left(b - \frac{a}{\frac{c}{d}}\right)\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 1.00000000000000007e260Initial program 78.9%
fma-def78.9%
*-un-lft-identity78.9%
add-sqr-sqrt78.9%
times-frac78.8%
fma-def78.8%
hypot-def78.9%
fma-def78.9%
hypot-def96.8%
Applied egg-rr96.8%
if 1.00000000000000007e260 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 14.5%
fma-def14.5%
*-un-lft-identity14.5%
add-sqr-sqrt14.5%
times-frac14.5%
fma-def14.5%
hypot-def14.5%
fma-def14.5%
hypot-def21.9%
Applied egg-rr21.9%
Taylor expanded in c around inf 31.8%
mul-1-neg31.8%
unsub-neg31.8%
associate-/l*38.2%
Simplified38.2%
Taylor expanded in c around inf 64.7%
Final simplification88.7%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* b c) (* d a))))
(if (<= d -1.44e+119)
(/ (- a (/ (* b c) d)) (hypot c d))
(if (<= d -4.3e-151)
(/ t_0 (+ (* c c) (* d d)))
(if (<= d 3.3e+23)
(* (/ 1.0 c) (- b (/ a (/ c d))))
(if (<= d 1.9e+166)
(/ t_0 (fma c c (* d d)))
(/ (- (/ b (/ d c)) a) (hypot c d))))))))
double code(double a, double b, double c, double d) {
double t_0 = (b * c) - (d * a);
double tmp;
if (d <= -1.44e+119) {
tmp = (a - ((b * c) / d)) / hypot(c, d);
} else if (d <= -4.3e-151) {
tmp = t_0 / ((c * c) + (d * d));
} else if (d <= 3.3e+23) {
tmp = (1.0 / c) * (b - (a / (c / d)));
} else if (d <= 1.9e+166) {
tmp = t_0 / fma(c, c, (d * d));
} else {
tmp = ((b / (d / c)) - a) / hypot(c, d);
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(b * c) - Float64(d * a)) tmp = 0.0 if (d <= -1.44e+119) tmp = Float64(Float64(a - Float64(Float64(b * c) / d)) / hypot(c, d)); elseif (d <= -4.3e-151) tmp = Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))); elseif (d <= 3.3e+23) tmp = Float64(Float64(1.0 / c) * Float64(b - Float64(a / Float64(c / d)))); elseif (d <= 1.9e+166) tmp = Float64(t_0 / fma(c, c, Float64(d * d))); else tmp = Float64(Float64(Float64(b / Float64(d / c)) - a) / hypot(c, d)); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b * c), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.44e+119], N[(N[(a - N[(N[(b * c), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -4.3e-151], N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.3e+23], N[(N[(1.0 / c), $MachinePrecision] * N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.9e+166], N[(t$95$0 / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := b \cdot c - d \cdot a\\
\mathbf{if}\;d \leq -1.44 \cdot 10^{+119}:\\
\;\;\;\;\frac{a - \frac{b \cdot c}{d}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq -4.3 \cdot 10^{-151}:\\
\;\;\;\;\frac{t_0}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 3.3 \cdot 10^{+23}:\\
\;\;\;\;\frac{1}{c} \cdot \left(b - \frac{a}{\frac{c}{d}}\right)\\
\mathbf{elif}\;d \leq 1.9 \cdot 10^{+166}:\\
\;\;\;\;\frac{t_0}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{b}{\frac{d}{c}} - a}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if d < -1.44e119Initial program 36.6%
fma-def36.6%
*-un-lft-identity36.6%
add-sqr-sqrt36.6%
times-frac36.7%
fma-def36.7%
hypot-def36.7%
fma-def36.7%
hypot-def61.7%
Applied egg-rr61.7%
*-commutative61.7%
associate-*l/61.7%
div-inv61.8%
fma-neg61.8%
distribute-rgt-neg-in61.8%
Applied egg-rr61.8%
Taylor expanded in d around -inf 85.9%
if -1.44e119 < d < -4.30000000000000018e-151Initial program 81.3%
if -4.30000000000000018e-151 < d < 3.30000000000000029e23Initial program 68.6%
fma-def68.6%
*-un-lft-identity68.6%
add-sqr-sqrt68.6%
times-frac68.6%
fma-def68.6%
hypot-def68.6%
fma-def68.6%
hypot-def84.1%
Applied egg-rr84.1%
Taylor expanded in c around inf 54.7%
mul-1-neg54.7%
unsub-neg54.7%
associate-/l*54.7%
Simplified54.7%
Taylor expanded in c around inf 87.8%
if 3.30000000000000029e23 < d < 1.90000000000000003e166Initial program 81.0%
fma-def81.1%
Simplified81.1%
if 1.90000000000000003e166 < d Initial program 12.1%
fma-def12.1%
*-un-lft-identity12.1%
add-sqr-sqrt12.1%
times-frac12.1%
fma-def12.1%
hypot-def12.1%
fma-def12.1%
hypot-def48.0%
Applied egg-rr48.0%
*-commutative48.0%
associate-*l/48.0%
div-inv48.1%
fma-neg48.1%
distribute-rgt-neg-in48.1%
Applied egg-rr48.1%
Taylor expanded in c around 0 83.9%
+-commutative83.9%
neg-mul-183.9%
unsub-neg83.9%
associate-/l*93.6%
Simplified93.6%
Final simplification85.8%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* b c) (* d a)) (+ (* c c) (* d d)))) (t_1 (/ b (/ d c))))
(if (<= d -6e+119)
(/ (- a t_1) (hypot c d))
(if (<= d -6.8e-151)
t_0
(if (<= d 3.3e+23)
(* (/ 1.0 c) (- b (/ a (/ c d))))
(if (<= d 1.9e+166) t_0 (/ (- t_1 a) (hypot c d))))))))
double code(double a, double b, double c, double d) {
double t_0 = ((b * c) - (d * a)) / ((c * c) + (d * d));
double t_1 = b / (d / c);
double tmp;
if (d <= -6e+119) {
tmp = (a - t_1) / hypot(c, d);
} else if (d <= -6.8e-151) {
tmp = t_0;
} else if (d <= 3.3e+23) {
tmp = (1.0 / c) * (b - (a / (c / d)));
} else if (d <= 1.9e+166) {
tmp = t_0;
} else {
tmp = (t_1 - a) / hypot(c, d);
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = ((b * c) - (d * a)) / ((c * c) + (d * d));
double t_1 = b / (d / c);
double tmp;
if (d <= -6e+119) {
tmp = (a - t_1) / Math.hypot(c, d);
} else if (d <= -6.8e-151) {
tmp = t_0;
} else if (d <= 3.3e+23) {
tmp = (1.0 / c) * (b - (a / (c / d)));
} else if (d <= 1.9e+166) {
tmp = t_0;
} else {
tmp = (t_1 - a) / Math.hypot(c, d);
}
return tmp;
}
def code(a, b, c, d): t_0 = ((b * c) - (d * a)) / ((c * c) + (d * d)) t_1 = b / (d / c) tmp = 0 if d <= -6e+119: tmp = (a - t_1) / math.hypot(c, d) elif d <= -6.8e-151: tmp = t_0 elif d <= 3.3e+23: tmp = (1.0 / c) * (b - (a / (c / d))) elif d <= 1.9e+166: tmp = t_0 else: tmp = (t_1 - a) / math.hypot(c, d) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(b * c) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))) t_1 = Float64(b / Float64(d / c)) tmp = 0.0 if (d <= -6e+119) tmp = Float64(Float64(a - t_1) / hypot(c, d)); elseif (d <= -6.8e-151) tmp = t_0; elseif (d <= 3.3e+23) tmp = Float64(Float64(1.0 / c) * Float64(b - Float64(a / Float64(c / d)))); elseif (d <= 1.9e+166) tmp = t_0; else tmp = Float64(Float64(t_1 - a) / hypot(c, d)); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((b * c) - (d * a)) / ((c * c) + (d * d)); t_1 = b / (d / c); tmp = 0.0; if (d <= -6e+119) tmp = (a - t_1) / hypot(c, d); elseif (d <= -6.8e-151) tmp = t_0; elseif (d <= 3.3e+23) tmp = (1.0 / c) * (b - (a / (c / d))); elseif (d <= 1.9e+166) tmp = t_0; else tmp = (t_1 - a) / hypot(c, d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(b * c), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -6e+119], N[(N[(a - t$95$1), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -6.8e-151], t$95$0, If[LessEqual[d, 3.3e+23], N[(N[(1.0 / c), $MachinePrecision] * N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.9e+166], t$95$0, N[(N[(t$95$1 - a), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b \cdot c - d \cdot a}{c \cdot c + d \cdot d}\\
t_1 := \frac{b}{\frac{d}{c}}\\
\mathbf{if}\;d \leq -6 \cdot 10^{+119}:\\
\;\;\;\;\frac{a - t_1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq -6.8 \cdot 10^{-151}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 3.3 \cdot 10^{+23}:\\
\;\;\;\;\frac{1}{c} \cdot \left(b - \frac{a}{\frac{c}{d}}\right)\\
\mathbf{elif}\;d \leq 1.9 \cdot 10^{+166}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{t_1 - a}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if d < -6.00000000000000002e119Initial program 36.6%
fma-def36.6%
*-un-lft-identity36.6%
add-sqr-sqrt36.6%
times-frac36.7%
fma-def36.7%
hypot-def36.7%
fma-def36.7%
hypot-def61.7%
Applied egg-rr61.7%
*-commutative61.7%
associate-*l/61.7%
div-inv61.8%
fma-neg61.8%
distribute-rgt-neg-in61.8%
Applied egg-rr61.8%
Taylor expanded in d around -inf 85.9%
mul-1-neg85.9%
unsub-neg85.9%
associate-/l*85.8%
Simplified85.8%
if -6.00000000000000002e119 < d < -6.8000000000000005e-151 or 3.30000000000000029e23 < d < 1.90000000000000003e166Initial program 81.2%
if -6.8000000000000005e-151 < d < 3.30000000000000029e23Initial program 68.6%
fma-def68.6%
*-un-lft-identity68.6%
add-sqr-sqrt68.6%
times-frac68.6%
fma-def68.6%
hypot-def68.6%
fma-def68.6%
hypot-def84.1%
Applied egg-rr84.1%
Taylor expanded in c around inf 54.7%
mul-1-neg54.7%
unsub-neg54.7%
associate-/l*54.7%
Simplified54.7%
Taylor expanded in c around inf 87.8%
if 1.90000000000000003e166 < d Initial program 12.1%
fma-def12.1%
*-un-lft-identity12.1%
add-sqr-sqrt12.1%
times-frac12.1%
fma-def12.1%
hypot-def12.1%
fma-def12.1%
hypot-def48.0%
Applied egg-rr48.0%
*-commutative48.0%
associate-*l/48.0%
div-inv48.1%
fma-neg48.1%
distribute-rgt-neg-in48.1%
Applied egg-rr48.1%
Taylor expanded in c around 0 83.9%
+-commutative83.9%
neg-mul-183.9%
unsub-neg83.9%
associate-/l*93.6%
Simplified93.6%
Final simplification85.8%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* b c) (* d a)) (+ (* c c) (* d d)))))
(if (<= d -3.65e+118)
(/ (- a (/ (* b c) d)) (hypot c d))
(if (<= d -9.5e-150)
t_0
(if (<= d 3.3e+23)
(* (/ 1.0 c) (- b (/ a (/ c d))))
(if (<= d 1.9e+166) t_0 (/ (- (/ b (/ d c)) a) (hypot c d))))))))
double code(double a, double b, double c, double d) {
double t_0 = ((b * c) - (d * a)) / ((c * c) + (d * d));
double tmp;
if (d <= -3.65e+118) {
tmp = (a - ((b * c) / d)) / hypot(c, d);
} else if (d <= -9.5e-150) {
tmp = t_0;
} else if (d <= 3.3e+23) {
tmp = (1.0 / c) * (b - (a / (c / d)));
} else if (d <= 1.9e+166) {
tmp = t_0;
} else {
tmp = ((b / (d / c)) - a) / hypot(c, d);
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = ((b * c) - (d * a)) / ((c * c) + (d * d));
double tmp;
if (d <= -3.65e+118) {
tmp = (a - ((b * c) / d)) / Math.hypot(c, d);
} else if (d <= -9.5e-150) {
tmp = t_0;
} else if (d <= 3.3e+23) {
tmp = (1.0 / c) * (b - (a / (c / d)));
} else if (d <= 1.9e+166) {
tmp = t_0;
} else {
tmp = ((b / (d / c)) - a) / Math.hypot(c, d);
}
return tmp;
}
def code(a, b, c, d): t_0 = ((b * c) - (d * a)) / ((c * c) + (d * d)) tmp = 0 if d <= -3.65e+118: tmp = (a - ((b * c) / d)) / math.hypot(c, d) elif d <= -9.5e-150: tmp = t_0 elif d <= 3.3e+23: tmp = (1.0 / c) * (b - (a / (c / d))) elif d <= 1.9e+166: tmp = t_0 else: tmp = ((b / (d / c)) - a) / math.hypot(c, d) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(b * c) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (d <= -3.65e+118) tmp = Float64(Float64(a - Float64(Float64(b * c) / d)) / hypot(c, d)); elseif (d <= -9.5e-150) tmp = t_0; elseif (d <= 3.3e+23) tmp = Float64(Float64(1.0 / c) * Float64(b - Float64(a / Float64(c / d)))); elseif (d <= 1.9e+166) tmp = t_0; else tmp = Float64(Float64(Float64(b / Float64(d / c)) - a) / hypot(c, d)); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((b * c) - (d * a)) / ((c * c) + (d * d)); tmp = 0.0; if (d <= -3.65e+118) tmp = (a - ((b * c) / d)) / hypot(c, d); elseif (d <= -9.5e-150) tmp = t_0; elseif (d <= 3.3e+23) tmp = (1.0 / c) * (b - (a / (c / d))); elseif (d <= 1.9e+166) tmp = t_0; else tmp = ((b / (d / c)) - a) / hypot(c, d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(b * c), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -3.65e+118], N[(N[(a - N[(N[(b * c), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -9.5e-150], t$95$0, If[LessEqual[d, 3.3e+23], N[(N[(1.0 / c), $MachinePrecision] * N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.9e+166], t$95$0, N[(N[(N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b \cdot c - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -3.65 \cdot 10^{+118}:\\
\;\;\;\;\frac{a - \frac{b \cdot c}{d}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq -9.5 \cdot 10^{-150}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 3.3 \cdot 10^{+23}:\\
\;\;\;\;\frac{1}{c} \cdot \left(b - \frac{a}{\frac{c}{d}}\right)\\
\mathbf{elif}\;d \leq 1.9 \cdot 10^{+166}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{b}{\frac{d}{c}} - a}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if d < -3.6500000000000002e118Initial program 36.6%
fma-def36.6%
*-un-lft-identity36.6%
add-sqr-sqrt36.6%
times-frac36.7%
fma-def36.7%
hypot-def36.7%
fma-def36.7%
hypot-def61.7%
Applied egg-rr61.7%
*-commutative61.7%
associate-*l/61.7%
div-inv61.8%
fma-neg61.8%
distribute-rgt-neg-in61.8%
Applied egg-rr61.8%
Taylor expanded in d around -inf 85.9%
if -3.6500000000000002e118 < d < -9.50000000000000013e-150 or 3.30000000000000029e23 < d < 1.90000000000000003e166Initial program 81.2%
if -9.50000000000000013e-150 < d < 3.30000000000000029e23Initial program 68.6%
fma-def68.6%
*-un-lft-identity68.6%
add-sqr-sqrt68.6%
times-frac68.6%
fma-def68.6%
hypot-def68.6%
fma-def68.6%
hypot-def84.1%
Applied egg-rr84.1%
Taylor expanded in c around inf 54.7%
mul-1-neg54.7%
unsub-neg54.7%
associate-/l*54.7%
Simplified54.7%
Taylor expanded in c around inf 87.8%
if 1.90000000000000003e166 < d Initial program 12.1%
fma-def12.1%
*-un-lft-identity12.1%
add-sqr-sqrt12.1%
times-frac12.1%
fma-def12.1%
hypot-def12.1%
fma-def12.1%
hypot-def48.0%
Applied egg-rr48.0%
*-commutative48.0%
associate-*l/48.0%
div-inv48.1%
fma-neg48.1%
distribute-rgt-neg-in48.1%
Applied egg-rr48.1%
Taylor expanded in c around 0 83.9%
+-commutative83.9%
neg-mul-183.9%
unsub-neg83.9%
associate-/l*93.6%
Simplified93.6%
Final simplification85.8%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* b c) (* d a)) (+ (* c c) (* d d)))))
(if (<= d -1.65e+145)
(/ a (hypot c d))
(if (<= d -1.85e-150)
t_0
(if (<= d 3.3e+23)
(* (/ 1.0 c) (- b (/ a (/ c d))))
(if (<= d 2.5e+143) t_0 (* a (/ -1.0 (hypot c d)))))))))
double code(double a, double b, double c, double d) {
double t_0 = ((b * c) - (d * a)) / ((c * c) + (d * d));
double tmp;
if (d <= -1.65e+145) {
tmp = a / hypot(c, d);
} else if (d <= -1.85e-150) {
tmp = t_0;
} else if (d <= 3.3e+23) {
tmp = (1.0 / c) * (b - (a / (c / d)));
} else if (d <= 2.5e+143) {
tmp = t_0;
} else {
tmp = a * (-1.0 / hypot(c, d));
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = ((b * c) - (d * a)) / ((c * c) + (d * d));
double tmp;
if (d <= -1.65e+145) {
tmp = a / Math.hypot(c, d);
} else if (d <= -1.85e-150) {
tmp = t_0;
} else if (d <= 3.3e+23) {
tmp = (1.0 / c) * (b - (a / (c / d)));
} else if (d <= 2.5e+143) {
tmp = t_0;
} else {
tmp = a * (-1.0 / Math.hypot(c, d));
}
return tmp;
}
def code(a, b, c, d): t_0 = ((b * c) - (d * a)) / ((c * c) + (d * d)) tmp = 0 if d <= -1.65e+145: tmp = a / math.hypot(c, d) elif d <= -1.85e-150: tmp = t_0 elif d <= 3.3e+23: tmp = (1.0 / c) * (b - (a / (c / d))) elif d <= 2.5e+143: tmp = t_0 else: tmp = a * (-1.0 / math.hypot(c, d)) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(b * c) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (d <= -1.65e+145) tmp = Float64(a / hypot(c, d)); elseif (d <= -1.85e-150) tmp = t_0; elseif (d <= 3.3e+23) tmp = Float64(Float64(1.0 / c) * Float64(b - Float64(a / Float64(c / d)))); elseif (d <= 2.5e+143) tmp = t_0; else tmp = Float64(a * Float64(-1.0 / hypot(c, d))); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((b * c) - (d * a)) / ((c * c) + (d * d)); tmp = 0.0; if (d <= -1.65e+145) tmp = a / hypot(c, d); elseif (d <= -1.85e-150) tmp = t_0; elseif (d <= 3.3e+23) tmp = (1.0 / c) * (b - (a / (c / d))); elseif (d <= 2.5e+143) tmp = t_0; else tmp = a * (-1.0 / hypot(c, d)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(b * c), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.65e+145], N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.85e-150], t$95$0, If[LessEqual[d, 3.3e+23], N[(N[(1.0 / c), $MachinePrecision] * N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 2.5e+143], t$95$0, N[(a * N[(-1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b \cdot c - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -1.65 \cdot 10^{+145}:\\
\;\;\;\;\frac{a}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq -1.85 \cdot 10^{-150}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 3.3 \cdot 10^{+23}:\\
\;\;\;\;\frac{1}{c} \cdot \left(b - \frac{a}{\frac{c}{d}}\right)\\
\mathbf{elif}\;d \leq 2.5 \cdot 10^{+143}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;a \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if d < -1.65000000000000013e145Initial program 32.6%
fma-def32.6%
*-un-lft-identity32.6%
add-sqr-sqrt32.6%
times-frac32.6%
fma-def32.6%
hypot-def32.6%
fma-def32.6%
hypot-def59.3%
Applied egg-rr59.3%
*-commutative59.3%
associate-*l/59.3%
div-inv59.3%
fma-neg59.3%
distribute-rgt-neg-in59.3%
Applied egg-rr59.3%
Taylor expanded in d around -inf 82.2%
if -1.65000000000000013e145 < d < -1.85e-150 or 3.30000000000000029e23 < d < 2.50000000000000006e143Initial program 80.8%
if -1.85e-150 < d < 3.30000000000000029e23Initial program 68.6%
fma-def68.6%
*-un-lft-identity68.6%
add-sqr-sqrt68.6%
times-frac68.6%
fma-def68.6%
hypot-def68.6%
fma-def68.6%
hypot-def84.1%
Applied egg-rr84.1%
Taylor expanded in c around inf 54.7%
mul-1-neg54.7%
unsub-neg54.7%
associate-/l*54.7%
Simplified54.7%
Taylor expanded in c around inf 87.8%
if 2.50000000000000006e143 < d Initial program 22.5%
fma-def22.5%
*-un-lft-identity22.5%
add-sqr-sqrt22.5%
times-frac22.5%
fma-def22.5%
hypot-def22.5%
fma-def22.5%
hypot-def54.1%
Applied egg-rr54.1%
Taylor expanded in c around 0 75.7%
neg-mul-175.7%
Simplified75.7%
Final simplification83.0%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* b c) (* d a)) (+ (* c c) (* d d)))))
(if (<= d -4.15e+123)
(/ (- a (/ b (/ d c))) (hypot c d))
(if (<= d -2e-150)
t_0
(if (<= d 2.15e+24)
(* (/ 1.0 c) (- b (/ a (/ c d))))
(if (<= d 5e+141) t_0 (* a (/ -1.0 (hypot c d)))))))))
double code(double a, double b, double c, double d) {
double t_0 = ((b * c) - (d * a)) / ((c * c) + (d * d));
double tmp;
if (d <= -4.15e+123) {
tmp = (a - (b / (d / c))) / hypot(c, d);
} else if (d <= -2e-150) {
tmp = t_0;
} else if (d <= 2.15e+24) {
tmp = (1.0 / c) * (b - (a / (c / d)));
} else if (d <= 5e+141) {
tmp = t_0;
} else {
tmp = a * (-1.0 / hypot(c, d));
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = ((b * c) - (d * a)) / ((c * c) + (d * d));
double tmp;
if (d <= -4.15e+123) {
tmp = (a - (b / (d / c))) / Math.hypot(c, d);
} else if (d <= -2e-150) {
tmp = t_0;
} else if (d <= 2.15e+24) {
tmp = (1.0 / c) * (b - (a / (c / d)));
} else if (d <= 5e+141) {
tmp = t_0;
} else {
tmp = a * (-1.0 / Math.hypot(c, d));
}
return tmp;
}
def code(a, b, c, d): t_0 = ((b * c) - (d * a)) / ((c * c) + (d * d)) tmp = 0 if d <= -4.15e+123: tmp = (a - (b / (d / c))) / math.hypot(c, d) elif d <= -2e-150: tmp = t_0 elif d <= 2.15e+24: tmp = (1.0 / c) * (b - (a / (c / d))) elif d <= 5e+141: tmp = t_0 else: tmp = a * (-1.0 / math.hypot(c, d)) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(b * c) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (d <= -4.15e+123) tmp = Float64(Float64(a - Float64(b / Float64(d / c))) / hypot(c, d)); elseif (d <= -2e-150) tmp = t_0; elseif (d <= 2.15e+24) tmp = Float64(Float64(1.0 / c) * Float64(b - Float64(a / Float64(c / d)))); elseif (d <= 5e+141) tmp = t_0; else tmp = Float64(a * Float64(-1.0 / hypot(c, d))); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((b * c) - (d * a)) / ((c * c) + (d * d)); tmp = 0.0; if (d <= -4.15e+123) tmp = (a - (b / (d / c))) / hypot(c, d); elseif (d <= -2e-150) tmp = t_0; elseif (d <= 2.15e+24) tmp = (1.0 / c) * (b - (a / (c / d))); elseif (d <= 5e+141) tmp = t_0; else tmp = a * (-1.0 / hypot(c, d)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(b * c), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -4.15e+123], N[(N[(a - N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -2e-150], t$95$0, If[LessEqual[d, 2.15e+24], N[(N[(1.0 / c), $MachinePrecision] * N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5e+141], t$95$0, N[(a * N[(-1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b \cdot c - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -4.15 \cdot 10^{+123}:\\
\;\;\;\;\frac{a - \frac{b}{\frac{d}{c}}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq -2 \cdot 10^{-150}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 2.15 \cdot 10^{+24}:\\
\;\;\;\;\frac{1}{c} \cdot \left(b - \frac{a}{\frac{c}{d}}\right)\\
\mathbf{elif}\;d \leq 5 \cdot 10^{+141}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;a \cdot \frac{-1}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if d < -4.1499999999999999e123Initial program 36.6%
fma-def36.6%
*-un-lft-identity36.6%
add-sqr-sqrt36.6%
times-frac36.7%
fma-def36.7%
hypot-def36.7%
fma-def36.7%
hypot-def61.7%
Applied egg-rr61.7%
*-commutative61.7%
associate-*l/61.7%
div-inv61.8%
fma-neg61.8%
distribute-rgt-neg-in61.8%
Applied egg-rr61.8%
Taylor expanded in d around -inf 85.9%
mul-1-neg85.9%
unsub-neg85.9%
associate-/l*85.8%
Simplified85.8%
if -4.1499999999999999e123 < d < -2.00000000000000001e-150 or 2.14999999999999994e24 < d < 5.00000000000000025e141Initial program 80.4%
if -2.00000000000000001e-150 < d < 2.14999999999999994e24Initial program 68.6%
fma-def68.6%
*-un-lft-identity68.6%
add-sqr-sqrt68.6%
times-frac68.6%
fma-def68.6%
hypot-def68.6%
fma-def68.6%
hypot-def84.1%
Applied egg-rr84.1%
Taylor expanded in c around inf 54.7%
mul-1-neg54.7%
unsub-neg54.7%
associate-/l*54.7%
Simplified54.7%
Taylor expanded in c around inf 87.8%
if 5.00000000000000025e141 < d Initial program 22.5%
fma-def22.5%
*-un-lft-identity22.5%
add-sqr-sqrt22.5%
times-frac22.5%
fma-def22.5%
hypot-def22.5%
fma-def22.5%
hypot-def54.1%
Applied egg-rr54.1%
Taylor expanded in c around 0 75.7%
neg-mul-175.7%
Simplified75.7%
Final simplification83.3%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* b c) (* d a)) (+ (* c c) (* d d)))))
(if (<= d -2.5e+145)
(/ a (hypot c d))
(if (<= d -9.2e-150)
t_0
(if (<= d 3.3e+23)
(* (/ 1.0 c) (- b (/ a (/ c d))))
(if (<= d 1.15e+149) t_0 (/ (- a) d)))))))
double code(double a, double b, double c, double d) {
double t_0 = ((b * c) - (d * a)) / ((c * c) + (d * d));
double tmp;
if (d <= -2.5e+145) {
tmp = a / hypot(c, d);
} else if (d <= -9.2e-150) {
tmp = t_0;
} else if (d <= 3.3e+23) {
tmp = (1.0 / c) * (b - (a / (c / d)));
} else if (d <= 1.15e+149) {
tmp = t_0;
} else {
tmp = -a / d;
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = ((b * c) - (d * a)) / ((c * c) + (d * d));
double tmp;
if (d <= -2.5e+145) {
tmp = a / Math.hypot(c, d);
} else if (d <= -9.2e-150) {
tmp = t_0;
} else if (d <= 3.3e+23) {
tmp = (1.0 / c) * (b - (a / (c / d)));
} else if (d <= 1.15e+149) {
tmp = t_0;
} else {
tmp = -a / d;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((b * c) - (d * a)) / ((c * c) + (d * d)) tmp = 0 if d <= -2.5e+145: tmp = a / math.hypot(c, d) elif d <= -9.2e-150: tmp = t_0 elif d <= 3.3e+23: tmp = (1.0 / c) * (b - (a / (c / d))) elif d <= 1.15e+149: tmp = t_0 else: tmp = -a / d return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(b * c) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (d <= -2.5e+145) tmp = Float64(a / hypot(c, d)); elseif (d <= -9.2e-150) tmp = t_0; elseif (d <= 3.3e+23) tmp = Float64(Float64(1.0 / c) * Float64(b - Float64(a / Float64(c / d)))); elseif (d <= 1.15e+149) tmp = t_0; else tmp = Float64(Float64(-a) / d); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((b * c) - (d * a)) / ((c * c) + (d * d)); tmp = 0.0; if (d <= -2.5e+145) tmp = a / hypot(c, d); elseif (d <= -9.2e-150) tmp = t_0; elseif (d <= 3.3e+23) tmp = (1.0 / c) * (b - (a / (c / d))); elseif (d <= 1.15e+149) tmp = t_0; else tmp = -a / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(b * c), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -2.5e+145], N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -9.2e-150], t$95$0, If[LessEqual[d, 3.3e+23], N[(N[(1.0 / c), $MachinePrecision] * N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.15e+149], t$95$0, N[((-a) / d), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b \cdot c - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -2.5 \cdot 10^{+145}:\\
\;\;\;\;\frac{a}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq -9.2 \cdot 10^{-150}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 3.3 \cdot 10^{+23}:\\
\;\;\;\;\frac{1}{c} \cdot \left(b - \frac{a}{\frac{c}{d}}\right)\\
\mathbf{elif}\;d \leq 1.15 \cdot 10^{+149}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{-a}{d}\\
\end{array}
\end{array}
if d < -2.49999999999999983e145Initial program 32.6%
fma-def32.6%
*-un-lft-identity32.6%
add-sqr-sqrt32.6%
times-frac32.6%
fma-def32.6%
hypot-def32.6%
fma-def32.6%
hypot-def59.3%
Applied egg-rr59.3%
*-commutative59.3%
associate-*l/59.3%
div-inv59.3%
fma-neg59.3%
distribute-rgt-neg-in59.3%
Applied egg-rr59.3%
Taylor expanded in d around -inf 82.2%
if -2.49999999999999983e145 < d < -9.20000000000000011e-150 or 3.30000000000000029e23 < d < 1.1499999999999999e149Initial program 81.0%
if -9.20000000000000011e-150 < d < 3.30000000000000029e23Initial program 68.6%
fma-def68.6%
*-un-lft-identity68.6%
add-sqr-sqrt68.6%
times-frac68.6%
fma-def68.6%
hypot-def68.6%
fma-def68.6%
hypot-def84.1%
Applied egg-rr84.1%
Taylor expanded in c around inf 54.7%
mul-1-neg54.7%
unsub-neg54.7%
associate-/l*54.7%
Simplified54.7%
Taylor expanded in c around inf 87.8%
if 1.1499999999999999e149 < d Initial program 20.1%
Taylor expanded in c around 0 74.9%
associate-*r/74.9%
neg-mul-174.9%
Simplified74.9%
Final simplification82.9%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- a) d)) (t_1 (/ (- (* b c) (* d a)) (+ (* c c) (* d d)))))
(if (<= d -2.05e+145)
t_0
(if (<= d -1.9e-150)
t_1
(if (<= d 3.3e+23)
(* (/ 1.0 c) (- b (/ a (/ c d))))
(if (<= d 1.6e+145) t_1 t_0))))))
double code(double a, double b, double c, double d) {
double t_0 = -a / d;
double t_1 = ((b * c) - (d * a)) / ((c * c) + (d * d));
double tmp;
if (d <= -2.05e+145) {
tmp = t_0;
} else if (d <= -1.9e-150) {
tmp = t_1;
} else if (d <= 3.3e+23) {
tmp = (1.0 / c) * (b - (a / (c / d)));
} else if (d <= 1.6e+145) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = -a / d
t_1 = ((b * c) - (d * a)) / ((c * c) + (d * d))
if (d <= (-2.05d+145)) then
tmp = t_0
else if (d <= (-1.9d-150)) then
tmp = t_1
else if (d <= 3.3d+23) then
tmp = (1.0d0 / c) * (b - (a / (c / d)))
else if (d <= 1.6d+145) then
tmp = t_1
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 t_1 = ((b * c) - (d * a)) / ((c * c) + (d * d));
double tmp;
if (d <= -2.05e+145) {
tmp = t_0;
} else if (d <= -1.9e-150) {
tmp = t_1;
} else if (d <= 3.3e+23) {
tmp = (1.0 / c) * (b - (a / (c / d)));
} else if (d <= 1.6e+145) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = -a / d t_1 = ((b * c) - (d * a)) / ((c * c) + (d * d)) tmp = 0 if d <= -2.05e+145: tmp = t_0 elif d <= -1.9e-150: tmp = t_1 elif d <= 3.3e+23: tmp = (1.0 / c) * (b - (a / (c / d))) elif d <= 1.6e+145: tmp = t_1 else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(-a) / d) t_1 = Float64(Float64(Float64(b * c) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (d <= -2.05e+145) tmp = t_0; elseif (d <= -1.9e-150) tmp = t_1; elseif (d <= 3.3e+23) tmp = Float64(Float64(1.0 / c) * Float64(b - Float64(a / Float64(c / d)))); elseif (d <= 1.6e+145) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = -a / d; t_1 = ((b * c) - (d * a)) / ((c * c) + (d * d)); tmp = 0.0; if (d <= -2.05e+145) tmp = t_0; elseif (d <= -1.9e-150) tmp = t_1; elseif (d <= 3.3e+23) tmp = (1.0 / c) * (b - (a / (c / d))); elseif (d <= 1.6e+145) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[((-a) / d), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(b * c), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -2.05e+145], t$95$0, If[LessEqual[d, -1.9e-150], t$95$1, If[LessEqual[d, 3.3e+23], N[(N[(1.0 / c), $MachinePrecision] * N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.6e+145], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{-a}{d}\\
t_1 := \frac{b \cdot c - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -2.05 \cdot 10^{+145}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq -1.9 \cdot 10^{-150}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d \leq 3.3 \cdot 10^{+23}:\\
\;\;\;\;\frac{1}{c} \cdot \left(b - \frac{a}{\frac{c}{d}}\right)\\
\mathbf{elif}\;d \leq 1.6 \cdot 10^{+145}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if d < -2.0500000000000001e145 or 1.60000000000000004e145 < d Initial program 26.2%
Taylor expanded in c around 0 78.3%
associate-*r/78.3%
neg-mul-178.3%
Simplified78.3%
if -2.0500000000000001e145 < d < -1.8999999999999999e-150 or 3.30000000000000029e23 < d < 1.60000000000000004e145Initial program 81.0%
if -1.8999999999999999e-150 < d < 3.30000000000000029e23Initial program 68.6%
fma-def68.6%
*-un-lft-identity68.6%
add-sqr-sqrt68.6%
times-frac68.6%
fma-def68.6%
hypot-def68.6%
fma-def68.6%
hypot-def84.1%
Applied egg-rr84.1%
Taylor expanded in c around inf 54.7%
mul-1-neg54.7%
unsub-neg54.7%
associate-/l*54.7%
Simplified54.7%
Taylor expanded in c around inf 87.8%
Final simplification82.9%
(FPCore (a b c d) :precision binary64 (if (or (<= d -5.5e+52) (not (<= d 9.5e+28))) (/ (- a) d) (* (/ 1.0 c) (- b (/ a (/ c d))))))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -5.5e+52) || !(d <= 9.5e+28)) {
tmp = -a / d;
} else {
tmp = (1.0 / c) * (b - (a / (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 ((d <= (-5.5d+52)) .or. (.not. (d <= 9.5d+28))) then
tmp = -a / d
else
tmp = (1.0d0 / c) * (b - (a / (c / d)))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -5.5e+52) || !(d <= 9.5e+28)) {
tmp = -a / d;
} else {
tmp = (1.0 / c) * (b - (a / (c / d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -5.5e+52) or not (d <= 9.5e+28): tmp = -a / d else: tmp = (1.0 / c) * (b - (a / (c / d))) return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -5.5e+52) || !(d <= 9.5e+28)) tmp = Float64(Float64(-a) / d); else tmp = Float64(Float64(1.0 / c) * Float64(b - Float64(a / Float64(c / d)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -5.5e+52) || ~((d <= 9.5e+28))) tmp = -a / d; else tmp = (1.0 / c) * (b - (a / (c / d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -5.5e+52], N[Not[LessEqual[d, 9.5e+28]], $MachinePrecision]], N[((-a) / d), $MachinePrecision], N[(N[(1.0 / c), $MachinePrecision] * N[(b - N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -5.5 \cdot 10^{+52} \lor \neg \left(d \leq 9.5 \cdot 10^{+28}\right):\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{c} \cdot \left(b - \frac{a}{\frac{c}{d}}\right)\\
\end{array}
\end{array}
if d < -5.49999999999999996e52 or 9.49999999999999927e28 < d Initial program 51.2%
Taylor expanded in c around 0 67.4%
associate-*r/67.4%
neg-mul-167.4%
Simplified67.4%
if -5.49999999999999996e52 < d < 9.49999999999999927e28Initial program 71.7%
fma-def71.7%
*-un-lft-identity71.7%
add-sqr-sqrt71.7%
times-frac71.7%
fma-def71.7%
hypot-def71.7%
fma-def71.7%
hypot-def83.3%
Applied egg-rr83.3%
Taylor expanded in c around inf 51.1%
mul-1-neg51.1%
unsub-neg51.1%
associate-/l*51.2%
Simplified51.2%
Taylor expanded in c around inf 78.4%
Final simplification73.4%
(FPCore (a b c d) :precision binary64 (if (or (<= d -1.35e-44) (not (<= d 6e+29))) (/ (- a) d) (/ b c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.35e-44) || !(d <= 6e+29)) {
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 <= (-1.35d-44)) .or. (.not. (d <= 6d+29))) 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 <= -1.35e-44) || !(d <= 6e+29)) {
tmp = -a / d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -1.35e-44) or not (d <= 6e+29): tmp = -a / d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -1.35e-44) || !(d <= 6e+29)) 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 <= -1.35e-44) || ~((d <= 6e+29))) tmp = -a / d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -1.35e-44], N[Not[LessEqual[d, 6e+29]], $MachinePrecision]], N[((-a) / d), $MachinePrecision], N[(b / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.35 \cdot 10^{-44} \lor \neg \left(d \leq 6 \cdot 10^{+29}\right):\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if d < -1.35e-44 or 5.9999999999999998e29 < d Initial program 55.7%
Taylor expanded in c around 0 62.5%
associate-*r/62.5%
neg-mul-162.5%
Simplified62.5%
if -1.35e-44 < d < 5.9999999999999998e29Initial program 70.5%
Taylor expanded in c around inf 65.3%
Final simplification63.7%
(FPCore (a b c d) :precision binary64 (/ a c))
double code(double a, double b, double c, double d) {
return a / 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 = a / c
end function
public static double code(double a, double b, double c, double d) {
return a / c;
}
def code(a, b, c, d): return a / c
function code(a, b, c, d) return Float64(a / c) end
function tmp = code(a, b, c, d) tmp = a / c; end
code[a_, b_, c_, d_] := N[(a / c), $MachinePrecision]
\begin{array}{l}
\\
\frac{a}{c}
\end{array}
Initial program 62.5%
fma-def62.5%
*-un-lft-identity62.5%
add-sqr-sqrt62.5%
times-frac62.5%
fma-def62.5%
hypot-def62.5%
fma-def62.5%
hypot-def77.8%
Applied egg-rr77.8%
Taylor expanded in c around inf 35.3%
mul-1-neg35.3%
unsub-neg35.3%
associate-/l*36.6%
Simplified36.6%
Taylor expanded in d around -inf 9.8%
Final simplification9.8%
(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 62.5%
Taylor expanded in c around inf 43.4%
Final simplification43.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 2024024
(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))))