Julian just sent me a very annoying message, ALL UPPERCASE, and consistently placing e before i. Don't tell me that I'm being hypersensitive just because the message is only seven characters long: GCD[E,I]? Furthermore, his subtle exposure of my hypocrisy is ABSOLUTELY IRRELEVANT. My proposed diddle leaves GCD[E,I] unchanged. But it should be 0. Kosher GCD already extends to Gaussian rationals: In[1023]:= GCD[1/(1198 + 197*I), 1/(1147 + 398*I)] Out[1023]= 42/1474013 + (25 I)/1474013 In[1024]:= {1/(1198 + 197*I), 1/(1147 + 398*I)}/% Out[1024]= {19 - 16 I, 16 - 19 I} This follows, modulo powers of I, from extending Euclid's algorithm by defining Floor, Round, etc, to simply treat real and imaginary parts separately: In[1020]:= NestList[ Simplify[{#2, #1 - #2*Round[#1/#2]} & @@ #] &, {1/(1198 + 197*I), 1/(1147 + 398*I)}, 4] Out[1020]= {{1198/1474013 - (197 I)/1474013, 1147/1474013 - (398 I)/1474013}, {1147/1474013 - (398 I)/1474013, 51/1474013 + (201 I)/1474013}, {51/1474013 + (201 I)/ 1474013, -(59/1474013) - (92 I)/1474013}, {-(59/1474013) - (92 I)/ 1474013, 25/1474013 - (42 I)/1474013}, {25/1474013 - (42 I)/1474013, 0}} (This is consistent with my proposal for the reals.) Giving it E and I: In[1017]:= NestList[ Simplify[{#2, #1 - #2*Round[#1/#2]} & @@ #] &, {E, I}, 9] Out[1017]= {{E, I}, {I, -3 + E}, {-3 + E, I (-11 + 4 E)}, {I (-11 + 4 E), 19 - 7 E}, {19 - 7 E, I (-106 + 39 E)}, {I (-106 + 39 E), -193 + 71 E}, {-193 + 71 E, I (-1457 + 536 E)}, {I (-1457 + 536 E), 2721 - 1001 E}, {2721 - 1001 E, I (-25946 + 9545 E)}, {I (-25946 + 9545 E), -49171 + 18089 E}} In[1018]:= N[%] Out[1018]= {{2.71828, 0. + 1. I}, {0. + 1. I, -0.281718}, {-0.281718, 0. - 0.126873 I}, {0. - 0.126873 I, -0.0279728}, {-0.0279728, 0. + 0.0129913 I}, {0. + 0.0129913 I, -0.00199018}, {-0.00199018, 0. - 0.000939946 I}, {0. - 0.000939946 I, -0.000110288}, {-0.000110288, 0. + 0.0000526416 I}, {0. + 0.0000526416 I, -5.00433*10^-6}} resolutely seeking to vanish, as claimed. --rwg I "sent" this last night and it never went. Meanwhile, Gareth had the same thought: So you don't want gcd(1, i pi) = 0? -- g On Sat, Nov 30, 2013 at 9:06 PM, Bill Gosper <billgosper@gmail.com> wrote:
On Fri, Nov 29, 2013 at 11:44 AM, Bill Gosper <billgosper@gmail.com>wrote:
OK, I give up. Especially since anyone who agrees with me can just In[895]:= Unprotect[GCD]; GCD[a_, b_] /; a/b ∉ Rationals = 0;
In[896]:= GCD[1/6, 1/9]
Out[896]= 1/18
In[897]:= {GCD[π, 1], GCD[1, π]}
Out[897]= {0, 0}
In[908]:= GCD[E,π]
Out[908]= GCD[E, π]
In[909]:= GCD[Sqrt[2], π]
Out[909]= 0
[...]
ARGH!
In[952]:= GCD[1198 - 197*I, 1147 + 398*I]
Out[952]= 0 <Hasty retreat>
In[953]:= Unprotect[GCD]; Clear[GCD]; GCD[1198 - 197*I, 1147 + 398*I]
Out[953]= 16 + 19 I
OK, how about Unprotect[GCD]; GCD[a_, b_] /; a/b \[NotElement] Rationals && a/b \[Element] Reals =0; In[1006]:= GCD[1198 + 197*I, 1147 + 398*I]
Out[1006]= 25 + 42 I
In[1007]:= GCD[1/6, 1/9]
Out[1007]= 1/18
In[1008]:= GCD[E, 1]
Out[1008]= 0
This time fer shure. --rwg