Function Repository Resource:

 HarmonicNumberToSum

Source Notebook

Convert harmonic number expressions to inactive finite-sum representations

Contributed by: Jayanta Phadikar

ResourceFunction["HarmonicNumberToSum"][expr]

gives an inactive finite-sum representation of the supported harmonic number expression expr.

Details

ResourceFunction["HarmonicNumberToSum"][expr] returns an expression with head Inactive[Sum]. The sum is displayed in ordinary summation notation, but it is not evaluated immediately.
Supported inputs include ordinary HarmonicNumber expressions, AlternatingHarmonicNumber expressions, HyperHarmonicNumber expressions, and MultipleHarmonicNumber expressions in the forms shown in the examples.
Generated summation variables use formal symbols such as i and subscripted formal variables, which helps avoid collisions with variables already present in the input.
Use Activate on the result to turn the inactive sum into an ordinary Sum expression. In the examples, the activated result agrees with the original harmonic-number expression.

Examples

Basic Examples (2) 

Convert an ordinary harmonic number to an inactive finite sum:

In[1]:=
ResourceFunction["HarmonicNumberToSum"][HarmonicNumber[n]]
Out[1]=
In[2]:=
Activate[%] == HarmonicNumber[n]
Out[2]=

Convert an alternating harmonic number:

In[3]:=
ResourceFunction["HarmonicNumberToSum"][AlternatingHarmonicNumber[n]]
Out[3]=
In[4]:=
Activate[%] == AlternatingHarmonicNumber[n]
Out[4]=

Scope (9) 

Convert a generalized harmonic number with symbolic order r:

In[5]:=
ResourceFunction["HarmonicNumberToSum"][HarmonicNumber[n, r]]
Out[5]=
In[6]:=
Activate[%] == HarmonicNumber[n, r]
Out[6]=

Include an additional color or scale parameter s in the generalized harmonic number:

In[7]:=
ResourceFunction["HarmonicNumberToSum"][HarmonicNumber[n, r, s]]
Out[7]=
In[8]:=
Activate[%] == HarmonicNumber[n, r, s]
Out[8]=

Convert a higher-order alternating harmonic number:

In[9]:=
ResourceFunction["HarmonicNumberToSum"][
 AlternatingHarmonicNumber[n, r]]
Out[9]=
In[10]:=
Activate[%] == AlternatingHarmonicNumber[n, r]
Out[10]=

Combine the alternating sign with a symbolic order and color parameter:

In[11]:=
ResourceFunction["HarmonicNumberToSum"][
 AlternatingHarmonicNumber[n, r, s]]
Out[11]=
In[12]:=
Activate[%] == AlternatingHarmonicNumber[n, r, s]
Out[12]=

For first-order hyperharmonic numbers, the result is the corresponding generalized harmonic sum:

In[13]:=
ResourceFunction["HarmonicNumberToSum"][
 HyperHarmonicNumber[1, n, r, s]]
Out[13]=
In[14]:=
Activate[%] == HyperHarmonicNumber[1, n, r, s]
Out[14]=

For higher-order hyperharmonic numbers, the function writes the result as a sum over a lower-order hyperharmonic number:

In[15]:=
ResourceFunction["HarmonicNumberToSum"][
 HyperHarmonicNumber[3, n, r, s]]
Out[15]=
In[16]:=
Activate[%] == HyperHarmonicNumber[3, n, r, s]
Out[16]=

MultipleHarmonicNumber[n] reduces to the same one-dimensional sum as the ordinary harmonic number:

In[17]:=
ResourceFunction["HarmonicNumberToSum"][MultipleHarmonicNumber[n]]
Out[17]=
In[18]:=
Activate[%] == MultipleHarmonicNumber[n]
Out[18]=

A depth-two multiple harmonic number becomes a nested sum with a strict upper bound for the inner index:

In[19]:=
ResourceFunction["HarmonicNumberToSum"][
 MultipleHarmonicNumber[n, {r1, r2}]]
Out[19]=
In[20]:=
Activate[%] == MultipleHarmonicNumber[n, {r1, r2}]
Out[20]=

Color parameters in a multiple harmonic number are carried into the nested summand:

In[21]:=
ResourceFunction["HarmonicNumberToSum"][
 MultipleHarmonicNumber[n, {r1, r2}, {s1, s2}]]
Out[21]=
In[22]:=
Activate[%] == MultipleHarmonicNumber[n, {r1, r2}, {s1, s2}]
Out[22]=

Publisher

Jayanta Kumar Phadikar

Version History

  • 1.0.0 – 01 July 2026

Related Resources

License Information