
(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 15 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))
(/ (- a) (/ (pow (hypot c d) 2.0) d))))
(t_1 (- (* (/ 1.0 (hypot c d)) (/ c (/ (hypot c d) b))) (/ a d))))
(if (<= d -1.75e+155)
t_1
(if (<= d -1.15e-135)
t_0
(if (<= d 5.8e-180)
(* (/ -1.0 c) (- (/ a (/ c d)) b))
(if (<= d 3.55e+90) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = fma((c / hypot(c, d)), (b / hypot(c, d)), (-a / (pow(hypot(c, d), 2.0) / d)));
double t_1 = ((1.0 / hypot(c, d)) * (c / (hypot(c, d) / b))) - (a / d);
double tmp;
if (d <= -1.75e+155) {
tmp = t_1;
} else if (d <= -1.15e-135) {
tmp = t_0;
} else if (d <= 5.8e-180) {
tmp = (-1.0 / c) * ((a / (c / d)) - b);
} else if (d <= 3.55e+90) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
function code(a, b, c, d) t_0 = fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(Float64(-a) / Float64((hypot(c, d) ^ 2.0) / d))) t_1 = Float64(Float64(Float64(1.0 / hypot(c, d)) * Float64(c / Float64(hypot(c, d) / b))) - Float64(a / d)) tmp = 0.0 if (d <= -1.75e+155) tmp = t_1; elseif (d <= -1.15e-135) tmp = t_0; elseif (d <= 5.8e-180) tmp = Float64(Float64(-1.0 / c) * Float64(Float64(a / Float64(c / d)) - b)); elseif (d <= 3.55e+90) tmp = t_0; else tmp = t_1; 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[((-a) / N[(N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(c / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.75e+155], t$95$1, If[LessEqual[d, -1.15e-135], t$95$0, If[LessEqual[d, 5.8e-180], N[(N[(-1.0 / c), $MachinePrecision] * N[(N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 3.55e+90], t$95$0, t$95$1]]]]]]
\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{-a}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}\right)\\
t_1 := \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{b}} - \frac{a}{d}\\
\mathbf{if}\;d \leq -1.75 \cdot 10^{+155}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d \leq -1.15 \cdot 10^{-135}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 5.8 \cdot 10^{-180}:\\
\;\;\;\;\frac{-1}{c} \cdot \left(\frac{a}{\frac{c}{d}} - b\right)\\
\mathbf{elif}\;d \leq 3.55 \cdot 10^{+90}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if d < -1.74999999999999992e155 or 3.54999999999999988e90 < d Initial program 36.6%
div-sub36.6%
sub-neg36.6%
*-un-lft-identity36.6%
add-sqr-sqrt36.6%
times-frac36.6%
fma-def36.6%
hypot-def36.6%
hypot-def49.2%
associate-/l*50.4%
add-sqr-sqrt50.4%
pow250.4%
hypot-def50.4%
Applied egg-rr50.4%
fma-neg50.4%
*-commutative50.4%
associate-/l*52.2%
associate-/r/51.0%
*-commutative51.0%
Simplified51.0%
Taylor expanded in d around inf 96.5%
if -1.74999999999999992e155 < d < -1.15e-135 or 5.79999999999999961e-180 < d < 3.54999999999999988e90Initial program 77.5%
div-sub76.7%
sub-neg76.7%
*-commutative76.7%
add-sqr-sqrt76.7%
times-frac78.8%
fma-def78.8%
hypot-def78.8%
hypot-def90.9%
associate-/l*95.8%
add-sqr-sqrt95.8%
pow295.8%
hypot-def95.8%
Applied egg-rr95.8%
if -1.15e-135 < d < 5.79999999999999961e-180Initial program 71.7%
*-un-lft-identity71.7%
add-sqr-sqrt71.7%
times-frac71.8%
hypot-def71.9%
hypot-def84.7%
Applied egg-rr84.7%
Taylor expanded in c around -inf 50.4%
+-commutative50.4%
neg-mul-150.4%
unsub-neg50.4%
associate-/l*51.9%
Simplified51.9%
Taylor expanded in c around -inf 94.5%
Final simplification95.7%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (* (/ 1.0 (hypot c d)) (/ c (/ (hypot c d) b))))
(t_1 (- t_0 (* d (/ a (pow (hypot c d) 2.0)))))
(t_2 (- t_0 (/ a d))))
(if (<= d -4.1e+89)
t_2
(if (<= d -1.55e-69)
t_1
(if (<= d 2.95e-170)
(* (/ -1.0 c) (- (/ a (/ c d)) b))
(if (<= d 1.85e+90) t_1 t_2))))))
double code(double a, double b, double c, double d) {
double t_0 = (1.0 / hypot(c, d)) * (c / (hypot(c, d) / b));
double t_1 = t_0 - (d * (a / pow(hypot(c, d), 2.0)));
double t_2 = t_0 - (a / d);
double tmp;
if (d <= -4.1e+89) {
tmp = t_2;
} else if (d <= -1.55e-69) {
tmp = t_1;
} else if (d <= 2.95e-170) {
tmp = (-1.0 / c) * ((a / (c / d)) - b);
} else if (d <= 1.85e+90) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = (1.0 / Math.hypot(c, d)) * (c / (Math.hypot(c, d) / b));
double t_1 = t_0 - (d * (a / Math.pow(Math.hypot(c, d), 2.0)));
double t_2 = t_0 - (a / d);
double tmp;
if (d <= -4.1e+89) {
tmp = t_2;
} else if (d <= -1.55e-69) {
tmp = t_1;
} else if (d <= 2.95e-170) {
tmp = (-1.0 / c) * ((a / (c / d)) - b);
} else if (d <= 1.85e+90) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
def code(a, b, c, d): t_0 = (1.0 / math.hypot(c, d)) * (c / (math.hypot(c, d) / b)) t_1 = t_0 - (d * (a / math.pow(math.hypot(c, d), 2.0))) t_2 = t_0 - (a / d) tmp = 0 if d <= -4.1e+89: tmp = t_2 elif d <= -1.55e-69: tmp = t_1 elif d <= 2.95e-170: tmp = (-1.0 / c) * ((a / (c / d)) - b) elif d <= 1.85e+90: tmp = t_1 else: tmp = t_2 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(1.0 / hypot(c, d)) * Float64(c / Float64(hypot(c, d) / b))) t_1 = Float64(t_0 - Float64(d * Float64(a / (hypot(c, d) ^ 2.0)))) t_2 = Float64(t_0 - Float64(a / d)) tmp = 0.0 if (d <= -4.1e+89) tmp = t_2; elseif (d <= -1.55e-69) tmp = t_1; elseif (d <= 2.95e-170) tmp = Float64(Float64(-1.0 / c) * Float64(Float64(a / Float64(c / d)) - b)); elseif (d <= 1.85e+90) tmp = t_1; else tmp = t_2; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (1.0 / hypot(c, d)) * (c / (hypot(c, d) / b)); t_1 = t_0 - (d * (a / (hypot(c, d) ^ 2.0))); t_2 = t_0 - (a / d); tmp = 0.0; if (d <= -4.1e+89) tmp = t_2; elseif (d <= -1.55e-69) tmp = t_1; elseif (d <= 2.95e-170) tmp = (-1.0 / c) * ((a / (c / d)) - b); elseif (d <= 1.85e+90) tmp = t_1; else tmp = t_2; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(c / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 - N[(d * N[(a / N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 - N[(a / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -4.1e+89], t$95$2, If[LessEqual[d, -1.55e-69], t$95$1, If[LessEqual[d, 2.95e-170], N[(N[(-1.0 / c), $MachinePrecision] * N[(N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.85e+90], t$95$1, t$95$2]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{b}}\\
t_1 := t_0 - d \cdot \frac{a}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\\
t_2 := t_0 - \frac{a}{d}\\
\mathbf{if}\;d \leq -4.1 \cdot 10^{+89}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;d \leq -1.55 \cdot 10^{-69}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d \leq 2.95 \cdot 10^{-170}:\\
\;\;\;\;\frac{-1}{c} \cdot \left(\frac{a}{\frac{c}{d}} - b\right)\\
\mathbf{elif}\;d \leq 1.85 \cdot 10^{+90}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if d < -4.09999999999999985e89 or 1.85e90 < d Initial program 45.0%
div-sub45.0%
sub-neg45.0%
*-un-lft-identity45.0%
add-sqr-sqrt45.0%
times-frac45.0%
fma-def45.0%
hypot-def45.0%
hypot-def55.7%
associate-/l*57.9%
add-sqr-sqrt57.9%
pow257.9%
hypot-def57.9%
Applied egg-rr57.9%
fma-neg57.9%
*-commutative57.9%
associate-/l*59.4%
associate-/r/57.2%
*-commutative57.2%
Simplified57.2%
Taylor expanded in d around inf 97.0%
if -4.09999999999999985e89 < d < -1.55e-69 or 2.9499999999999999e-170 < d < 1.85e90Initial program 75.0%
div-sub74.0%
sub-neg74.0%
*-un-lft-identity74.0%
add-sqr-sqrt74.0%
times-frac73.9%
fma-def73.9%
hypot-def73.9%
hypot-def80.2%
associate-/l*85.2%
add-sqr-sqrt85.2%
pow285.2%
hypot-def85.2%
Applied egg-rr85.2%
fma-neg85.2%
*-commutative85.2%
associate-/l*95.4%
associate-/r/93.2%
*-commutative93.2%
Simplified93.2%
if -1.55e-69 < d < 2.9499999999999999e-170Initial program 73.2%
*-un-lft-identity73.2%
add-sqr-sqrt73.2%
times-frac73.2%
hypot-def73.2%
hypot-def84.3%
Applied egg-rr84.3%
Taylor expanded in c around -inf 51.4%
+-commutative51.4%
neg-mul-151.4%
unsub-neg51.4%
associate-/l*52.6%
Simplified52.6%
Taylor expanded in c around -inf 92.8%
Final simplification94.4%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* c b) (* d a))))
(if (<= (/ t_0 (+ (* c c) (* d d))) 5e+280)
(* (/ 1.0 (hypot c d)) (/ t_0 (hypot c d)))
(* (/ -1.0 c) (- (/ a (/ c d)) b)))))
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))) <= 5e+280) {
tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
} else {
tmp = (-1.0 / c) * ((a / (c / d)) - b);
}
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))) <= 5e+280) {
tmp = (1.0 / Math.hypot(c, d)) * (t_0 / Math.hypot(c, d));
} else {
tmp = (-1.0 / c) * ((a / (c / d)) - b);
}
return tmp;
}
def code(a, b, c, d): t_0 = (c * b) - (d * a) tmp = 0 if (t_0 / ((c * c) + (d * d))) <= 5e+280: tmp = (1.0 / math.hypot(c, d)) * (t_0 / math.hypot(c, d)) else: tmp = (-1.0 / c) * ((a / (c / d)) - b) 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))) <= 5e+280) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(t_0 / hypot(c, d))); else tmp = Float64(Float64(-1.0 / c) * Float64(Float64(a / Float64(c / d)) - b)); 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))) <= 5e+280) tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d)); else tmp = (-1.0 / c) * ((a / (c / d)) - b); 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], 5e+280], 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[(N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision] - b), $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 5 \cdot 10^{+280}:\\
\;\;\;\;\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(\frac{a}{\frac{c}{d}} - b\right)\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 5.0000000000000002e280Initial program 80.0%
*-un-lft-identity80.0%
add-sqr-sqrt80.0%
times-frac80.0%
hypot-def80.0%
hypot-def96.7%
Applied egg-rr96.7%
if 5.0000000000000002e280 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 16.6%
*-un-lft-identity16.6%
add-sqr-sqrt16.6%
times-frac16.6%
hypot-def16.6%
hypot-def24.3%
Applied egg-rr24.3%
Taylor expanded in c around -inf 32.9%
+-commutative32.9%
neg-mul-132.9%
unsub-neg32.9%
associate-/l*36.1%
Simplified36.1%
Taylor expanded in c around -inf 63.0%
Final simplification88.4%
(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))) 5e+280)
(* t_0 (/ t_1 (hypot c d)))
(- (* t_0 (/ c (/ (hypot c d) b))) (/ a 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))) <= 5e+280) {
tmp = t_0 * (t_1 / hypot(c, d));
} else {
tmp = (t_0 * (c / (hypot(c, d) / b))) - (a / 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))) <= 5e+280) {
tmp = t_0 * (t_1 / Math.hypot(c, d));
} else {
tmp = (t_0 * (c / (Math.hypot(c, d) / b))) - (a / 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))) <= 5e+280: tmp = t_0 * (t_1 / math.hypot(c, d)) else: tmp = (t_0 * (c / (math.hypot(c, d) / b))) - (a / 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))) <= 5e+280) tmp = Float64(t_0 * Float64(t_1 / hypot(c, d))); else tmp = Float64(Float64(t_0 * Float64(c / Float64(hypot(c, d) / b))) - Float64(a / 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))) <= 5e+280) tmp = t_0 * (t_1 / hypot(c, d)); else tmp = (t_0 * (c / (hypot(c, d) / b))) - (a / 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], 5e+280], 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[(a / d), $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 5 \cdot 10^{+280}:\\
\;\;\;\;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}} - \frac{a}{d}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 5.0000000000000002e280Initial program 80.0%
*-un-lft-identity80.0%
add-sqr-sqrt80.0%
times-frac80.0%
hypot-def80.0%
hypot-def96.7%
Applied egg-rr96.7%
if 5.0000000000000002e280 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 16.6%
div-sub6.7%
sub-neg6.7%
*-un-lft-identity6.7%
add-sqr-sqrt6.7%
times-frac6.7%
fma-def6.7%
hypot-def6.7%
hypot-def12.4%
associate-/l*15.5%
add-sqr-sqrt15.5%
pow215.5%
hypot-def15.5%
Applied egg-rr15.5%
fma-neg15.5%
*-commutative15.5%
associate-/l*50.7%
associate-/r/50.7%
*-commutative50.7%
Simplified50.7%
Taylor expanded in d around inf 67.5%
Final simplification89.5%
(FPCore (a b c d) :precision binary64 (if (<= (/ (- (* c b) (* d a)) (+ (* c c) (* d d))) 5e+280) (/ (/ (- (* d a) (* c b)) (hypot c d)) (- (hypot c d))) (- (* (/ 1.0 (hypot c d)) (/ c (/ (hypot c d) b))) (/ a d))))
double code(double a, double b, double c, double d) {
double tmp;
if ((((c * b) - (d * a)) / ((c * c) + (d * d))) <= 5e+280) {
tmp = (((d * a) - (c * b)) / hypot(c, d)) / -hypot(c, d);
} else {
tmp = ((1.0 / hypot(c, d)) * (c / (hypot(c, d) / b))) - (a / d);
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double tmp;
if ((((c * b) - (d * a)) / ((c * c) + (d * d))) <= 5e+280) {
tmp = (((d * a) - (c * b)) / Math.hypot(c, d)) / -Math.hypot(c, d);
} else {
tmp = ((1.0 / Math.hypot(c, d)) * (c / (Math.hypot(c, d) / b))) - (a / d);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (((c * b) - (d * a)) / ((c * c) + (d * d))) <= 5e+280: tmp = (((d * a) - (c * b)) / math.hypot(c, d)) / -math.hypot(c, d) else: tmp = ((1.0 / math.hypot(c, d)) * (c / (math.hypot(c, d) / b))) - (a / d) return tmp
function code(a, b, c, d) tmp = 0.0 if (Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))) <= 5e+280) tmp = Float64(Float64(Float64(Float64(d * a) - Float64(c * b)) / hypot(c, d)) / Float64(-hypot(c, d))); else tmp = Float64(Float64(Float64(1.0 / hypot(c, d)) * Float64(c / Float64(hypot(c, d) / b))) - Float64(a / d)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((((c * b) - (d * a)) / ((c * c) + (d * d))) <= 5e+280) tmp = (((d * a) - (c * b)) / hypot(c, d)) / -hypot(c, d); else tmp = ((1.0 / hypot(c, d)) * (c / (hypot(c, d) / b))) - (a / d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e+280], N[(N[(N[(N[(d * a), $MachinePrecision] - N[(c * b), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] / (-N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision])), $MachinePrecision], N[(N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(c / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d} \leq 5 \cdot 10^{+280}:\\
\;\;\;\;\frac{\frac{d \cdot a - c \cdot b}{\mathsf{hypot}\left(c, d\right)}}{-\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{b}} - \frac{a}{d}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 5.0000000000000002e280Initial program 80.0%
*-un-lft-identity80.0%
add-sqr-sqrt80.0%
times-frac80.0%
hypot-def80.0%
hypot-def96.7%
Applied egg-rr96.7%
associate-*l/96.8%
*-un-lft-identity96.8%
frac-2neg96.8%
fma-neg96.8%
distribute-rgt-neg-in96.8%
Applied egg-rr96.8%
distribute-neg-frac96.8%
fma-def96.8%
+-commutative96.8%
distribute-neg-in96.8%
distribute-rgt-neg-out96.8%
remove-double-neg96.8%
*-commutative96.8%
distribute-rgt-neg-in96.8%
Simplified96.8%
if 5.0000000000000002e280 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 16.6%
div-sub6.7%
sub-neg6.7%
*-un-lft-identity6.7%
add-sqr-sqrt6.7%
times-frac6.7%
fma-def6.7%
hypot-def6.7%
hypot-def12.4%
associate-/l*15.5%
add-sqr-sqrt15.5%
pow215.5%
hypot-def15.5%
Applied egg-rr15.5%
fma-neg15.5%
*-commutative15.5%
associate-/l*50.7%
associate-/r/50.7%
*-commutative50.7%
Simplified50.7%
Taylor expanded in d around inf 67.5%
Final simplification89.6%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (* (- (* c b) (* d a)) (pow (hypot c d) -2.0)))
(t_1 (/ b (/ d c)))
(t_2 (- (hypot c d))))
(if (<= d -3.4e+143)
(/ (- t_1 a) t_2)
(if (<= d -6.9e-74)
t_0
(if (<= d 6.8e-105)
(* (/ -1.0 c) (- (/ a (/ c d)) b))
(if (<= d 7.5e+28) t_0 (/ (- a t_1) t_2)))))))
double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) * pow(hypot(c, d), -2.0);
double t_1 = b / (d / c);
double t_2 = -hypot(c, d);
double tmp;
if (d <= -3.4e+143) {
tmp = (t_1 - a) / t_2;
} else if (d <= -6.9e-74) {
tmp = t_0;
} else if (d <= 6.8e-105) {
tmp = (-1.0 / c) * ((a / (c / d)) - b);
} else if (d <= 7.5e+28) {
tmp = t_0;
} else {
tmp = (a - t_1) / t_2;
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) * Math.pow(Math.hypot(c, d), -2.0);
double t_1 = b / (d / c);
double t_2 = -Math.hypot(c, d);
double tmp;
if (d <= -3.4e+143) {
tmp = (t_1 - a) / t_2;
} else if (d <= -6.9e-74) {
tmp = t_0;
} else if (d <= 6.8e-105) {
tmp = (-1.0 / c) * ((a / (c / d)) - b);
} else if (d <= 7.5e+28) {
tmp = t_0;
} else {
tmp = (a - t_1) / t_2;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((c * b) - (d * a)) * math.pow(math.hypot(c, d), -2.0) t_1 = b / (d / c) t_2 = -math.hypot(c, d) tmp = 0 if d <= -3.4e+143: tmp = (t_1 - a) / t_2 elif d <= -6.9e-74: tmp = t_0 elif d <= 6.8e-105: tmp = (-1.0 / c) * ((a / (c / d)) - b) elif d <= 7.5e+28: tmp = t_0 else: tmp = (a - t_1) / t_2 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(c * b) - Float64(d * a)) * (hypot(c, d) ^ -2.0)) t_1 = Float64(b / Float64(d / c)) t_2 = Float64(-hypot(c, d)) tmp = 0.0 if (d <= -3.4e+143) tmp = Float64(Float64(t_1 - a) / t_2); elseif (d <= -6.9e-74) tmp = t_0; elseif (d <= 6.8e-105) tmp = Float64(Float64(-1.0 / c) * Float64(Float64(a / Float64(c / d)) - b)); elseif (d <= 7.5e+28) tmp = t_0; else tmp = Float64(Float64(a - t_1) / t_2); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((c * b) - (d * a)) * (hypot(c, d) ^ -2.0); t_1 = b / (d / c); t_2 = -hypot(c, d); tmp = 0.0; if (d <= -3.4e+143) tmp = (t_1 - a) / t_2; elseif (d <= -6.9e-74) tmp = t_0; elseif (d <= 6.8e-105) tmp = (-1.0 / c) * ((a / (c / d)) - b); elseif (d <= 7.5e+28) tmp = t_0; else tmp = (a - t_1) / t_2; 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[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = (-N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision])}, If[LessEqual[d, -3.4e+143], N[(N[(t$95$1 - a), $MachinePrecision] / t$95$2), $MachinePrecision], If[LessEqual[d, -6.9e-74], t$95$0, If[LessEqual[d, 6.8e-105], N[(N[(-1.0 / c), $MachinePrecision] * N[(N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 7.5e+28], t$95$0, N[(N[(a - t$95$1), $MachinePrecision] / t$95$2), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(c \cdot b - d \cdot a\right) \cdot {\left(\mathsf{hypot}\left(c, d\right)\right)}^{-2}\\
t_1 := \frac{b}{\frac{d}{c}}\\
t_2 := -\mathsf{hypot}\left(c, d\right)\\
\mathbf{if}\;d \leq -3.4 \cdot 10^{+143}:\\
\;\;\;\;\frac{t_1 - a}{t_2}\\
\mathbf{elif}\;d \leq -6.9 \cdot 10^{-74}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 6.8 \cdot 10^{-105}:\\
\;\;\;\;\frac{-1}{c} \cdot \left(\frac{a}{\frac{c}{d}} - b\right)\\
\mathbf{elif}\;d \leq 7.5 \cdot 10^{+28}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{a - t_1}{t_2}\\
\end{array}
\end{array}
if d < -3.39999999999999982e143Initial program 39.9%
*-un-lft-identity39.9%
add-sqr-sqrt39.9%
times-frac40.0%
hypot-def40.0%
hypot-def72.0%
Applied egg-rr72.0%
associate-*l/72.0%
*-un-lft-identity72.0%
frac-2neg72.0%
fma-neg72.1%
distribute-rgt-neg-in72.1%
Applied egg-rr72.1%
distribute-neg-frac72.1%
fma-def72.0%
+-commutative72.0%
distribute-neg-in72.0%
distribute-rgt-neg-out72.0%
remove-double-neg72.0%
*-commutative72.0%
distribute-rgt-neg-in72.0%
Simplified72.0%
Taylor expanded in d around -inf 91.8%
+-commutative91.8%
mul-1-neg91.8%
unsub-neg91.8%
associate-/l*92.0%
Simplified92.0%
if -3.39999999999999982e143 < d < -6.89999999999999981e-74 or 6.79999999999999984e-105 < d < 7.4999999999999998e28Initial program 82.9%
*-un-lft-identity82.9%
add-sqr-sqrt82.9%
times-frac82.7%
hypot-def82.7%
hypot-def87.8%
Applied egg-rr87.8%
frac-times82.9%
*-un-lft-identity82.9%
*-commutative82.9%
unpow282.9%
expm1-log1p-u66.1%
expm1-udef37.1%
div-inv37.1%
*-commutative37.1%
fma-neg37.1%
distribute-rgt-neg-in37.1%
pow-flip37.1%
metadata-eval37.1%
Applied egg-rr37.1%
expm1-def66.1%
expm1-log1p83.0%
fma-def83.0%
distribute-rgt-neg-out83.0%
unsub-neg83.0%
*-commutative83.0%
Simplified83.0%
if -6.89999999999999981e-74 < d < 6.79999999999999984e-105Initial program 70.3%
*-un-lft-identity70.3%
add-sqr-sqrt70.3%
times-frac70.4%
hypot-def70.4%
hypot-def81.1%
Applied egg-rr81.1%
Taylor expanded in c around -inf 46.4%
+-commutative46.4%
neg-mul-146.4%
unsub-neg46.4%
associate-/l*47.5%
Simplified47.5%
Taylor expanded in c around -inf 88.5%
if 7.4999999999999998e28 < d Initial program 46.5%
*-un-lft-identity46.5%
add-sqr-sqrt46.5%
times-frac46.4%
hypot-def46.4%
hypot-def68.0%
Applied egg-rr68.0%
associate-*l/68.1%
*-un-lft-identity68.1%
frac-2neg68.1%
fma-neg68.2%
distribute-rgt-neg-in68.2%
Applied egg-rr68.2%
distribute-neg-frac68.2%
fma-def68.1%
+-commutative68.1%
distribute-neg-in68.1%
distribute-rgt-neg-out68.1%
remove-double-neg68.1%
*-commutative68.1%
distribute-rgt-neg-in68.1%
Simplified68.1%
Taylor expanded in d around inf 88.3%
mul-1-neg88.3%
unsub-neg88.3%
associate-/l*90.1%
Simplified90.1%
Final simplification87.8%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
(if (<= d -6.2e+143)
(/ (- a) d)
(if (<= d -1.45e-69)
t_0
(if (<= d 4.8e-106)
(* (/ -1.0 c) (- (/ a (/ c d)) b))
(if (<= d 7.5e+28) t_0 (/ (- a (/ b (/ d c))) (- (hypot 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 (d <= -6.2e+143) {
tmp = -a / d;
} else if (d <= -1.45e-69) {
tmp = t_0;
} else if (d <= 4.8e-106) {
tmp = (-1.0 / c) * ((a / (c / d)) - b);
} else if (d <= 7.5e+28) {
tmp = t_0;
} else {
tmp = (a - (b / (d / c))) / -hypot(c, d);
}
return tmp;
}
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 (d <= -6.2e+143) {
tmp = -a / d;
} else if (d <= -1.45e-69) {
tmp = t_0;
} else if (d <= 4.8e-106) {
tmp = (-1.0 / c) * ((a / (c / d)) - b);
} else if (d <= 7.5e+28) {
tmp = t_0;
} else {
tmp = (a - (b / (d / c))) / -Math.hypot(c, d);
}
return tmp;
}
def code(a, b, c, d): t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)) tmp = 0 if d <= -6.2e+143: tmp = -a / d elif d <= -1.45e-69: tmp = t_0 elif d <= 4.8e-106: tmp = (-1.0 / c) * ((a / (c / d)) - b) elif d <= 7.5e+28: tmp = t_0 else: tmp = (a - (b / (d / c))) / -math.hypot(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 (d <= -6.2e+143) tmp = Float64(Float64(-a) / d); elseif (d <= -1.45e-69) tmp = t_0; elseif (d <= 4.8e-106) tmp = Float64(Float64(-1.0 / c) * Float64(Float64(a / Float64(c / d)) - b)); elseif (d <= 7.5e+28) tmp = t_0; else tmp = Float64(Float64(a - Float64(b / Float64(d / c))) / Float64(-hypot(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 (d <= -6.2e+143) tmp = -a / d; elseif (d <= -1.45e-69) tmp = t_0; elseif (d <= 4.8e-106) tmp = (-1.0 / c) * ((a / (c / d)) - b); elseif (d <= 7.5e+28) tmp = t_0; else tmp = (a - (b / (d / c))) / -hypot(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[d, -6.2e+143], N[((-a) / d), $MachinePrecision], If[LessEqual[d, -1.45e-69], t$95$0, If[LessEqual[d, 4.8e-106], N[(N[(-1.0 / c), $MachinePrecision] * N[(N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 7.5e+28], t$95$0, N[(N[(a - N[(b / N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / (-N[Sqrt[c ^ 2 + d ^ 2], $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 -6.2 \cdot 10^{+143}:\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{elif}\;d \leq -1.45 \cdot 10^{-69}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 4.8 \cdot 10^{-106}:\\
\;\;\;\;\frac{-1}{c} \cdot \left(\frac{a}{\frac{c}{d}} - b\right)\\
\mathbf{elif}\;d \leq 7.5 \cdot 10^{+28}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{a - \frac{b}{\frac{d}{c}}}{-\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if d < -6.1999999999999998e143Initial program 39.9%
Taylor expanded in c around 0 79.1%
associate-*r/79.1%
neg-mul-179.1%
Simplified79.1%
if -6.1999999999999998e143 < d < -1.4499999999999999e-69 or 4.7999999999999995e-106 < d < 7.4999999999999998e28Initial program 82.4%
if -1.4499999999999999e-69 < d < 4.7999999999999995e-106Initial program 70.9%
*-un-lft-identity70.9%
add-sqr-sqrt70.9%
times-frac71.0%
hypot-def71.0%
hypot-def81.5%
Applied egg-rr81.5%
Taylor expanded in c around -inf 47.6%
+-commutative47.6%
neg-mul-147.6%
unsub-neg47.6%
associate-/l*48.6%
Simplified48.6%
Taylor expanded in c around -inf 88.8%
if 7.4999999999999998e28 < d Initial program 46.5%
*-un-lft-identity46.5%
add-sqr-sqrt46.5%
times-frac46.4%
hypot-def46.4%
hypot-def68.0%
Applied egg-rr68.0%
associate-*l/68.1%
*-un-lft-identity68.1%
frac-2neg68.1%
fma-neg68.2%
distribute-rgt-neg-in68.2%
Applied egg-rr68.2%
distribute-neg-frac68.2%
fma-def68.1%
+-commutative68.1%
distribute-neg-in68.1%
distribute-rgt-neg-out68.1%
remove-double-neg68.1%
*-commutative68.1%
distribute-rgt-neg-in68.1%
Simplified68.1%
Taylor expanded in d around inf 88.3%
mul-1-neg88.3%
unsub-neg88.3%
associate-/l*90.1%
Simplified90.1%
Final simplification86.0%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d))))
(t_1 (/ b (/ d c)))
(t_2 (- (hypot c d))))
(if (<= d -3.4e+143)
(/ (- t_1 a) t_2)
(if (<= d -1.45e-69)
t_0
(if (<= d 1.1e-104)
(* (/ -1.0 c) (- (/ a (/ c d)) b))
(if (<= d 7.5e+28) t_0 (/ (- a t_1) t_2)))))))
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 / (d / c);
double t_2 = -hypot(c, d);
double tmp;
if (d <= -3.4e+143) {
tmp = (t_1 - a) / t_2;
} else if (d <= -1.45e-69) {
tmp = t_0;
} else if (d <= 1.1e-104) {
tmp = (-1.0 / c) * ((a / (c / d)) - b);
} else if (d <= 7.5e+28) {
tmp = t_0;
} else {
tmp = (a - t_1) / t_2;
}
return tmp;
}
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 / (d / c);
double t_2 = -Math.hypot(c, d);
double tmp;
if (d <= -3.4e+143) {
tmp = (t_1 - a) / t_2;
} else if (d <= -1.45e-69) {
tmp = t_0;
} else if (d <= 1.1e-104) {
tmp = (-1.0 / c) * ((a / (c / d)) - b);
} else if (d <= 7.5e+28) {
tmp = t_0;
} else {
tmp = (a - t_1) / t_2;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)) t_1 = b / (d / c) t_2 = -math.hypot(c, d) tmp = 0 if d <= -3.4e+143: tmp = (t_1 - a) / t_2 elif d <= -1.45e-69: tmp = t_0 elif d <= 1.1e-104: tmp = (-1.0 / c) * ((a / (c / d)) - b) elif d <= 7.5e+28: tmp = t_0 else: tmp = (a - t_1) / t_2 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(b / Float64(d / c)) t_2 = Float64(-hypot(c, d)) tmp = 0.0 if (d <= -3.4e+143) tmp = Float64(Float64(t_1 - a) / t_2); elseif (d <= -1.45e-69) tmp = t_0; elseif (d <= 1.1e-104) tmp = Float64(Float64(-1.0 / c) * Float64(Float64(a / Float64(c / d)) - b)); elseif (d <= 7.5e+28) tmp = t_0; else tmp = Float64(Float64(a - t_1) / t_2); 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 / (d / c); t_2 = -hypot(c, d); tmp = 0.0; if (d <= -3.4e+143) tmp = (t_1 - a) / t_2; elseif (d <= -1.45e-69) tmp = t_0; elseif (d <= 1.1e-104) tmp = (-1.0 / c) * ((a / (c / d)) - b); elseif (d <= 7.5e+28) tmp = t_0; else tmp = (a - t_1) / t_2; 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[(b / N[(d / c), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = (-N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision])}, If[LessEqual[d, -3.4e+143], N[(N[(t$95$1 - a), $MachinePrecision] / t$95$2), $MachinePrecision], If[LessEqual[d, -1.45e-69], t$95$0, If[LessEqual[d, 1.1e-104], N[(N[(-1.0 / c), $MachinePrecision] * N[(N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 7.5e+28], t$95$0, N[(N[(a - t$95$1), $MachinePrecision] / t$95$2), $MachinePrecision]]]]]]]]
\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}{\frac{d}{c}}\\
t_2 := -\mathsf{hypot}\left(c, d\right)\\
\mathbf{if}\;d \leq -3.4 \cdot 10^{+143}:\\
\;\;\;\;\frac{t_1 - a}{t_2}\\
\mathbf{elif}\;d \leq -1.45 \cdot 10^{-69}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 1.1 \cdot 10^{-104}:\\
\;\;\;\;\frac{-1}{c} \cdot \left(\frac{a}{\frac{c}{d}} - b\right)\\
\mathbf{elif}\;d \leq 7.5 \cdot 10^{+28}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{a - t_1}{t_2}\\
\end{array}
\end{array}
if d < -3.39999999999999982e143Initial program 39.9%
*-un-lft-identity39.9%
add-sqr-sqrt39.9%
times-frac40.0%
hypot-def40.0%
hypot-def72.0%
Applied egg-rr72.0%
associate-*l/72.0%
*-un-lft-identity72.0%
frac-2neg72.0%
fma-neg72.1%
distribute-rgt-neg-in72.1%
Applied egg-rr72.1%
distribute-neg-frac72.1%
fma-def72.0%
+-commutative72.0%
distribute-neg-in72.0%
distribute-rgt-neg-out72.0%
remove-double-neg72.0%
*-commutative72.0%
distribute-rgt-neg-in72.0%
Simplified72.0%
Taylor expanded in d around -inf 91.8%
+-commutative91.8%
mul-1-neg91.8%
unsub-neg91.8%
associate-/l*92.0%
Simplified92.0%
if -3.39999999999999982e143 < d < -1.4499999999999999e-69 or 1.10000000000000006e-104 < d < 7.4999999999999998e28Initial program 82.4%
if -1.4499999999999999e-69 < d < 1.10000000000000006e-104Initial program 70.9%
*-un-lft-identity70.9%
add-sqr-sqrt70.9%
times-frac71.0%
hypot-def71.0%
hypot-def81.5%
Applied egg-rr81.5%
Taylor expanded in c around -inf 47.6%
+-commutative47.6%
neg-mul-147.6%
unsub-neg47.6%
associate-/l*48.6%
Simplified48.6%
Taylor expanded in c around -inf 88.8%
if 7.4999999999999998e28 < d Initial program 46.5%
*-un-lft-identity46.5%
add-sqr-sqrt46.5%
times-frac46.4%
hypot-def46.4%
hypot-def68.0%
Applied egg-rr68.0%
associate-*l/68.1%
*-un-lft-identity68.1%
frac-2neg68.1%
fma-neg68.2%
distribute-rgt-neg-in68.2%
Applied egg-rr68.2%
distribute-neg-frac68.2%
fma-def68.1%
+-commutative68.1%
distribute-neg-in68.1%
distribute-rgt-neg-out68.1%
remove-double-neg68.1%
*-commutative68.1%
distribute-rgt-neg-in68.1%
Simplified68.1%
Taylor expanded in d around inf 88.3%
mul-1-neg88.3%
unsub-neg88.3%
associate-/l*90.1%
Simplified90.1%
Final simplification87.7%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
(if (<= d -6.2e+143)
(/ (- a) d)
(if (<= d -1.65e-69)
t_0
(if (<= d 1.18e-105)
(* (/ -1.0 c) (- (/ a (/ c d)) b))
(if (<= d 1.8e+28) 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 <= -6.2e+143) {
tmp = -a / d;
} else if (d <= -1.65e-69) {
tmp = t_0;
} else if (d <= 1.18e-105) {
tmp = (-1.0 / c) * ((a / (c / d)) - b);
} else if (d <= 1.8e+28) {
tmp = t_0;
} else {
tmp = (b / (pow(d, 2.0) / c)) - (a / 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 (d <= (-6.2d+143)) then
tmp = -a / d
else if (d <= (-1.65d-69)) then
tmp = t_0
else if (d <= 1.18d-105) then
tmp = ((-1.0d0) / c) * ((a / (c / d)) - b)
else if (d <= 1.8d+28) then
tmp = t_0
else
tmp = (b / ((d ** 2.0d0) / c)) - (a / 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 (d <= -6.2e+143) {
tmp = -a / d;
} else if (d <= -1.65e-69) {
tmp = t_0;
} else if (d <= 1.18e-105) {
tmp = (-1.0 / c) * ((a / (c / d)) - b);
} else if (d <= 1.8e+28) {
tmp = t_0;
} else {
tmp = (b / (Math.pow(d, 2.0) / c)) - (a / d);
}
return tmp;
}
def code(a, b, c, d): t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)) tmp = 0 if d <= -6.2e+143: tmp = -a / d elif d <= -1.65e-69: tmp = t_0 elif d <= 1.18e-105: tmp = (-1.0 / c) * ((a / (c / d)) - b) elif d <= 1.8e+28: tmp = t_0 else: tmp = (b / (math.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 <= -6.2e+143) tmp = Float64(Float64(-a) / d); elseif (d <= -1.65e-69) tmp = t_0; elseif (d <= 1.18e-105) tmp = Float64(Float64(-1.0 / c) * Float64(Float64(a / Float64(c / d)) - b)); elseif (d <= 1.8e+28) tmp = t_0; else tmp = Float64(Float64(b / Float64((d ^ 2.0) / c)) - Float64(a / 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 (d <= -6.2e+143) tmp = -a / d; elseif (d <= -1.65e-69) tmp = t_0; elseif (d <= 1.18e-105) tmp = (-1.0 / c) * ((a / (c / d)) - b); elseif (d <= 1.8e+28) tmp = t_0; else tmp = (b / ((d ^ 2.0) / c)) - (a / 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[d, -6.2e+143], N[((-a) / d), $MachinePrecision], If[LessEqual[d, -1.65e-69], t$95$0, If[LessEqual[d, 1.18e-105], N[(N[(-1.0 / c), $MachinePrecision] * N[(N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.8e+28], 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 -6.2 \cdot 10^{+143}:\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{elif}\;d \leq -1.65 \cdot 10^{-69}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 1.18 \cdot 10^{-105}:\\
\;\;\;\;\frac{-1}{c} \cdot \left(\frac{a}{\frac{c}{d}} - b\right)\\
\mathbf{elif}\;d \leq 1.8 \cdot 10^{+28}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{\frac{{d}^{2}}{c}} - \frac{a}{d}\\
\end{array}
\end{array}
if d < -6.1999999999999998e143Initial program 39.9%
Taylor expanded in c around 0 79.1%
associate-*r/79.1%
neg-mul-179.1%
Simplified79.1%
if -6.1999999999999998e143 < d < -1.65e-69 or 1.1799999999999999e-105 < d < 1.8e28Initial program 82.4%
if -1.65e-69 < d < 1.1799999999999999e-105Initial program 70.9%
*-un-lft-identity70.9%
add-sqr-sqrt70.9%
times-frac71.0%
hypot-def71.0%
hypot-def81.5%
Applied egg-rr81.5%
Taylor expanded in c around -inf 47.6%
+-commutative47.6%
neg-mul-147.6%
unsub-neg47.6%
associate-/l*48.6%
Simplified48.6%
Taylor expanded in c around -inf 88.8%
if 1.8e28 < d Initial program 46.5%
Taylor expanded in c around 0 83.4%
+-commutative83.4%
mul-1-neg83.4%
unsub-neg83.4%
associate-/l*86.8%
Simplified86.8%
Final simplification85.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- a) d)) (t_1 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
(if (<= d -1.05e+144)
t_0
(if (<= d -1.45e-69)
t_1
(if (<= d 1.45e-105)
(* (/ -1.0 c) (- (/ a (/ c d)) b))
(if (<= d 1.72e+130) t_1 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 <= -1.05e+144) {
tmp = t_0;
} else if (d <= -1.45e-69) {
tmp = t_1;
} else if (d <= 1.45e-105) {
tmp = (-1.0 / c) * ((a / (c / d)) - b);
} else if (d <= 1.72e+130) {
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 = ((c * b) - (d * a)) / ((c * c) + (d * d))
if (d <= (-1.05d+144)) then
tmp = t_0
else if (d <= (-1.45d-69)) then
tmp = t_1
else if (d <= 1.45d-105) then
tmp = ((-1.0d0) / c) * ((a / (c / d)) - b)
else if (d <= 1.72d+130) 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 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double tmp;
if (d <= -1.05e+144) {
tmp = t_0;
} else if (d <= -1.45e-69) {
tmp = t_1;
} else if (d <= 1.45e-105) {
tmp = (-1.0 / c) * ((a / (c / d)) - b);
} else if (d <= 1.72e+130) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = -a / d t_1 = ((c * b) - (d * a)) / ((c * c) + (d * d)) tmp = 0 if d <= -1.05e+144: tmp = t_0 elif d <= -1.45e-69: tmp = t_1 elif d <= 1.45e-105: tmp = (-1.0 / c) * ((a / (c / d)) - b) elif d <= 1.72e+130: 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(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (d <= -1.05e+144) tmp = t_0; elseif (d <= -1.45e-69) tmp = t_1; elseif (d <= 1.45e-105) tmp = Float64(Float64(-1.0 / c) * Float64(Float64(a / Float64(c / d)) - b)); elseif (d <= 1.72e+130) 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 = ((c * b) - (d * a)) / ((c * c) + (d * d)); tmp = 0.0; if (d <= -1.05e+144) tmp = t_0; elseif (d <= -1.45e-69) tmp = t_1; elseif (d <= 1.45e-105) tmp = (-1.0 / c) * ((a / (c / d)) - b); elseif (d <= 1.72e+130) 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[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.05e+144], t$95$0, If[LessEqual[d, -1.45e-69], t$95$1, If[LessEqual[d, 1.45e-105], N[(N[(-1.0 / c), $MachinePrecision] * N[(N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.72e+130], t$95$1, t$95$0]]]]]]
\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 -1.05 \cdot 10^{+144}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq -1.45 \cdot 10^{-69}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d \leq 1.45 \cdot 10^{-105}:\\
\;\;\;\;\frac{-1}{c} \cdot \left(\frac{a}{\frac{c}{d}} - b\right)\\
\mathbf{elif}\;d \leq 1.72 \cdot 10^{+130}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if d < -1.04999999999999998e144 or 1.72000000000000008e130 < d Initial program 36.1%
Taylor expanded in c around 0 82.5%
associate-*r/82.5%
neg-mul-182.5%
Simplified82.5%
if -1.04999999999999998e144 < d < -1.4499999999999999e-69 or 1.45000000000000002e-105 < d < 1.72000000000000008e130Initial program 80.8%
if -1.4499999999999999e-69 < d < 1.45000000000000002e-105Initial program 70.9%
*-un-lft-identity70.9%
add-sqr-sqrt70.9%
times-frac71.0%
hypot-def71.0%
hypot-def81.5%
Applied egg-rr81.5%
Taylor expanded in c around -inf 47.6%
+-commutative47.6%
neg-mul-147.6%
unsub-neg47.6%
associate-/l*48.6%
Simplified48.6%
Taylor expanded in c around -inf 88.8%
Final simplification84.1%
(FPCore (a b c d) :precision binary64 (if (or (<= d -1.4e-31) (not (<= d 3.25e-68))) (/ (- a) d) (* (/ -1.0 c) (- (/ a (/ c d)) b))))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.4e-31) || !(d <= 3.25e-68)) {
tmp = -a / d;
} else {
tmp = (-1.0 / c) * ((a / (c / d)) - b);
}
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.4d-31)) .or. (.not. (d <= 3.25d-68))) then
tmp = -a / d
else
tmp = ((-1.0d0) / c) * ((a / (c / d)) - b)
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.4e-31) || !(d <= 3.25e-68)) {
tmp = -a / d;
} else {
tmp = (-1.0 / c) * ((a / (c / d)) - b);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -1.4e-31) or not (d <= 3.25e-68): tmp = -a / d else: tmp = (-1.0 / c) * ((a / (c / d)) - b) return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -1.4e-31) || !(d <= 3.25e-68)) tmp = Float64(Float64(-a) / d); else tmp = Float64(Float64(-1.0 / c) * Float64(Float64(a / Float64(c / d)) - b)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -1.4e-31) || ~((d <= 3.25e-68))) tmp = -a / d; else tmp = (-1.0 / c) * ((a / (c / d)) - b); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -1.4e-31], N[Not[LessEqual[d, 3.25e-68]], $MachinePrecision]], N[((-a) / d), $MachinePrecision], N[(N[(-1.0 / c), $MachinePrecision] * N[(N[(a / N[(c / d), $MachinePrecision]), $MachinePrecision] - b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.4 \cdot 10^{-31} \lor \neg \left(d \leq 3.25 \cdot 10^{-68}\right):\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{-1}{c} \cdot \left(\frac{a}{\frac{c}{d}} - b\right)\\
\end{array}
\end{array}
if d < -1.3999999999999999e-31 or 3.2499999999999999e-68 < d Initial program 59.3%
Taylor expanded in c around 0 68.8%
associate-*r/68.8%
neg-mul-168.8%
Simplified68.8%
if -1.3999999999999999e-31 < d < 3.2499999999999999e-68Initial program 71.0%
*-un-lft-identity71.0%
add-sqr-sqrt71.0%
times-frac71.0%
hypot-def71.1%
hypot-def82.2%
Applied egg-rr82.2%
Taylor expanded in c around -inf 45.8%
+-commutative45.8%
neg-mul-145.8%
unsub-neg45.8%
associate-/l*46.7%
Simplified46.7%
Taylor expanded in c around -inf 82.2%
Final simplification74.6%
(FPCore (a b c d) :precision binary64 (if (or (<= d -1.92e-60) (not (<= d 1.35e-69))) (/ (- a) d) (/ b c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.92e-60) || !(d <= 1.35e-69)) {
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.92d-60)) .or. (.not. (d <= 1.35d-69))) 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.92e-60) || !(d <= 1.35e-69)) {
tmp = -a / d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -1.92e-60) or not (d <= 1.35e-69): tmp = -a / d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -1.92e-60) || !(d <= 1.35e-69)) 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.92e-60) || ~((d <= 1.35e-69))) tmp = -a / d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -1.92e-60], N[Not[LessEqual[d, 1.35e-69]], $MachinePrecision]], N[((-a) / d), $MachinePrecision], N[(b / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.92 \cdot 10^{-60} \lor \neg \left(d \leq 1.35 \cdot 10^{-69}\right):\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if d < -1.9200000000000001e-60 or 1.3499999999999999e-69 < d Initial program 58.9%
Taylor expanded in c around 0 66.8%
associate-*r/66.8%
neg-mul-166.8%
Simplified66.8%
if -1.9200000000000001e-60 < d < 1.3499999999999999e-69Initial program 72.8%
Taylor expanded in c around inf 69.4%
Final simplification67.8%
(FPCore (a b c d) :precision binary64 (if (or (<= d -5.8e+129) (not (<= d 2.8e+183))) (/ a d) (/ b c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -5.8e+129) || !(d <= 2.8e+183)) {
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 <= (-5.8d+129)) .or. (.not. (d <= 2.8d+183))) 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 <= -5.8e+129) || !(d <= 2.8e+183)) {
tmp = a / d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -5.8e+129) or not (d <= 2.8e+183): tmp = a / d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -5.8e+129) || !(d <= 2.8e+183)) tmp = 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 <= -5.8e+129) || ~((d <= 2.8e+183))) tmp = a / d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -5.8e+129], N[Not[LessEqual[d, 2.8e+183]], $MachinePrecision]], N[(a / d), $MachinePrecision], N[(b / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -5.8 \cdot 10^{+129} \lor \neg \left(d \leq 2.8 \cdot 10^{+183}\right):\\
\;\;\;\;\frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if d < -5.80000000000000005e129 or 2.80000000000000018e183 < d Initial program 39.3%
*-un-lft-identity39.3%
add-sqr-sqrt39.3%
times-frac39.3%
hypot-def39.3%
hypot-def68.4%
Applied egg-rr68.4%
Taylor expanded in c around 0 60.5%
neg-mul-160.5%
Simplified60.5%
Taylor expanded in d around -inf 35.4%
if -5.80000000000000005e129 < d < 2.80000000000000018e183Initial program 72.9%
Taylor expanded in c around inf 48.7%
Final simplification45.3%
(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 64.4%
*-un-lft-identity64.4%
add-sqr-sqrt64.4%
times-frac64.4%
hypot-def64.4%
hypot-def78.8%
Applied egg-rr78.8%
Taylor expanded in c around 0 34.6%
neg-mul-134.6%
Simplified34.6%
Taylor expanded in c around -inf 7.2%
Final simplification7.2%
(FPCore (a b c d) :precision binary64 (/ a d))
double code(double a, double b, double c, double d) {
return a / 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 = a / d
end function
public static double code(double a, double b, double c, double d) {
return a / d;
}
def code(a, b, c, d): return a / d
function code(a, b, c, d) return Float64(a / d) end
function tmp = code(a, b, c, d) tmp = a / d; end
code[a_, b_, c_, d_] := N[(a / d), $MachinePrecision]
\begin{array}{l}
\\
\frac{a}{d}
\end{array}
Initial program 64.4%
*-un-lft-identity64.4%
add-sqr-sqrt64.4%
times-frac64.4%
hypot-def64.4%
hypot-def78.8%
Applied egg-rr78.8%
Taylor expanded in c around 0 34.6%
neg-mul-134.6%
Simplified34.6%
Taylor expanded in d around -inf 11.8%
Final simplification11.8%
(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 2023320
(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))))