
(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 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c d) :precision binary64 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = ((b * c) - (a * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((b * c) - (a * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\end{array}
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* b c) (* a d))))
(if (<= (/ t_0 (+ (* c c) (* d d))) INFINITY)
(/ (/ t_0 (hypot c d)) (hypot c d))
(- (* (/ c d) (/ b d)) (/ a d)))))
double code(double a, double b, double c, double d) {
double t_0 = (b * c) - (a * d);
double tmp;
if ((t_0 / ((c * c) + (d * d))) <= ((double) INFINITY)) {
tmp = (t_0 / hypot(c, d)) / hypot(c, d);
} else {
tmp = ((c / d) * (b / d)) - (a / d);
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = (b * c) - (a * d);
double tmp;
if ((t_0 / ((c * c) + (d * d))) <= Double.POSITIVE_INFINITY) {
tmp = (t_0 / Math.hypot(c, d)) / Math.hypot(c, d);
} else {
tmp = ((c / d) * (b / d)) - (a / d);
}
return tmp;
}
def code(a, b, c, d): t_0 = (b * c) - (a * d) tmp = 0 if (t_0 / ((c * c) + (d * d))) <= math.inf: tmp = (t_0 / math.hypot(c, d)) / math.hypot(c, d) else: tmp = ((c / d) * (b / d)) - (a / d) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(b * c) - Float64(a * d)) tmp = 0.0 if (Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))) <= Inf) tmp = Float64(Float64(t_0 / hypot(c, d)) / hypot(c, d)); 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 = (b * c) - (a * d); tmp = 0.0; if ((t_0 / ((c * c) + (d * d))) <= Inf) tmp = (t_0 / hypot(c, d)) / hypot(c, d); else tmp = ((c / d) * (b / d)) - (a / d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(N[(t$95$0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], N[(N[(N[(c / d), $MachinePrecision] * N[(b / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := b \cdot c - a \cdot d\\
\mathbf{if}\;\frac{t_0}{c \cdot c + d \cdot d} \leq \infty:\\
\;\;\;\;\frac{\frac{t_0}{\mathsf{hypot}\left(c, d\right)}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < +inf.0Initial program 79.0%
*-un-lft-identity79.0%
add-sqr-sqrt79.0%
times-frac79.0%
hypot-def79.0%
hypot-def96.9%
Applied egg-rr96.9%
associate-*l/97.1%
*-un-lft-identity97.1%
Applied egg-rr97.1%
if +inf.0 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 0.0%
Taylor expanded in c around 0 49.7%
+-commutative49.7%
mul-1-neg49.7%
unsub-neg49.7%
unpow249.7%
times-frac52.5%
Simplified52.5%
Final simplification88.9%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (- (* b c) (* a d))))
(if (<= d -3.2e+20)
(/ (- a (/ (* b c) d)) (hypot c d))
(if (<= d -3.7e-124)
(/ t_0 (+ (* c c) (* d d)))
(if (<= d 5.7e-114)
(/ (- b (/ (* a d) c)) c)
(if (<= d 2.5e+61)
(* t_0 (/ 1.0 (pow (hypot c d) 2.0)))
(/ (- (/ c (/ d b)) a) (hypot c d))))))))
double code(double a, double b, double c, double d) {
double t_0 = (b * c) - (a * d);
double tmp;
if (d <= -3.2e+20) {
tmp = (a - ((b * c) / d)) / hypot(c, d);
} else if (d <= -3.7e-124) {
tmp = t_0 / ((c * c) + (d * d));
} else if (d <= 5.7e-114) {
tmp = (b - ((a * d) / c)) / c;
} else if (d <= 2.5e+61) {
tmp = t_0 * (1.0 / pow(hypot(c, d), 2.0));
} else {
tmp = ((c / (d / b)) - a) / hypot(c, d);
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = (b * c) - (a * d);
double tmp;
if (d <= -3.2e+20) {
tmp = (a - ((b * c) / d)) / Math.hypot(c, d);
} else if (d <= -3.7e-124) {
tmp = t_0 / ((c * c) + (d * d));
} else if (d <= 5.7e-114) {
tmp = (b - ((a * d) / c)) / c;
} else if (d <= 2.5e+61) {
tmp = t_0 * (1.0 / Math.pow(Math.hypot(c, d), 2.0));
} else {
tmp = ((c / (d / b)) - a) / Math.hypot(c, d);
}
return tmp;
}
def code(a, b, c, d): t_0 = (b * c) - (a * d) tmp = 0 if d <= -3.2e+20: tmp = (a - ((b * c) / d)) / math.hypot(c, d) elif d <= -3.7e-124: tmp = t_0 / ((c * c) + (d * d)) elif d <= 5.7e-114: tmp = (b - ((a * d) / c)) / c elif d <= 2.5e+61: tmp = t_0 * (1.0 / math.pow(math.hypot(c, d), 2.0)) else: tmp = ((c / (d / b)) - a) / math.hypot(c, d) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(b * c) - Float64(a * d)) tmp = 0.0 if (d <= -3.2e+20) tmp = Float64(Float64(a - Float64(Float64(b * c) / d)) / hypot(c, d)); elseif (d <= -3.7e-124) tmp = Float64(t_0 / Float64(Float64(c * c) + Float64(d * d))); elseif (d <= 5.7e-114) tmp = Float64(Float64(b - Float64(Float64(a * d) / c)) / c); elseif (d <= 2.5e+61) tmp = Float64(t_0 * Float64(1.0 / (hypot(c, d) ^ 2.0))); else tmp = Float64(Float64(Float64(c / Float64(d / b)) - a) / hypot(c, d)); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (b * c) - (a * d); tmp = 0.0; if (d <= -3.2e+20) tmp = (a - ((b * c) / d)) / hypot(c, d); elseif (d <= -3.7e-124) tmp = t_0 / ((c * c) + (d * d)); elseif (d <= 5.7e-114) tmp = (b - ((a * d) / c)) / c; elseif (d <= 2.5e+61) tmp = t_0 * (1.0 / (hypot(c, d) ^ 2.0)); else tmp = ((c / (d / b)) - a) / hypot(c, d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -3.2e+20], N[(N[(a - N[(N[(b * c), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -3.7e-124], N[(t$95$0 / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, 5.7e-114], N[(N[(b - N[(N[(a * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 2.5e+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[(c / N[(d / b), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := b \cdot c - a \cdot d\\
\mathbf{if}\;d \leq -3.2 \cdot 10^{+20}:\\
\;\;\;\;\frac{a - \frac{b \cdot c}{d}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq -3.7 \cdot 10^{-124}:\\
\;\;\;\;\frac{t_0}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;d \leq 5.7 \cdot 10^{-114}:\\
\;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\
\mathbf{elif}\;d \leq 2.5 \cdot 10^{+61}:\\
\;\;\;\;t_0 \cdot \frac{1}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{c}{\frac{d}{b}} - a}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if d < -3.2e20Initial program 43.9%
*-un-lft-identity43.9%
add-sqr-sqrt43.9%
times-frac43.9%
hypot-def43.9%
hypot-def66.8%
Applied egg-rr66.8%
associate-*l/67.0%
*-un-lft-identity67.0%
Applied egg-rr67.0%
Taylor expanded in d around -inf 80.4%
if -3.2e20 < d < -3.6999999999999999e-124Initial program 79.3%
if -3.6999999999999999e-124 < d < 5.6999999999999997e-114Initial program 71.8%
*-un-lft-identity71.8%
add-sqr-sqrt71.8%
times-frac71.8%
hypot-def71.8%
hypot-def89.3%
Applied egg-rr89.3%
associate-*l/89.5%
*-un-lft-identity89.5%
Applied egg-rr89.5%
Taylor expanded in c around inf 83.6%
+-commutative83.6%
mul-1-neg83.6%
associate-/l*86.1%
unpow286.1%
associate-*r/92.0%
*-commutative92.0%
associate-/l/90.9%
sub-neg90.9%
associate-/r/82.6%
*-commutative82.6%
associate-*r/90.9%
div-sub90.9%
associate-*r/92.9%
*-commutative92.9%
Simplified92.9%
if 5.6999999999999997e-114 < d < 2.50000000000000009e61Initial program 89.7%
clear-num89.6%
associate-/r/89.9%
add-sqr-sqrt89.9%
pow289.9%
hypot-def89.9%
Applied egg-rr89.9%
if 2.50000000000000009e61 < d Initial program 53.2%
*-un-lft-identity53.2%
add-sqr-sqrt53.2%
times-frac53.2%
hypot-def53.2%
hypot-def65.0%
Applied egg-rr65.0%
associate-*l/65.2%
*-un-lft-identity65.2%
Applied egg-rr65.2%
Taylor expanded in c around 0 80.4%
neg-mul-180.4%
unsub-neg80.4%
associate-/l*82.4%
Simplified82.4%
Final simplification85.9%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (+ (* c c) (* d d))) (t_1 (/ c (/ d b))))
(if (<= d -5.8e+20)
(/ (- a t_1) (hypot c d))
(if (<= d -7.5e-118)
(/ (- (* b c) (* a d)) t_0)
(if (<= d 1.45e-112)
(/ (- b (/ (* a d) c)) c)
(if (<= d 1.5e+57)
(- (/ (* b c) t_0) (/ (* a d) t_0))
(/ (- t_1 a) (hypot c d))))))))
double code(double a, double b, double c, double d) {
double t_0 = (c * c) + (d * d);
double t_1 = c / (d / b);
double tmp;
if (d <= -5.8e+20) {
tmp = (a - t_1) / hypot(c, d);
} else if (d <= -7.5e-118) {
tmp = ((b * c) - (a * d)) / t_0;
} else if (d <= 1.45e-112) {
tmp = (b - ((a * d) / c)) / c;
} else if (d <= 1.5e+57) {
tmp = ((b * c) / t_0) - ((a * d) / t_0);
} else {
tmp = (t_1 - a) / hypot(c, d);
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = (c * c) + (d * d);
double t_1 = c / (d / b);
double tmp;
if (d <= -5.8e+20) {
tmp = (a - t_1) / Math.hypot(c, d);
} else if (d <= -7.5e-118) {
tmp = ((b * c) - (a * d)) / t_0;
} else if (d <= 1.45e-112) {
tmp = (b - ((a * d) / c)) / c;
} else if (d <= 1.5e+57) {
tmp = ((b * c) / t_0) - ((a * d) / t_0);
} else {
tmp = (t_1 - a) / Math.hypot(c, d);
}
return tmp;
}
def code(a, b, c, d): t_0 = (c * c) + (d * d) t_1 = c / (d / b) tmp = 0 if d <= -5.8e+20: tmp = (a - t_1) / math.hypot(c, d) elif d <= -7.5e-118: tmp = ((b * c) - (a * d)) / t_0 elif d <= 1.45e-112: tmp = (b - ((a * d) / c)) / c elif d <= 1.5e+57: tmp = ((b * c) / t_0) - ((a * d) / t_0) else: tmp = (t_1 - a) / math.hypot(c, d) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(c * c) + Float64(d * d)) t_1 = Float64(c / Float64(d / b)) tmp = 0.0 if (d <= -5.8e+20) tmp = Float64(Float64(a - t_1) / hypot(c, d)); elseif (d <= -7.5e-118) tmp = Float64(Float64(Float64(b * c) - Float64(a * d)) / t_0); elseif (d <= 1.45e-112) tmp = Float64(Float64(b - Float64(Float64(a * d) / c)) / c); elseif (d <= 1.5e+57) tmp = Float64(Float64(Float64(b * c) / t_0) - Float64(Float64(a * d) / t_0)); else tmp = Float64(Float64(t_1 - a) / hypot(c, d)); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (c * c) + (d * d); t_1 = c / (d / b); tmp = 0.0; if (d <= -5.8e+20) tmp = (a - t_1) / hypot(c, d); elseif (d <= -7.5e-118) tmp = ((b * c) - (a * d)) / t_0; elseif (d <= 1.45e-112) tmp = (b - ((a * d) / c)) / c; elseif (d <= 1.5e+57) tmp = ((b * c) / t_0) - ((a * d) / t_0); else tmp = (t_1 - a) / hypot(c, d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(c / N[(d / b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -5.8e+20], N[(N[(a - t$95$1), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -7.5e-118], N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[d, 1.45e-112], N[(N[(b - N[(N[(a * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 1.5e+57], N[(N[(N[(b * c), $MachinePrecision] / t$95$0), $MachinePrecision] - N[(N[(a * d), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$1 - a), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot c + d \cdot d\\
t_1 := \frac{c}{\frac{d}{b}}\\
\mathbf{if}\;d \leq -5.8 \cdot 10^{+20}:\\
\;\;\;\;\frac{a - t_1}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq -7.5 \cdot 10^{-118}:\\
\;\;\;\;\frac{b \cdot c - a \cdot d}{t_0}\\
\mathbf{elif}\;d \leq 1.45 \cdot 10^{-112}:\\
\;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\
\mathbf{elif}\;d \leq 1.5 \cdot 10^{+57}:\\
\;\;\;\;\frac{b \cdot c}{t_0} - \frac{a \cdot d}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{t_1 - a}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if d < -5.8e20Initial program 43.9%
*-un-lft-identity43.9%
add-sqr-sqrt43.9%
times-frac43.9%
hypot-def43.9%
hypot-def66.8%
Applied egg-rr66.8%
associate-*l/67.0%
*-un-lft-identity67.0%
Applied egg-rr67.0%
Taylor expanded in d around -inf 80.4%
+-commutative80.4%
mul-1-neg80.4%
unsub-neg80.4%
associate-/l*80.4%
Simplified80.4%
if -5.8e20 < d < -7.49999999999999978e-118Initial program 79.3%
if -7.49999999999999978e-118 < d < 1.44999999999999996e-112Initial program 71.8%
*-un-lft-identity71.8%
add-sqr-sqrt71.8%
times-frac71.8%
hypot-def71.8%
hypot-def89.3%
Applied egg-rr89.3%
associate-*l/89.5%
*-un-lft-identity89.5%
Applied egg-rr89.5%
Taylor expanded in c around inf 83.6%
+-commutative83.6%
mul-1-neg83.6%
associate-/l*86.1%
unpow286.1%
associate-*r/92.0%
*-commutative92.0%
associate-/l/90.9%
sub-neg90.9%
associate-/r/82.6%
*-commutative82.6%
associate-*r/90.9%
div-sub90.9%
associate-*r/92.9%
*-commutative92.9%
Simplified92.9%
if 1.44999999999999996e-112 < d < 1.5e57Initial program 89.7%
Taylor expanded in b around 0 89.7%
+-commutative89.7%
associate-*r/89.7%
mul-1-neg89.7%
distribute-rgt-neg-out89.7%
unpow289.7%
unpow289.7%
unpow289.7%
unpow289.7%
Simplified89.7%
if 1.5e57 < d Initial program 53.2%
*-un-lft-identity53.2%
add-sqr-sqrt53.2%
times-frac53.2%
hypot-def53.2%
hypot-def65.0%
Applied egg-rr65.0%
associate-*l/65.2%
*-un-lft-identity65.2%
Applied egg-rr65.2%
Taylor expanded in c around 0 80.4%
neg-mul-180.4%
unsub-neg80.4%
associate-/l*82.4%
Simplified82.4%
Final simplification85.9%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (+ (* c c) (* d d))))
(if (<= d -5.8e+20)
(/ (- a (/ (* b c) d)) (hypot c d))
(if (<= d -4.3e-124)
(/ (- (* b c) (* a d)) t_0)
(if (<= d 1.3e-114)
(/ (- b (/ (* a d) c)) c)
(if (<= d 9e+57)
(- (/ (* b c) t_0) (/ (* a d) t_0))
(/ (- (/ c (/ d b)) a) (hypot c d))))))))
double code(double a, double b, double c, double d) {
double t_0 = (c * c) + (d * d);
double tmp;
if (d <= -5.8e+20) {
tmp = (a - ((b * c) / d)) / hypot(c, d);
} else if (d <= -4.3e-124) {
tmp = ((b * c) - (a * d)) / t_0;
} else if (d <= 1.3e-114) {
tmp = (b - ((a * d) / c)) / c;
} else if (d <= 9e+57) {
tmp = ((b * c) / t_0) - ((a * d) / t_0);
} else {
tmp = ((c / (d / b)) - a) / hypot(c, d);
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = (c * c) + (d * d);
double tmp;
if (d <= -5.8e+20) {
tmp = (a - ((b * c) / d)) / Math.hypot(c, d);
} else if (d <= -4.3e-124) {
tmp = ((b * c) - (a * d)) / t_0;
} else if (d <= 1.3e-114) {
tmp = (b - ((a * d) / c)) / c;
} else if (d <= 9e+57) {
tmp = ((b * c) / t_0) - ((a * d) / t_0);
} else {
tmp = ((c / (d / b)) - a) / Math.hypot(c, d);
}
return tmp;
}
def code(a, b, c, d): t_0 = (c * c) + (d * d) tmp = 0 if d <= -5.8e+20: tmp = (a - ((b * c) / d)) / math.hypot(c, d) elif d <= -4.3e-124: tmp = ((b * c) - (a * d)) / t_0 elif d <= 1.3e-114: tmp = (b - ((a * d) / c)) / c elif d <= 9e+57: tmp = ((b * c) / t_0) - ((a * d) / t_0) else: tmp = ((c / (d / b)) - a) / math.hypot(c, d) return tmp
function code(a, b, c, d) t_0 = Float64(Float64(c * c) + Float64(d * d)) tmp = 0.0 if (d <= -5.8e+20) tmp = Float64(Float64(a - Float64(Float64(b * c) / d)) / hypot(c, d)); elseif (d <= -4.3e-124) tmp = Float64(Float64(Float64(b * c) - Float64(a * d)) / t_0); elseif (d <= 1.3e-114) tmp = Float64(Float64(b - Float64(Float64(a * d) / c)) / c); elseif (d <= 9e+57) tmp = Float64(Float64(Float64(b * c) / t_0) - Float64(Float64(a * d) / t_0)); else tmp = Float64(Float64(Float64(c / Float64(d / b)) - a) / hypot(c, d)); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (c * c) + (d * d); tmp = 0.0; if (d <= -5.8e+20) tmp = (a - ((b * c) / d)) / hypot(c, d); elseif (d <= -4.3e-124) tmp = ((b * c) - (a * d)) / t_0; elseif (d <= 1.3e-114) tmp = (b - ((a * d) / c)) / c; elseif (d <= 9e+57) tmp = ((b * c) / t_0) - ((a * d) / t_0); else tmp = ((c / (d / b)) - a) / hypot(c, d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -5.8e+20], N[(N[(a - N[(N[(b * c), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -4.3e-124], N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[d, 1.3e-114], N[(N[(b - N[(N[(a * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 9e+57], N[(N[(N[(b * c), $MachinePrecision] / t$95$0), $MachinePrecision] - N[(N[(a * d), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(c / N[(d / b), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot c + d \cdot d\\
\mathbf{if}\;d \leq -5.8 \cdot 10^{+20}:\\
\;\;\;\;\frac{a - \frac{b \cdot c}{d}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq -4.3 \cdot 10^{-124}:\\
\;\;\;\;\frac{b \cdot c - a \cdot d}{t_0}\\
\mathbf{elif}\;d \leq 1.3 \cdot 10^{-114}:\\
\;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\
\mathbf{elif}\;d \leq 9 \cdot 10^{+57}:\\
\;\;\;\;\frac{b \cdot c}{t_0} - \frac{a \cdot d}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{c}{\frac{d}{b}} - a}{\mathsf{hypot}\left(c, d\right)}\\
\end{array}
\end{array}
if d < -5.8e20Initial program 43.9%
*-un-lft-identity43.9%
add-sqr-sqrt43.9%
times-frac43.9%
hypot-def43.9%
hypot-def66.8%
Applied egg-rr66.8%
associate-*l/67.0%
*-un-lft-identity67.0%
Applied egg-rr67.0%
Taylor expanded in d around -inf 80.4%
if -5.8e20 < d < -4.3e-124Initial program 79.3%
if -4.3e-124 < d < 1.30000000000000007e-114Initial program 71.8%
*-un-lft-identity71.8%
add-sqr-sqrt71.8%
times-frac71.8%
hypot-def71.8%
hypot-def89.3%
Applied egg-rr89.3%
associate-*l/89.5%
*-un-lft-identity89.5%
Applied egg-rr89.5%
Taylor expanded in c around inf 83.6%
+-commutative83.6%
mul-1-neg83.6%
associate-/l*86.1%
unpow286.1%
associate-*r/92.0%
*-commutative92.0%
associate-/l/90.9%
sub-neg90.9%
associate-/r/82.6%
*-commutative82.6%
associate-*r/90.9%
div-sub90.9%
associate-*r/92.9%
*-commutative92.9%
Simplified92.9%
if 1.30000000000000007e-114 < d < 8.99999999999999991e57Initial program 89.7%
Taylor expanded in b around 0 89.7%
+-commutative89.7%
associate-*r/89.7%
mul-1-neg89.7%
distribute-rgt-neg-out89.7%
unpow289.7%
unpow289.7%
unpow289.7%
unpow289.7%
Simplified89.7%
if 8.99999999999999991e57 < d Initial program 53.2%
*-un-lft-identity53.2%
add-sqr-sqrt53.2%
times-frac53.2%
hypot-def53.2%
hypot-def65.0%
Applied egg-rr65.0%
associate-*l/65.2%
*-un-lft-identity65.2%
Applied egg-rr65.2%
Taylor expanded in c around 0 80.4%
neg-mul-180.4%
unsub-neg80.4%
associate-/l*82.4%
Simplified82.4%
Final simplification85.9%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (+ (* c c) (* d d))))
(if (<= d -2.9e+20)
(/ (- a (/ c (/ d b))) (hypot c d))
(if (<= d -3.3e-121)
(/ (- (* b c) (* a d)) t_0)
(if (<= d 1.45e-112)
(/ (- b (/ (* a d) c)) c)
(if (<= d 2.3e+62)
(- (/ (* b c) t_0) (/ (* a d) t_0))
(- (* (/ c d) (/ 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 <= -2.9e+20) {
tmp = (a - (c / (d / b))) / hypot(c, d);
} else if (d <= -3.3e-121) {
tmp = ((b * c) - (a * d)) / t_0;
} else if (d <= 1.45e-112) {
tmp = (b - ((a * d) / c)) / c;
} else if (d <= 2.3e+62) {
tmp = ((b * c) / t_0) - ((a * d) / t_0);
} else {
tmp = ((c / d) * (b / d)) - (a / d);
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = (c * c) + (d * d);
double tmp;
if (d <= -2.9e+20) {
tmp = (a - (c / (d / b))) / Math.hypot(c, d);
} else if (d <= -3.3e-121) {
tmp = ((b * c) - (a * d)) / t_0;
} else if (d <= 1.45e-112) {
tmp = (b - ((a * d) / c)) / c;
} else if (d <= 2.3e+62) {
tmp = ((b * c) / t_0) - ((a * d) / t_0);
} else {
tmp = ((c / d) * (b / d)) - (a / d);
}
return tmp;
}
def code(a, b, c, d): t_0 = (c * c) + (d * d) tmp = 0 if d <= -2.9e+20: tmp = (a - (c / (d / b))) / math.hypot(c, d) elif d <= -3.3e-121: tmp = ((b * c) - (a * d)) / t_0 elif d <= 1.45e-112: tmp = (b - ((a * d) / c)) / c elif d <= 2.3e+62: tmp = ((b * c) / t_0) - ((a * d) / t_0) else: tmp = ((c / d) * (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 <= -2.9e+20) tmp = Float64(Float64(a - Float64(c / Float64(d / b))) / hypot(c, d)); elseif (d <= -3.3e-121) tmp = Float64(Float64(Float64(b * c) - Float64(a * d)) / t_0); elseif (d <= 1.45e-112) tmp = Float64(Float64(b - Float64(Float64(a * d) / c)) / c); elseif (d <= 2.3e+62) tmp = Float64(Float64(Float64(b * c) / t_0) - Float64(Float64(a * d) / 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 * c) + (d * d); tmp = 0.0; if (d <= -2.9e+20) tmp = (a - (c / (d / b))) / hypot(c, d); elseif (d <= -3.3e-121) tmp = ((b * c) - (a * d)) / t_0; elseif (d <= 1.45e-112) tmp = (b - ((a * d) / c)) / c; elseif (d <= 2.3e+62) tmp = ((b * c) / t_0) - ((a * d) / 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[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -2.9e+20], N[(N[(a - N[(c / N[(d / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -3.3e-121], N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[d, 1.45e-112], N[(N[(b - N[(N[(a * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 2.3e+62], N[(N[(N[(b * c), $MachinePrecision] / t$95$0), $MachinePrecision] - N[(N[(a * d), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(c / d), $MachinePrecision] * N[(b / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot c + d \cdot d\\
\mathbf{if}\;d \leq -2.9 \cdot 10^{+20}:\\
\;\;\;\;\frac{a - \frac{c}{\frac{d}{b}}}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{elif}\;d \leq -3.3 \cdot 10^{-121}:\\
\;\;\;\;\frac{b \cdot c - a \cdot d}{t_0}\\
\mathbf{elif}\;d \leq 1.45 \cdot 10^{-112}:\\
\;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\
\mathbf{elif}\;d \leq 2.3 \cdot 10^{+62}:\\
\;\;\;\;\frac{b \cdot c}{t_0} - \frac{a \cdot d}{t_0}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\
\end{array}
\end{array}
if d < -2.9e20Initial program 43.9%
*-un-lft-identity43.9%
add-sqr-sqrt43.9%
times-frac43.9%
hypot-def43.9%
hypot-def66.8%
Applied egg-rr66.8%
associate-*l/67.0%
*-un-lft-identity67.0%
Applied egg-rr67.0%
Taylor expanded in d around -inf 80.4%
+-commutative80.4%
mul-1-neg80.4%
unsub-neg80.4%
associate-/l*80.4%
Simplified80.4%
if -2.9e20 < d < -3.3000000000000001e-121Initial program 79.3%
if -3.3000000000000001e-121 < d < 1.44999999999999996e-112Initial program 71.8%
*-un-lft-identity71.8%
add-sqr-sqrt71.8%
times-frac71.8%
hypot-def71.8%
hypot-def89.3%
Applied egg-rr89.3%
associate-*l/89.5%
*-un-lft-identity89.5%
Applied egg-rr89.5%
Taylor expanded in c around inf 83.6%
+-commutative83.6%
mul-1-neg83.6%
associate-/l*86.1%
unpow286.1%
associate-*r/92.0%
*-commutative92.0%
associate-/l/90.9%
sub-neg90.9%
associate-/r/82.6%
*-commutative82.6%
associate-*r/90.9%
div-sub90.9%
associate-*r/92.9%
*-commutative92.9%
Simplified92.9%
if 1.44999999999999996e-112 < d < 2.29999999999999984e62Initial program 89.7%
Taylor expanded in b around 0 89.7%
+-commutative89.7%
associate-*r/89.7%
mul-1-neg89.7%
distribute-rgt-neg-out89.7%
unpow289.7%
unpow289.7%
unpow289.7%
unpow289.7%
Simplified89.7%
if 2.29999999999999984e62 < d Initial program 53.2%
Taylor expanded in c around 0 80.1%
+-commutative80.1%
mul-1-neg80.1%
unsub-neg80.1%
unpow280.1%
times-frac82.0%
Simplified82.0%
Final simplification85.8%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (+ (* c c) (* d d))) (t_1 (- (* (/ c d) (/ b d)) (/ a d))))
(if (<= d -5.8e+20)
t_1
(if (<= d -1.75e-122)
(/ (- (* b c) (* a d)) t_0)
(if (<= d 1.5e-106)
(/ (- b (/ (* a d) c)) c)
(if (<= d 1.4e+58) (- (/ (* b c) t_0) (/ (* a d) t_0)) t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = (c * c) + (d * d);
double t_1 = ((c / d) * (b / d)) - (a / d);
double tmp;
if (d <= -5.8e+20) {
tmp = t_1;
} else if (d <= -1.75e-122) {
tmp = ((b * c) - (a * d)) / t_0;
} else if (d <= 1.5e-106) {
tmp = (b - ((a * d) / c)) / c;
} else if (d <= 1.4e+58) {
tmp = ((b * c) / t_0) - ((a * d) / t_0);
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (c * c) + (d * d)
t_1 = ((c / d) * (b / d)) - (a / d)
if (d <= (-5.8d+20)) then
tmp = t_1
else if (d <= (-1.75d-122)) then
tmp = ((b * c) - (a * d)) / t_0
else if (d <= 1.5d-106) then
tmp = (b - ((a * d) / c)) / c
else if (d <= 1.4d+58) then
tmp = ((b * c) / t_0) - ((a * d) / t_0)
else
tmp = t_1
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = (c * c) + (d * d);
double t_1 = ((c / d) * (b / d)) - (a / d);
double tmp;
if (d <= -5.8e+20) {
tmp = t_1;
} else if (d <= -1.75e-122) {
tmp = ((b * c) - (a * d)) / t_0;
} else if (d <= 1.5e-106) {
tmp = (b - ((a * d) / c)) / c;
} else if (d <= 1.4e+58) {
tmp = ((b * c) / t_0) - ((a * d) / t_0);
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = (c * c) + (d * d) t_1 = ((c / d) * (b / d)) - (a / d) tmp = 0 if d <= -5.8e+20: tmp = t_1 elif d <= -1.75e-122: tmp = ((b * c) - (a * d)) / t_0 elif d <= 1.5e-106: tmp = (b - ((a * d) / c)) / c elif d <= 1.4e+58: tmp = ((b * c) / t_0) - ((a * d) / t_0) else: tmp = t_1 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(c * c) + Float64(d * d)) t_1 = Float64(Float64(Float64(c / d) * Float64(b / d)) - Float64(a / d)) tmp = 0.0 if (d <= -5.8e+20) tmp = t_1; elseif (d <= -1.75e-122) tmp = Float64(Float64(Float64(b * c) - Float64(a * d)) / t_0); elseif (d <= 1.5e-106) tmp = Float64(Float64(b - Float64(Float64(a * d) / c)) / c); elseif (d <= 1.4e+58) tmp = Float64(Float64(Float64(b * c) / t_0) - Float64(Float64(a * d) / t_0)); else tmp = t_1; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (c * c) + (d * d); t_1 = ((c / d) * (b / d)) - (a / d); tmp = 0.0; if (d <= -5.8e+20) tmp = t_1; elseif (d <= -1.75e-122) tmp = ((b * c) - (a * d)) / t_0; elseif (d <= 1.5e-106) tmp = (b - ((a * d) / c)) / c; elseif (d <= 1.4e+58) tmp = ((b * c) / t_0) - ((a * d) / t_0); else tmp = t_1; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(c / d), $MachinePrecision] * N[(b / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -5.8e+20], t$95$1, If[LessEqual[d, -1.75e-122], N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision], If[LessEqual[d, 1.5e-106], N[(N[(b - N[(N[(a * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 1.4e+58], N[(N[(N[(b * c), $MachinePrecision] / t$95$0), $MachinePrecision] - N[(N[(a * d), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := c \cdot c + d \cdot d\\
t_1 := \frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\
\mathbf{if}\;d \leq -5.8 \cdot 10^{+20}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d \leq -1.75 \cdot 10^{-122}:\\
\;\;\;\;\frac{b \cdot c - a \cdot d}{t_0}\\
\mathbf{elif}\;d \leq 1.5 \cdot 10^{-106}:\\
\;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\
\mathbf{elif}\;d \leq 1.4 \cdot 10^{+58}:\\
\;\;\;\;\frac{b \cdot c}{t_0} - \frac{a \cdot d}{t_0}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if d < -5.8e20 or 1.3999999999999999e58 < d Initial program 48.3%
Taylor expanded in c around 0 78.5%
+-commutative78.5%
mul-1-neg78.5%
unsub-neg78.5%
unpow278.5%
times-frac80.2%
Simplified80.2%
if -5.8e20 < d < -1.7500000000000001e-122Initial program 79.3%
if -1.7500000000000001e-122 < d < 1.50000000000000009e-106Initial program 71.8%
*-un-lft-identity71.8%
add-sqr-sqrt71.8%
times-frac71.8%
hypot-def71.8%
hypot-def89.3%
Applied egg-rr89.3%
associate-*l/89.5%
*-un-lft-identity89.5%
Applied egg-rr89.5%
Taylor expanded in c around inf 83.6%
+-commutative83.6%
mul-1-neg83.6%
associate-/l*86.1%
unpow286.1%
associate-*r/92.0%
*-commutative92.0%
associate-/l/90.9%
sub-neg90.9%
associate-/r/82.6%
*-commutative82.6%
associate-*r/90.9%
div-sub90.9%
associate-*r/92.9%
*-commutative92.9%
Simplified92.9%
if 1.50000000000000009e-106 < d < 1.3999999999999999e58Initial program 89.7%
Taylor expanded in b around 0 89.7%
+-commutative89.7%
associate-*r/89.7%
mul-1-neg89.7%
distribute-rgt-neg-out89.7%
unpow289.7%
unpow289.7%
unpow289.7%
unpow289.7%
Simplified89.7%
Final simplification85.4%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
(t_1 (- (* (/ c d) (/ b d)) (/ a d))))
(if (<= d -5.8e+20)
t_1
(if (<= d -2e-116)
t_0
(if (<= d 1.1e-113)
(/ (- b (/ (* a d) c)) c)
(if (<= d 9e+57) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d));
double t_1 = ((c / d) * (b / d)) - (a / d);
double tmp;
if (d <= -5.8e+20) {
tmp = t_1;
} else if (d <= -2e-116) {
tmp = t_0;
} else if (d <= 1.1e-113) {
tmp = (b - ((a * d) / c)) / c;
} else if (d <= 9e+57) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d))
t_1 = ((c / d) * (b / d)) - (a / d)
if (d <= (-5.8d+20)) then
tmp = t_1
else if (d <= (-2d-116)) then
tmp = t_0
else if (d <= 1.1d-113) then
tmp = (b - ((a * d) / c)) / c
else if (d <= 9d+57) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d));
double t_1 = ((c / d) * (b / d)) - (a / d);
double tmp;
if (d <= -5.8e+20) {
tmp = t_1;
} else if (d <= -2e-116) {
tmp = t_0;
} else if (d <= 1.1e-113) {
tmp = (b - ((a * d) / c)) / c;
} else if (d <= 9e+57) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d)) t_1 = ((c / d) * (b / d)) - (a / d) tmp = 0 if d <= -5.8e+20: tmp = t_1 elif d <= -2e-116: tmp = t_0 elif d <= 1.1e-113: tmp = (b - ((a * d) / c)) / c elif d <= 9e+57: tmp = t_0 else: tmp = t_1 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) t_1 = Float64(Float64(Float64(c / d) * Float64(b / d)) - Float64(a / d)) tmp = 0.0 if (d <= -5.8e+20) tmp = t_1; elseif (d <= -2e-116) tmp = t_0; elseif (d <= 1.1e-113) tmp = Float64(Float64(b - Float64(Float64(a * d) / c)) / c); elseif (d <= 9e+57) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((b * c) - (a * d)) / ((c * c) + (d * d)); t_1 = ((c / d) * (b / d)) - (a / d); tmp = 0.0; if (d <= -5.8e+20) tmp = t_1; elseif (d <= -2e-116) tmp = t_0; elseif (d <= 1.1e-113) tmp = (b - ((a * d) / c)) / c; elseif (d <= 9e+57) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(c / d), $MachinePrecision] * N[(b / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -5.8e+20], t$95$1, If[LessEqual[d, -2e-116], t$95$0, If[LessEqual[d, 1.1e-113], N[(N[(b - N[(N[(a * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 9e+57], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}\\
t_1 := \frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\
\mathbf{if}\;d \leq -5.8 \cdot 10^{+20}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;d \leq -2 \cdot 10^{-116}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;d \leq 1.1 \cdot 10^{-113}:\\
\;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\
\mathbf{elif}\;d \leq 9 \cdot 10^{+57}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if d < -5.8e20 or 8.99999999999999991e57 < d Initial program 48.3%
Taylor expanded in c around 0 78.5%
+-commutative78.5%
mul-1-neg78.5%
unsub-neg78.5%
unpow278.5%
times-frac80.2%
Simplified80.2%
if -5.8e20 < d < -2e-116 or 1.10000000000000002e-113 < d < 8.99999999999999991e57Initial program 84.5%
if -2e-116 < d < 1.10000000000000002e-113Initial program 71.8%
*-un-lft-identity71.8%
add-sqr-sqrt71.8%
times-frac71.8%
hypot-def71.8%
hypot-def89.3%
Applied egg-rr89.3%
associate-*l/89.5%
*-un-lft-identity89.5%
Applied egg-rr89.5%
Taylor expanded in c around inf 83.6%
+-commutative83.6%
mul-1-neg83.6%
associate-/l*86.1%
unpow286.1%
associate-*r/92.0%
*-commutative92.0%
associate-/l/90.9%
sub-neg90.9%
associate-/r/82.6%
*-commutative82.6%
associate-*r/90.9%
div-sub90.9%
associate-*r/92.9%
*-commutative92.9%
Simplified92.9%
Final simplification85.4%
(FPCore (a b c d) :precision binary64 (if (or (<= d -1.95e+21) (not (<= d 2.5e-40))) (- (* (/ c d) (/ b d)) (/ a d)) (/ (- b (/ (* a d) c)) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.95e+21) || !(d <= 2.5e-40)) {
tmp = ((c / d) * (b / d)) - (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 <= (-1.95d+21)) .or. (.not. (d <= 2.5d-40))) then
tmp = ((c / d) * (b / d)) - (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 <= -1.95e+21) || !(d <= 2.5e-40)) {
tmp = ((c / d) * (b / d)) - (a / d);
} else {
tmp = (b - ((a * d) / c)) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -1.95e+21) or not (d <= 2.5e-40): tmp = ((c / d) * (b / d)) - (a / d) else: tmp = (b - ((a * d) / c)) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -1.95e+21) || !(d <= 2.5e-40)) tmp = Float64(Float64(Float64(c / d) * Float64(b / d)) - Float64(a / d)); else tmp = Float64(Float64(b - Float64(Float64(a * d) / c)) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -1.95e+21) || ~((d <= 2.5e-40))) tmp = ((c / d) * (b / d)) - (a / d); else tmp = (b - ((a * d) / c)) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -1.95e+21], N[Not[LessEqual[d, 2.5e-40]], $MachinePrecision]], N[(N[(N[(c / d), $MachinePrecision] * N[(b / d), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], N[(N[(b - N[(N[(a * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.95 \cdot 10^{+21} \lor \neg \left(d \leq 2.5 \cdot 10^{-40}\right):\\
\;\;\;\;\frac{c}{d} \cdot \frac{b}{d} - \frac{a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\
\end{array}
\end{array}
if d < -1.95e21 or 2.49999999999999982e-40 < d Initial program 54.0%
Taylor expanded in c around 0 76.7%
+-commutative76.7%
mul-1-neg76.7%
unsub-neg76.7%
unpow276.7%
times-frac78.2%
Simplified78.2%
if -1.95e21 < d < 2.49999999999999982e-40Initial program 75.1%
*-un-lft-identity75.1%
add-sqr-sqrt75.1%
times-frac75.0%
hypot-def75.1%
hypot-def88.3%
Applied egg-rr88.3%
associate-*l/88.5%
*-un-lft-identity88.5%
Applied egg-rr88.5%
Taylor expanded in c around inf 76.7%
+-commutative76.7%
mul-1-neg76.7%
associate-/l*78.3%
unpow278.3%
associate-*r/82.2%
*-commutative82.2%
associate-/l/81.5%
sub-neg81.5%
associate-/r/76.0%
*-commutative76.0%
associate-*r/81.5%
div-sub81.5%
associate-*r/82.9%
*-commutative82.9%
Simplified82.9%
Final simplification80.6%
(FPCore (a b c d) :precision binary64 (if (or (<= d -2.7e+22) (not (<= d 5.8e+31))) (/ (- a) d) (/ (- b (* d (/ a c))) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -2.7e+22) || !(d <= 5.8e+31)) {
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 ((d <= (-2.7d+22)) .or. (.not. (d <= 5.8d+31))) 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 ((d <= -2.7e+22) || !(d <= 5.8e+31)) {
tmp = -a / d;
} else {
tmp = (b - (d * (a / c))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -2.7e+22) or not (d <= 5.8e+31): tmp = -a / d else: tmp = (b - (d * (a / c))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -2.7e+22) || !(d <= 5.8e+31)) 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 ((d <= -2.7e+22) || ~((d <= 5.8e+31))) tmp = -a / d; else tmp = (b - (d * (a / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -2.7e+22], N[Not[LessEqual[d, 5.8e+31]], $MachinePrecision]], 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}\;d \leq -2.7 \cdot 10^{+22} \lor \neg \left(d \leq 5.8 \cdot 10^{+31}\right):\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - d \cdot \frac{a}{c}}{c}\\
\end{array}
\end{array}
if d < -2.7000000000000002e22 or 5.8000000000000001e31 < d Initial program 50.9%
Taylor expanded in c around 0 76.1%
associate-*r/76.1%
neg-mul-176.1%
Simplified76.1%
if -2.7000000000000002e22 < d < 5.8000000000000001e31Initial program 75.8%
Taylor expanded in c around inf 72.5%
+-commutative72.5%
mul-1-neg72.5%
unsub-neg72.5%
unpow272.5%
times-frac78.2%
Simplified78.2%
associate-*r/78.2%
Applied egg-rr78.2%
sub-div78.3%
*-commutative78.3%
Applied egg-rr78.3%
Final simplification77.3%
(FPCore (a b c d) :precision binary64 (if (or (<= d -1.25e+23) (not (<= d 6e+35))) (/ (- a) d) (/ (- b (/ (* a d) c)) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.25e+23) || !(d <= 6e+35)) {
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 <= (-1.25d+23)) .or. (.not. (d <= 6d+35))) 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 <= -1.25e+23) || !(d <= 6e+35)) {
tmp = -a / d;
} else {
tmp = (b - ((a * d) / c)) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -1.25e+23) or not (d <= 6e+35): tmp = -a / d else: tmp = (b - ((a * d) / c)) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -1.25e+23) || !(d <= 6e+35)) tmp = Float64(Float64(-a) / d); else tmp = Float64(Float64(b - Float64(Float64(a * d) / c)) / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -1.25e+23) || ~((d <= 6e+35))) tmp = -a / d; else tmp = (b - ((a * d) / c)) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -1.25e+23], N[Not[LessEqual[d, 6e+35]], $MachinePrecision]], N[((-a) / d), $MachinePrecision], N[(N[(b - N[(N[(a * d), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -1.25 \cdot 10^{+23} \lor \neg \left(d \leq 6 \cdot 10^{+35}\right):\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - \frac{a \cdot d}{c}}{c}\\
\end{array}
\end{array}
if d < -1.25e23 or 5.99999999999999981e35 < d Initial program 50.9%
Taylor expanded in c around 0 76.1%
associate-*r/76.1%
neg-mul-176.1%
Simplified76.1%
if -1.25e23 < d < 5.99999999999999981e35Initial program 75.8%
*-un-lft-identity75.8%
add-sqr-sqrt75.8%
times-frac75.8%
hypot-def75.8%
hypot-def89.3%
Applied egg-rr89.3%
associate-*l/89.4%
*-un-lft-identity89.4%
Applied egg-rr89.4%
Taylor expanded in c around inf 72.5%
+-commutative72.5%
mul-1-neg72.5%
associate-/l*74.0%
unpow274.0%
associate-*r/77.5%
*-commutative77.5%
associate-/l/78.2%
sub-neg78.2%
associate-/r/73.3%
*-commutative73.3%
associate-*r/78.2%
div-sub78.3%
associate-*r/79.6%
*-commutative79.6%
Simplified79.6%
Final simplification78.0%
(FPCore (a b c d) :precision binary64 (if (or (<= d -5.9e+20) (not (<= d 6.5e-8))) (/ (- a) d) (/ b c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -5.9e+20) || !(d <= 6.5e-8)) {
tmp = -a / d;
} else {
tmp = b / c;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if ((d <= (-5.9d+20)) .or. (.not. (d <= 6.5d-8))) then
tmp = -a / d
else
tmp = b / c
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -5.9e+20) || !(d <= 6.5e-8)) {
tmp = -a / d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -5.9e+20) or not (d <= 6.5e-8): tmp = -a / d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -5.9e+20) || !(d <= 6.5e-8)) 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 <= -5.9e+20) || ~((d <= 6.5e-8))) tmp = -a / d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -5.9e+20], N[Not[LessEqual[d, 6.5e-8]], $MachinePrecision]], N[((-a) / d), $MachinePrecision], N[(b / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -5.9 \cdot 10^{+20} \lor \neg \left(d \leq 6.5 \cdot 10^{-8}\right):\\
\;\;\;\;\frac{-a}{d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if d < -5.9e20 or 6.49999999999999997e-8 < d Initial program 51.4%
Taylor expanded in c around 0 74.7%
associate-*r/74.7%
neg-mul-174.7%
Simplified74.7%
if -5.9e20 < d < 6.49999999999999997e-8Initial program 76.3%
Taylor expanded in c around inf 65.5%
Final simplification69.9%
(FPCore (a b c d) :precision binary64 (/ a c))
double code(double a, double b, double c, double d) {
return a / c;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = a / c
end function
public static double code(double a, double b, double c, double d) {
return a / c;
}
def code(a, b, c, d): return a / c
function code(a, b, c, d) return Float64(a / c) end
function tmp = code(a, b, c, d) tmp = a / c; end
code[a_, b_, c_, d_] := N[(a / c), $MachinePrecision]
\begin{array}{l}
\\
\frac{a}{c}
\end{array}
Initial program 64.5%
*-un-lft-identity64.5%
add-sqr-sqrt64.5%
times-frac64.5%
hypot-def64.5%
hypot-def79.6%
Applied egg-rr79.6%
Taylor expanded in c around inf 26.4%
Taylor expanded in d around -inf 9.3%
Final simplification9.3%
(FPCore (a b c d) :precision binary64 (/ b c))
double code(double a, double b, double c, double d) {
return b / c;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = b / c
end function
public static double code(double a, double b, double c, double d) {
return b / c;
}
def code(a, b, c, d): return b / c
function code(a, b, c, d) return Float64(b / c) end
function tmp = code(a, b, c, d) tmp = b / c; end
code[a_, b_, c_, d_] := N[(b / c), $MachinePrecision]
\begin{array}{l}
\\
\frac{b}{c}
\end{array}
Initial program 64.5%
Taylor expanded in c around inf 43.3%
Final simplification43.3%
(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 2023200
(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))))