
(FPCore (a b c d) :precision binary64 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = ((b * c) - (a * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((b * c) - (a * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a b c d) :precision binary64 (/ (- (* b c) (* a d)) (+ (* c c) (* d d))))
double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = ((b * c) - (a * d)) / ((c * c) + (d * d))
end function
public static double code(double a, double b, double c, double d) {
return ((b * c) - (a * d)) / ((c * c) + (d * d));
}
def code(a, b, c, d): return ((b * c) - (a * d)) / ((c * c) + (d * d))
function code(a, b, c, d) return Float64(Float64(Float64(b * c) - Float64(a * d)) / Float64(Float64(c * c) + Float64(d * d))) end
function tmp = code(a, b, c, d) tmp = ((b * c) - (a * d)) / ((c * c) + (d * d)); end
code[a_, b_, c_, d_] := N[(N[(N[(b * c), $MachinePrecision] - N[(a * d), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{b \cdot c - a \cdot d}{c \cdot c + d \cdot d}
\end{array}
(FPCore (a b c d) :precision binary64 (fma (/ c (hypot c d)) (/ b (hypot c d)) (* a (/ (/ d (hypot d c)) (- (hypot d c))))))
double code(double a, double b, double c, double d) {
return fma((c / hypot(c, d)), (b / hypot(c, d)), (a * ((d / hypot(d, c)) / -hypot(d, c))));
}
function code(a, b, c, d) return fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(a * Float64(Float64(d / hypot(d, c)) / Float64(-hypot(d, c))))) end
code[a_, b_, c_, d_] := N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] + N[(a * N[(N[(d / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] / (-N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{c}{\mathsf{hypot}\left(c, d\right)}, \frac{b}{\mathsf{hypot}\left(c, d\right)}, a \cdot \frac{\frac{d}{\mathsf{hypot}\left(d, c\right)}}{-\mathsf{hypot}\left(d, c\right)}\right)
\end{array}
Initial program 64.5%
div-sub63.6%
*-commutative63.6%
fma-define63.6%
add-sqr-sqrt63.6%
times-frac65.5%
fmm-def65.5%
fma-define65.5%
hypot-define65.5%
fma-define65.5%
hypot-define78.1%
associate-/l*79.2%
fma-define79.2%
add-sqr-sqrt79.2%
pow279.2%
Applied egg-rr79.2%
*-un-lft-identity79.2%
unpow279.2%
times-frac94.4%
hypot-undefine79.3%
+-commutative79.3%
hypot-undefine94.4%
hypot-undefine79.3%
+-commutative79.3%
hypot-undefine94.4%
Applied egg-rr94.4%
associate-*l/94.4%
*-lft-identity94.4%
Simplified94.4%
Final simplification94.4%
(FPCore (a b c d)
:precision binary64
(if (or (<= a -3.2e+24) (not (<= a 1.5e-93)))
(* (/ 1.0 (/ (hypot d c) (- (* c (/ b a)) d))) (/ a (hypot d c)))
(fma
(/ c (hypot c d))
(/ b (hypot c d))
(* a (/ d (- (pow (hypot c d) 2.0)))))))
double code(double a, double b, double c, double d) {
double tmp;
if ((a <= -3.2e+24) || !(a <= 1.5e-93)) {
tmp = (1.0 / (hypot(d, c) / ((c * (b / a)) - d))) * (a / hypot(d, c));
} else {
tmp = fma((c / hypot(c, d)), (b / hypot(c, d)), (a * (d / -pow(hypot(c, d), 2.0))));
}
return tmp;
}
function code(a, b, c, d) tmp = 0.0 if ((a <= -3.2e+24) || !(a <= 1.5e-93)) tmp = Float64(Float64(1.0 / Float64(hypot(d, c) / Float64(Float64(c * Float64(b / a)) - d))) * Float64(a / hypot(d, c))); else tmp = fma(Float64(c / hypot(c, d)), Float64(b / hypot(c, d)), Float64(a * Float64(d / Float64(-(hypot(c, d) ^ 2.0))))); end return tmp end
code[a_, b_, c_, d_] := If[Or[LessEqual[a, -3.2e+24], N[Not[LessEqual[a, 1.5e-93]], $MachinePrecision]], N[(N[(1.0 / N[(N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision] / N[(N[(c * N[(b / a), $MachinePrecision]), $MachinePrecision] - d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(a / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision]), $MachinePrecision] + N[(a * N[(d / (-N[Power[N[Sqrt[c ^ 2 + d ^ 2], $MachinePrecision], 2.0], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a \leq -3.2 \cdot 10^{+24} \lor \neg \left(a \leq 1.5 \cdot 10^{-93}\right):\\
\;\;\;\;\frac{1}{\frac{\mathsf{hypot}\left(d, c\right)}{c \cdot \frac{b}{a} - d}} \cdot \frac{a}{\mathsf{hypot}\left(d, c\right)}\\
\mathbf{else}:\\
\;\;\;\;\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)\\
\end{array}
\end{array}
if a < -3.1999999999999997e24 or 1.5000000000000001e-93 < a Initial program 56.7%
Taylor expanded in a around inf 56.7%
*-commutative56.7%
associate-/l*56.7%
Simplified56.7%
*-commutative56.7%
add-sqr-sqrt56.7%
hypot-undefine56.7%
hypot-undefine56.7%
times-frac95.1%
associate-*r/87.1%
hypot-undefine55.6%
+-commutative55.6%
hypot-undefine87.1%
hypot-undefine55.5%
+-commutative55.5%
hypot-undefine87.1%
Applied egg-rr87.1%
clear-num86.7%
inv-pow86.7%
hypot-undefine55.1%
+-commutative55.1%
hypot-define86.7%
associate-/l*94.6%
fmm-def94.6%
Applied egg-rr94.6%
unpow-194.6%
hypot-undefine56.7%
unpow256.7%
unpow256.7%
+-commutative56.7%
unpow256.7%
unpow256.7%
hypot-define94.6%
fmm-undef94.6%
Simplified94.6%
if -3.1999999999999997e24 < a < 1.5000000000000001e-93Initial program 73.1%
div-sub72.9%
*-commutative72.9%
fma-define72.9%
add-sqr-sqrt72.9%
times-frac76.6%
fmm-def76.6%
fma-define76.6%
hypot-define76.6%
fma-define76.6%
hypot-define90.7%
associate-/l*90.9%
fma-define90.9%
add-sqr-sqrt90.9%
pow290.9%
Applied egg-rr90.9%
Final simplification92.8%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- b (* a (/ d c))) c)))
(if (<= c -4e+57)
t_0
(if (<= c -5.4e-117)
(/ (- (* c b) (* d a)) (+ (* c c) (* d d)))
(if (<= c 1.25e-28)
(/ (- (/ (* c b) d) a) d)
(if (<= c 4.6e+106)
(* (- (* c (/ b a)) d) (/ (/ a (hypot d c)) (hypot d c)))
t_0))))))
double code(double a, double b, double c, double d) {
double t_0 = (b - (a * (d / c))) / c;
double tmp;
if (c <= -4e+57) {
tmp = t_0;
} else if (c <= -5.4e-117) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else if (c <= 1.25e-28) {
tmp = (((c * b) / d) - a) / d;
} else if (c <= 4.6e+106) {
tmp = ((c * (b / a)) - d) * ((a / hypot(d, c)) / hypot(d, c));
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = (b - (a * (d / c))) / c;
double tmp;
if (c <= -4e+57) {
tmp = t_0;
} else if (c <= -5.4e-117) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else if (c <= 1.25e-28) {
tmp = (((c * b) / d) - a) / d;
} else if (c <= 4.6e+106) {
tmp = ((c * (b / a)) - d) * ((a / Math.hypot(d, c)) / Math.hypot(d, c));
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = (b - (a * (d / c))) / c tmp = 0 if c <= -4e+57: tmp = t_0 elif c <= -5.4e-117: tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)) elif c <= 1.25e-28: tmp = (((c * b) / d) - a) / d elif c <= 4.6e+106: tmp = ((c * (b / a)) - d) * ((a / math.hypot(d, c)) / math.hypot(d, c)) else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(b - Float64(a * Float64(d / c))) / c) tmp = 0.0 if (c <= -4e+57) tmp = t_0; elseif (c <= -5.4e-117) tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))); elseif (c <= 1.25e-28) tmp = Float64(Float64(Float64(Float64(c * b) / d) - a) / d); elseif (c <= 4.6e+106) tmp = Float64(Float64(Float64(c * Float64(b / a)) - d) * Float64(Float64(a / hypot(d, c)) / hypot(d, c))); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (b - (a * (d / c))) / c; tmp = 0.0; if (c <= -4e+57) tmp = t_0; elseif (c <= -5.4e-117) tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)); elseif (c <= 1.25e-28) tmp = (((c * b) / d) - a) / d; elseif (c <= 4.6e+106) tmp = ((c * (b / a)) - d) * ((a / hypot(d, c)) / hypot(d, c)); else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -4e+57], t$95$0, If[LessEqual[c, -5.4e-117], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 1.25e-28], N[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 4.6e+106], N[(N[(N[(c * N[(b / a), $MachinePrecision]), $MachinePrecision] - d), $MachinePrecision] * N[(N[(a / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{if}\;c \leq -4 \cdot 10^{+57}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq -5.4 \cdot 10^{-117}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 1.25 \cdot 10^{-28}:\\
\;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\
\mathbf{elif}\;c \leq 4.6 \cdot 10^{+106}:\\
\;\;\;\;\left(c \cdot \frac{b}{a} - d\right) \cdot \frac{\frac{a}{\mathsf{hypot}\left(d, c\right)}}{\mathsf{hypot}\left(d, c\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if c < -4.00000000000000019e57 or 4.6000000000000004e106 < c Initial program 42.3%
Taylor expanded in c around inf 78.3%
mul-1-neg78.3%
unsub-neg78.3%
unsub-neg78.3%
mul-1-neg78.3%
remove-double-neg78.3%
mul-1-neg78.3%
neg-mul-178.3%
distribute-lft-in78.3%
distribute-lft-in78.3%
mul-1-neg78.3%
unsub-neg78.3%
neg-mul-178.3%
mul-1-neg78.3%
remove-double-neg78.3%
associate-/l*83.4%
Simplified83.4%
if -4.00000000000000019e57 < c < -5.40000000000000005e-117Initial program 88.9%
if -5.40000000000000005e-117 < c < 1.25e-28Initial program 73.9%
div-sub71.4%
*-commutative71.4%
fma-define71.4%
add-sqr-sqrt71.4%
times-frac66.4%
fmm-def66.4%
fma-define66.4%
hypot-define66.4%
fma-define66.4%
hypot-define68.9%
associate-/l*69.3%
fma-define69.3%
add-sqr-sqrt69.3%
pow269.3%
Applied egg-rr69.3%
Taylor expanded in d around inf 92.9%
*-commutative92.9%
Simplified92.9%
if 1.25e-28 < c < 4.6000000000000004e106Initial program 76.5%
Taylor expanded in a around inf 70.1%
*-commutative70.1%
associate-/l*70.1%
Simplified70.1%
*-commutative70.1%
add-sqr-sqrt70.1%
hypot-undefine70.1%
hypot-undefine70.2%
times-frac85.5%
associate-*r/82.4%
hypot-undefine68.8%
+-commutative68.8%
hypot-undefine82.4%
hypot-undefine68.8%
+-commutative68.8%
hypot-undefine82.4%
Applied egg-rr82.4%
associate-*r/85.7%
associate-/l*89.0%
fmm-def89.0%
hypot-undefine75.4%
+-commutative75.4%
hypot-define89.0%
hypot-undefine75.3%
+-commutative75.3%
hypot-define89.0%
Applied egg-rr89.0%
associate-*l/77.6%
associate-*r/90.2%
associate-/l*86.1%
fmm-undef86.1%
hypot-undefine76.4%
unpow276.4%
unpow276.4%
+-commutative76.4%
unpow276.4%
unpow276.4%
hypot-define86.1%
hypot-undefine76.4%
unpow276.4%
unpow276.4%
+-commutative76.4%
unpow276.4%
unpow276.4%
hypot-define86.1%
Simplified86.1%
Final simplification88.0%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- b (* a (/ d c))) c)))
(if (<= c -4.6e+57)
t_0
(if (<= c -4.2e-116)
(/ (- (* c b) (* d a)) (+ (* c c) (* d d)))
(if (<= c 9e-28)
(/ (- (/ (* c b) d) a) d)
(if (<= c 7.5e+102)
(* (- (* c (/ b a)) d) (* a (pow (hypot d c) -2.0)))
t_0))))))
double code(double a, double b, double c, double d) {
double t_0 = (b - (a * (d / c))) / c;
double tmp;
if (c <= -4.6e+57) {
tmp = t_0;
} else if (c <= -4.2e-116) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else if (c <= 9e-28) {
tmp = (((c * b) / d) - a) / d;
} else if (c <= 7.5e+102) {
tmp = ((c * (b / a)) - d) * (a * pow(hypot(d, c), -2.0));
} else {
tmp = t_0;
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double t_0 = (b - (a * (d / c))) / c;
double tmp;
if (c <= -4.6e+57) {
tmp = t_0;
} else if (c <= -4.2e-116) {
tmp = ((c * b) - (d * a)) / ((c * c) + (d * d));
} else if (c <= 9e-28) {
tmp = (((c * b) / d) - a) / d;
} else if (c <= 7.5e+102) {
tmp = ((c * (b / a)) - d) * (a * Math.pow(Math.hypot(d, c), -2.0));
} else {
tmp = t_0;
}
return tmp;
}
def code(a, b, c, d): t_0 = (b - (a * (d / c))) / c tmp = 0 if c <= -4.6e+57: tmp = t_0 elif c <= -4.2e-116: tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)) elif c <= 9e-28: tmp = (((c * b) / d) - a) / d elif c <= 7.5e+102: tmp = ((c * (b / a)) - d) * (a * math.pow(math.hypot(d, c), -2.0)) else: tmp = t_0 return tmp
function code(a, b, c, d) t_0 = Float64(Float64(b - Float64(a * Float64(d / c))) / c) tmp = 0.0 if (c <= -4.6e+57) tmp = t_0; elseif (c <= -4.2e-116) tmp = Float64(Float64(Float64(c * b) - Float64(d * a)) / Float64(Float64(c * c) + Float64(d * d))); elseif (c <= 9e-28) tmp = Float64(Float64(Float64(Float64(c * b) / d) - a) / d); elseif (c <= 7.5e+102) tmp = Float64(Float64(Float64(c * Float64(b / a)) - d) * Float64(a * (hypot(d, c) ^ -2.0))); else tmp = t_0; end return tmp end
function tmp_2 = code(a, b, c, d) t_0 = (b - (a * (d / c))) / c; tmp = 0.0; if (c <= -4.6e+57) tmp = t_0; elseif (c <= -4.2e-116) tmp = ((c * b) - (d * a)) / ((c * c) + (d * d)); elseif (c <= 9e-28) tmp = (((c * b) / d) - a) / d; elseif (c <= 7.5e+102) tmp = ((c * (b / a)) - d) * (a * (hypot(d, c) ^ -2.0)); else tmp = t_0; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]}, If[LessEqual[c, -4.6e+57], t$95$0, If[LessEqual[c, -4.2e-116], N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(N[(c * c), $MachinePrecision] + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 9e-28], N[(N[(N[(N[(c * b), $MachinePrecision] / d), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[c, 7.5e+102], N[(N[(N[(c * N[(b / a), $MachinePrecision]), $MachinePrecision] - d), $MachinePrecision] * N[(a * N[Power[N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision], -2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{b - a \cdot \frac{d}{c}}{c}\\
\mathbf{if}\;c \leq -4.6 \cdot 10^{+57}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;c \leq -4.2 \cdot 10^{-116}:\\
\;\;\;\;\frac{c \cdot b - d \cdot a}{c \cdot c + d \cdot d}\\
\mathbf{elif}\;c \leq 9 \cdot 10^{-28}:\\
\;\;\;\;\frac{\frac{c \cdot b}{d} - a}{d}\\
\mathbf{elif}\;c \leq 7.5 \cdot 10^{+102}:\\
\;\;\;\;\left(c \cdot \frac{b}{a} - d\right) \cdot \left(a \cdot {\left(\mathsf{hypot}\left(d, c\right)\right)}^{-2}\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if c < -4.5999999999999998e57 or 7.5e102 < c Initial program 42.3%
Taylor expanded in c around inf 78.3%
mul-1-neg78.3%
unsub-neg78.3%
unsub-neg78.3%
mul-1-neg78.3%
remove-double-neg78.3%
mul-1-neg78.3%
neg-mul-178.3%
distribute-lft-in78.3%
distribute-lft-in78.3%
mul-1-neg78.3%
unsub-neg78.3%
neg-mul-178.3%
mul-1-neg78.3%
remove-double-neg78.3%
associate-/l*83.4%
Simplified83.4%
if -4.5999999999999998e57 < c < -4.1999999999999998e-116Initial program 88.9%
if -4.1999999999999998e-116 < c < 8.9999999999999996e-28Initial program 73.9%
div-sub71.4%
*-commutative71.4%
fma-define71.4%
add-sqr-sqrt71.4%
times-frac66.4%
fmm-def66.4%
fma-define66.4%
hypot-define66.4%
fma-define66.4%
hypot-define68.9%
associate-/l*69.3%
fma-define69.3%
add-sqr-sqrt69.3%
pow269.3%
Applied egg-rr69.3%
Taylor expanded in d around inf 92.9%
*-commutative92.9%
Simplified92.9%
if 8.9999999999999996e-28 < c < 7.5e102Initial program 76.5%
Taylor expanded in a around inf 70.1%
*-commutative70.1%
associate-/l*70.1%
Simplified70.1%
add-sqr-sqrt70.1%
hypot-undefine70.1%
hypot-undefine70.2%
unpow270.2%
associate-/l*73.3%
div-inv73.3%
associate-*r/70.1%
pow-flip72.3%
hypot-undefine70.3%
+-commutative70.3%
hypot-undefine72.3%
metadata-eval72.3%
Applied egg-rr72.3%
*-commutative72.3%
associate-*r*75.5%
associate-/l*78.6%
Simplified78.6%
Final simplification87.1%
(FPCore (a b c d) :precision binary64 (if (or (<= a -3.1e-76) (not (<= a 2.65e-123))) (* (/ 1.0 (/ (hypot d c) (- (* c (/ b a)) d))) (/ a (hypot d c))) (* (/ c (hypot d c)) (/ b (hypot d c)))))
double code(double a, double b, double c, double d) {
double tmp;
if ((a <= -3.1e-76) || !(a <= 2.65e-123)) {
tmp = (1.0 / (hypot(d, c) / ((c * (b / a)) - d))) * (a / hypot(d, c));
} 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 ((a <= -3.1e-76) || !(a <= 2.65e-123)) {
tmp = (1.0 / (Math.hypot(d, c) / ((c * (b / a)) - d))) * (a / Math.hypot(d, c));
} else {
tmp = (c / Math.hypot(d, c)) * (b / Math.hypot(d, c));
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (a <= -3.1e-76) or not (a <= 2.65e-123): tmp = (1.0 / (math.hypot(d, c) / ((c * (b / a)) - d))) * (a / math.hypot(d, c)) else: tmp = (c / math.hypot(d, c)) * (b / math.hypot(d, c)) return tmp
function code(a, b, c, d) tmp = 0.0 if ((a <= -3.1e-76) || !(a <= 2.65e-123)) tmp = Float64(Float64(1.0 / Float64(hypot(d, c) / Float64(Float64(c * Float64(b / a)) - d))) * Float64(a / hypot(d, c))); 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 ((a <= -3.1e-76) || ~((a <= 2.65e-123))) tmp = (1.0 / (hypot(d, c) / ((c * (b / a)) - d))) * (a / hypot(d, c)); else tmp = (c / hypot(d, c)) * (b / hypot(d, c)); end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[a, -3.1e-76], N[Not[LessEqual[a, 2.65e-123]], $MachinePrecision]], N[(N[(1.0 / N[(N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision] / N[(N[(c * N[(b / a), $MachinePrecision]), $MachinePrecision] - d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(a / N[Sqrt[d ^ 2 + c ^ 2], $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}\;a \leq -3.1 \cdot 10^{-76} \lor \neg \left(a \leq 2.65 \cdot 10^{-123}\right):\\
\;\;\;\;\frac{1}{\frac{\mathsf{hypot}\left(d, c\right)}{c \cdot \frac{b}{a} - d}} \cdot \frac{a}{\mathsf{hypot}\left(d, c\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{c}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{b}{\mathsf{hypot}\left(d, c\right)}\\
\end{array}
\end{array}
if a < -3.0999999999999997e-76 or 2.64999999999999985e-123 < a Initial program 55.7%
Taylor expanded in a around inf 55.7%
*-commutative55.7%
associate-/l*55.7%
Simplified55.7%
*-commutative55.7%
add-sqr-sqrt55.7%
hypot-undefine55.7%
hypot-undefine55.7%
times-frac91.2%
associate-*r/84.7%
hypot-undefine54.8%
+-commutative54.8%
hypot-undefine84.7%
hypot-undefine54.8%
+-commutative54.8%
hypot-undefine84.7%
Applied egg-rr84.7%
clear-num84.3%
inv-pow84.3%
hypot-undefine54.4%
+-commutative54.4%
hypot-define84.3%
associate-/l*90.8%
fmm-def90.8%
Applied egg-rr90.8%
unpow-190.8%
hypot-undefine55.8%
unpow255.8%
unpow255.8%
+-commutative55.8%
unpow255.8%
unpow255.8%
hypot-define90.8%
fmm-undef90.8%
Simplified90.8%
if -3.0999999999999997e-76 < a < 2.64999999999999985e-123Initial program 80.2%
Taylor expanded in b around inf 73.0%
*-commutative73.0%
Simplified73.0%
add-sqr-sqrt54.5%
sqrt-div40.0%
+-commutative40.0%
hypot-undefine40.0%
sqrt-div40.0%
+-commutative40.0%
hypot-undefine44.8%
times-frac40.0%
add-sqr-sqrt73.0%
frac-times90.3%
Applied egg-rr90.3%
Final simplification90.6%
(FPCore (a b c d)
:precision binary64
(if (<= c -8200000000.0)
(* (/ c (hypot d c)) (/ b (hypot d c)))
(if (<= c 2.6e+77)
(* (/ a (hypot d c)) (/ (- (/ (* c b) a) d) (hypot d c)))
(/ (- b (* a (/ d c))) c))))
double code(double a, double b, double c, double d) {
double tmp;
if (c <= -8200000000.0) {
tmp = (c / hypot(d, c)) * (b / hypot(d, c));
} else if (c <= 2.6e+77) {
tmp = (a / hypot(d, c)) * ((((c * b) / a) - d) / hypot(d, c));
} else {
tmp = (b - (a * (d / c))) / c;
}
return tmp;
}
public static double code(double a, double b, double c, double d) {
double tmp;
if (c <= -8200000000.0) {
tmp = (c / Math.hypot(d, c)) * (b / Math.hypot(d, c));
} else if (c <= 2.6e+77) {
tmp = (a / Math.hypot(d, c)) * ((((c * b) / a) - d) / Math.hypot(d, c));
} else {
tmp = (b - (a * (d / c))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if c <= -8200000000.0: tmp = (c / math.hypot(d, c)) * (b / math.hypot(d, c)) elif c <= 2.6e+77: tmp = (a / math.hypot(d, c)) * ((((c * b) / a) - d) / math.hypot(d, c)) else: tmp = (b - (a * (d / c))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if (c <= -8200000000.0) tmp = Float64(Float64(c / hypot(d, c)) * Float64(b / hypot(d, c))); elseif (c <= 2.6e+77) tmp = Float64(Float64(a / hypot(d, c)) * Float64(Float64(Float64(Float64(c * b) / a) - d) / hypot(d, c))); 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 (c <= -8200000000.0) tmp = (c / hypot(d, c)) * (b / hypot(d, c)); elseif (c <= 2.6e+77) tmp = (a / hypot(d, c)) * ((((c * b) / a) - d) / hypot(d, c)); else tmp = (b - (a * (d / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[LessEqual[c, -8200000000.0], N[(N[(c / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] * N[(b / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[c, 2.6e+77], N[(N[(a / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision] * N[(N[(N[(N[(c * b), $MachinePrecision] / a), $MachinePrecision] - d), $MachinePrecision] / N[Sqrt[d ^ 2 + c ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(b - N[(a * N[(d / c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -8200000000:\\
\;\;\;\;\frac{c}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{b}{\mathsf{hypot}\left(d, c\right)}\\
\mathbf{elif}\;c \leq 2.6 \cdot 10^{+77}:\\
\;\;\;\;\frac{a}{\mathsf{hypot}\left(d, c\right)} \cdot \frac{\frac{c \cdot b}{a} - d}{\mathsf{hypot}\left(d, c\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\end{array}
\end{array}
if c < -8.2e9Initial program 49.7%
Taylor expanded in b around inf 47.0%
*-commutative47.0%
Simplified47.0%
add-sqr-sqrt34.3%
sqrt-div24.6%
+-commutative24.6%
hypot-undefine24.6%
sqrt-div24.6%
+-commutative24.6%
hypot-undefine30.4%
times-frac24.6%
add-sqr-sqrt47.0%
frac-times83.3%
Applied egg-rr83.3%
if -8.2e9 < c < 2.6000000000000002e77Initial program 76.3%
Taylor expanded in a around inf 71.7%
*-commutative71.7%
associate-/l*67.1%
Simplified67.1%
*-commutative67.1%
add-sqr-sqrt67.1%
hypot-undefine67.1%
hypot-undefine67.1%
times-frac86.4%
associate-*r/90.3%
hypot-undefine70.1%
+-commutative70.1%
hypot-undefine90.3%
hypot-undefine70.1%
+-commutative70.1%
hypot-undefine90.3%
Applied egg-rr90.3%
if 2.6000000000000002e77 < c Initial program 48.5%
Taylor expanded in c around inf 80.2%
mul-1-neg80.2%
unsub-neg80.2%
unsub-neg80.2%
mul-1-neg80.2%
remove-double-neg80.2%
mul-1-neg80.2%
neg-mul-180.2%
distribute-lft-in80.2%
distribute-lft-in80.2%
mul-1-neg80.2%
unsub-neg80.2%
neg-mul-180.2%
mul-1-neg80.2%
remove-double-neg80.2%
associate-/l*85.5%
Simplified85.5%
Final simplification87.7%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (fma c c (* d d)))))
(if (<= d -6.2e+119)
(/ (fma c (/ b d) (- a)) d)
(if (<= d -1.8e-159)
t_0
(if (<= d 9.4e-150)
(/ (- b (/ (* d a) c)) c)
(if (<= d 6e+147) t_0 (/ (- (* b (/ c d)) a) d)))))))
double code(double a, double b, double c, double d) {
double t_0 = ((c * b) - (d * a)) / fma(c, c, (d * d));
double tmp;
if (d <= -6.2e+119) {
tmp = fma(c, (b / d), -a) / d;
} else if (d <= -1.8e-159) {
tmp = t_0;
} else if (d <= 9.4e-150) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 6e+147) {
tmp = t_0;
} else {
tmp = ((b * (c / d)) - a) / d;
}
return tmp;
}
function code(a, b, c, d) t_0 = Float64(Float64(Float64(c * b) - Float64(d * a)) / fma(c, c, Float64(d * d))) tmp = 0.0 if (d <= -6.2e+119) tmp = Float64(fma(c, Float64(b / d), Float64(-a)) / d); elseif (d <= -1.8e-159) tmp = t_0; elseif (d <= 9.4e-150) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); elseif (d <= 6e+147) tmp = t_0; else tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d); end return tmp end
code[a_, b_, c_, d_] := Block[{t$95$0 = N[(N[(N[(c * b), $MachinePrecision] - N[(d * a), $MachinePrecision]), $MachinePrecision] / N[(c * c + N[(d * d), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[d, -6.2e+119], N[(N[(c * N[(b / d), $MachinePrecision] + (-a)), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -1.8e-159], t$95$0, If[LessEqual[d, 9.4e-150], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 6e+147], t$95$0, N[(N[(N[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{c \cdot b - d \cdot a}{\mathsf{fma}\left(c, c, d \cdot d\right)}\\
\mathbf{if}\;d \leq -6.2 \cdot 10^{+119}:\\
\;\;\;\;\frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\
\mathbf{elif}\;d \leq -1.8 \cdot 10^{-159}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 9.4 \cdot 10^{-150}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{elif}\;d \leq 6 \cdot 10^{+147}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\end{array}
\end{array}
if d < -6.1999999999999999e119Initial program 33.7%
Taylor expanded in c around 0 68.5%
+-commutative68.5%
mul-1-neg68.5%
unsub-neg68.5%
unpow268.5%
associate-/r*72.4%
div-sub72.4%
*-commutative72.4%
associate-/l*85.3%
fmm-def85.3%
Simplified85.3%
if -6.1999999999999999e119 < d < -1.80000000000000011e-159 or 9.3999999999999998e-150 < d < 5.99999999999999987e147Initial program 83.9%
fma-define83.9%
Simplified83.9%
if -1.80000000000000011e-159 < d < 9.3999999999999998e-150Initial program 57.5%
Taylor expanded in c around inf 96.4%
mul-1-neg96.4%
unsub-neg96.4%
unsub-neg96.4%
remove-double-neg96.4%
mul-1-neg96.4%
neg-mul-196.4%
mul-1-neg96.4%
distribute-lft-in96.4%
distribute-lft-in96.4%
neg-mul-196.4%
mul-1-neg96.4%
remove-double-neg96.4%
associate-*r/96.4%
associate-*r*96.4%
neg-mul-196.4%
Simplified96.4%
if 5.99999999999999987e147 < d Initial program 34.4%
Taylor expanded in c around 0 79.8%
+-commutative79.8%
mul-1-neg79.8%
unsub-neg79.8%
unpow279.8%
associate-/r*88.1%
div-sub88.1%
associate-/l*91.3%
Simplified91.3%
Final simplification87.7%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d)))))
(if (<= d -5.8e+119)
(/ (fma c (/ b d) (- a)) d)
(if (<= d -1.3e-158)
t_0
(if (<= d 1.05e-147)
(/ (- b (/ (* d a) c)) c)
(if (<= d 6e+147) t_0 (/ (- (* b (/ c 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 <= -5.8e+119) {
tmp = fma(c, (b / d), -a) / d;
} else if (d <= -1.3e-158) {
tmp = t_0;
} else if (d <= 1.05e-147) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 6e+147) {
tmp = t_0;
} else {
tmp = ((b * (c / 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 <= -5.8e+119) tmp = Float64(fma(c, Float64(b / d), Float64(-a)) / d); elseif (d <= -1.3e-158) tmp = t_0; elseif (d <= 1.05e-147) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); elseif (d <= 6e+147) tmp = t_0; else tmp = Float64(Float64(Float64(b * Float64(c / d)) - a) / d); end return 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, -5.8e+119], N[(N[(c * N[(b / d), $MachinePrecision] + (-a)), $MachinePrecision] / d), $MachinePrecision], If[LessEqual[d, -1.3e-158], t$95$0, If[LessEqual[d, 1.05e-147], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 6e+147], t$95$0, N[(N[(N[(b * N[(c / 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 -5.8 \cdot 10^{+119}:\\
\;\;\;\;\frac{\mathsf{fma}\left(c, \frac{b}{d}, -a\right)}{d}\\
\mathbf{elif}\;d \leq -1.3 \cdot 10^{-158}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 1.05 \cdot 10^{-147}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{elif}\;d \leq 6 \cdot 10^{+147}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{b \cdot \frac{c}{d} - a}{d}\\
\end{array}
\end{array}
if d < -5.80000000000000014e119Initial program 33.7%
Taylor expanded in c around 0 68.5%
+-commutative68.5%
mul-1-neg68.5%
unsub-neg68.5%
unpow268.5%
associate-/r*72.4%
div-sub72.4%
*-commutative72.4%
associate-/l*85.3%
fmm-def85.3%
Simplified85.3%
if -5.80000000000000014e119 < d < -1.3e-158 or 1.05e-147 < d < 5.99999999999999987e147Initial program 83.9%
if -1.3e-158 < d < 1.05e-147Initial program 57.5%
Taylor expanded in c around inf 96.4%
mul-1-neg96.4%
unsub-neg96.4%
unsub-neg96.4%
remove-double-neg96.4%
mul-1-neg96.4%
neg-mul-196.4%
mul-1-neg96.4%
distribute-lft-in96.4%
distribute-lft-in96.4%
neg-mul-196.4%
mul-1-neg96.4%
remove-double-neg96.4%
associate-*r/96.4%
associate-*r*96.4%
neg-mul-196.4%
Simplified96.4%
if 5.99999999999999987e147 < d Initial program 34.4%
Taylor expanded in c around 0 79.8%
+-commutative79.8%
mul-1-neg79.8%
unsub-neg79.8%
unpow279.8%
associate-/r*88.1%
div-sub88.1%
associate-/l*91.3%
Simplified91.3%
Final simplification87.7%
(FPCore (a b c d)
:precision binary64
(let* ((t_0 (/ (- (* c b) (* d a)) (+ (* c c) (* d d))))
(t_1 (/ (- (* b (/ c d)) a) d)))
(if (<= d -6.2e+119)
t_1
(if (<= d -1.45e-159)
t_0
(if (<= d 1.75e-149)
(/ (- b (/ (* d a) c)) c)
(if (<= d 6.8e+149) 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 = ((b * (c / d)) - a) / d;
double tmp;
if (d <= -6.2e+119) {
tmp = t_1;
} else if (d <= -1.45e-159) {
tmp = t_0;
} else if (d <= 1.75e-149) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 6.8e+149) {
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 = ((b * (c / d)) - a) / d
if (d <= (-6.2d+119)) then
tmp = t_1
else if (d <= (-1.45d-159)) then
tmp = t_0
else if (d <= 1.75d-149) then
tmp = (b - ((d * a) / c)) / c
else if (d <= 6.8d+149) 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 = ((b * (c / d)) - a) / d;
double tmp;
if (d <= -6.2e+119) {
tmp = t_1;
} else if (d <= -1.45e-159) {
tmp = t_0;
} else if (d <= 1.75e-149) {
tmp = (b - ((d * a) / c)) / c;
} else if (d <= 6.8e+149) {
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 = ((b * (c / d)) - a) / d tmp = 0 if d <= -6.2e+119: tmp = t_1 elif d <= -1.45e-159: tmp = t_0 elif d <= 1.75e-149: tmp = (b - ((d * a) / c)) / c elif d <= 6.8e+149: 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(b * Float64(c / d)) - a) / d) tmp = 0.0 if (d <= -6.2e+119) tmp = t_1; elseif (d <= -1.45e-159) tmp = t_0; elseif (d <= 1.75e-149) tmp = Float64(Float64(b - Float64(Float64(d * a) / c)) / c); elseif (d <= 6.8e+149) 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 = ((b * (c / d)) - a) / d; tmp = 0.0; if (d <= -6.2e+119) tmp = t_1; elseif (d <= -1.45e-159) tmp = t_0; elseif (d <= 1.75e-149) tmp = (b - ((d * a) / c)) / c; elseif (d <= 6.8e+149) 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[(b * N[(c / d), $MachinePrecision]), $MachinePrecision] - a), $MachinePrecision] / d), $MachinePrecision]}, If[LessEqual[d, -6.2e+119], t$95$1, If[LessEqual[d, -1.45e-159], t$95$0, If[LessEqual[d, 1.75e-149], N[(N[(b - N[(N[(d * a), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision], If[LessEqual[d, 6.8e+149], 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{b \cdot \frac{c}{d} - a}{d}\\
\mathbf{if}\;d \leq -6.2 \cdot 10^{+119}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;d \leq -1.45 \cdot 10^{-159}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;d \leq 1.75 \cdot 10^{-149}:\\
\;\;\;\;\frac{b - \frac{d \cdot a}{c}}{c}\\
\mathbf{elif}\;d \leq 6.8 \cdot 10^{+149}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if d < -6.1999999999999999e119 or 6.7999999999999997e149 < d Initial program 34.0%
Taylor expanded in c around 0 73.7%
+-commutative73.7%
mul-1-neg73.7%
unsub-neg73.7%
unpow273.7%
associate-/r*79.7%
div-sub79.7%
associate-/l*85.1%
Simplified85.1%
if -6.1999999999999999e119 < d < -1.44999999999999995e-159 or 1.75e-149 < d < 6.7999999999999997e149Initial program 83.9%
if -1.44999999999999995e-159 < d < 1.75e-149Initial program 57.5%
Taylor expanded in c around inf 96.4%
mul-1-neg96.4%
unsub-neg96.4%
unsub-neg96.4%
remove-double-neg96.4%
mul-1-neg96.4%
neg-mul-196.4%
mul-1-neg96.4%
distribute-lft-in96.4%
distribute-lft-in96.4%
neg-mul-196.4%
mul-1-neg96.4%
remove-double-neg96.4%
associate-*r/96.4%
associate-*r*96.4%
neg-mul-196.4%
Simplified96.4%
Final simplification86.9%
(FPCore (a b c d)
:precision binary64
(if (or (<= d -8.1e+132)
(and (not (<= d -5.5e+107))
(or (<= d -8.6e+18) (not (<= d 9.8e-17)))))
(/ a (- d))
(/ (- b (* a (/ d c))) c)))
double code(double a, double b, double c, double d) {
double tmp;
if ((d <= -8.1e+132) || (!(d <= -5.5e+107) && ((d <= -8.6e+18) || !(d <= 9.8e-17)))) {
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 <= (-8.1d+132)) .or. (.not. (d <= (-5.5d+107))) .and. (d <= (-8.6d+18)) .or. (.not. (d <= 9.8d-17))) 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 <= -8.1e+132) || (!(d <= -5.5e+107) && ((d <= -8.6e+18) || !(d <= 9.8e-17)))) {
tmp = a / -d;
} else {
tmp = (b - (a * (d / c))) / c;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (d <= -8.1e+132) or (not (d <= -5.5e+107) and ((d <= -8.6e+18) or not (d <= 9.8e-17))): tmp = a / -d else: tmp = (b - (a * (d / c))) / c return tmp
function code(a, b, c, d) tmp = 0.0 if ((d <= -8.1e+132) || (!(d <= -5.5e+107) && ((d <= -8.6e+18) || !(d <= 9.8e-17)))) 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 <= -8.1e+132) || (~((d <= -5.5e+107)) && ((d <= -8.6e+18) || ~((d <= 9.8e-17))))) tmp = a / -d; else tmp = (b - (a * (d / c))) / c; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[d, -8.1e+132], And[N[Not[LessEqual[d, -5.5e+107]], $MachinePrecision], Or[LessEqual[d, -8.6e+18], N[Not[LessEqual[d, 9.8e-17]], $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 -8.1 \cdot 10^{+132} \lor \neg \left(d \leq -5.5 \cdot 10^{+107}\right) \land \left(d \leq -8.6 \cdot 10^{+18} \lor \neg \left(d \leq 9.8 \cdot 10^{-17}\right)\right):\\
\;\;\;\;\frac{a}{-d}\\
\mathbf{else}:\\
\;\;\;\;\frac{b - a \cdot \frac{d}{c}}{c}\\
\end{array}
\end{array}
if d < -8.09999999999999988e132 or -5.5000000000000003e107 < d < -8.6e18 or 9.80000000000000024e-17 < d Initial program 56.8%
Taylor expanded in c around 0 69.8%
associate-*r/69.8%
neg-mul-169.8%
Simplified69.8%
if -8.09999999999999988e132 < d < -5.5000000000000003e107 or -8.6e18 < d < 9.80000000000000024e-17Initial program 71.1%
Taylor expanded in c around inf 80.0%
mul-1-neg80.0%
unsub-neg80.0%
unsub-neg80.0%
mul-1-neg80.0%
remove-double-neg80.0%
mul-1-neg80.0%
neg-mul-180.0%
distribute-lft-in80.0%
distribute-lft-in80.0%
mul-1-neg80.0%
unsub-neg80.0%
neg-mul-180.0%
mul-1-neg80.0%
remove-double-neg80.0%
associate-/l*79.7%
Simplified79.7%
Final simplification75.2%
(FPCore (a b c d) :precision binary64 (if (or (<= c -8.5e-84) (not (<= c 28000000.0))) (/ (- b (* a (/ d c))) c) (/ (- (* b (/ c d)) a) d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -8.5e-84) || !(c <= 28000000.0)) {
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 <= (-8.5d-84)) .or. (.not. (c <= 28000000.0d0))) 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 <= -8.5e-84) || !(c <= 28000000.0)) {
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 <= -8.5e-84) or not (c <= 28000000.0): 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 <= -8.5e-84) || !(c <= 28000000.0)) 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 <= -8.5e-84) || ~((c <= 28000000.0))) 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, -8.5e-84], N[Not[LessEqual[c, 28000000.0]], $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 -8.5 \cdot 10^{-84} \lor \neg \left(c \leq 28000000\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 < -8.4999999999999994e-84 or 2.8e7 < c Initial program 56.7%
Taylor expanded in c around inf 73.2%
mul-1-neg73.2%
unsub-neg73.2%
unsub-neg73.2%
mul-1-neg73.2%
remove-double-neg73.2%
mul-1-neg73.2%
neg-mul-173.2%
distribute-lft-in73.2%
distribute-lft-in73.2%
mul-1-neg73.2%
unsub-neg73.2%
neg-mul-173.2%
mul-1-neg73.2%
remove-double-neg73.2%
associate-/l*75.6%
Simplified75.6%
if -8.4999999999999994e-84 < c < 2.8e7Initial program 75.4%
Taylor expanded in c around 0 84.5%
+-commutative84.5%
mul-1-neg84.5%
unsub-neg84.5%
unpow284.5%
associate-/r*88.9%
div-sub89.9%
associate-/l*88.7%
Simplified88.7%
Final simplification81.1%
(FPCore (a b c d) :precision binary64 (if (or (<= c -8.5e-84) (not (<= c 48000000000000.0))) (/ (- b (* a (/ d c))) c) (/ (- (/ (* c b) d) a) d)))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -8.5e-84) || !(c <= 48000000000000.0)) {
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 <= (-8.5d-84)) .or. (.not. (c <= 48000000000000.0d0))) 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 <= -8.5e-84) || !(c <= 48000000000000.0)) {
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 <= -8.5e-84) or not (c <= 48000000000000.0): 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 <= -8.5e-84) || !(c <= 48000000000000.0)) 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 <= -8.5e-84) || ~((c <= 48000000000000.0))) 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, -8.5e-84], N[Not[LessEqual[c, 48000000000000.0]], $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 -8.5 \cdot 10^{-84} \lor \neg \left(c \leq 48000000000000\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 < -8.4999999999999994e-84 or 4.8e13 < c Initial program 56.7%
Taylor expanded in c around inf 73.2%
mul-1-neg73.2%
unsub-neg73.2%
unsub-neg73.2%
mul-1-neg73.2%
remove-double-neg73.2%
mul-1-neg73.2%
neg-mul-173.2%
distribute-lft-in73.2%
distribute-lft-in73.2%
mul-1-neg73.2%
unsub-neg73.2%
neg-mul-173.2%
mul-1-neg73.2%
remove-double-neg73.2%
associate-/l*75.6%
Simplified75.6%
if -8.4999999999999994e-84 < c < 4.8e13Initial program 75.4%
div-sub73.2%
*-commutative73.2%
fma-define73.2%
add-sqr-sqrt73.2%
times-frac68.9%
fmm-def68.9%
fma-define68.9%
hypot-define68.9%
fma-define68.9%
hypot-define71.0%
associate-/l*71.4%
fma-define71.4%
add-sqr-sqrt71.4%
pow271.4%
Applied egg-rr71.4%
Taylor expanded in d around inf 89.9%
*-commutative89.9%
Simplified89.9%
Final simplification81.6%
(FPCore (a b c d) :precision binary64 (if (or (<= c -0.000225) (not (<= c 6.6e+47))) (/ b c) (/ a (- d))))
double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -0.000225) || !(c <= 6.6e+47)) {
tmp = b / c;
} else {
tmp = 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 <= (-0.000225d0)) .or. (.not. (c <= 6.6d+47))) then
tmp = b / c
else
tmp = a / -d
end if
code = tmp
end function
public static double code(double a, double b, double c, double d) {
double tmp;
if ((c <= -0.000225) || !(c <= 6.6e+47)) {
tmp = b / c;
} else {
tmp = a / -d;
}
return tmp;
}
def code(a, b, c, d): tmp = 0 if (c <= -0.000225) or not (c <= 6.6e+47): tmp = b / c else: tmp = a / -d return tmp
function code(a, b, c, d) tmp = 0.0 if ((c <= -0.000225) || !(c <= 6.6e+47)) tmp = Float64(b / c); else tmp = Float64(a / Float64(-d)); end return tmp end
function tmp_2 = code(a, b, c, d) tmp = 0.0; if ((c <= -0.000225) || ~((c <= 6.6e+47))) tmp = b / c; else tmp = a / -d; end tmp_2 = tmp; end
code[a_, b_, c_, d_] := If[Or[LessEqual[c, -0.000225], N[Not[LessEqual[c, 6.6e+47]], $MachinePrecision]], N[(b / c), $MachinePrecision], N[(a / (-d)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;c \leq -0.000225 \lor \neg \left(c \leq 6.6 \cdot 10^{+47}\right):\\
\;\;\;\;\frac{b}{c}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{-d}\\
\end{array}
\end{array}
if c < -2.2499999999999999e-4 or 6.5999999999999998e47 < c Initial program 51.1%
Taylor expanded in c around inf 68.6%
if -2.2499999999999999e-4 < c < 6.5999999999999998e47Initial program 76.4%
Taylor expanded in c around 0 59.0%
associate-*r/59.0%
neg-mul-159.0%
Simplified59.0%
Final simplification63.5%
(FPCore (a b c d) :precision binary64 (/ b c))
double code(double a, double b, double c, double d) {
return b / c;
}
real(8) function code(a, b, c, d)
real(8), intent (in) :: a
real(8), intent (in) :: b
real(8), intent (in) :: c
real(8), intent (in) :: d
code = b / c
end function
public static double code(double a, double b, double c, double d) {
return b / c;
}
def code(a, b, c, d): return b / c
function code(a, b, c, d) return Float64(b / c) end
function tmp = code(a, b, c, d) tmp = b / c; end
code[a_, b_, c_, d_] := N[(b / c), $MachinePrecision]
\begin{array}{l}
\\
\frac{b}{c}
\end{array}
Initial program 64.5%
Taylor expanded in c around inf 40.5%
Final simplification40.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 2024089
(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))))