
(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
(fma
(/ c (hypot c d))
(/ b (hypot c d))
(* a (/ (- d) (pow (hypot c d) 2.0)))))
(t_1 (* c (/ b d))))
(if (<= d -3.4e+122)
(* (/ 1.0 (hypot c d)) (- a t_1))
(if (<= d -5.6e-161)
t_0
(if (<= d 2e-191)
(/ (- b (/ (* d a) c)) c)
(if (<= d 1.3e+108) t_0 (/ (- t_1 a) d)))))))
double code(double a, double b, double c, double d) {
double t_0 = fma((c / hypot(c, d)), (b / hypot(c, d)), (a * (-d / pow(hypot(c, d), 2.0))));
double t_1 = c * (b / d);
double tmp;
if (d <= -3.4e+122) {
tmp = (1.0 / hypot(c, d)) * (a - t_1);
} else if (d <= -5.6e-161) {
tmp = t_0;
} else if (d <= 2e-191) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 1.3e+108) {
tmp = t_0;
} else {
tmp = (t_1 - a) / d;
}
return tmp;
}
function code(a, b, c, d) t_0 = fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(a * Float64(Float64(-d) / (hypot(c, d) ^ 2.0)))) t_1 = Float64(c * Float64(b / d)) tmp = 0.0 if (d <= -3.4e+122) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(a - t_1)); elseif (d <= -5.6e-161) tmp = t_0; elseif (d <= 2e-191) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); elseif (d <= 1.3e+108) tmp = t_0; else tmp = Float64(Float64(t_1 - a) / d); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] + N[(a * N[((-d) / N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -3.4e+122], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(a - t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -5.6e-161], t$95$0, If[LessEqual[d, 2e-191], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 1.3e+108], t$95$0, N[(N[(t$95$1 - a), $MachinePrecision] / d), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, a \cdot \frac{-d}{{\left(\mathsf{hypot}\left(c, d\right)\right)}^{2}}\right)\\
t_1 := c \cdot \frac{b}{d}\\
\mathbf{if}\;d \leq -3.4 \cdot 10^{+122}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(a - t\_1\right)\\
\mathbf{elif}\;d \leq -5.6 \cdot 10^{-161}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 2 \cdot 10^{-191}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{elif}\;d \leq 1.3 \cdot 10^{+108}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1 - a}{d}\\
\end{array}
\end{array}
if d < -3.4e122Initial program 54.3%
*-un-lft-identity54.3%
add-sqr-sqrt54.3%
times-frac54.2%
hypot-define54.2%
fmm-def54.2%
distribute-rgt-neg-in54.2%
hypot-define68.6%
Applied egg-rr68.6%
Taylor expanded in d around -inf 86.6%
neg-mul-186.6%
unsub-neg86.6%
*-lft-identity86.6%
*-commutative86.6%
times-frac90.0%
/-rgt-identity90.0%
Simplified90.0%
if -3.4e122 < d < -5.59999999999999984e-161 or 2e-191 < d < 1.3000000000000001e108Initial program 74.1%
div-sub74.0%
*-commutative74.0%
add-sqr-sqrt74.0%
times-frac76.8%
fmm-def76.8%
hypot-define76.8%
hypot-define90.9%
associate-/l*95.5%
add-sqr-sqrt95.5%
pow295.5%
hypot-define95.5%
Applied egg-rr95.5%
if -5.59999999999999984e-161 < d < 2e-191Initial program 73.0%
div-sub62.7%
*-commutative62.7%
add-sqr-sqrt62.7%
times-frac67.8%
fmm-def67.8%
hypot-define67.9%
hypot-define82.6%
associate-/l*83.1%
add-sqr-sqrt83.1%
pow283.1%
hypot-define83.1%
Applied egg-rr83.1%
Taylor expanded in c around inf 93.3%
mul-1-neg93.3%
unsub-neg93.3%
*-commutative93.3%
Simplified93.3%
if 1.3000000000000001e108 < d Initial program 38.5%
*-un-lft-identity38.5%
add-sqr-sqrt38.5%
times-frac38.4%
hypot-define38.4%
fmm-def38.4%
distribute-rgt-neg-in38.4%
hypot-define53.4%
Applied egg-rr53.4%
Taylor expanded in c around 0 85.5%
+-commutative85.5%
neg-mul-185.5%
sub-neg85.5%
unpow285.5%
associate-/l/84.1%
div-sub84.1%
*-lft-identity84.1%
*-commutative84.1%
times-frac96.2%
/-rgt-identity96.2%
Simplified96.2%
Final simplification94.5%
(FPCore (a b c d) :precision binary64 (if (<= (/ (- (* c b) (* d a)) (+ (* c c) (* d d))) 5e+287) (* (/ 1.0 (hypot c d)) (/ (fma b c (* d (- a))) (hypot c d))) (/ (- (* c (/ b d)) a) d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((((c * b) - (d * a)) / ((c * c) + (d * d))) <= 5e+287) {
tmp = (1.0 / hypot(c, d)) * (fma(b, c, (d * -a)) / hypot(c, d));
} else {
tmp = ((c * (b / d)) - a) / d;
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if (Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))) <= 5e+287) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(fma(b, c, Float64(d * Float64(-a))) / hypot(c, d))); else tmp = Float64(Float64(Float64(c * Float64(b / d)) - a) / d); end return tmp end
code[a_, b_, c_, d_] := If[LessEqual[N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e+287], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(b * c + N[(d * (-a)), $MachinePrecision]), $MachinePrecision] / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d} \leq 5 \cdot 10^{+287}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \frac{\mathsf{fma}\left(b, c, d \cdot \left(-a\right)\right)}{\mathsf{hypot}\left(c, d\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\end{array}
\end{array}
if (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) < 5e287Initial program 81.1%
*-un-lft-identity81.1%
add-sqr-sqrt81.1%
times-frac81.0%
hypot-define81.1%
fmm-def81.1%
distribute-rgt-neg-in81.1%
hypot-define95.2%
Applied egg-rr95.2%
if 5e287 < (/.f64 (-.f64 (*.f64 b c) (*.f64 a d)) (+.f64 (*.f64 c c) (*.f64 d d))) Initial program 16.5%
*-un-lft-identity16.5%
add-sqr-sqrt16.5%
times-frac16.5%
hypot-define16.5%
fmm-def16.5%
distribute-rgt-neg-in16.5%
hypot-define24.2%
Applied egg-rr24.2%
Taylor expanded in c around 0 49.4%
+-commutative49.4%
neg-mul-149.4%
sub-neg49.4%
unpow249.4%
associate-/l/59.0%
div-sub59.1%
*-lft-identity59.1%
*-commutative59.1%
times-frac68.2%
/-rgt-identity68.2%
Simplified68.2%
Final simplification88.4%
(FPCore (a b c d)
:precision binary64
(if (<= c -4.5e-7)
(/ (- b (* a (/ d c))) c)
(if (<= c 1.8e-144)
(/ (- (/ (* c b) d) a) d)
(if (<= c 6.4e+139)
(/ (- (* c b) (* d a)) (+ (* c c) (* d d)))
(* (/ c (hypot d c)) (/ b (hypot d c)))))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -4.5e-7) {
tmp = (b - (a * (d / c))) / c;
} else if (c <= 1.8e-144) {
tmp = (((c * b) / d) - a) / d;
} else if (c <= 6.4e+139) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else {
tmp = (c / hypot(d, c)) * (b / hypot(d, c));
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -4.5e-7) {
tmp = (b - (a * (d / c))) / c;
} else if (c <= 1.8e-144) {
tmp = (((c * b) / d) - a) / d;
} else if (c <= 6.4e+139) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else {
tmp = (c / Math.hypot(d, c)) * (b / Math.hypot(d, c));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -4.5e-7: tmp = (b - (a * (d / c))) / c elif c <= 1.8e-144: tmp = (((c * b) / d) - a) / d elif c <= 6.4e+139: tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)) else: tmp = (c / math.hypot(d, c)) * (b / math.hypot(d, c)) return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -4.5e-7) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); elseif (c <= 1.8e-144) tmp = Float64(Float64(Float64(Float64(c * b) / d) - a) / d); elseif (c <= 6.4e+139) tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))); else tmp = Float64(Float64(c / hypot(d, c)) * Float64(b / hypot(d, c))); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if (c <= -4.5e-7) tmp = (b - (a * (d / c))) / c; elseif (c <= 1.8e-144) tmp = (((c * b) / d) - a) / d; elseif (c <= 6.4e+139) tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)); else tmp = (c / hypot(d, c)) * (b / hypot(d, c)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -4.5e-7], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[c, 1.8e-144], N[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 6.4e+139], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -4.5 \cdot 10^{-7}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{elif}\;c \leq 1.8 \cdot 10^{-144}:\\
\;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\
\mathbf{elif}\;c \leq 6.4 \cdot 10^{+139}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{b}{\mathsf{hypot}\left(d, c\right)}\\
\end{array}
\end{array}
if c < -4.4999999999999998e-7Initial program 60.1%
Taylor expanded in c around inf 80.3%
mul-1-neg80.3%
unsub-neg80.3%
associate-/l*83.4%
Simplified83.4%
if -4.4999999999999998e-7 < c < 1.8e-144Initial program 73.6%
div-sub67.1%
*-commutative67.1%
add-sqr-sqrt67.1%
times-frac66.7%
fmm-def66.7%
hypot-define66.7%
hypot-define68.7%
associate-/l*75.9%
add-sqr-sqrt75.9%
pow275.9%
hypot-define75.9%
Applied egg-rr75.9%
Taylor expanded in d around inf 92.3%
if 1.8e-144 < c < 6.4000000000000002e139Initial program 78.7%
if 6.4000000000000002e139 < c Initial program 24.6%
Taylor expanded in b around inf 25.1%
*-commutative25.1%
Simplified25.1%
add-sqr-sqrt25.1%
hypot-undefine25.1%
hypot-undefine25.1%
frac-times83.0%
hypot-undefine29.4%
+-commutative29.4%
hypot-define83.0%
hypot-undefine29.4%
+-commutative29.4%
hypot-define83.0%
Applied egg-rr83.0%
Final simplification85.7%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))) (t_1 (* c (/ b d))))
(if (<= d -2.1e+121)
(* (/ 1.0 (hypot c d)) (- a t_1))
(if (<= d -1.02e-158)
t_0
(if (<= d 1.22e-104)
(/ (- b (/ (* d a) c)) c)
(if (<= d 1.75e+64) t_0 (/ (- t_1 a) d)))))))
double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double t_1 = c * (b / d);
double tmp;
if (d <= -2.1e+121) {
tmp = (1.0 / hypot(c, d)) * (a - t_1);
} else if (d <= -1.02e-158) {
tmp = t_0;
} else if (d <= 1.22e-104) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 1.75e+64) {
tmp = t_0;
} else {
tmp = (t_1 - a) / 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 t_1 = c * (b / d);
double tmp;
if (d <= -2.1e+121) {
tmp = (1.0 / Math.hypot(c, d)) * (a - t_1);
} else if (d <= -1.02e-158) {
tmp = t_0;
} else if (d <= 1.22e-104) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 1.75e+64) {
tmp = t_0;
} else {
tmp = (t_1 - a) / d;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)) t_1 = c * (b / d) tmp = 0 if d <= -2.1e+121: tmp = (1.0 / math.hypot(c, d)) * (a - t_1) elif d <= -1.02e-158: tmp = t_0 elif d <= 1.22e-104: tmp = (b - ((d * a) / c)) / c elif d <= 1.75e+64: tmp = t_0 else: tmp = (t_1 - 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))) t_1 = Float64(c * Float64(b / d)) tmp = 0.0 if (d <= -2.1e+121) tmp = Float64(Float64(1.0 / hypot(c, d)) * Float64(a - t_1)); elseif (d <= -1.02e-158) tmp = t_0; elseif (d <= 1.22e-104) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); elseif (d <= 1.75e+64) tmp = t_0; else tmp = Float64(Float64(t_1 - a) / d); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)); t_1 = c * (b / d); tmp = 0.0; if (d <= -2.1e+121) tmp = (1.0 / hypot(c, d)) * (a - t_1); elseif (d <= -1.02e-158) tmp = t_0; elseif (d <= 1.22e-104) tmp = (b - ((d * a) / c)) / c; elseif (d <= 1.75e+64) tmp = t_0; else tmp = (t_1 - 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]}, Block[{t$95$1 = N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -2.1e+121], N[(N[(1.0 / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(a - t$95$1), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.02e-158], t$95$0, If[LessEqual[d, 1.22e-104], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 1.75e+64], t$95$0, N[(N[(t$95$1 - a), $MachinePrecision] / d), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
t_1 := c \cdot \frac{b}{d}\\
\mathbf{if}\;d \leq -2.1 \cdot 10^{+121}:\\
\;\;\;\;\frac{1}{\mathsf{hypot}\left(c, d\right)} \cdot \left(a - t\_1\right)\\
\mathbf{elif}\;d \leq -1.02 \cdot 10^{-158}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 1.22 \cdot 10^{-104}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{elif}\;d \leq 1.75 \cdot 10^{+64}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1 - a}{d}\\
\end{array}
\end{array}
if d < -2.1000000000000002e121Initial program 52.6%
*-un-lft-identity52.6%
add-sqr-sqrt52.6%
times-frac52.5%
hypot-define52.5%
fmm-def52.5%
distribute-rgt-neg-in52.5%
hypot-define66.4%
Applied egg-rr66.4%
Taylor expanded in d around -inf 87.0%
neg-mul-187.0%
unsub-neg87.0%
*-lft-identity87.0%
*-commutative87.0%
times-frac90.4%
/-rgt-identity90.4%
Simplified90.4%
if -2.1000000000000002e121 < d < -1.0199999999999999e-158 or 1.21999999999999997e-104 < d < 1.7499999999999999e64Initial program 78.2%
if -1.0199999999999999e-158 < d < 1.21999999999999997e-104Initial program 72.3%
div-sub64.1%
*-commutative64.1%
add-sqr-sqrt64.1%
times-frac68.3%
fmm-def68.3%
hypot-define68.3%
hypot-define85.0%
associate-/l*85.3%
add-sqr-sqrt85.3%
pow285.3%
hypot-define85.3%
Applied egg-rr85.3%
Taylor expanded in c around inf 92.2%
mul-1-neg92.2%
unsub-neg92.2%
*-commutative92.2%
Simplified92.2%
if 1.7499999999999999e64 < d Initial program 40.6%
*-un-lft-identity40.6%
add-sqr-sqrt40.6%
times-frac40.5%
hypot-define40.5%
fmm-def40.5%
distribute-rgt-neg-in40.5%
hypot-define53.1%
Applied egg-rr53.1%
Taylor expanded in c around 0 81.3%
+-commutative81.3%
neg-mul-181.3%
sub-neg81.3%
unpow281.3%
associate-/l/80.2%
div-sub80.2%
*-lft-identity80.2%
*-commutative80.2%
times-frac90.2%
/-rgt-identity90.2%
Simplified90.2%
Final simplification86.6%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
(if (<= d -1.42e+121)
(- (* b (/ c (pow d 2.0))) (/ a d))
(if (<= d -1.5e-158)
t_0
(if (<= d 2.2e-104)
(/ (- b (/ (* d a) c)) c)
(if (<= d 7.6e+64) t_0 (/ (- (* c (/ b d)) a) d)))))))
double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double tmp;
if (d <= -1.42e+121) {
tmp = (b * (c / pow(d, 2.0))) - (a / d);
} else if (d <= -1.5e-158) {
tmp = t_0;
} else if (d <= 2.2e-104) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 7.6e+64) {
tmp = t_0;
} else {
tmp = ((c * (b / d)) - a) / d;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: t_0
real(8) :: tmp
t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d))
if (d <= (-1.42d+121)) then
tmp = (b * (c / (d ** 2.0d0))) - (a / d)
else if (d <= (-1.5d-158)) then
tmp = t_0
else if (d <= 2.2d-104) then
tmp = (b - ((d * a) / c)) / c
else if (d <= 7.6d+64) then
tmp = t_0
else
tmp = ((c * (b / d)) - a) / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double tmp;
if (d <= -1.42e+121) {
tmp = (b * (c / Math.pow(d, 2.0))) - (a / d);
} else if (d <= -1.5e-158) {
tmp = t_0;
} else if (d <= 2.2e-104) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 7.6e+64) {
tmp = t_0;
} else {
tmp = ((c * (b / d)) - a) / d;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)) tmp = 0 if d <= -1.42e+121: tmp = (b * (c / math.pow(d, 2.0))) - (a / d) elif d <= -1.5e-158: tmp = t_0 elif d <= 2.2e-104: tmp = (b - ((d * a) / c)) / c elif d <= 7.6e+64: tmp = t_0 else: tmp = ((c * (b / d)) - a) / d return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))) tmp = 0.0 if (d <= -1.42e+121) tmp = Float64(Float64(b * Float64(c / (d ^ 2.0))) - Float64(a / d)); elseif (d <= -1.5e-158) tmp = t_0; elseif (d <= 2.2e-104) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); elseif (d <= 7.6e+64) tmp = t_0; else tmp = Float64(Float64(Float64(c * Float64(b / d)) - a) / d); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)); tmp = 0.0; if (d <= -1.42e+121) tmp = (b * (c / (d ^ 2.0))) - (a / d); elseif (d <= -1.5e-158) tmp = t_0; elseif (d <= 2.2e-104) tmp = (b - ((d * a) / c)) / c; elseif (d <= 7.6e+64) tmp = t_0; else tmp = ((c * (b / d)) - a) / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -1.42e+121], N[(N[(b * N[(c / N[Power[d, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(a / d), $MachinePrecision]), $MachinePrecision], If[LessEqual[d, -1.5e-158], t$95$0, If[LessEqual[d, 2.2e-104], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 7.6e+64], t$95$0, N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{if}\;d \leq -1.42 \cdot 10^{+121}:\\
\;\;\;\;b \cdot \frac{c}{{d}^{2}} - \frac{a}{d}\\
\mathbf{elif}\;d \leq -1.5 \cdot 10^{-158}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 2.2 \cdot 10^{-104}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{elif}\;d \leq 7.6 \cdot 10^{+64}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{c \cdot \frac{b}{d} - a}{d}\\
\end{array}
\end{array}
if d < -1.42e121Initial program 52.6%
div-sub52.5%
*-commutative52.5%
add-sqr-sqrt52.5%
times-frac52.9%
fmm-def52.9%
hypot-define52.9%
hypot-define59.5%
associate-/l*67.1%
add-sqr-sqrt67.1%
pow267.1%
hypot-define67.1%
Applied egg-rr67.1%
Taylor expanded in c around 0 89.8%
associate-/l*90.0%
Simplified90.0%
if -1.42e121 < d < -1.5e-158 or 2.20000000000000012e-104 < d < 7.6000000000000002e64Initial program 78.2%
if -1.5e-158 < d < 2.20000000000000012e-104Initial program 72.3%
div-sub64.1%
*-commutative64.1%
add-sqr-sqrt64.1%
times-frac68.3%
fmm-def68.3%
hypot-define68.3%
hypot-define85.0%
associate-/l*85.3%
add-sqr-sqrt85.3%
pow285.3%
hypot-define85.3%
Applied egg-rr85.3%
Taylor expanded in c around inf 92.2%
mul-1-neg92.2%
unsub-neg92.2%
*-commutative92.2%
Simplified92.2%
if 7.6000000000000002e64 < d Initial program 40.6%
*-un-lft-identity40.6%
add-sqr-sqrt40.6%
times-frac40.5%
hypot-define40.5%
fmm-def40.5%
distribute-rgt-neg-in40.5%
hypot-define53.1%
Applied egg-rr53.1%
Taylor expanded in c around 0 81.3%
+-commutative81.3%
neg-mul-181.3%
sub-neg81.3%
unpow281.3%
associate-/l/80.2%
div-sub80.2%
*-lft-identity80.2%
*-commutative80.2%
times-frac90.2%
/-rgt-identity90.2%
Simplified90.2%
Final simplification86.5%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d))))
(t_1 (/ (- (* c (/ b d)) a) d)))
(if (<= d -1.8e+121)
t_1
(if (<= d -1.4e-158)
t_0
(if (<= d 5.6e-104)
(/ (- b (/ (* d a) c)) c)
(if (<= d 1e+60) t_0 t_1))))))
double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double t_1 = ((c * (b / d)) - a) / d;
double tmp;
if (d <= -1.8e+121) {
tmp = t_1;
} else if (d <= -1.4e-158) {
tmp = t_0;
} else if (d <= 5.6e-104) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 1e+60) {
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 = ((c * b) - (d * a)) / ((c * c) + (d * d))
t_1 = ((c * (b / d)) - a) / d
if (d <= (-1.8d+121)) then
tmp = t_1
else if (d <= (-1.4d-158)) then
tmp = t_0
else if (d <= 5.6d-104) then
tmp = (b - ((d * a) / c)) / c
else if (d <= 1d+60) 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 = ((c * b) - (d * a)) / ((c * c) + (d * d));
double t_1 = ((c * (b / d)) - a) / d;
double tmp;
if (d <= -1.8e+121) {
tmp = t_1;
} else if (d <= -1.4e-158) {
tmp = t_0;
} else if (d <= 5.6e-104) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 1e+60) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(a, b, c, d): t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)) t_1 = ((c * (b / d)) - a) / d tmp = 0 if d <= -1.8e+121: tmp = t_1 elif d <= -1.4e-158: tmp = t_0 elif d <= 5.6e-104: tmp = (b - ((d * a) / c)) / c elif d <= 1e+60: tmp = t_0 else: tmp = t_1 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))) t_1 = Float64(Float64(Float64(c * Float64(b / d)) - a) / d) tmp = 0.0 if (d <= -1.8e+121) tmp = t_1; elseif (d <= -1.4e-158) tmp = t_0; elseif (d <= 5.6e-104) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); elseif (d <= 1e+60) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = ((c * b) - (d * a)) / ((c * c) + (d * d)); t_1 = ((c * (b / d)) - a) / d; tmp = 0.0; if (d <= -1.8e+121) tmp = t_1; elseif (d <= -1.4e-158) tmp = t_0; elseif (d <= 5.6e-104) tmp = (b - ((d * a) / c)) / c; elseif (d <= 1e+60) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(c * N[(b / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -1.8e+121], t$95$1, If[LessEqual[d, -1.4e-158], t$95$0, If[LessEqual[d, 5.6e-104], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 1e+60], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
t_1 := \frac{c \cdot \frac{b}{d} - a}{d}\\
\mathbf{if}\;d \leq -1.8 \cdot 10^{+121}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq -1.4 \cdot 10^{-158}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 5.6 \cdot 10^{-104}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{elif}\;d \leq 10^{+60}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if d < -1.79999999999999991e121 or 9.9999999999999995e59 < d Initial program 44.6%
*-un-lft-identity44.6%
add-sqr-sqrt44.6%
times-frac44.5%
hypot-define44.5%
fmm-def44.5%
distribute-rgt-neg-in44.5%
hypot-define57.5%
Applied egg-rr57.5%
Taylor expanded in c around 0 84.1%
+-commutative84.1%
neg-mul-184.1%
sub-neg84.1%
unpow284.1%
associate-/l/81.5%
div-sub81.5%
*-lft-identity81.5%
*-commutative81.5%
times-frac90.1%
/-rgt-identity90.1%
Simplified90.1%
if -1.79999999999999991e121 < d < -1.40000000000000001e-158 or 5.6e-104 < d < 9.9999999999999995e59Initial program 78.2%
if -1.40000000000000001e-158 < d < 5.6e-104Initial program 72.3%
div-sub64.1%
*-commutative64.1%
add-sqr-sqrt64.1%
times-frac68.3%
fmm-def68.3%
hypot-define68.3%
hypot-define85.0%
associate-/l*85.3%
add-sqr-sqrt85.3%
pow285.3%
hypot-define85.3%
Applied egg-rr85.3%
Taylor expanded in c around inf 92.2%
mul-1-neg92.2%
unsub-neg92.2%
*-commutative92.2%
Simplified92.2%
Final simplification86.5%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ a (- d))))
(if (<= d -5.5e+65)
t_0
(if (<= d 2.5e-92)
(/ b c)
(if (or (<= d 2.8e-39) (not (<= d 8.8e+73)))
t_0
(* b (/ (/ c d) d)))))))
double code(double a, double b, double c, double d) {
double t_0 = a / -d;
double tmp;
if (d <= -5.5e+65) {
tmp = t_0;
} else if (d <= 2.5e-92) {
tmp = b / c;
} else if ((d <= 2.8e-39) || !(d <= 8.8e+73)) {
tmp = t_0;
} else {
tmp = b * ((c / d) / 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 = a / -d
if (d <= (-5.5d+65)) then
tmp = t_0
else if (d <= 2.5d-92) then
tmp = b / c
else if ((d <= 2.8d-39) .or. (.not. (d <= 8.8d+73))) then
tmp = t_0
else
tmp = b * ((c / d) / d)
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = a / -d;
double tmp;
if (d <= -5.5e+65) {
tmp = t_0;
} else if (d <= 2.5e-92) {
tmp = b / c;
} else if ((d <= 2.8e-39) || !(d <= 8.8e+73)) {
tmp = t_0;
} else {
tmp = b * ((c / d) / d);
}
return tmp;
}
def code(a, b, c, d): t_0 = a / -d tmp = 0 if d <= -5.5e+65: tmp = t_0 elif d <= 2.5e-92: tmp = b / c elif (d <= 2.8e-39) or not (d <= 8.8e+73): tmp = t_0 else: tmp = b * ((c / d) / d) return tmp
function code(a, b, c, d) t_0 = Float64(a / Float64(-d)) tmp = 0.0 if (d <= -5.5e+65) tmp = t_0; elseif (d <= 2.5e-92) tmp = Float64(b / c); elseif ((d <= 2.8e-39) || !(d <= 8.8e+73)) tmp = t_0; else tmp = Float64(b * Float64(Float64(c / d) / d)); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = a / -d; tmp = 0.0; if (d <= -5.5e+65) tmp = t_0; elseif (d <= 2.5e-92) tmp = b / c; elseif ((d <= 2.8e-39) || ~((d <= 8.8e+73))) tmp = t_0; else tmp = b * ((c / d) / d); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(a / (-d)), $MachinePrecision]}, If[LessEqual[d, -5.5e+65], t$95$0, If[LessEqual[d, 2.5e-92], N[(b / c), $MachinePrecision], If[Or[LessEqual[d, 2.8e-39], N[Not[LessEqual[d, 8.8e+73]], $MachinePrecision]], t$95$0, N[(b * N[(N[(c / d), $MachinePrecision] / d), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a}{-d}\\
\mathbf{if}\;d \leq -5.5 \cdot 10^{+65}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 2.5 \cdot 10^{-92}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;d \leq 2.8 \cdot 10^{-39} \lor \neg \left(d \leq 8.8 \cdot 10^{+73}\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;b \cdot \frac{\frac{c}{d}}{d}\\
\end{array}
\end{array}
if d < -5.4999999999999996e65 or 2.50000000000000006e-92 < d < 2.8000000000000001e-39 or 8.8e73 < d Initial program 54.3%
Taylor expanded in c around 0 78.0%
associate-*r/78.0%
neg-mul-178.0%
Simplified78.0%
if -5.4999999999999996e65 < d < 2.50000000000000006e-92Initial program 73.4%
Taylor expanded in c around inf 71.7%
if 2.8000000000000001e-39 < d < 8.8e73Initial program 72.1%
Taylor expanded in b around inf 56.1%
*-commutative56.1%
Simplified56.1%
Taylor expanded in c around 0 45.7%
associate-/l*45.8%
Simplified45.8%
*-un-lft-identity45.8%
unpow245.8%
times-frac45.6%
Applied egg-rr45.6%
associate-*l/45.7%
*-lft-identity45.7%
Simplified45.7%
Final simplification72.6%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ a (- d))))
(if (<= d -1.2e+66)
t_0
(if (<= d 2.5e-92)
(/ b c)
(if (or (<= d 1.7e-37) (not (<= d 8.8e+73)))
t_0
(/ b (* d (/ d c))))))))
double code(double a, double b, double c, double d) {
double t_0 = a / -d;
double tmp;
if (d <= -1.2e+66) {
tmp = t_0;
} else if (d <= 2.5e-92) {
tmp = b / c;
} else if ((d <= 1.7e-37) || !(d <= 8.8e+73)) {
tmp = t_0;
} else {
tmp = b / (d * (d / 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) :: t_0
real(8) :: tmp
t_0 = a / -d
if (d <= (-1.2d+66)) then
tmp = t_0
else if (d <= 2.5d-92) then
tmp = b / c
else if ((d <= 1.7d-37) .or. (.not. (d <= 8.8d+73))) then
tmp = t_0
else
tmp = b / (d * (d / c))
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double t_0 = a / -d;
double tmp;
if (d <= -1.2e+66) {
tmp = t_0;
} else if (d <= 2.5e-92) {
tmp = b / c;
} else if ((d <= 1.7e-37) || !(d <= 8.8e+73)) {
tmp = t_0;
} else {
tmp = b / (d * (d / c));
}
return tmp;
}
def code(a, b, c, d): t_0 = a / -d tmp = 0 if d <= -1.2e+66: tmp = t_0 elif d <= 2.5e-92: tmp = b / c elif (d <= 1.7e-37) or not (d <= 8.8e+73): tmp = t_0 else: tmp = b / (d * (d / c)) return tmp
function code(a, b, c, d) t_0 = Float64(a / Float64(-d)) tmp = 0.0 if (d <= -1.2e+66) tmp = t_0; elseif (d <= 2.5e-92) tmp = Float64(b / c); elseif ((d <= 1.7e-37) || !(d <= 8.8e+73)) tmp = t_0; else tmp = Float64(b / Float64(d * Float64(d / c))); end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = a / -d; tmp = 0.0; if (d <= -1.2e+66) tmp = t_0; elseif (d <= 2.5e-92) tmp = b / c; elseif ((d <= 1.7e-37) || ~((d <= 8.8e+73))) tmp = t_0; else tmp = b / (d * (d / c)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(a / (-d)), $MachinePrecision]}, If[LessEqual[d, -1.2e+66], t$95$0, If[LessEqual[d, 2.5e-92], N[(b / c), $MachinePrecision], If[Or[LessEqual[d, 1.7e-37], N[Not[LessEqual[d, 8.8e+73]], $MachinePrecision]], t$95$0, N[(b / N[(d * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a}{-d}\\
\mathbf{if}\;d \leq -1.2 \cdot 10^{+66}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 2.5 \cdot 10^{-92}:\\
\;\;\;\;\frac{b}{c}\\
\mathbf{elif}\;d \leq 1.7 \cdot 10^{-37} \lor \neg \left(d \leq 8.8 \cdot 10^{+73}\right):\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{d \cdot \frac{d}{c}}\\
\end{array}
\end{array}
if d < -1.2000000000000001e66 or 2.50000000000000006e-92 < d < 1.70000000000000009e-37 or 8.8e73 < d Initial program 54.3%
Taylor expanded in c around 0 78.0%
associate-*r/78.0%
neg-mul-178.0%
Simplified78.0%
if -1.2000000000000001e66 < d < 2.50000000000000006e-92Initial program 73.4%
Taylor expanded in c around inf 71.7%
if 1.70000000000000009e-37 < d < 8.8e73Initial program 72.1%
Taylor expanded in b around inf 56.1%
*-commutative56.1%
Simplified56.1%
Taylor expanded in c around 0 45.7%
associate-/l*45.8%
Simplified45.8%
*-un-lft-identity45.8%
unpow245.8%
times-frac45.6%
Applied egg-rr45.6%
associate-*l/45.7%
*-lft-identity45.7%
Simplified45.7%
clear-num45.8%
un-div-inv45.7%
div-inv45.8%
clear-num45.9%
Applied egg-rr45.9%
Final simplification72.6%
(FPCore (a b c d) :precision binary64 (if (or (<= d -1.16e+66) (not (<= d 5.3e+70))) (/ a (- d)) (/ (- b (* a (/ d c))) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -1.16e+66) || !(d <= 5.3e+70)) {
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.16d+66)) .or. (.not. (d <= 5.3d+70))) 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.16e+66) || !(d <= 5.3e+70)) {
tmp = a / -d;
} else {
tmp = (b - (a * (d / c))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -1.16e+66) or not (d <= 5.3e+70): tmp = a / -d else: tmp = (b - (a * (d / c))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -1.16e+66) || !(d <= 5.3e+70)) tmp = Float64(a / Float64(-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 <= -1.16e+66) || ~((d <= 5.3e+70))) 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.16e+66], N[Not[LessEqual[d, 5.3e+70]], $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 -1.16 \cdot 10^{+66} \lor \neg \left(d \leq 5.3 \cdot 10^{+70}\right):\\
\;\;\;\;\frac{a}{-d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\end{array}
\end{array}
if d < -1.16e66 or 5.3e70 < d Initial program 50.3%
Taylor expanded in c around 0 79.3%
associate-*r/79.3%
neg-mul-179.3%
Simplified79.3%
if -1.16e66 < d < 5.3e70Initial program 74.5%
Taylor expanded in c around inf 74.6%
mul-1-neg74.6%
unsub-neg74.6%
associate-/l*74.7%
Simplified74.7%
Final simplification76.5%
(FPCore (a b c d) :precision binary64 (if (or (<= c -2.5e-11) (not (<= c 5.9e+34))) (/ (- b (* a (/ d c))) c) (/ (- (* b (/ c d)) a) d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -2.5e-11) || !(c <= 5.9e+34)) {
tmp = (b - (a * (d / c))) / c;
} else {
tmp = ((b * (c / d)) - a) / d;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if ((c <= (-2.5d-11)) .or. (.not. (c <= 5.9d+34))) then
tmp = (b - (a * (d / c))) / c
else
tmp = ((b * (c / d)) - a) / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -2.5e-11) || !(c <= 5.9e+34)) {
tmp = (b - (a * (d / c))) / c;
} else {
tmp = ((b * (c / d)) - a) / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -2.5e-11) or not (c <= 5.9e+34): tmp = (b - (a * (d / c))) / c else: tmp = ((b * (c / d)) - a) / d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -2.5e-11) || !(c <= 5.9e+34)) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); else tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -2.5e-11) || ~((c <= 5.9e+34))) tmp = (b - (a * (d / c))) / c; else tmp = ((b * (c / d)) - a) / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -2.5e-11], N[Not[LessEqual[c, 5.9e+34]], $MachinePrecision]], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.5 \cdot 10^{-11} \lor \neg \left(c \leq 5.9 \cdot 10^{+34}\right):\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\end{array}
\end{array}
if c < -2.50000000000000009e-11 or 5.8999999999999999e34 < c Initial program 53.2%
Taylor expanded in c around inf 76.3%
mul-1-neg76.3%
unsub-neg76.3%
associate-/l*79.0%
Simplified79.0%
if -2.50000000000000009e-11 < c < 5.8999999999999999e34Initial program 74.9%
div-sub70.2%
*-commutative70.2%
add-sqr-sqrt70.2%
times-frac70.6%
fmm-def70.6%
hypot-define70.7%
hypot-define72.1%
associate-/l*78.6%
add-sqr-sqrt78.6%
pow278.6%
hypot-define78.6%
Applied egg-rr78.6%
Taylor expanded in d around inf 84.9%
associate-/l*84.5%
Simplified84.5%
Final simplification82.0%
(FPCore (a b c d) :precision binary64 (if (or (<= c -2.6e-11) (not (<= c 2.2e+33))) (/ (- b (* a (/ d c))) c) (/ (- (/ (* c b) d) a) d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -2.6e-11) || !(c <= 2.2e+33)) {
tmp = (b - (a * (d / c))) / c;
} else {
tmp = (((c * b) / d) - a) / d;
}
return tmp;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
real(8) :: tmp
if ((c <= (-2.6d-11)) .or. (.not. (c <= 2.2d+33))) then
tmp = (b - (a * (d / c))) / c
else
tmp = (((c * b) / d) - a) / d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -2.6e-11) || !(c <= 2.2e+33)) {
tmp = (b - (a * (d / c))) / c;
} else {
tmp = (((c * b) / d) - a) / d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -2.6e-11) or not (c <= 2.2e+33): tmp = (b - (a * (d / c))) / c else: tmp = (((c * b) / d) - a) / d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -2.6e-11) || !(c <= 2.2e+33)) tmp = Float64(Float64(b - Float64(a * Float64(d / c))) / c); else tmp = Float64(Float64(Float64(Float64(c * b) / d) - a) / d); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -2.6e-11) || ~((c <= 2.2e+33))) tmp = (b - (a * (d / c))) / c; else tmp = (((c * b) / d) - a) / d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -2.6e-11], N[Not[LessEqual[c, 2.2e+33]], $MachinePrecision]], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], N[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -2.6 \cdot 10^{-11} \lor \neg \left(c \leq 2.2 \cdot 10^{+33}\right):\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\
\end{array}
\end{array}
if c < -2.6000000000000001e-11 or 2.19999999999999994e33 < c Initial program 53.2%
Taylor expanded in c around inf 76.3%
mul-1-neg76.3%
unsub-neg76.3%
associate-/l*79.0%
Simplified79.0%
if -2.6000000000000001e-11 < c < 2.19999999999999994e33Initial program 74.9%
div-sub70.2%
*-commutative70.2%
add-sqr-sqrt70.2%
times-frac70.6%
fmm-def70.6%
hypot-define70.7%
hypot-define72.1%
associate-/l*78.6%
add-sqr-sqrt78.6%
pow278.6%
hypot-define78.6%
Applied egg-rr78.6%
Taylor expanded in d around inf 84.9%
Final simplification82.2%
(FPCore (a b c d) :precision binary64 (if (or (<= d -2.5e+65) (not (<= d 2.5e-92))) (/ a (- d)) (/ b c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -2.5e+65) || !(d <= 2.5e-92)) {
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 <= (-2.5d+65)) .or. (.not. (d <= 2.5d-92))) 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 <= -2.5e+65) || !(d <= 2.5e-92)) {
tmp = a / -d;
} else {
tmp = b / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -2.5e+65) or not (d <= 2.5e-92): tmp = a / -d else: tmp = b / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -2.5e+65) || !(d <= 2.5e-92)) tmp = Float64(a / Float64(-d)); else tmp = Float64(b / c); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((d <= -2.5e+65) || ~((d <= 2.5e-92))) tmp = a / -d; else tmp = b / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -2.5e+65], N[Not[LessEqual[d, 2.5e-92]], $MachinePrecision]], N[(a / (-d)), $MachinePrecision], N[(b / c), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;d \leq -2.5 \cdot 10^{+65} \lor \neg \left(d \leq 2.5 \cdot 10^{-92}\right):\\
\;\;\;\;\frac{a}{-d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b}{c}\\
\end{array}
\end{array}
if d < -2.49999999999999986e65 or 2.50000000000000006e-92 < d Initial program 56.8%
Taylor expanded in c around 0 68.5%
associate-*r/68.5%
neg-mul-168.5%
Simplified68.5%
if -2.49999999999999986e65 < d < 2.50000000000000006e-92Initial program 73.4%
Taylor expanded in c around inf 71.7%
Final simplification70.1%
(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 65.0%
Taylor expanded in c around inf 45.5%
Final simplification45.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 2024130
(FPCore (a b c d)
:name "Complex division, imag part"
:precision binary64
:alt
(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))))