Relatively Prime

Author

Eric W. Weisstein
January 20, 2006

This notebook downloaded from http://mathworld.wolfram.com/notebooks/NumberTheory/RelativelyPrime.nb.

For more information, see Eric's MathWorld entry http://mathworld.wolfram.com/RelativelyPrime.html.

©2006 Wolfram Research, Inc. except for portions noted otherwise

Probability that Pairs of Integers Are Relatively Prime

Two Integers

With[{n=10^6,max=10^6},Count[GCD@@@Table[Random[Integer,{1,max}],{n},{2}],1]/n
]//N//Timing

N[6/Pi^2,10]

Three Integers

With[{n=10^6,max=10^6},Count[GCD@@@Table[Random[Integer,{1,max}],{n},{3}],1]/n
]//N//Timing

N[1/Zeta[3],20]

Two Gaussian Integers

With[{n=10^6,max=10^6},Count[GCD@@@Table[Random[Integer,{-1,1}max]+Random[Integer,{-1,1}max]I,{n},{2}],1]/n
]//N//Timing

N[6/Pi^2/Catalan,20]

Two Eisenstein Integers

Sum[(1/(((3k+1))^2))-(1/(((3k+2))^2)),{k,0,∞}]

N[%,20]

i[t_]:=Integrate[Log[2Cos[x/2]],{x,0,t}]

FullSimplify[4Pi/(3Sqrt[3])(1/Pi i[2Pi/3])]

FullSimplify[FunctionExpand[PolyLog[2,-(((-1))^(2/3))]]]

N[%,20]

N[6/(Pi^2h),20]

Plot

Show[
Block[{$DisplayFunction=Identity},
GraphicsArray[{
ArrayPlot[Table[Boole[GCD[a, b] == 1], {a, 127}, {b, 127}],ImageSize ->255,PixelConstrained->True,  Frame -> False],
ArrayPlot[Table[GCD[a, b], {a, 127}, {b, 127}],ImageSize -> 300, PixelConstrained -> True, Frame -> False,ColorFunction->(Hue[#/50]&)]
}]],GraphicsSpacing->1]

...bug..

ArrayPlot[Table[Boole[GCD[a, b] == 1], {a, 127}, {b, 127}],PixelConstrained->True,  Frame -> False]

ArrayPlot[Table[GCD[a, b], {a, 127}, {b, 127}],
 PixelConstrained -> True, Frame -> False,ColorFunction->(Hue[#/50]&)]