Function Repository Resource:

JordanTotient

Source Notebook

Evaluate Jordan's totient function

Contributed by: Jan Mangaldan

ResourceFunction["JordanTotient"][k,n]

gives the Jordan totient function Jk(n).

Details

Integer mathematical function, suitable for both symbolic and numerical manipulation.
The Jordan totient function Jk(n) gives the number of k-tuples of positive integers that are less than or equal to n that form a coprime (k+1)-tuple together with n.
For a number with u a unit and pi primes, ResourceFunction["JordanTotient"][k,n] gives .
ResourceFunction["JordanTotient"][1,n] is equivalent to EulerPhi[n].
ResourceFunction["JordanTotient"] automatically threads over lists.

Examples

Basic Examples (2) 

Evaluate J1(10):

In[1]:=
ResourceFunction["JordanTotient"][1, 10]
Out[1]=

Plot JordanTotient with log-scaled values:

In[2]:=
(* Evaluate this cell to get the example input *) CloudGet["https://www.wolframcloud.com/obj/57711127-5bb2-4af3-9b65-142cf9a9804c"]
Out[2]=

Scope (2) 

Show a table of Jordan totients:

In[3]:=
TableForm[Array[ResourceFunction["JordanTotient"], {7, 7}], TableHeadings -> {Range[7], Range[7]}]
Out[3]=

JordanTotient threads elementwise over lists:

In[4]:=
ResourceFunction["JordanTotient"][3, {2, 4, 6}]
Out[4]=

Applications (2) 

Verify Gegenbauer's formula:

In[5]:=
With[{k = 5, l = 7, n = 31}, ResourceFunction["JordanTotient"][k + l, n] == DirichletConvolve[d^k ResourceFunction["JordanTotient"][l, d], ResourceFunction["JordanTotient"][k, d], d, n]]
Out[5]=

A formula for the logarithmic derivative of a cyclotomic polynomial evaluated at 1 due to Lehmer:

In[6]:=
With[{k = 5, n = 17}, Limit[D[Log[Cyclotomic[n, t]], {t, k}], t -> 1] == \!\(
\*UnderoverscriptBox[\(\[Sum]\), \(j = 1\), \(k\)]\(
\*FractionBox[\(BernoulliB[j, 1] StirlingS1[k, j]\), \(j\)] \*
InterpretationBox[
TagBox[
DynamicModuleBox[{Typeset`open = False}, 
FrameBox[
PaneSelectorBox[{False->GridBox[{
{
PaneBox[GridBox[{
{
StyleBox[
StyleBox[
AdjustmentBox["\<\"[\[FilledSmallSquare]]\"\>",
BoxBaselineShift->-0.25,
BoxMargins->{{0, 0}, {-1, -1}}], "ResourceFunctionIcon",
FontColor->RGBColor[
                    0.8745098039215686, 0.2784313725490196, 0.03137254901960784]],
ShowStringCharacters->False,
FontFamily->"Source Sans Pro Black",
FontSize->0.6538461538461539 Inherited,
FontWeight->"Heavy",
PrivateFontOptions->{"OperatorSubstitution"->False}], 
StyleBox[
RowBox[{
StyleBox["JordanTotient", "ResourceFunctionLabel"], " "}],
ShowAutoStyles->False,
ShowStringCharacters->False,
FontSize->Rational[12, 13] Inherited,
FontColor->GrayLevel[0.1]]}
},
GridBoxSpacings->{"Columns" -> {{0.25}}}],
Alignment->Left,
BaseStyle->{LineSpacing -> {0, 0}, LineBreakWithin -> False},
BaselinePosition->Baseline,
FrameMargins->{{3, 0}, {0, 0}}], 
ItemBox[
PaneBox[
TogglerBox[Dynamic[Typeset`open], {True-> DynamicBox[FEPrivate`FrontEndResource[
                 "FEBitmaps", "IconizeCloser"],
ImageSizeCache->{11., {1., 10.}}], False-> DynamicBox[FEPrivate`FrontEndResource[
                 "FEBitmaps", "IconizeOpener"],
ImageSizeCache->{11., {1., 10.}}]},
Appearance->None,
BaselinePosition->Baseline,
ContentPadding->False,
FrameMargins->0],
Alignment->Left,
BaselinePosition->Baseline,
FrameMargins->{{1, 1}, {0, 0}}],
Frame->{{
RGBColor[
                 0.8313725490196079, 0.8470588235294118, 0.8509803921568627, 0.5], False}, {False, False}}]}
},
BaselinePosition->{1, 1},
GridBoxAlignment->{"Columns" -> {{Left}}, "Rows" -> {{Baseline}}},
GridBoxItemSize->{"Columns" -> {{Automatic}}, "Rows" -> {{Automatic}}},
           
GridBoxSpacings->{"Columns" -> {{0}}, "Rows" -> {{0}}}], True->GridBox[{
{GridBox[{
{
PaneBox[GridBox[{
{
StyleBox[
StyleBox[
AdjustmentBox["\<\"[\[FilledSmallSquare]]\"\>",
BoxBaselineShift->-0.25,
BoxMargins->{{0, 0}, {-1, -1}}], "ResourceFunctionIcon",
FontColor->RGBColor[
                    0.8745098039215686, 0.2784313725490196, 0.03137254901960784]],
ShowStringCharacters->False,
FontFamily->"Source Sans Pro Black",
FontSize->0.6538461538461539 Inherited,
FontWeight->"Heavy",
PrivateFontOptions->{"OperatorSubstitution"->False}], 
StyleBox[
RowBox[{
StyleBox["JordanTotient", "ResourceFunctionLabel"], " "}],
ShowAutoStyles->False,
ShowStringCharacters->False,
FontSize->Rational[12, 13] Inherited,
FontColor->GrayLevel[0.1]]}
},
GridBoxSpacings->{"Columns" -> {{0.25}}}],
Alignment->Left,
BaseStyle->{LineSpacing -> {0, 0}, LineBreakWithin -> False},
BaselinePosition->Baseline,
FrameMargins->{{3, 0}, {0, 0}}], 
ItemBox[
PaneBox[
TogglerBox[Dynamic[Typeset`open], {True-> DynamicBox[FEPrivate`FrontEndResource[
                    "FEBitmaps", "IconizeCloser"]], False-> DynamicBox[FEPrivate`FrontEndResource[
                    "FEBitmaps", "IconizeOpener"]]},
Appearance->None,
BaselinePosition->Baseline,
ContentPadding->False,
FrameMargins->0],
Alignment->Left,
BaselinePosition->Baseline,
FrameMargins->{{1, 1}, {0, 0}}],
Frame->{{
RGBColor[
                    0.8313725490196079, 0.8470588235294118, 0.8509803921568627, 0.5], False}, {False, False}}]}
},
BaselinePosition->{1, 1},
GridBoxAlignment->{"Columns" -> {{Left}}, "Rows" -> {{Baseline}}},
GridBoxItemSize->{"Columns" -> {{Automatic}}, "Rows" -> {{Automatic}}},
              
GridBoxSpacings->{"Columns" -> {{0}}, "Rows" -> {{0}}}]},
{
StyleBox[
PaneBox[GridBox[{
{
RowBox[{
TagBox["\<\"Version (latest): \"\>",
"IconizedLabel"], " ", 
TagBox["\<\"1.0.0\"\>",
"IconizedItem"]}]},
{
TagBox[
TemplateBox[{"\"Documentation »\"", "https://resources.wolframcloud.com/FunctionRepository/resources/055b08ea-79a0-458a-8254-4720bc316c4f/"},
"HyperlinkURL"],
"IconizedItem"]}
},
DefaultBaseStyle->"Column",
GridBoxAlignment->{"Columns" -> {{Left}}},
GridBoxItemSize->{"Columns" -> {{Automatic}}, "Rows" -> {{Automatic}}}],
Alignment->Left,
BaselinePosition->Baseline,
FrameMargins->{{5, 4}, {0, 4}}], "DialogStyle",
FontFamily->"Roboto",
FontSize->11]}
},
BaselinePosition->{1, 1},
GridBoxAlignment->{"Columns" -> {{Left}}, "Rows" -> {{Baseline}}},
GridBoxDividers->{"Columns" -> {{None}}, "Rows" -> {False, {
GrayLevel[0.8]}, False}},
GridBoxItemSize->{"Columns" -> {{Automatic}}, "Rows" -> {{Automatic}}}]}, Dynamic[Typeset`open],
BaselinePosition->Baseline,
ImageSize->Automatic],
Background->RGBColor[
          0.9686274509803922, 0.9764705882352941, 0.984313725490196],
BaselinePosition->Baseline,
DefaultBaseStyle->{},
FrameMargins->{{0, 0}, {1, 0}},
FrameStyle->RGBColor[
          0.8313725490196079, 0.8470588235294118, 0.8509803921568627],
         
RoundingRadius->4]],
{"FunctionResourceBox", 
RGBColor[0.8745098039215686, 0.2784313725490196, 0.03137254901960784],
         "JordanTotient"},
TagBoxNote->"FunctionResourceBox"],
ResourceFunction["JordanTotient"],
BoxID -> "JordanTotient",
Selectable->False][j, n]\)\)]
Out[6]=

Properties and Relations (5) 

JordanTotient[1,n] is the same as EulerPhi[n]:

In[7]:=
ResourceFunction["JordanTotient"][1, Range[20]] == EulerPhi[Range[20]]
Out[7]=

JordanTotient is a multiplicative function:

In[8]:=
With[{k = 5, m = 10, n = 13}, ResourceFunction["JordanTotient"][k, m] ResourceFunction[
     "JordanTotient"][k, n] == ResourceFunction["JordanTotient"][k, m n] && CoprimeQ[m, n]]
Out[8]=

where p is prime:

In[9]:=
With[{k = 3, n = 5}, ResourceFunction["JordanTotient"][k, n] == n^k Product[1 - p^-k, {p, Select[Divisors[n], PrimeQ]}]]
Out[9]=

JordanTotient[k,n] counts the number of k-tuples n that form a coprime (k+1)-tuple together with n:

In[10]:=
With[{k = 3, n = 5}, Length[Select[Tuples[Range[n], {k}], Apply[GCD, Append[#, n]] == 1 &]]]
Out[10]=
In[11]:=
ResourceFunction["JordanTotient"][3, 5]
Out[11]=

The power function can be expressed as a divisor sum of Jordan totients:

In[12]:=
With[{k = 3, n = 5}, DivisorSum[n, ResourceFunction["JordanTotient"][k, #] &] == n^k]
Out[12]=

Neat Examples (1) 

Plot the Ulam spiral with numbers colored based on the values of JordanTotient:

In[13]:=
ulam[n_] := Partition[Permute[Range[n^2], Accumulate[Take[Flatten[{{n^2 + 1}/2,
       Table[(-1)^j i, {j, n}, {i, {-1, n}}, {j}]}], n^2]]], n]
In[14]:=
Manipulate[
 ArrayPlot[ResourceFunction["JordanTotient"][k, ulam[141]], ColorFunction -> Hue], {k, 1, 10, 1}, ContinuousAction -> False, SaveDefinitions -> True]
Out[14]=

Version History

  • 1.0.0 – 10 March 2021

Related Resources

License Information