gives the n^(th) harmonic number .


gives the harmonic number of order r.


  • Mathematical function, suitable for both symbolic and numerical manipulation.
  • The harmonic numbers are given by with .
  • HarmonicNumber can be evaluated to arbitrary numerical precision.
  • HarmonicNumber automatically threads over lists.


open allclose all

Basic Examples  (7)

First ten harmonic numbers:

Plot over a subset of the integers:

Plot over a subset of the complexes:

Series expansion at the origin:

Series expansion at Infinity:

Series expansion at a singular point:

Carry out sums involving harmonic numbers:

Scope  (25)

Numerical Evaluation  (4)

Evaluate numerically:

Evaluate to high precision:

The precision of the output tracks the precision of the input:

Complex number input:

Evaluate efficiently at high precision:

Specific Values  (4)

HarmonicNumber[n,a] for symbolic a:

HarmonicNumber[n,a] for symbolic n:

Value at zero:

Find a value of n for which HarmonicNumber[n]=1.5:

Visualization  (3)

Plot the HarmonicNumber function:

Plot the HarmonicNumber function for various orders:

Plot the real part of HarmonicNumber:

Plot the imaginary part of HarmonicNumber:

Function Properties  (4)

Real domain of HarmonicNumber:

Complex domain:

HarmonicNumber threads elementwise over lists and arrays:

TraditionalForm formatting:

Differentiation  (3)

First derivative with respect to n:

Higher derivatives with respect to n:

Plot the higher derivatives with respect to n:

Formula for the ^(th) derivative with respect to n:

Integration  (3)

Compute the indefinite integral using Integrate:

Verify the anti-derivative:

Definite integral:

More integrals:

Series Expansions  (2)

Find the Taylor expansion using Series:

Plots of the first three approximations around :

General term in the series expansion using SeriesCoefficient:

Function Identities and Simplifications  (2)

HarmonicNumber is defined through the identity:

Recurrence identities:

Generalizations & Extensions  (5)

Harmonic Numbers  (2)

Series expansion at infinity:

HarmonicNumber can be applied to power series:

Harmonic Numbers of Order r  (3)

Evaluate at exact arguments:

Series expansion at any point:

Series expansion at infinity:

Applications  (4)

The average number of comparisons in Quicksort:

Plot over the complex plane:

Book stacking with the maximal overhang:

Picking the best candidate out of n after x evaluated choices [more info]:

Evaluate for n=100:

Plot as a function of harem size:

Properties & Relations  (9)

Use FullSimplify to simplify expressions containing harmonic numbers:

Expand in simpler functions:


Generate from sums and integrals:

Generating function:

HarmonicNumber can be represented as a DifferenceRoot:

General term in the series expansion of HarmonicNumber:

The generating function for HarmonicNumber:

The exponential generating function for HarmonicNumber:

Possible Issues  (3)

Large arguments can give results too large to be computed explicitly:

Machine-number inputs can give highprecision results:

Often results are expressed in PolyGamma instead of HarmonicNumber:

Wolfram Research (1999), HarmonicNumber, Wolfram Language function, https://reference.wolfram.com/language/ref/HarmonicNumber.html.


Wolfram Research (1999), HarmonicNumber, Wolfram Language function, https://reference.wolfram.com/language/ref/HarmonicNumber.html.


@misc{reference.wolfram_2020_harmonicnumber, author="Wolfram Research", title="{HarmonicNumber}", year="1999", howpublished="\url{https://reference.wolfram.com/language/ref/HarmonicNumber.html}", note=[Accessed: 04-March-2021 ]}


@online{reference.wolfram_2020_harmonicnumber, organization={Wolfram Research}, title={HarmonicNumber}, year={1999}, url={https://reference.wolfram.com/language/ref/HarmonicNumber.html}, note=[Accessed: 04-March-2021 ]}


Wolfram Language. 1999. "HarmonicNumber." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/HarmonicNumber.html.


Wolfram Language. (1999). HarmonicNumber. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/HarmonicNumber.html