
(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 (- (* (/ 1.0 (hypot c d)) (/ b (/ (hypot c d) c))) (/ (* d (/ a (hypot c d))) (hypot c d))))
double code(double a, double b, double c, double d) {
return ((1.0 / hypot(c, d)) * (b / (hypot(c, d) / c))) - ((d * (a / hypot(c, d))) / hypot(c, d));
}
public static double code(double a, double b, double c, double d) {
return ((1.0 / Math.hypot(c, d)) * (b / (Math.hypot(c, d) / c))) - ((d * (a / Math.hypot(c, d))) / Math.hypot(c, d));
}
def code(a, b, c, d): return ((1.0 / math.hypot(c, d)) * (b / (math.hypot(c, d) / c))) - ((d * (a / math.hypot(c, d))) / math.hypot(c, d))
function code(a, b, c, d) return Float64(Float64(Float64(1.0 / hypot(c, d)) * Float64(b / Float64(hypot(c, d) / c))) - Float64(Float64(d * Float64(a / hypot(c, d))) / hypot(c, d))) end
function tmp = code(a, b, c, d) tmp = ((1.0 / hypot(c, d)) * (b / (hypot(c, d) / c))) - ((d * (a / hypot(c, d))) / hypot(c, d)); end
code[a_, b_, c_, d_] := N[(N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[(N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(d * N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{b}{\frac{\mathsf{hypot}\left(c, d\right)}{c}} - \frac{d \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}
\end{array}
Initial program 56.8%
div-sub55.5%
*-un-lft-identity55.5%
add-sqr-sqrt55.5%
times-frac55.5%
fma-neg55.5%
hypot-def55.5%
hypot-def61.4%
associate-/l*63.4%
add-sqr-sqrt63.4%
pow263.4%
hypot-def63.4%
Applied egg-rr63.4%
fma-neg63.4%
associate-/l*79.9%
associate-/r/75.9%
*-commutative75.9%
Simplified75.9%
*-un-lft-identity75.9%
unpow275.9%
times-frac84.1%
Applied egg-rr84.1%
associate-*l/84.2%
*-lft-identity84.2%
Simplified84.2%
associate-*r/98.2%
Applied egg-rr98.2%
Final simplification98.2%
(FPCore (a b c d) :precision binary64 (- (/ (* c (/ b (hypot c d))) (hypot c d)) (/ (* d (/ a (hypot c d))) (hypot c d))))
double code(double a, double b, double c, double d) {
return ((c * (b / hypot(c, d))) / hypot(c, d)) - ((d * (a / hypot(c, d))) / hypot(c, d));
}
public static double code(double a, double b, double c, double d) {
return ((c * (b / Math.hypot(c, d))) / Math.hypot(c, d)) - ((d * (a / Math.hypot(c, d))) / Math.hypot(c, d));
}
def code(a, b, c, d): return ((c * (b / math.hypot(c, d))) / math.hypot(c, d)) - ((d * (a / math.hypot(c, d))) / math.hypot(c, d))
function code(a, b, c, d) return Float64(Float64(Float64(c * Float64(b / hypot(c, d))) / hypot(c, d)) - Float64(Float64(d * Float64(a / hypot(c, d))) / hypot(c, d))) end
function tmp = code(a, b, c, d) tmp = ((c * (b / hypot(c, d))) / hypot(c, d)) - ((d * (a / hypot(c, d))) / hypot(c, d)); end
code[a_, b_, c_, d_] := N[(N[(N[(c * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] - N[(N[(d * N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{c \cdot \frac{b}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)} - \frac{d \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}
\end{array}
Initial program 56.8%
div-sub55.5%
*-un-lft-identity55.5%
add-sqr-sqrt55.5%
times-frac55.5%
fma-neg55.5%
hypot-def55.5%
hypot-def61.4%
associate-/l*63.4%
add-sqr-sqrt63.4%
pow263.4%
hypot-def63.4%
Applied egg-rr63.4%
fma-neg63.4%
associate-/l*79.9%
associate-/r/75.9%
*-commutative75.9%
Simplified75.9%
*-un-lft-identity75.9%
unpow275.9%
times-frac84.1%
Applied egg-rr84.1%
associate-*l/84.2%
*-lft-identity84.2%
Simplified84.2%
associate-*r/98.2%
Applied egg-rr98.2%
associate-*l/98.4%
*-un-lft-identity98.4%
associate-/r/98.0%
Applied egg-rr98.0%
Final simplification98.0%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* c b) (* d a))) (t_1 (/ t_0 (+ (* c c) (* d d)))))
(if (or (<= t_1 (- INFINITY)) (not (<= t_1 2e+264)))
(- (/ b c) (/ (* d (/ a (hypot c d))) (hypot c d)))
(* (/ 1.0 (hypot c d)) (/ t_0 (hypot c d))))))
double code(double a, double b, double c, double d) {
double t_0 = (c * b) - (d * a);
double t_1 = t_0 / ((c * c) + (d * d));
double tmp;
if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 2e+264)) {
tmp = (b / c) - ((d * (a / hypot(c, d))) / hypot(c, d));
} else {
tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d));
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = (c * b) - (d * a);
double t_1 = t_0 / ((c * c) + (d * d));
double tmp;
if ((t_1 <= -Double.POSITIVE_INFINITY) || !(t_1 <= 2e+264)) {
tmp = (b / c) - ((d * (a / Math.hypot(c, d))) / Math.hypot(c, d));
} else {
tmp = (1.0 / Math.hypot(c, d)) * (t_0 / Math.hypot(c, d));
}
return tmp;
}
def code(a, b, c, d): t_0 = (c * b) - (d * a) t_1 = t_0 / ((c * c) + (d * d)) tmp = 0 if (t_1 <= -math.inf) or not (t_1 <= 2e+264): tmp = (b / c) - ((d * (a / math.hypot(c, d))) / math.hypot(c, d)) else: tmp = (1.0 / math.hypot(c, d)) * (t_0 / math.hypot(c, d)) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(c * b) - Float64(d * a)) t_1 = Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if ((t_1 <= Float64(-Inf)) || !(t_1 <= 2e+264)) tmp = Float64(Float64(b / c) - Float64(Float64(d * Float64(a / hypot(c, d))) / hypot(c, d))); else tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(t_0 / hypot(c, d))); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (c * b) - (d * a); t_1 = t_0 / ((c * c) + (d * d)); tmp = 0.0; if ((t_1 <= -Inf) || ~((t_1 <= 2e+264))) tmp = (b / c) - ((d * (a / hypot(c, d))) / hypot(c, d)); else tmp = (1.0 / hypot(c, d)) * (t_0 / hypot(c, d)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, (-Infinity)], N[Not[LessEqual[t$95$1, 2e+264]], $MachinePrecision]], N[(N[(b / c), $MachinePrecision] - N[(N[(d * N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot b - d \cdot a\\
t_1 := \frac{t_0}{c \cdot c + d \cdot d}\\
\mathbf{if}\;t_1 \leq -\infty \lor \neg \left(t_1 \leq 2 \cdot 10^{+264}\right):\\
\;\;\;\;\frac{b}{c} - \frac{d \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{t_0}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < -inf.0 or 2.00000000000000009e264 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 14.9%
div-sub11.3%
*-un-lft-identity11.3%
add-sqr-sqrt11.3%
times-frac11.3%
fma-neg11.3%
hypot-def11.3%
hypot-def13.5%
associate-/l*19.8%
add-sqr-sqrt19.8%
pow219.8%
hypot-def19.8%
Applied egg-rr19.8%
fma-neg19.8%
associate-/l*64.7%
associate-/r/63.6%
*-commutative63.6%
Simplified63.6%
*-un-lft-identity63.6%
unpow263.6%
times-frac81.2%
Applied egg-rr81.2%
associate-*l/81.3%
*-lft-identity81.3%
Simplified81.3%
associate-*r/98.6%
Applied egg-rr98.6%
Taylor expanded in c around inf 76.0%
if -inf.0 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 2.00000000000000009e264Initial program 81.1%
*-un-lft-identity81.1%
add-sqr-sqrt81.1%
times-frac81.2%
hypot-def81.3%
hypot-def99.0%
Applied egg-rr99.0%
Final simplification90.6%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* c b) (* d a))))
(if (<= d -1.95e+90)
(* (/ 1.0 (hypot c d)) (- a (/ c (/ d b))))
(if (<= d -1.35e-60)
(/ t_0 (+ (* c c) (* d d)))
(if (<= d 1e-70)
(/ (- b (* a (/ d c))) c)
(if (<= d 3e+61)
(* t_0 (/ 1.0 (pow (hypot c d) 2.0)))
(/ (- (* b (/ c d)) a) (hypot c d))))))))
double code(double a, double b, double c, double d) {
double t_0 = (c * b) - (d * a);
double tmp;
if (d <= -1.95e+90) {
tmp = (1.0 / hypot(c, d)) * (a - (c / (d / b)));
} else if (d <= -1.35e-60) {
tmp = t_0 / ((c * c) + (d * d));
} else if (d <= 1e-70) {
tmp = (b - (a * (d / c))) / c;
} else if (d <= 3e+61) {
tmp = t_0 * (1.0 / pow(hypot(c, d), 2.0));
} else {
tmp = ((b * (c / d)) - a) / hypot(c, d);
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = (c * b) - (d * a);
double tmp;
if (d <= -1.95e+90) {
tmp = (1.0 / Math.hypot(c, d)) * (a - (c / (d / b)));
} else if (d <= -1.35e-60) {
tmp = t_0 / ((c * c) + (d * d));
} else if (d <= 1e-70) {
tmp = (b - (a * (d / c))) / c;
} else if (d <= 3e+61) {
tmp = t_0 * (1.0 / Math.pow(Math.hypot(c, d), 2.0));
} else {
tmp = ((b * (c / d)) - a) / Math.hypot(c, d);
}
return tmp;
}
def code(a, b, c, d): t_0 = (c * b) - (d * a) tmp = 0 if d <= -1.95e+90: tmp = (1.0 / math.hypot(c, d)) * (a - (c / (d / b))) elif d <= -1.35e-60: tmp = t_0 / ((c * c) + (d * d)) elif d <= 1e-70: tmp = (b - (a * (d / c))) / c elif d <= 3e+61: tmp = t_0 * (1.0 / math.pow(math.hypot(c, d), 2.0)) else: tmp = ((b * (c / d)) - a) / math.hypot(c, d) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(c * b) - Float64(d * a)) tmp = 0.0 if (d <= -1.95e+90) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(a - Float64(c / Float64(d / b)))); elseif (d <= -1.35e-60) tmp = Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))); elseif (d <= 1e-70) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); elseif (d <= 3e+61) tmp = Float64(t_0 * Float64(1.0 / (hypot(c, d) ^ 2.0))); else tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / hypot(c, d)); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (c * b) - (d * a); tmp = 0.0; if (d <= -1.95e+90) tmp = (1.0 / hypot(c, d)) * (a - (c / (d / b))); elseif (d <= -1.35e-60) tmp = t_0 / ((c * c) + (d * d)); elseif (d <= 1e-70) tmp = (b - (a * (d / c))) / c; elseif (d <= 3e+61) tmp = t_0 * (1.0 / (hypot(c, d) ^ 2.0)); else tmp = ((b * (c / d)) - a) / hypot(c, d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.95e+90], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(a - N[(c / N[(d / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.35e-60], N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 1e-70], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 3e+61], N[(t$95$0 * N[(1.0 / N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot b - d \cdot a\\
\mathbf{if}\;d \leq -1.95 \cdot 10^{+90}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(a - \frac{c}{\frac{d}{b}}\right)\\
\mathbf{elif}\;d \leq -1.35 \cdot 10^{-60}:\\
\;\;\;\;\frac{t_0}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 10^{-70}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{elif}\;d \leq 3 \cdot 10^{+61}:\\
\;\;\;\;t_0 \cdot \frac{1}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if d < -1.9500000000000001e90Initial program 43.3%
*-un-lft-identity43.3%
add-sqr-sqrt43.3%
times-frac43.5%
hypot-def43.5%
hypot-def59.0%
Applied egg-rr59.0%
Taylor expanded in d around -inf 78.4%
+-commutative78.4%
mul-1-neg78.4%
unsub-neg78.4%
associate-/l*90.2%
Simplified90.2%
if -1.9500000000000001e90 < d < -1.35e-60Initial program 83.4%
if -1.35e-60 < d < 9.99999999999999996e-71Initial program 60.1%
Taylor expanded in c around inf 77.8%
+-commutative77.8%
mul-1-neg77.8%
unsub-neg77.8%
unpow277.8%
times-frac82.1%
Simplified82.1%
Taylor expanded in b around 0 77.8%
+-commutative77.8%
unpow277.8%
associate-*r/77.8%
*-commutative77.8%
neg-mul-177.8%
distribute-frac-neg77.8%
times-frac82.1%
*-commutative82.1%
unsub-neg82.1%
associate-*l/83.8%
div-sub84.8%
Simplified84.8%
if 9.99999999999999996e-71 < d < 3e61Initial program 81.6%
clear-num81.6%
associate-/r/81.7%
add-sqr-sqrt81.7%
pow281.7%
hypot-def81.7%
Applied egg-rr81.7%
if 3e61 < d Initial program 34.0%
*-un-lft-identity34.0%
add-sqr-sqrt34.0%
times-frac34.0%
hypot-def34.0%
hypot-def56.7%
Applied egg-rr56.7%
Taylor expanded in c around 0 72.4%
neg-mul-172.4%
unsub-neg72.4%
associate-/l*80.8%
Simplified80.8%
associate-*l/81.0%
*-un-lft-identity81.0%
associate-/r/81.1%
Applied egg-rr81.1%
Final simplification84.8%
(FPCore (a b c d) :precision binary64 (if (or (<= c -5.5e+45) (not (<= c 1.7e+24))) (- (/ b c) (/ (* d (/ a (hypot c d))) (hypot c d))) (* (/ 1.0 d) (- (/ c (/ d b)) a))))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -5.5e+45) || !(c <= 1.7e+24)) {
tmp = (b / c) - ((d * (a / hypot(c, d))) / hypot(c, d));
} else {
tmp = (1.0 / d) * ((c / (d / b)) - a);
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -5.5e+45) || !(c <= 1.7e+24)) {
tmp = (b / c) - ((d * (a / Math.hypot(c, d))) / Math.hypot(c, d));
} else {
tmp = (1.0 / d) * ((c / (d / b)) - a);
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -5.5e+45) or not (c <= 1.7e+24): tmp = (b / c) - ((d * (a / math.hypot(c, d))) / math.hypot(c, d)) else: tmp = (1.0 / d) * ((c / (d / b)) - a) return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -5.5e+45) || !(c <= 1.7e+24)) tmp = Float64(Float64(b / c) - Float64(Float64(d * Float64(a / hypot(c, d))) / hypot(c, d))); else tmp = Float64(Float64(1.0 / d) * Float64(Float64(c / Float64(d / b)) - a)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -5.5e+45) || ~((c <= 1.7e+24))) tmp = (b / c) - ((d * (a / hypot(c, d))) / hypot(c, d)); else tmp = (1.0 / d) * ((c / (d / b)) - a); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -5.5e+45], N[Not[LessEqual[c, 1.7e+24]], $MachinePrecision]], N[(N[(b / c), $MachinePrecision] - N[(N[(d * N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 / d), $MachinePrecision] * N[(N[(c / N[(d / b), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -5.5 \cdot 10^{+45} \lor \neg \left(c \leq 1.7 \cdot 10^{+24}\right):\\
\;\;\;\;\frac{b}{c} - \frac{d \cdot \frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{d} \cdot \left(\frac{c}{\frac{d}{b}} - a\right)\\
\end{array}
\end{array}
if c < -5.5000000000000001e45 or 1.7e24 < c Initial program 41.8%
div-sub41.8%
*-un-lft-identity41.8%
add-sqr-sqrt41.8%
times-frac41.9%
fma-neg41.9%
hypot-def41.9%
hypot-def52.5%
associate-/l*52.9%
add-sqr-sqrt52.9%
pow252.9%
hypot-def52.9%
Applied egg-rr52.9%
fma-neg52.9%
associate-/l*86.6%
associate-/r/87.4%
*-commutative87.4%
Simplified87.4%
*-un-lft-identity87.4%
unpow287.4%
times-frac93.6%
Applied egg-rr93.6%
associate-*l/93.7%
*-lft-identity93.7%
Simplified93.7%
associate-*r/99.6%
Applied egg-rr99.6%
Taylor expanded in c around inf 86.0%
if -5.5000000000000001e45 < c < 1.7e24Initial program 71.2%
*-un-lft-identity71.2%
add-sqr-sqrt71.2%
times-frac71.2%
hypot-def71.2%
hypot-def84.2%
Applied egg-rr84.2%
Taylor expanded in c around 0 41.2%
neg-mul-141.2%
unsub-neg41.2%
associate-/l*41.2%
Simplified41.2%
Taylor expanded in c around 0 82.7%
Final simplification84.3%
(FPCore (a b c d)
:precision binary64
(if (<= c -5.5e+45)
(/ (- b (* a (/ d c))) c)
(if (<= c 8.6e+24)
(* (/ 1.0 d) (- (/ c (/ d b)) a))
(- (/ b c) (* d (/ (/ a (hypot c d)) (hypot c d)))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -5.5e+45) {
tmp = (b - (a * (d / c))) / c;
} else if (c <= 8.6e+24) {
tmp = (1.0 / d) * ((c / (d / b)) - a);
} else {
tmp = (b / c) - (d * ((a / hypot(c, d)) / hypot(c, d)));
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -5.5e+45) {
tmp = (b - (a * (d / c))) / c;
} else if (c <= 8.6e+24) {
tmp = (1.0 / d) * ((c / (d / b)) - a);
} else {
tmp = (b / c) - (d * ((a / Math.hypot(c, d)) / Math.hypot(c, d)));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -5.5e+45: tmp = (b - (a * (d / c))) / c elif c <= 8.6e+24: tmp = (1.0 / d) * ((c / (d / b)) - a) else: tmp = (b / c) - (d * ((a / math.hypot(c, d)) / math.hypot(c, d))) return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -5.5e+45) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); elseif (c <= 8.6e+24) tmp = Float64(Float64(1.0 / d) * Float64(Float64(c / Float64(d / b)) - a)); else tmp = Float64(Float64(b / c) - Float64(d * Float64(Float64(a / hypot(c, d)) / hypot(c, d)))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -5.5e+45) tmp = (b - (a * (d / c))) / c; elseif (c <= 8.6e+24) tmp = (1.0 / d) * ((c / (d / b)) - a); else tmp = (b / c) - (d * ((a / hypot(c, d)) / hypot(c, d))); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -5.5e+45], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, 8.6e+24], N[(N[(1.0 / d), $MachinePrecision] * N[(N[(c / N[(d / b), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], N[(N[(b / c), $MachinePrecision] - N[(d * N[(N[(a / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -5.5 \cdot 10^{+45}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{elif}\;c \leq 8.6 \cdot 10^{+24}:\\
\;\;\;\;\frac{1}{d} \cdot \left(\frac{c}{\frac{d}{b}} - a\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c} - d \cdot \frac{\frac{a}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if c < -5.5000000000000001e45Initial program 35.4%
Taylor expanded in c around inf 68.5%
+-commutative68.5%
mul-1-neg68.5%
unsub-neg68.5%
unpow268.5%
times-frac76.6%
Simplified76.6%
Taylor expanded in b around 0 68.5%
+-commutative68.5%
unpow268.5%
associate-*r/68.5%
*-commutative68.5%
neg-mul-168.5%
distribute-frac-neg68.5%
times-frac76.6%
*-commutative76.6%
unsub-neg76.6%
associate-*l/76.6%
div-sub76.6%
Simplified76.6%
if -5.5000000000000001e45 < c < 8.59999999999999975e24Initial program 71.2%
*-un-lft-identity71.2%
add-sqr-sqrt71.2%
times-frac71.2%
hypot-def71.2%
hypot-def84.2%
Applied egg-rr84.2%
Taylor expanded in c around 0 41.2%
neg-mul-141.2%
unsub-neg41.2%
associate-/l*41.2%
Simplified41.2%
Taylor expanded in c around 0 82.7%
if 8.59999999999999975e24 < c Initial program 48.1%
div-sub48.1%
*-un-lft-identity48.1%
add-sqr-sqrt48.1%
times-frac48.1%
fma-neg48.1%
hypot-def48.1%
hypot-def61.1%
associate-/l*60.0%
add-sqr-sqrt60.0%
pow260.0%
hypot-def60.0%
Applied egg-rr60.0%
fma-neg60.0%
associate-/l*87.4%
associate-/r/88.9%
*-commutative88.9%
Simplified88.9%
*-un-lft-identity88.9%
unpow288.9%
times-frac96.4%
Applied egg-rr96.4%
associate-*l/96.6%
*-lft-identity96.6%
Simplified96.6%
Taylor expanded in c around inf 86.5%
Final simplification82.2%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
(if (<= d -9.2e+90)
(* (/ 1.0 d) (- (/ c (/ d b)) a))
(if (<= d -1.4e-60)
t_0
(if (<= d 3.15e-71)
(/ (- b (* a (/ d c))) c)
(if (<= d 3.5e+60) t_0 (/ (- (* b (/ c d)) a) (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 <= -9.2e+90) {
tmp = (1.0 / d) * ((c / (d / b)) - a);
} else if (d <= -1.4e-60) {
tmp = t_0;
} else if (d <= 3.15e-71) {
tmp = (b - (a * (d / c))) / c;
} else if (d <= 3.5e+60) {
tmp = t_0;
} else {
tmp = ((b * (c / d)) - a) / 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 <= -9.2e+90) {
tmp = (1.0 / d) * ((c / (d / b)) - a);
} else if (d <= -1.4e-60) {
tmp = t_0;
} else if (d <= 3.15e-71) {
tmp = (b - (a * (d / c))) / c;
} else if (d <= 3.5e+60) {
tmp = t_0;
} else {
tmp = ((b * (c / d)) - a) / 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 <= -9.2e+90: tmp = (1.0 / d) * ((c / (d / b)) - a) elif d <= -1.4e-60: tmp = t_0 elif d <= 3.15e-71: tmp = (b - (a * (d / c))) / c elif d <= 3.5e+60: tmp = t_0 else: tmp = ((b * (c / d)) - a) / 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 <= -9.2e+90) tmp = Float64(Float64(1.0 / d) * Float64(Float64(c / Float64(d / b)) - a)); elseif (d <= -1.4e-60) tmp = t_0; elseif (d <= 3.15e-71) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); elseif (d <= 3.5e+60) tmp = t_0; else tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / 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 <= -9.2e+90) tmp = (1.0 / d) * ((c / (d / b)) - a); elseif (d <= -1.4e-60) tmp = t_0; elseif (d <= 3.15e-71) tmp = (b - (a * (d / c))) / c; elseif (d <= 3.5e+60) tmp = t_0; else tmp = ((b * (c / d)) - a) / 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, -9.2e+90], N[(N[(1.0 / d), $MachinePrecision] * N[(N[(c / N[(d / b), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.4e-60], t$95$0, If[LessEqual[d, 3.15e-71], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 3.5e+60], t$95$0, N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $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 -9.2 \cdot 10^{+90}:\\
\;\;\;\;\frac{1}{d} \cdot \left(\frac{c}{\frac{d}{b}} - a\right)\\
\mathbf{elif}\;d \leq -1.4 \cdot 10^{-60}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 3.15 \cdot 10^{-71}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{elif}\;d \leq 3.5 \cdot 10^{+60}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if d < -9.20000000000000001e90Initial program 43.3%
*-un-lft-identity43.3%
add-sqr-sqrt43.3%
times-frac43.5%
hypot-def43.5%
hypot-def59.0%
Applied egg-rr59.0%
Taylor expanded in c around 0 19.3%
neg-mul-119.3%
unsub-neg19.3%
associate-/l*19.5%
Simplified19.5%
Taylor expanded in c around 0 90.0%
if -9.20000000000000001e90 < d < -1.4000000000000001e-60 or 3.1500000000000002e-71 < d < 3.5000000000000002e60Initial program 82.6%
if -1.4000000000000001e-60 < d < 3.1500000000000002e-71Initial program 60.1%
Taylor expanded in c around inf 77.8%
+-commutative77.8%
mul-1-neg77.8%
unsub-neg77.8%
unpow277.8%
times-frac82.1%
Simplified82.1%
Taylor expanded in b around 0 77.8%
+-commutative77.8%
unpow277.8%
associate-*r/77.8%
*-commutative77.8%
neg-mul-177.8%
distribute-frac-neg77.8%
times-frac82.1%
*-commutative82.1%
unsub-neg82.1%
associate-*l/83.8%
div-sub84.8%
Simplified84.8%
if 3.5000000000000002e60 < d Initial program 34.0%
*-un-lft-identity34.0%
add-sqr-sqrt34.0%
times-frac34.0%
hypot-def34.0%
hypot-def56.7%
Applied egg-rr56.7%
Taylor expanded in c around 0 72.4%
neg-mul-172.4%
unsub-neg72.4%
associate-/l*80.8%
Simplified80.8%
associate-*l/81.0%
*-un-lft-identity81.0%
associate-/r/81.1%
Applied egg-rr81.1%
Final simplification84.7%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
(if (<= d -4.7e+85)
(* (/ 1.0 (hypot c d)) (- a (/ c (/ d b))))
(if (<= d -1.3e-58)
t_0
(if (<= d 2e-71)
(/ (- b (* a (/ d c))) c)
(if (<= d 3.6e+59) t_0 (/ (- (* b (/ c d)) a) (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 <= -4.7e+85) {
tmp = (1.0 / hypot(c, d)) * (a - (c / (d / b)));
} else if (d <= -1.3e-58) {
tmp = t_0;
} else if (d <= 2e-71) {
tmp = (b - (a * (d / c))) / c;
} else if (d <= 3.6e+59) {
tmp = t_0;
} else {
tmp = ((b * (c / d)) - a) / 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 <= -4.7e+85) {
tmp = (1.0 / Math.hypot(c, d)) * (a - (c / (d / b)));
} else if (d <= -1.3e-58) {
tmp = t_0;
} else if (d <= 2e-71) {
tmp = (b - (a * (d / c))) / c;
} else if (d <= 3.6e+59) {
tmp = t_0;
} else {
tmp = ((b * (c / d)) - a) / 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 <= -4.7e+85: tmp = (1.0 / math.hypot(c, d)) * (a - (c / (d / b))) elif d <= -1.3e-58: tmp = t_0 elif d <= 2e-71: tmp = (b - (a * (d / c))) / c elif d <= 3.6e+59: tmp = t_0 else: tmp = ((b * (c / d)) - a) / 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 <= -4.7e+85) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(a - Float64(c / Float64(d / b)))); elseif (d <= -1.3e-58) tmp = t_0; elseif (d <= 2e-71) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); elseif (d <= 3.6e+59) tmp = t_0; else tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / 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 <= -4.7e+85) tmp = (1.0 / hypot(c, d)) * (a - (c / (d / b))); elseif (d <= -1.3e-58) tmp = t_0; elseif (d <= 2e-71) tmp = (b - (a * (d / c))) / c; elseif (d <= 3.6e+59) tmp = t_0; else tmp = ((b * (c / d)) - a) / 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, -4.7e+85], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(a - N[(c / N[(d / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.3e-58], t$95$0, If[LessEqual[d, 2e-71], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 3.6e+59], t$95$0, N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $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 -4.7 \cdot 10^{+85}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(a - \frac{c}{\frac{d}{b}}\right)\\
\mathbf{elif}\;d \leq -1.3 \cdot 10^{-58}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 2 \cdot 10^{-71}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{elif}\;d \leq 3.6 \cdot 10^{+59}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if d < -4.7000000000000002e85Initial program 43.3%
*-un-lft-identity43.3%
add-sqr-sqrt43.3%
times-frac43.5%
hypot-def43.5%
hypot-def59.0%
Applied egg-rr59.0%
Taylor expanded in d around -inf 78.4%
+-commutative78.4%
mul-1-neg78.4%
unsub-neg78.4%
associate-/l*90.2%
Simplified90.2%
if -4.7000000000000002e85 < d < -1.30000000000000003e-58 or 1.9999999999999998e-71 < d < 3.5999999999999999e59Initial program 82.6%
if -1.30000000000000003e-58 < d < 1.9999999999999998e-71Initial program 60.1%
Taylor expanded in c around inf 77.8%
+-commutative77.8%
mul-1-neg77.8%
unsub-neg77.8%
unpow277.8%
times-frac82.1%
Simplified82.1%
Taylor expanded in b around 0 77.8%
+-commutative77.8%
unpow277.8%
associate-*r/77.8%
*-commutative77.8%
neg-mul-177.8%
distribute-frac-neg77.8%
times-frac82.1%
*-commutative82.1%
unsub-neg82.1%
associate-*l/83.8%
div-sub84.8%
Simplified84.8%
if 3.5999999999999999e59 < d Initial program 34.0%
*-un-lft-identity34.0%
add-sqr-sqrt34.0%
times-frac34.0%
hypot-def34.0%
hypot-def56.7%
Applied egg-rr56.7%
Taylor expanded in c around 0 72.4%
neg-mul-172.4%
unsub-neg72.4%
associate-/l*80.8%
Simplified80.8%
associate-*l/81.0%
*-un-lft-identity81.0%
associate-/r/81.1%
Applied egg-rr81.1%
Final simplification84.8%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
(if (<= d -9.2e+89)
(* (/ 1.0 d) (- (/ c (/ d b)) a))
(if (<= d -4.2e-57)
t_0
(if (<= d 1.32e-61)
(/ (- b (* a (/ d c))) c)
(if (<= d 9.2e+53) t_0 (- (* (/ c d) (/ 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 <= -9.2e+89) {
tmp = (1.0 / d) * ((c / (d / b)) - a);
} else if (d <= -4.2e-57) {
tmp = t_0;
} else if (d <= 1.32e-61) {
tmp = (b - (a * (d / c))) / c;
} else if (d <= 9.2e+53) {
tmp = t_0;
} else {
tmp = ((c / d) * (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 <= (-9.2d+89)) then
tmp = (1.0d0 / d) * ((c / (d / b)) - a)
else if (d <= (-4.2d-57)) then
tmp = t_0
else if (d <= 1.32d-61) then
tmp = (b - (a * (d / c))) / c
else if (d <= 9.2d+53) then
tmp = t_0
else
tmp = ((c / d) * (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 <= -9.2e+89) {
tmp = (1.0 / d) * ((c / (d / b)) - a);
} else if (d <= -4.2e-57) {
tmp = t_0;
} else if (d <= 1.32e-61) {
tmp = (b - (a * (d / c))) / c;
} else if (d <= 9.2e+53) {
tmp = t_0;
} else {
tmp = ((c / d) * (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 <= -9.2e+89: tmp = (1.0 / d) * ((c / (d / b)) - a) elif d <= -4.2e-57: tmp = t_0 elif d <= 1.32e-61: tmp = (b - (a * (d / c))) / c elif d <= 9.2e+53: tmp = t_0 else: tmp = ((c / d) * (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 <= -9.2e+89) tmp = Float64(Float64(1.0 / d) * Float64(Float64(c / Float64(d / b)) - a)); elseif (d <= -4.2e-57) tmp = t_0; elseif (d <= 1.32e-61) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); elseif (d <= 9.2e+53) tmp = t_0; else tmp = Float64(Float64(Float64(c / d) * Float64(b / d)) - 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 <= -9.2e+89) tmp = (1.0 / d) * ((c / (d / b)) - a); elseif (d <= -4.2e-57) tmp = t_0; elseif (d <= 1.32e-61) tmp = (b - (a * (d / c))) / c; elseif (d <= 9.2e+53) tmp = t_0; else tmp = ((c / d) * (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, -9.2e+89], N[(N[(1.0 / d), $MachinePrecision] * N[(N[(c / N[(d / b), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -4.2e-57], t$95$0, If[LessEqual[d, 1.32e-61], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 9.2e+53], t$95$0, N[(N[(N[(c / d), $MachinePrecision] * N[(b / d), $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 -9.2 \cdot 10^{+89}:\\
\;\;\;\;\frac{1}{d} \cdot \left(\frac{c}{\frac{d}{b}} - a\right)\\
\mathbf{elif}\;d \leq -4.2 \cdot 10^{-57}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 1.32 \cdot 10^{-61}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{elif}\;d \leq 9.2 \cdot 10^{+53}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\
\end{array}
\end{array}
if d < -9.1999999999999996e89Initial program 43.3%
*-un-lft-identity43.3%
add-sqr-sqrt43.3%
times-frac43.5%
hypot-def43.5%
hypot-def59.0%
Applied egg-rr59.0%
Taylor expanded in c around 0 19.3%
neg-mul-119.3%
unsub-neg19.3%
associate-/l*19.5%
Simplified19.5%
Taylor expanded in c around 0 90.0%
if -9.1999999999999996e89 < d < -4.1999999999999999e-57 or 1.32000000000000002e-61 < d < 9.20000000000000079e53Initial program 82.3%
if -4.1999999999999999e-57 < d < 1.32000000000000002e-61Initial program 60.1%
Taylor expanded in c around inf 77.8%
+-commutative77.8%
mul-1-neg77.8%
unsub-neg77.8%
unpow277.8%
times-frac82.1%
Simplified82.1%
Taylor expanded in b around 0 77.8%
+-commutative77.8%
unpow277.8%
associate-*r/77.8%
*-commutative77.8%
neg-mul-177.8%
distribute-frac-neg77.8%
times-frac82.1%
*-commutative82.1%
unsub-neg82.1%
associate-*l/83.8%
div-sub84.8%
Simplified84.8%
if 9.20000000000000079e53 < d Initial program 35.5%
Taylor expanded in c around 0 68.7%
+-commutative68.7%
mul-1-neg68.7%
unsub-neg68.7%
unpow268.7%
times-frac81.1%
Simplified81.1%
Final simplification84.7%
(FPCore (a b c d)
:precision binary64
(if (<= c -6e+45)
(/ (- b (* a (/ d c))) c)
(if (<= c 5.8e+27)
(* (/ 1.0 d) (- (/ c (/ d b)) a))
(/ (- b (* d (/ a c))) c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -6e+45) {
tmp = (b - (a * (d / c))) / c;
} else if (c <= 5.8e+27) {
tmp = (1.0 / d) * ((c / (d / b)) - a);
} else {
tmp = (b - (d * (a / c))) / 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 (c <= (-6d+45)) then
tmp = (b - (a * (d / c))) / c
else if (c <= 5.8d+27) then
tmp = (1.0d0 / d) * ((c / (d / b)) - a)
else
tmp = (b - (d * (a / c))) / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -6e+45) {
tmp = (b - (a * (d / c))) / c;
} else if (c <= 5.8e+27) {
tmp = (1.0 / d) * ((c / (d / b)) - a);
} else {
tmp = (b - (d * (a / c))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -6e+45: tmp = (b - (a * (d / c))) / c elif c <= 5.8e+27: tmp = (1.0 / d) * ((c / (d / b)) - a) else: tmp = (b - (d * (a / c))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -6e+45) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); elseif (c <= 5.8e+27) tmp = Float64(Float64(1.0 / d) * Float64(Float64(c / Float64(d / b)) - a)); else tmp = Float64(Float64(b - Float64(d * Float64(a / c))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -6e+45) tmp = (b - (a * (d / c))) / c; elseif (c <= 5.8e+27) tmp = (1.0 / d) * ((c / (d / b)) - a); else tmp = (b - (d * (a / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -6e+45], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, 5.8e+27], N[(N[(1.0 / d), $MachinePrecision] * N[(N[(c / N[(d / b), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision]), $MachinePrecision], N[(N[(b - N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -6 \cdot 10^{+45}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{elif}\;c \leq 5.8 \cdot 10^{+27}:\\
\;\;\;\;\frac{1}{d} \cdot \left(\frac{c}{\frac{d}{b}} - a\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\
\end{array}
\end{array}
if c < -6.00000000000000021e45Initial program 35.4%
Taylor expanded in c around inf 68.5%
+-commutative68.5%
mul-1-neg68.5%
unsub-neg68.5%
unpow268.5%
times-frac76.6%
Simplified76.6%
Taylor expanded in b around 0 68.5%
+-commutative68.5%
unpow268.5%
associate-*r/68.5%
*-commutative68.5%
neg-mul-168.5%
distribute-frac-neg68.5%
times-frac76.6%
*-commutative76.6%
unsub-neg76.6%
associate-*l/76.6%
div-sub76.6%
Simplified76.6%
if -6.00000000000000021e45 < c < 5.8000000000000002e27Initial program 71.2%
*-un-lft-identity71.2%
add-sqr-sqrt71.2%
times-frac71.2%
hypot-def71.2%
hypot-def84.2%
Applied egg-rr84.2%
Taylor expanded in c around 0 41.2%
neg-mul-141.2%
unsub-neg41.2%
associate-/l*41.2%
Simplified41.2%
Taylor expanded in c around 0 82.7%
if 5.8000000000000002e27 < c Initial program 48.1%
Taylor expanded in c around inf 77.0%
+-commutative77.0%
mul-1-neg77.0%
unsub-neg77.0%
unpow277.0%
times-frac81.8%
Simplified81.8%
associate-*r/83.5%
sub-div83.5%
Applied egg-rr83.5%
Final simplification81.4%
(FPCore (a b c d) :precision binary64 (if (or (<= d -2.5e+52) (not (<= d 2.8e+55))) (/ (- a) d) (/ (- b (* a (/ d c))) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -2.5e+52) || !(d <= 2.8e+55)) {
tmp = -a / d;
} else {
tmp = (b - (a * (d / c))) / 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 <= (-2.5d+52)) .or. (.not. (d <= 2.8d+55))) then
tmp = -a / d
else
tmp = (b - (a * (d / c))) / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -2.5e+52) || !(d <= 2.8e+55)) {
tmp = -a / d;
} else {
tmp = (b - (a * (d / c))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -2.5e+52) or not (d <= 2.8e+55): tmp = -a / d else: tmp = (b - (a * (d / c))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -2.5e+52) || !(d <= 2.8e+55)) tmp = Float64(Float64(-a) / d); else tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -2.5e+52) || ~((d <= 2.8e+55))) tmp = -a / d; else tmp = (b - (a * (d / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -2.5e+52], N[Not[LessEqual[d, 2.8e+55]], $MachinePrecision]], N[((-a) / d), $MachinePrecision], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.5 \cdot 10^{+52} \lor \neg \left(d \leq 2.8 \cdot 10^{+55}\right):\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\end{array}
\end{array}
if d < -2.5e52 or 2.8000000000000001e55 < d Initial program 42.5%
Taylor expanded in c around 0 72.4%
associate-*r/72.4%
neg-mul-172.4%
Simplified72.4%
if -2.5e52 < d < 2.8000000000000001e55Initial program 66.2%
Taylor expanded in c around inf 69.6%
+-commutative69.6%
mul-1-neg69.6%
unsub-neg69.6%
unpow269.6%
times-frac72.6%
Simplified72.6%
Taylor expanded in b around 0 69.6%
+-commutative69.6%
unpow269.6%
associate-*r/69.6%
*-commutative69.6%
neg-mul-169.6%
distribute-frac-neg69.6%
times-frac72.6%
*-commutative72.6%
unsub-neg72.6%
associate-*l/73.8%
div-sub74.6%
Simplified74.6%
Final simplification73.8%
(FPCore (a b c d) :precision binary64 (if (<= c -5.5e+45) (/ (- b (* a (/ d c))) c) (if (<= c 1.75e+24) (/ (- a) d) (/ (- b (* d (/ a c))) c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -5.5e+45) {
tmp = (b - (a * (d / c))) / c;
} else if (c <= 1.75e+24) {
tmp = -a / d;
} else {
tmp = (b - (d * (a / c))) / 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 (c <= (-5.5d+45)) then
tmp = (b - (a * (d / c))) / c
else if (c <= 1.75d+24) then
tmp = -a / d
else
tmp = (b - (d * (a / c))) / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -5.5e+45) {
tmp = (b - (a * (d / c))) / c;
} else if (c <= 1.75e+24) {
tmp = -a / d;
} else {
tmp = (b - (d * (a / c))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -5.5e+45: tmp = (b - (a * (d / c))) / c elif c <= 1.75e+24: tmp = -a / d else: tmp = (b - (d * (a / c))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -5.5e+45) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); elseif (c <= 1.75e+24) tmp = Float64(Float64(-a) / d); else tmp = Float64(Float64(b - Float64(d * Float64(a / c))) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -5.5e+45) tmp = (b - (a * (d / c))) / c; elseif (c <= 1.75e+24) tmp = -a / d; else tmp = (b - (d * (a / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -5.5e+45], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, 1.75e+24], N[((-a) / d), $MachinePrecision], N[(N[(b - N[(d * N[(a / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -5.5 \cdot 10^{+45}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{elif}\;c \leq 1.75 \cdot 10^{+24}:\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\
\end{array}
\end{array}
if c < -5.5000000000000001e45Initial program 35.4%
Taylor expanded in c around inf 68.5%
+-commutative68.5%
mul-1-neg68.5%
unsub-neg68.5%
unpow268.5%
times-frac76.6%
Simplified76.6%
Taylor expanded in b around 0 68.5%
+-commutative68.5%
unpow268.5%
associate-*r/68.5%
*-commutative68.5%
neg-mul-168.5%
distribute-frac-neg68.5%
times-frac76.6%
*-commutative76.6%
unsub-neg76.6%
associate-*l/76.6%
div-sub76.6%
Simplified76.6%
if -5.5000000000000001e45 < c < 1.7500000000000001e24Initial program 71.2%
Taylor expanded in c around 0 68.3%
associate-*r/68.3%
neg-mul-168.3%
Simplified68.3%
if 1.7500000000000001e24 < c Initial program 48.1%
Taylor expanded in c around inf 77.0%
+-commutative77.0%
mul-1-neg77.0%
unsub-neg77.0%
unpow277.0%
times-frac81.8%
Simplified81.8%
associate-*r/83.5%
sub-div83.5%
Applied egg-rr83.5%
Final simplification74.0%
(FPCore (a b c d) :precision binary64 (if (<= c -5.5e+45) (/ b c) (if (<= c 7.2e+30) (/ (- a) d) (/ b c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -5.5e+45) {
tmp = b / c;
} else if (c <= 7.2e+30) {
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 (c <= (-5.5d+45)) then
tmp = b / c
else if (c <= 7.2d+30) 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 (c <= -5.5e+45) {
tmp = b / c;
} else if (c <= 7.2e+30) {
tmp = -a / d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -5.5e+45: tmp = b / c elif c <= 7.2e+30: tmp = -a / d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -5.5e+45) tmp = Float64(b / c); elseif (c <= 7.2e+30) 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 (c <= -5.5e+45) tmp = b / c; elseif (c <= 7.2e+30) tmp = -a / d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -5.5e+45], N[(b / c), $MachinePrecision], If[LessEqual[c, 7.2e+30], N[((-a) / d), $MachinePrecision], N[(b / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -5.5 \cdot 10^{+45}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;c \leq 7.2 \cdot 10^{+30}:\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if c < -5.5000000000000001e45 or 7.2000000000000004e30 < c Initial program 41.3%
Taylor expanded in c around inf 68.3%
if -5.5000000000000001e45 < c < 7.2000000000000004e30Initial program 71.4%
Taylor expanded in c around 0 67.8%
associate-*r/67.8%
neg-mul-167.8%
Simplified67.8%
Final simplification68.0%
(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 56.8%
Taylor expanded in c around inf 41.5%
Final simplification41.5%
(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 2023192
(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))))