
(FPCore (a b c d) :precision binary64 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = ((b * c) - (a * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((b * c) - (a * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c d) :precision binary64 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = ((b * c) - (a * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((b * c) - (a * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\end{array}
(FPCore (a b c d) :precision binary64 (fma (/ c (hypot c d)) (/ b (hypot c d)) (/ (* d (- (/ a (hypot d c)))) (hypot d c))))
double code(double a, double b, double c, double d) {
return fma((c / hypot(c, d)), (b / hypot(c, d)), ((d * -(a / hypot(d, c))) / hypot(d, c)));
}
function code(a, b, c, d) return fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(Float64(d * Float64(-Float64(a / hypot(d, c)))) / hypot(d, c))) end
code[a_, b_, c_, d_] := N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] + N[(N[(d * (-N[(a / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision])), $MachinePrecision] / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{d \cdot \left(-\frac{a}{\mathsf{hypot}\left(d, c\right)}\right)}{\mathsf{hypot}\left(d, c\right)}\right)
\end{array}
Initial program 58.8%
div-sub56.4%
sub-neg56.4%
*-commutative56.4%
add-sqr-sqrt56.4%
times-frac59.1%
fma-def59.1%
hypot-def59.1%
hypot-def69.1%
associate-/l*73.9%
add-sqr-sqrt73.9%
pow273.9%
hypot-def73.9%
Applied egg-rr73.9%
unpow273.9%
*-un-lft-identity73.9%
times-frac94.4%
Applied egg-rr94.4%
/-rgt-identity94.4%
*-un-lft-identity94.4%
times-frac96.8%
Applied egg-rr96.8%
associate-*l/97.0%
*-lft-identity97.0%
associate-/r/97.7%
hypot-def75.0%
unpow275.0%
unpow275.0%
+-commutative75.0%
unpow275.0%
unpow275.0%
hypot-def97.7%
hypot-def75.0%
unpow275.0%
unpow275.0%
+-commutative75.0%
unpow275.0%
unpow275.0%
hypot-def97.7%
Simplified97.7%
Final simplification97.7%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ c (hypot c d)))
(t_1 (/ b (hypot c d)))
(t_2 (fma t_0 t_1 (/ (- a) (/ (pow (hypot c d) 2.0) d))))
(t_3 (- (* c b) (* d a)))
(t_4 (/ t_3 (+ (* c c) (* d d)))))
(if (<= t_4 -4e+291)
t_2
(if (<= t_4 2e+142)
(* (/ 1.0 (hypot c d)) (/ t_3 (hypot c d)))
(if (<= t_4 INFINITY) t_2 (fma t_0 t_1 (/ (- a) d)))))))
double code(double a, double b, double c, double d) {
double t_0 = c / hypot(c, d);
double t_1 = b / hypot(c, d);
double t_2 = fma(t_0, t_1, (-a / (pow(hypot(c, d), 2.0) / d)));
double t_3 = (c * b) - (d * a);
double t_4 = t_3 / ((c * c) + (d * d));
double tmp;
if (t_4 <= -4e+291) {
tmp = t_2;
} else if (t_4 <= 2e+142) {
tmp = (1.0 / hypot(c, d)) * (t_3 / hypot(c, d));
} else if (t_4 <= ((double) INFINITY)) {
tmp = t_2;
} else {
tmp = fma(t_0, t_1, (-a / d));
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(c / hypot(c, d)) t_1 = Float64(b / hypot(c, d)) t_2 = fma(t_0, t_1, Float64(Float64(-a) / Float64((hypot(c, d) ^ 2.0) / d))) t_3 = Float64(Float64(c * b) - Float64(d * a)) t_4 = Float64(t_3 / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (t_4 <= -4e+291) tmp = t_2; elseif (t_4 <= 2e+142) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(t_3 / hypot(c, d))); elseif (t_4 <= Inf) tmp = t_2; else tmp = fma(t_0, t_1, Float64(Float64(-a) / d)); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 * t$95$1 + N[((-a) / N[(N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$4, -4e+291], t$95$2, If[LessEqual[t$95$4, 2e+142], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(t$95$3 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, Infinity], t$95$2, N[(t$95$0 * t$95$1 + N[((-a) / d), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c}{\mathsf{hypot}\left(c, d\right)}\\
t_1 := \frac{b}{\mathsf{hypot}\left(c, d\right)}\\
t_2 := \mathsf{fma}\left(t_0, t_1, \frac{-a}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{d}}\right)\\
t_3 := c \cdot b - d \cdot a\\
t_4 := \frac{t_3}{c \cdot c + d \cdot d}\\
\mathbf{if}\;t_4 \leq -4 \cdot 10^{+291}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_4 \leq 2 \cdot 10^{+142}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t_3}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;t_4 \leq \infty:\\
\;\;\;\;t_2\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t_0, t_1, \frac{-a}{d}\right)\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < -3.9999999999999998e291 or 2.0000000000000001e142 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < +inf.0Initial program 58.3%
div-sub45.5%
sub-neg45.5%
*-commutative45.5%
add-sqr-sqrt45.5%
times-frac67.7%
fma-def67.7%
hypot-def67.7%
hypot-def69.9%
associate-/l*94.0%
add-sqr-sqrt94.0%
pow294.0%
hypot-def94.0%
Applied egg-rr94.0%
if -3.9999999999999998e291 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 2.0000000000000001e142Initial program 79.5%
*-un-lft-identity79.5%
add-sqr-sqrt79.5%
times-frac79.6%
hypot-def79.6%
hypot-def99.6%
Applied egg-rr99.6%
if +inf.0 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 0.0%
div-sub0.0%
sub-neg0.0%
*-commutative0.0%
add-sqr-sqrt0.0%
times-frac1.0%
fma-def1.0%
hypot-def1.0%
hypot-def27.7%
associate-/l*34.0%
add-sqr-sqrt34.0%
pow234.0%
hypot-def34.0%
Applied egg-rr34.0%
Taylor expanded in c around 0 75.6%
Final simplification93.5%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ 1.0 (hypot c d)))
(t_1 (- (* c b) (* d a)))
(t_2 (/ t_1 (+ (* c c) (* d d)))))
(if (<= t_2 (- INFINITY))
(- (* t_0 (/ c (/ (hypot c d) b))) (/ d (/ (pow (hypot c d) 2.0) a)))
(if (<= t_2 2e+252)
(* t_0 (/ t_1 (hypot c d)))
(fma (/ c (hypot c d)) (/ b (hypot c d)) (/ (- 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 t_2 = t_1 / ((c * c) + (d * d));
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = (t_0 * (c / (hypot(c, d) / b))) - (d / (pow(hypot(c, d), 2.0) / a));
} else if (t_2 <= 2e+252) {
tmp = t_0 * (t_1 / hypot(c, d));
} else {
tmp = fma((c / hypot(c, d)), (b / hypot(c, d)), (-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)) t_2 = Float64(t_1 / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = Float64(Float64(t_0 * Float64(c / Float64(hypot(c, d) / b))) - Float64(d / Float64((hypot(c, d) ^ 2.0) / a))); elseif (t_2 <= 2e+252) tmp = Float64(t_0 * Float64(t_1 / hypot(c, d))); else tmp = fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(Float64(-a) / d)); end return 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]}, Block[{t$95$2 = N[(t$95$1 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(N[(t$95$0 * N[(c / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(d / N[(N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2e+252], N[(t$95$0 * N[(t$95$1 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $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\\
t_2 := \frac{t_1}{c \cdot c + d \cdot d}\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;t_0 \cdot \frac{c}{\frac{\mathsf{hypot}\left(c, d\right)}{b}} - \frac{d}{\frac{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}{a}}\\
\mathbf{elif}\;t_2 \leq 2 \cdot 10^{+252}:\\
\;\;\;\;t_0 \cdot \frac{t_1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{-a}{d}\right)\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < -inf.0Initial program 45.5%
div-sub16.5%
sub-neg16.5%
*-un-lft-identity16.5%
add-sqr-sqrt16.5%
times-frac16.5%
fma-def16.5%
hypot-def16.5%
hypot-def38.3%
associate-/l*66.0%
add-sqr-sqrt66.0%
pow266.0%
hypot-def66.0%
Applied egg-rr66.0%
fma-neg58.9%
*-commutative58.9%
associate-/l*85.9%
associate-/l*58.2%
*-commutative58.2%
associate-/l*85.9%
Simplified85.9%
if -inf.0 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 2.0000000000000002e252Initial program 81.0%
*-un-lft-identity81.0%
add-sqr-sqrt81.0%
times-frac81.0%
hypot-def81.0%
hypot-def99.6%
Applied egg-rr99.6%
if 2.0000000000000002e252 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 12.7%
div-sub10.0%
sub-neg10.0%
*-commutative10.0%
add-sqr-sqrt10.0%
times-frac18.3%
fma-def18.3%
hypot-def18.3%
hypot-def37.4%
associate-/l*51.9%
add-sqr-sqrt51.9%
pow251.9%
hypot-def51.9%
Applied egg-rr51.9%
Taylor expanded in c around 0 76.2%
Final simplification91.9%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* c b) (* d a))))
(if (<= (/ t_0 (+ (* c c) (* d d))) 2e+252)
(* (/ 1.0 (hypot c d)) (/ t_0 (hypot c d)))
(fma (/ c (hypot c d)) (/ b (hypot c d)) (/ (- a) d)))))
double code(double a, double b, double c, double d) {
double t_0 = (c * b) - (d * a);
double tmp;
if ((t_0 / ((c * c) + (d * d))) <= 2e+252) {
tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
} else {
tmp = fma((c / hypot(c, d)), (b / hypot(c, d)), (-a / d));
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(c * b) - Float64(d * a)) tmp = 0.0 if (Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))) <= 2e+252) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(t_0 / hypot(c, d))); else tmp = fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(Float64(-a) / d)); end return 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], 2e+252], 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[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] + N[((-a) / d), $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 2 \cdot 10^{+252}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t_0}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, \frac{-a}{d}\right)\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 2.0000000000000002e252Initial program 78.2%
*-un-lft-identity78.2%
add-sqr-sqrt78.2%
times-frac78.3%
hypot-def78.3%
hypot-def95.9%
Applied egg-rr95.9%
if 2.0000000000000002e252 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 12.7%
div-sub10.0%
sub-neg10.0%
*-commutative10.0%
add-sqr-sqrt10.0%
times-frac18.3%
fma-def18.3%
hypot-def18.3%
hypot-def37.4%
associate-/l*51.9%
add-sqr-sqrt51.9%
pow251.9%
hypot-def51.9%
Applied egg-rr51.9%
Taylor expanded in c around 0 76.2%
Final simplification90.0%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* c b) (* d a))))
(if (<= (/ t_0 (+ (* c c) (* d d))) 2e+252)
(* (/ 1.0 (hypot c d)) (/ t_0 (hypot c d)))
(/ (- (* c (/ b d)) a) d))))
double code(double a, double b, double c, double d) {
double t_0 = (c * b) - (d * a);
double tmp;
if ((t_0 / ((c * c) + (d * d))) <= 2e+252) {
tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
} else {
tmp = ((c * (b / d)) - a) / d;
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = (c * b) - (d * a);
double tmp;
if ((t_0 / ((c * c) + (d * d))) <= 2e+252) {
tmp = (1.0 / Math.hypot(c, d)) * (t_0 / Math.hypot(c, d));
} else {
tmp = ((c * (b / d)) - a) / d;
}
return tmp;
}
def code(a, b, c, d): t_0 = (c * b) - (d * a) tmp = 0 if (t_0 / ((c * c) + (d * d))) <= 2e+252: tmp = (1.0 / math.hypot(c, d)) * (t_0 / math.hypot(c, d)) else: tmp = ((c * (b / d)) - a) / d return tmp
function code(a, b, c, d) t_0 = Float64(Float64(c * b) - Float64(d * a)) tmp = 0.0 if (Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))) <= 2e+252) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(t_0 / hypot(c, d))); else tmp = Float64(Float64(Float64(c * Float64(b / d)) - a) / d); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (c * b) - (d * a); tmp = 0.0; if ((t_0 / ((c * c) + (d * d))) <= 2e+252) tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d)); else tmp = ((c * (b / d)) - a) / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2e+252], 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[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $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 2 \cdot 10^{+252}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t_0}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 2.0000000000000002e252Initial program 78.2%
*-un-lft-identity78.2%
add-sqr-sqrt78.2%
times-frac78.3%
hypot-def78.3%
hypot-def95.9%
Applied egg-rr95.9%
if 2.0000000000000002e252 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 12.7%
Taylor expanded in c around 0 59.3%
+-commutative59.3%
mul-1-neg59.3%
unsub-neg59.3%
associate-/l*61.0%
associate-/r/59.9%
Simplified59.9%
*-un-lft-identity59.9%
pow259.9%
times-frac62.5%
Applied egg-rr62.5%
associate-*l/62.5%
*-lft-identity62.5%
Simplified62.5%
associate-*l/65.0%
sub-div65.2%
Applied egg-rr65.2%
Final simplification86.8%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (+ (* c c) (* d d))))
(if (<= d -4.7e+88)
(- (* c (/ (* b (/ 1.0 d)) d)) (/ a d))
(if (<= d -6e-95)
(/ (fma (- d) a (* c b)) t_0)
(if (<= d 1.8e-137)
(- (/ b c) (* d (/ a (pow c 2.0))))
(if (<= d 1.2e+54)
(/ (- (* c b) (* d a)) t_0)
(/ (- (* c (/ b d)) a) d)))))))
double code(double a, double b, double c, double d) {
double t_0 = (c * c) + (d * d);
double tmp;
if (d <= -4.7e+88) {
tmp = (c * ((b * (1.0 / d)) / d)) - (a / d);
} else if (d <= -6e-95) {
tmp = fma(-d, a, (c * b)) / t_0;
} else if (d <= 1.8e-137) {
tmp = (b / c) - (d * (a / pow(c, 2.0)));
} else if (d <= 1.2e+54) {
tmp = ((c * b) - (d * a)) / t_0;
} else {
tmp = ((c * (b / d)) - a) / d;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(c * c) + Float64(d * d)) tmp = 0.0 if (d <= -4.7e+88) tmp = Float64(Float64(c * Float64(Float64(b * Float64(1.0 / d)) / d)) - Float64(a / d)); elseif (d <= -6e-95) tmp = Float64(fma(Float64(-d), a, Float64(c * b)) / t_0); elseif (d <= 1.8e-137) tmp = Float64(Float64(b / c) - Float64(d * Float64(a / (c ^ 2.0)))); elseif (d <= 1.2e+54) tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / t_0); else tmp = Float64(Float64(Float64(c * Float64(b / d)) - a) / d); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -4.7e+88], N[(N[(c * N[(N[(b * N[(1.0 / d), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -6e-95], N[(N[((-d) * a + N[(c * b), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[d, 1.8e-137], N[(N[(b / c), $MachinePrecision] - N[(d * N[(a / N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.2e+54], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot c + d \cdot d\\
\mathbf{if}\;d \leq -4.7 \cdot 10^{+88}:\\
\;\;\;\;c \cdot \frac{b \cdot \frac{1}{d}}{d} - \frac{a}{d}\\
\mathbf{elif}\;d \leq -6 \cdot 10^{-95}:\\
\;\;\;\;\frac{\mathsf{fma}\left(-d, a, c \cdot b\right)}{t_0}\\
\mathbf{elif}\;d \leq 1.8 \cdot 10^{-137}:\\
\;\;\;\;\frac{b}{c} - d \cdot \frac{a}{{c}^{2}}\\
\mathbf{elif}\;d \leq 1.2 \cdot 10^{+54}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\end{array}
\end{array}
if d < -4.70000000000000007e88Initial program 30.8%
Taylor expanded in c around 0 82.4%
+-commutative82.4%
mul-1-neg82.4%
unsub-neg82.4%
associate-/l*82.5%
associate-/r/80.5%
Simplified80.5%
*-un-lft-identity80.5%
pow280.5%
times-frac82.6%
Applied egg-rr82.6%
associate-*r/82.6%
Simplified82.6%
if -4.70000000000000007e88 < d < -6e-95Initial program 87.4%
sub-neg87.4%
+-commutative87.4%
*-commutative87.4%
distribute-lft-neg-in87.4%
fma-def87.4%
Applied egg-rr87.4%
if -6e-95 < d < 1.80000000000000003e-137Initial program 67.4%
Taylor expanded in c around inf 85.9%
+-commutative85.9%
mul-1-neg85.9%
unsub-neg85.9%
associate-/l*84.8%
associate-/r/87.4%
Simplified87.4%
if 1.80000000000000003e-137 < d < 1.19999999999999999e54Initial program 89.0%
if 1.19999999999999999e54 < d Initial program 35.0%
Taylor expanded in c around 0 79.0%
+-commutative79.0%
mul-1-neg79.0%
unsub-neg79.0%
associate-/l*78.0%
associate-/r/80.7%
Simplified80.7%
*-un-lft-identity80.7%
pow280.7%
times-frac83.7%
Applied egg-rr83.7%
associate-*l/83.7%
*-lft-identity83.7%
Simplified83.7%
associate-*l/87.9%
sub-div88.0%
Applied egg-rr88.0%
Final simplification86.9%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
(if (<= d -6.1e+88)
(- (* c (/ (* b (/ 1.0 d)) d)) (/ a d))
(if (<= d -6.8e-96)
t_0
(if (<= d 1.5e-130)
(- (/ b c) (* a (/ d (pow c 2.0))))
(if (<= d 1.45e+54) t_0 (/ (- (* c (/ b d)) 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.1e+88) {
tmp = (c * ((b * (1.0 / d)) / d)) - (a / d);
} else if (d <= -6.8e-96) {
tmp = t_0;
} else if (d <= 1.5e-130) {
tmp = (b / c) - (a * (d / pow(c, 2.0)));
} else if (d <= 1.45e+54) {
tmp = t_0;
} else {
tmp = ((c * (b / d)) - 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.1d+88)) then
tmp = (c * ((b * (1.0d0 / d)) / d)) - (a / d)
else if (d <= (-6.8d-96)) then
tmp = t_0
else if (d <= 1.5d-130) then
tmp = (b / c) - (a * (d / (c ** 2.0d0)))
else if (d <= 1.45d+54) then
tmp = t_0
else
tmp = ((c * (b / d)) - 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.1e+88) {
tmp = (c * ((b * (1.0 / d)) / d)) - (a / d);
} else if (d <= -6.8e-96) {
tmp = t_0;
} else if (d <= 1.5e-130) {
tmp = (b / c) - (a * (d / Math.pow(c, 2.0)));
} else if (d <= 1.45e+54) {
tmp = t_0;
} else {
tmp = ((c * (b / d)) - 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.1e+88: tmp = (c * ((b * (1.0 / d)) / d)) - (a / d) elif d <= -6.8e-96: tmp = t_0 elif d <= 1.5e-130: tmp = (b / c) - (a * (d / math.pow(c, 2.0))) elif d <= 1.45e+54: tmp = t_0 else: tmp = ((c * (b / d)) - 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.1e+88) tmp = Float64(Float64(c * Float64(Float64(b * Float64(1.0 / d)) / d)) - Float64(a / d)); elseif (d <= -6.8e-96) tmp = t_0; elseif (d <= 1.5e-130) tmp = Float64(Float64(b / c) - Float64(a * Float64(d / (c ^ 2.0)))); elseif (d <= 1.45e+54) tmp = t_0; else tmp = Float64(Float64(Float64(c * Float64(b / d)) - 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.1e+88) tmp = (c * ((b * (1.0 / d)) / d)) - (a / d); elseif (d <= -6.8e-96) tmp = t_0; elseif (d <= 1.5e-130) tmp = (b / c) - (a * (d / (c ^ 2.0))); elseif (d <= 1.45e+54) tmp = t_0; else tmp = ((c * (b / d)) - 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.1e+88], N[(N[(c * N[(N[(b * N[(1.0 / d), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -6.8e-96], t$95$0, If[LessEqual[d, 1.5e-130], N[(N[(b / c), $MachinePrecision] - N[(a * N[(d / N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.45e+54], t$95$0, N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $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.1 \cdot 10^{+88}:\\
\;\;\;\;c \cdot \frac{b \cdot \frac{1}{d}}{d} - \frac{a}{d}\\
\mathbf{elif}\;d \leq -6.8 \cdot 10^{-96}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 1.5 \cdot 10^{-130}:\\
\;\;\;\;\frac{b}{c} - a \cdot \frac{d}{{c}^{2}}\\
\mathbf{elif}\;d \leq 1.45 \cdot 10^{+54}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\end{array}
\end{array}
if d < -6.0999999999999998e88Initial program 30.8%
Taylor expanded in c around 0 82.4%
+-commutative82.4%
mul-1-neg82.4%
unsub-neg82.4%
associate-/l*82.5%
associate-/r/80.5%
Simplified80.5%
*-un-lft-identity80.5%
pow280.5%
times-frac82.6%
Applied egg-rr82.6%
associate-*r/82.6%
Simplified82.6%
if -6.0999999999999998e88 < d < -6.8000000000000002e-96 or 1.49999999999999993e-130 < d < 1.4499999999999999e54Initial program 88.2%
if -6.8000000000000002e-96 < d < 1.49999999999999993e-130Initial program 67.4%
div-sub58.5%
sub-neg58.5%
*-commutative58.5%
add-sqr-sqrt58.5%
times-frac69.0%
fma-def69.0%
hypot-def69.0%
hypot-def88.6%
associate-/l*87.6%
add-sqr-sqrt87.6%
pow287.6%
hypot-def87.6%
Applied egg-rr87.6%
unpow287.6%
*-un-lft-identity87.6%
times-frac93.1%
Applied egg-rr93.1%
/-rgt-identity93.1%
*-un-lft-identity93.1%
times-frac95.7%
Applied egg-rr95.7%
associate-*l/95.8%
*-lft-identity95.8%
associate-/r/98.5%
hypot-def91.6%
unpow291.6%
unpow291.6%
+-commutative91.6%
unpow291.6%
unpow291.6%
hypot-def98.5%
hypot-def91.6%
unpow291.6%
unpow291.6%
+-commutative91.6%
unpow291.6%
unpow291.6%
hypot-def98.5%
Simplified98.5%
Taylor expanded in c around inf 85.9%
+-commutative85.9%
mul-1-neg85.9%
*-commutative85.9%
associate-*l/84.8%
unsub-neg84.8%
*-commutative84.8%
Simplified84.8%
if 1.4499999999999999e54 < d Initial program 35.0%
Taylor expanded in c around 0 79.0%
+-commutative79.0%
mul-1-neg79.0%
unsub-neg79.0%
associate-/l*78.0%
associate-/r/80.7%
Simplified80.7%
*-un-lft-identity80.7%
pow280.7%
times-frac83.7%
Applied egg-rr83.7%
associate-*l/83.7%
*-lft-identity83.7%
Simplified83.7%
associate-*l/87.9%
sub-div88.0%
Applied egg-rr88.0%
Final simplification86.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
(if (<= d -1.45e+89)
(- (* c (/ (* b (/ 1.0 d)) d)) (/ a d))
(if (<= d -2.8e-105)
t_0
(if (<= d 3.8e-138)
(- (/ b c) (* d (/ a (pow c 2.0))))
(if (<= d 1.45e+54) t_0 (/ (- (* c (/ b d)) 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 <= -1.45e+89) {
tmp = (c * ((b * (1.0 / d)) / d)) - (a / d);
} else if (d <= -2.8e-105) {
tmp = t_0;
} else if (d <= 3.8e-138) {
tmp = (b / c) - (d * (a / pow(c, 2.0)));
} else if (d <= 1.45e+54) {
tmp = t_0;
} else {
tmp = ((c * (b / d)) - 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 <= (-1.45d+89)) then
tmp = (c * ((b * (1.0d0 / d)) / d)) - (a / d)
else if (d <= (-2.8d-105)) then
tmp = t_0
else if (d <= 3.8d-138) then
tmp = (b / c) - (d * (a / (c ** 2.0d0)))
else if (d <= 1.45d+54) then
tmp = t_0
else
tmp = ((c * (b / d)) - 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 <= -1.45e+89) {
tmp = (c * ((b * (1.0 / d)) / d)) - (a / d);
} else if (d <= -2.8e-105) {
tmp = t_0;
} else if (d <= 3.8e-138) {
tmp = (b / c) - (d * (a / Math.pow(c, 2.0)));
} else if (d <= 1.45e+54) {
tmp = t_0;
} else {
tmp = ((c * (b / d)) - a) / d;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)) tmp = 0 if d <= -1.45e+89: tmp = (c * ((b * (1.0 / d)) / d)) - (a / d) elif d <= -2.8e-105: tmp = t_0 elif d <= 3.8e-138: tmp = (b / c) - (d * (a / math.pow(c, 2.0))) elif d <= 1.45e+54: tmp = t_0 else: tmp = ((c * (b / d)) - 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 <= -1.45e+89) tmp = Float64(Float64(c * Float64(Float64(b * Float64(1.0 / d)) / d)) - Float64(a / d)); elseif (d <= -2.8e-105) tmp = t_0; elseif (d <= 3.8e-138) tmp = Float64(Float64(b / c) - Float64(d * Float64(a / (c ^ 2.0)))); elseif (d <= 1.45e+54) tmp = t_0; else tmp = Float64(Float64(Float64(c * Float64(b / d)) - 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 <= -1.45e+89) tmp = (c * ((b * (1.0 / d)) / d)) - (a / d); elseif (d <= -2.8e-105) tmp = t_0; elseif (d <= 3.8e-138) tmp = (b / c) - (d * (a / (c ^ 2.0))); elseif (d <= 1.45e+54) tmp = t_0; else tmp = ((c * (b / d)) - 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, -1.45e+89], N[(N[(c * N[(N[(b * N[(1.0 / d), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -2.8e-105], t$95$0, If[LessEqual[d, 3.8e-138], N[(N[(b / c), $MachinePrecision] - N[(d * N[(a / N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1.45e+54], t$95$0, N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $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 -1.45 \cdot 10^{+89}:\\
\;\;\;\;c \cdot \frac{b \cdot \frac{1}{d}}{d} - \frac{a}{d}\\
\mathbf{elif}\;d \leq -2.8 \cdot 10^{-105}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 3.8 \cdot 10^{-138}:\\
\;\;\;\;\frac{b}{c} - d \cdot \frac{a}{{c}^{2}}\\
\mathbf{elif}\;d \leq 1.45 \cdot 10^{+54}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\end{array}
\end{array}
if d < -1.45000000000000013e89Initial program 30.8%
Taylor expanded in c around 0 82.4%
+-commutative82.4%
mul-1-neg82.4%
unsub-neg82.4%
associate-/l*82.5%
associate-/r/80.5%
Simplified80.5%
*-un-lft-identity80.5%
pow280.5%
times-frac82.6%
Applied egg-rr82.6%
associate-*r/82.6%
Simplified82.6%
if -1.45000000000000013e89 < d < -2.8e-105 or 3.8000000000000002e-138 < d < 1.4499999999999999e54Initial program 88.2%
if -2.8e-105 < d < 3.8000000000000002e-138Initial program 67.4%
Taylor expanded in c around inf 85.9%
+-commutative85.9%
mul-1-neg85.9%
unsub-neg85.9%
associate-/l*84.8%
associate-/r/87.4%
Simplified87.4%
if 1.4499999999999999e54 < d Initial program 35.0%
Taylor expanded in c around 0 79.0%
+-commutative79.0%
mul-1-neg79.0%
unsub-neg79.0%
associate-/l*78.0%
associate-/r/80.7%
Simplified80.7%
*-un-lft-identity80.7%
pow280.7%
times-frac83.7%
Applied egg-rr83.7%
associate-*l/83.7%
*-lft-identity83.7%
Simplified83.7%
associate-*l/87.9%
sub-div88.0%
Applied egg-rr88.0%
Final simplification86.9%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
(if (<= d -3.6e+88)
(- (* c (/ (* b (/ 1.0 d)) d)) (/ a d))
(if (<= d -1e-92)
t_0
(if (<= d 2.7e-170)
(/ b c)
(if (<= d 6.1e+53) t_0 (/ (- (* c (/ b d)) 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 <= -3.6e+88) {
tmp = (c * ((b * (1.0 / d)) / d)) - (a / d);
} else if (d <= -1e-92) {
tmp = t_0;
} else if (d <= 2.7e-170) {
tmp = b / c;
} else if (d <= 6.1e+53) {
tmp = t_0;
} else {
tmp = ((c * (b / d)) - 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 <= (-3.6d+88)) then
tmp = (c * ((b * (1.0d0 / d)) / d)) - (a / d)
else if (d <= (-1d-92)) then
tmp = t_0
else if (d <= 2.7d-170) then
tmp = b / c
else if (d <= 6.1d+53) then
tmp = t_0
else
tmp = ((c * (b / d)) - 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 <= -3.6e+88) {
tmp = (c * ((b * (1.0 / d)) / d)) - (a / d);
} else if (d <= -1e-92) {
tmp = t_0;
} else if (d <= 2.7e-170) {
tmp = b / c;
} else if (d <= 6.1e+53) {
tmp = t_0;
} else {
tmp = ((c * (b / d)) - a) / d;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)) tmp = 0 if d <= -3.6e+88: tmp = (c * ((b * (1.0 / d)) / d)) - (a / d) elif d <= -1e-92: tmp = t_0 elif d <= 2.7e-170: tmp = b / c elif d <= 6.1e+53: tmp = t_0 else: tmp = ((c * (b / d)) - 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 <= -3.6e+88) tmp = Float64(Float64(c * Float64(Float64(b * Float64(1.0 / d)) / d)) - Float64(a / d)); elseif (d <= -1e-92) tmp = t_0; elseif (d <= 2.7e-170) tmp = Float64(b / c); elseif (d <= 6.1e+53) tmp = t_0; else tmp = Float64(Float64(Float64(c * Float64(b / d)) - 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 <= -3.6e+88) tmp = (c * ((b * (1.0 / d)) / d)) - (a / d); elseif (d <= -1e-92) tmp = t_0; elseif (d <= 2.7e-170) tmp = b / c; elseif (d <= 6.1e+53) tmp = t_0; else tmp = ((c * (b / d)) - 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, -3.6e+88], N[(N[(c * N[(N[(b * N[(1.0 / d), $MachinePrecision]), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1e-92], t$95$0, If[LessEqual[d, 2.7e-170], N[(b / c), $MachinePrecision], If[LessEqual[d, 6.1e+53], t$95$0, N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -3.6 \cdot 10^{+88}:\\
\;\;\;\;c \cdot \frac{b \cdot \frac{1}{d}}{d} - \frac{a}{d}\\
\mathbf{elif}\;d \leq -1 \cdot 10^{-92}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 2.7 \cdot 10^{-170}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;d \leq 6.1 \cdot 10^{+53}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\end{array}
\end{array}
if d < -3.6000000000000002e88Initial program 30.8%
Taylor expanded in c around 0 82.4%
+-commutative82.4%
mul-1-neg82.4%
unsub-neg82.4%
associate-/l*82.5%
associate-/r/80.5%
Simplified80.5%
*-un-lft-identity80.5%
pow280.5%
times-frac82.6%
Applied egg-rr82.6%
associate-*r/82.6%
Simplified82.6%
if -3.6000000000000002e88 < d < -9.99999999999999988e-93 or 2.6999999999999999e-170 < d < 6.1000000000000002e53Initial program 87.8%
if -9.99999999999999988e-93 < d < 2.6999999999999999e-170Initial program 65.9%
Taylor expanded in c around inf 75.6%
if 6.1000000000000002e53 < d Initial program 35.0%
Taylor expanded in c around 0 79.0%
+-commutative79.0%
mul-1-neg79.0%
unsub-neg79.0%
associate-/l*78.0%
associate-/r/80.7%
Simplified80.7%
*-un-lft-identity80.7%
pow280.7%
times-frac83.7%
Applied egg-rr83.7%
associate-*l/83.7%
*-lft-identity83.7%
Simplified83.7%
associate-*l/87.9%
sub-div88.0%
Applied egg-rr88.0%
Final simplification83.9%
(FPCore (a b c d) :precision binary64 (if (or (<= c -1.45e+23) (not (<= c 4.7e+14))) (/ b c) (- (* b (/ (/ c d) d)) (/ a d))))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -1.45e+23) || !(c <= 4.7e+14)) {
tmp = b / c;
} else {
tmp = (b * ((c / d) / d)) - (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) :: tmp
if ((c <= (-1.45d+23)) .or. (.not. (c <= 4.7d+14))) then
tmp = b / c
else
tmp = (b * ((c / d) / d)) - (a / d)
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -1.45e+23) || !(c <= 4.7e+14)) {
tmp = b / c;
} else {
tmp = (b * ((c / d) / d)) - (a / d);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -1.45e+23) or not (c <= 4.7e+14): tmp = b / c else: tmp = (b * ((c / d) / d)) - (a / d) return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -1.45e+23) || !(c <= 4.7e+14)) tmp = Float64(b / c); else tmp = Float64(Float64(b * Float64(Float64(c / d) / d)) - Float64(a / d)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -1.45e+23) || ~((c <= 4.7e+14))) tmp = b / c; else tmp = (b * ((c / d) / d)) - (a / d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -1.45e+23], N[Not[LessEqual[c, 4.7e+14]], $MachinePrecision]], N[(b / c), $MachinePrecision], N[(N[(b * N[(N[(c / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -1.45 \cdot 10^{+23} \lor \neg \left(c \leq 4.7 \cdot 10^{+14}\right):\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{\frac{c}{d}}{d} - \frac{a}{d}\\
\end{array}
\end{array}
if c < -1.45000000000000006e23 or 4.7e14 < c Initial program 51.6%
Taylor expanded in c around inf 62.8%
if -1.45000000000000006e23 < c < 4.7e14Initial program 64.5%
div-sub60.2%
sub-neg60.2%
*-commutative60.2%
add-sqr-sqrt60.2%
times-frac58.5%
fma-def58.5%
hypot-def58.5%
hypot-def59.9%
associate-/l*66.7%
add-sqr-sqrt66.7%
pow266.7%
hypot-def66.7%
Applied egg-rr66.7%
Taylor expanded in c around 0 82.6%
neg-mul-182.6%
+-commutative82.6%
unsub-neg82.6%
*-commutative82.6%
associate-/l*80.4%
associate-/r/82.9%
Simplified82.9%
*-un-lft-identity82.9%
unpow282.9%
times-frac84.2%
Applied egg-rr84.2%
associate-*l/84.2%
*-lft-identity84.2%
Simplified84.2%
Final simplification74.8%
(FPCore (a b c d) :precision binary64 (if (or (<= c -8.5e+22) (not (<= c 2.8e+14))) (/ b c) (/ (- (* c (/ b d)) a) d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -8.5e+22) || !(c <= 2.8e+14)) {
tmp = b / c;
} else {
tmp = ((c * (b / d)) - 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) :: tmp
if ((c <= (-8.5d+22)) .or. (.not. (c <= 2.8d+14))) then
tmp = b / c
else
tmp = ((c * (b / d)) - a) / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -8.5e+22) || !(c <= 2.8e+14)) {
tmp = b / c;
} else {
tmp = ((c * (b / d)) - a) / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -8.5e+22) or not (c <= 2.8e+14): tmp = b / c else: tmp = ((c * (b / d)) - a) / d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -8.5e+22) || !(c <= 2.8e+14)) tmp = Float64(b / c); else tmp = Float64(Float64(Float64(c * Float64(b / d)) - a) / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -8.5e+22) || ~((c <= 2.8e+14))) tmp = b / c; else tmp = ((c * (b / d)) - a) / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -8.5e+22], N[Not[LessEqual[c, 2.8e+14]], $MachinePrecision]], N[(b / c), $MachinePrecision], N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -8.5 \cdot 10^{+22} \lor \neg \left(c \leq 2.8 \cdot 10^{+14}\right):\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\end{array}
\end{array}
if c < -8.49999999999999979e22 or 2.8e14 < c Initial program 51.6%
Taylor expanded in c around inf 62.8%
if -8.49999999999999979e22 < c < 2.8e14Initial program 64.5%
Taylor expanded in c around 0 82.6%
+-commutative82.6%
mul-1-neg82.6%
unsub-neg82.6%
associate-/l*82.8%
associate-/r/79.5%
Simplified79.5%
*-un-lft-identity79.5%
pow279.5%
times-frac80.1%
Applied egg-rr80.1%
associate-*l/80.1%
*-lft-identity80.1%
Simplified80.1%
associate-*l/83.6%
sub-div83.6%
Applied egg-rr83.6%
Final simplification74.4%
(FPCore (a b c d) :precision binary64 (if (or (<= d -1.5e-63) (not (<= d 1.05e-11))) (/ (- a) d) (/ b c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.5e-63) || !(d <= 1.05e-11)) {
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.5d-63)) .or. (.not. (d <= 1.05d-11))) 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.5e-63) || !(d <= 1.05e-11)) {
tmp = -a / d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -1.5e-63) or not (d <= 1.05e-11): tmp = -a / d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -1.5e-63) || !(d <= 1.05e-11)) 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.5e-63) || ~((d <= 1.05e-11))) tmp = -a / d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -1.5e-63], N[Not[LessEqual[d, 1.05e-11]], $MachinePrecision]], N[((-a) / d), $MachinePrecision], N[(b / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.5 \cdot 10^{-63} \lor \neg \left(d \leq 1.05 \cdot 10^{-11}\right):\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if d < -1.4999999999999999e-63 or 1.0499999999999999e-11 < d Initial program 48.8%
Taylor expanded in c around 0 68.3%
associate-*r/68.3%
neg-mul-168.3%
Simplified68.3%
if -1.4999999999999999e-63 < d < 1.0499999999999999e-11Initial program 74.9%
Taylor expanded in c around inf 67.6%
Final simplification68.0%
(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 58.8%
Taylor expanded in b around 0 38.1%
associate-*r/38.1%
associate-*r*38.1%
neg-mul-138.1%
*-commutative38.1%
associate-/l*40.2%
+-commutative40.2%
unpow240.2%
fma-udef40.2%
Simplified40.2%
fma-udef40.2%
+-commutative40.2%
add-sqr-sqrt40.2%
pow240.2%
hypot-udef40.2%
pow240.2%
hypot-udef40.2%
neg-mul-140.2%
times-frac49.2%
Applied egg-rr49.2%
Taylor expanded in d around -inf 29.0%
associate-*r/29.0%
neg-mul-129.0%
Simplified29.0%
Taylor expanded in d around 0 10.5%
Final simplification10.5%
(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 58.8%
Taylor expanded in c around inf 36.1%
Final simplification36.1%
(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 2023315
(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))))