WOLFRAM

gives the n^(th) harmonic number TemplateBox[{n}, HarmonicNumber].

gives the harmonic number TemplateBox[{n, r}, HarmonicNumber2] of order r.

Details

  • Mathematical function, suitable for both symbolic and numerical manipulation.
  • For positive integers n, the harmonic numbers are given by TemplateBox[{n, r}, HarmonicNumber2]=sum_(i=1)^(n)1/i^r with TemplateBox[{n}, HarmonicNumber]=TemplateBox[{n, 1}, HarmonicNumber2].
  • For arbitrary n and r1, the numerical value of TemplateBox[{n, r}, HarmonicNumber2] is given by Zeta[r]-HurwitzZeta[r,n+1].
  • HarmonicNumber can be evaluated to arbitrary numerical precision.
  • HarmonicNumber automatically threads over lists.
  • HarmonicNumber can be used with Interval and CenteredInterval objects. »

Examples

open allclose all

Basic Examples  (7)Summary of the most common use cases

First ten harmonic numbers:

Out[1]=1

Plot over a subset of the integers:

Out[1]=1

Plot over a subset of the complexes:

Out[1]=1

Series expansion at the origin:

Out[1]=1

Series expansion at Infinity:

Out[1]=1

Series expansion at a singular point:

Out[1]=1

Carry out sums involving harmonic numbers:

Out[1]=1

Scope  (35)Survey of the scope of standard use cases

Numerical Evaluation  (6)

Evaluate numerically:

Out[1]=1
Out[2]=2

Evaluate to high precision:

Out[1]=1

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

Out[2]=2

Complex number input:

Out[1]=1

Evaluate efficiently at high precision:

Out[1]=1
Out[2]=2

Compute worst-case guaranteed intervals using Interval and CenteredInterval objects:

Out[1]=1
Out[2]=2

Or compute average-case statistical intervals using Around:

Out[3]=3

Compute the elementwise values of an array:

Out[1]=1

Or compute the matrix HarmonicNumber function using MatrixFunction:

Out[2]=2

Specific Values  (5)

HarmonicNumber[n,a] for symbolic a:

Out[1]=1

HarmonicNumber[n,a] for symbolic n:

Out[1]=1

Value at zero:

Out[1]=1

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

Out[1]=1
Out[2]=2

Express harmonic numbers of fractional arguments in terms of elementary functions:

Out[1]=1
Out[2]=2

Visualization  (3)

Plot the HarmonicNumber function:

Out[1]=1

Plot the HarmonicNumber function for various orders:

Out[1]=1

Plot the real part of HarmonicNumber:

Out[1]=1

Plot the imaginary part of HarmonicNumber:

Out[2]=2

Function Properties  (11)

Real domain of HarmonicNumber:

Out[1]=1

Complex domain:

Out[2]=2

Real range of HarmonicNumber:

Out[1]=1

HarmonicNumber threads elementwise over lists and arrays:

Out[1]=1

HarmonicNumber is not an analytic function:

Out[1]=1

However, it is meromorphic:

Out[2]=2

HarmonicNumber is neither non-increasing nor non-decreasing:

Out[1]=1

HarmonicNumber is not injective:

Out[1]=1
Out[2]=2

HarmonicNumber is surjective:

Out[1]=1
Out[2]=2

HarmonicNumber is neither non-negative nor non-positive:

Out[1]=1

HarmonicNumber has both singularities and discontinuities for negative integers:

Out[1]=1
Out[2]=2

HarmonicNumber is neither convex nor concave:

Out[1]=1

TraditionalForm formatting:

Differentiation  (3)

First derivative with respect to n:

Out[1]=1

Higher derivatives with respect to n:

Out[1]=1

Plot the higher derivatives with respect to n:

Out[2]=2

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

Out[1]=1

Integration  (3)

Compute the indefinite integral using Integrate:

Out[1]=1

Verify the anti-derivative:

Out[2]=2

Definite integral:

Out[1]=1

More integrals:

Out[1]=1
Out[2]=2

Series Expansions  (2)

Find the Taylor expansion using Series:

Out[1]=1

Plots of the first three approximations around :

Out[2]=2

General term in the series expansion using SeriesCoefficient:

Out[1]=1

Function Identities and Simplifications  (2)

The defining identity for HarmonicNumber:

Out[1]=1

Recurrence identities:

Out[1]=1
Out[2]=2

Generalizations & Extensions  (5)Generalized and extended use cases

Harmonic Numbers  (2)

Series expansion at infinity:

Out[1]=1

HarmonicNumber can be applied to power series:

Out[1]=1

Harmonic Numbers of Order r  (3)

Evaluate at exact arguments:

Out[1]=1
Out[2]=2
Out[3]=3

Series expansion at any point:

Out[1]=1

Series expansion at infinity:

Out[1]=1

Applications  (5)Sample problems that can be solved with this function

The average number of comparisons in Quicksort:

Out[1]=1

Plot over the complex plane:

Out[1]=1

Book stacking with the maximal overhang:

Out[1]=1

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

Evaluate for n=100:

Out[2]=2

Plot as a function of the size of the candidate pool:

Out[3]=3

A finite sum with StirlingS1 expressed in terms of HarmonicNumber:

Out[1]=1

A finite sum with StirlingS2 expressed in terms of HarmonicNumber:

Out[2]=2

Properties & Relations  (10)Properties of the function, and connections to other functions

HarmonicNumber can be expressed in terms of PolyGamma:

Out[1]=1

HarmonicNumber can be expressed in terms of Zeta and HurwitzZeta:

Out[1]=1

Use FullSimplify to simplify expressions containing harmonic numbers:

Out[1]=1
Out[2]=2

Expand in simpler functions:

Out[1]=1

Sums:

Out[1]=1
Out[2]=2

Generate from sums and integrals:

Out[1]=1
Out[2]=2

HarmonicNumber can be represented as a DifferenceRoot:

Out[1]=1
Out[2]=2

General term in the series expansion of HarmonicNumber:

Out[1]=1

The ordinary generating function for HarmonicNumber:

Out[1]=1
Out[2]=2
Out[3]=3
Out[4]=4

The exponential generating function for HarmonicNumber:

Out[1]=1

Possible Issues  (3)Common pitfalls and unexpected behavior

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

Out[1]=1

Machine-number inputs can give highprecision results:

Out[1]=1
Out[2]=2

Results are often expressed in terms of PolyGamma instead of HarmonicNumber:

Out[1]=1
Out[2]=2
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.

Text

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.

CMS

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. Wolfram Research. https://reference.wolfram.com/language/ref/HarmonicNumber.html.

APA

Wolfram Language. (1999). HarmonicNumber. Wolfram Language & System Documentation Center. Retrieved from 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

BibTeX

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

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

BibLaTeX

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

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