HarmonicNumber
✖
HarmonicNumber
Details

- Mathematical function, suitable for both symbolic and numerical manipulation.
- For positive integers n, the harmonic numbers are given by
with
.
- For arbitrary n and r≠1, the numerical value of
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 allBasic Examples (7)Summary of the most common use cases

https://wolfram.com/xid/09cdorq2a-hl13l

Plot over a subset of the integers:

https://wolfram.com/xid/09cdorq2a-25h1s

Plot over a subset of the complexes:

https://wolfram.com/xid/09cdorq2a-kiedlx

Series expansion at the origin:

https://wolfram.com/xid/09cdorq2a-fdkkja

Series expansion at Infinity:

https://wolfram.com/xid/09cdorq2a-20imb

Series expansion at a singular point:

https://wolfram.com/xid/09cdorq2a-d2klx1

Carry out sums involving harmonic numbers:

https://wolfram.com/xid/09cdorq2a-b57d70

Scope (35)Survey of the scope of standard use cases
Numerical Evaluation (6)

https://wolfram.com/xid/09cdorq2a-l274ju


https://wolfram.com/xid/09cdorq2a-wlv0g


https://wolfram.com/xid/09cdorq2a-b0wt9

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

https://wolfram.com/xid/09cdorq2a-y7k4a


https://wolfram.com/xid/09cdorq2a-hfml09

Evaluate efficiently at high precision:

https://wolfram.com/xid/09cdorq2a-di5gcr


https://wolfram.com/xid/09cdorq2a-bq2c6r

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

https://wolfram.com/xid/09cdorq2a-h0d6g


https://wolfram.com/xid/09cdorq2a-emr3q7

Or compute average-case statistical intervals using Around:

https://wolfram.com/xid/09cdorq2a-cw18bq

Compute the elementwise values of an array:

https://wolfram.com/xid/09cdorq2a-thgd2

Or compute the matrix HarmonicNumber function using MatrixFunction:

https://wolfram.com/xid/09cdorq2a-o5jpo

Specific Values (5)
HarmonicNumber[n,a] for symbolic a:

https://wolfram.com/xid/09cdorq2a-fc9m8o

HarmonicNumber[n,a] for symbolic n:

https://wolfram.com/xid/09cdorq2a-h7p5ce


https://wolfram.com/xid/09cdorq2a-bmqd0y

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

https://wolfram.com/xid/09cdorq2a-f2hrld


https://wolfram.com/xid/09cdorq2a-bm9h1

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

https://wolfram.com/xid/09cdorq2a-nk52mh


https://wolfram.com/xid/09cdorq2a-n4ycy

Visualization (3)
Plot the HarmonicNumber function:

https://wolfram.com/xid/09cdorq2a-b1j98m

Plot the HarmonicNumber function for various orders:

https://wolfram.com/xid/09cdorq2a-ecj8m7

Plot the real part of HarmonicNumber:

https://wolfram.com/xid/09cdorq2a-b8vnf

Plot the imaginary part of HarmonicNumber:

https://wolfram.com/xid/09cdorq2a-fjwo7k

Function Properties (11)
Real domain of HarmonicNumber:

https://wolfram.com/xid/09cdorq2a-cl7ele


https://wolfram.com/xid/09cdorq2a-de3irc

Real range of HarmonicNumber:

https://wolfram.com/xid/09cdorq2a-5j1gt2

HarmonicNumber threads elementwise over lists and arrays:

https://wolfram.com/xid/09cdorq2a-g4bqu6

HarmonicNumber is not an analytic function:

https://wolfram.com/xid/09cdorq2a-h5x4l2


https://wolfram.com/xid/09cdorq2a-1snzk8

HarmonicNumber is neither non-increasing nor non-decreasing:

https://wolfram.com/xid/09cdorq2a-g6kynf

HarmonicNumber is not injective:

https://wolfram.com/xid/09cdorq2a-fkbstt


https://wolfram.com/xid/09cdorq2a-9fxpr3

HarmonicNumber is surjective:

https://wolfram.com/xid/09cdorq2a-hkqec4


https://wolfram.com/xid/09cdorq2a-hdm869

HarmonicNumber is neither non-negative nor non-positive:

https://wolfram.com/xid/09cdorq2a-84dui

HarmonicNumber has both singularities and discontinuities for negative integers:

https://wolfram.com/xid/09cdorq2a-mdtl3h


https://wolfram.com/xid/09cdorq2a-mn5jws

HarmonicNumber is neither convex nor concave:

https://wolfram.com/xid/09cdorq2a-kdss3

TraditionalForm formatting:

https://wolfram.com/xid/09cdorq2a-l5d69d

Differentiation (3)
First derivative with respect to n:

https://wolfram.com/xid/09cdorq2a-krpoah

Higher derivatives with respect to n:

https://wolfram.com/xid/09cdorq2a-z33jv

Plot the higher derivatives with respect to n:

https://wolfram.com/xid/09cdorq2a-fxwmfc

Formula for the derivative with respect to n:

https://wolfram.com/xid/09cdorq2a-cb5zgj

Integration (3)
Compute the indefinite integral using Integrate:

https://wolfram.com/xid/09cdorq2a-bponid


https://wolfram.com/xid/09cdorq2a-op9yly


https://wolfram.com/xid/09cdorq2a-b9jw7l


https://wolfram.com/xid/09cdorq2a-4nbst


https://wolfram.com/xid/09cdorq2a-h9t4zs

Series Expansions (2)
Find the Taylor expansion using Series:

https://wolfram.com/xid/09cdorq2a-ewr1h8

Plots of the first three approximations around :

https://wolfram.com/xid/09cdorq2a-binhar

General term in the series expansion using SeriesCoefficient:

https://wolfram.com/xid/09cdorq2a-dznx2j

Function Identities and Simplifications (2)
The defining identity for HarmonicNumber:

https://wolfram.com/xid/09cdorq2a-b5js3b


https://wolfram.com/xid/09cdorq2a-d34lia


https://wolfram.com/xid/09cdorq2a-liy2m1

Generalizations & Extensions (5)Generalized and extended use cases
Harmonic Numbers (2)

https://wolfram.com/xid/09cdorq2a-chlfqs

HarmonicNumber can be applied to power series:

https://wolfram.com/xid/09cdorq2a-ejq61x

Harmonic Numbers of Order r (3)

https://wolfram.com/xid/09cdorq2a-def9vx


https://wolfram.com/xid/09cdorq2a-jj7vas


https://wolfram.com/xid/09cdorq2a-89i7j

Series expansion at any point:

https://wolfram.com/xid/09cdorq2a-vp64w


https://wolfram.com/xid/09cdorq2a-gfa8uu

Applications (5)Sample problems that can be solved with this function
The average number of comparisons in Quicksort:

https://wolfram.com/xid/09cdorq2a-d1sgx2


https://wolfram.com/xid/09cdorq2a-jyr60y

Book stacking with the maximal overhang:

https://wolfram.com/xid/09cdorq2a-cguq1w

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

https://wolfram.com/xid/09cdorq2a-h7f0w

https://wolfram.com/xid/09cdorq2a-dh9nl7

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

https://wolfram.com/xid/09cdorq2a-kri504

A finite sum with StirlingS1 expressed in terms of HarmonicNumber:

https://wolfram.com/xid/09cdorq2a-b5uguq

A finite sum with StirlingS2 expressed in terms of HarmonicNumber:

https://wolfram.com/xid/09cdorq2a-dco1yi

Properties & Relations (10)Properties of the function, and connections to other functions
HarmonicNumber can be expressed in terms of PolyGamma:

https://wolfram.com/xid/09cdorq2a-dqx8pq

HarmonicNumber can be expressed in terms of Zeta and HurwitzZeta:

https://wolfram.com/xid/09cdorq2a-kmgk7z

Use FullSimplify to simplify expressions containing harmonic numbers:

https://wolfram.com/xid/09cdorq2a-3mmk2


https://wolfram.com/xid/09cdorq2a-bh6ykg


https://wolfram.com/xid/09cdorq2a-gvy9r2


https://wolfram.com/xid/09cdorq2a-c5syve


https://wolfram.com/xid/09cdorq2a-xl7aq

Generate from sums and integrals:

https://wolfram.com/xid/09cdorq2a-ckuacd


https://wolfram.com/xid/09cdorq2a-esv1y7

HarmonicNumber can be represented as a DifferenceRoot:

https://wolfram.com/xid/09cdorq2a-ojcks5


https://wolfram.com/xid/09cdorq2a-d7mw27

General term in the series expansion of HarmonicNumber:

https://wolfram.com/xid/09cdorq2a-dlm2b6

The ordinary generating function for HarmonicNumber:

https://wolfram.com/xid/09cdorq2a-pz93yz


https://wolfram.com/xid/09cdorq2a-frz0l8


https://wolfram.com/xid/09cdorq2a-nalti6


https://wolfram.com/xid/09cdorq2a-e1gujp

The exponential generating function for HarmonicNumber:

https://wolfram.com/xid/09cdorq2a-gaiyeu

Possible Issues (3)Common pitfalls and unexpected behavior
Large arguments can give results too large to be computed explicitly:

https://wolfram.com/xid/09cdorq2a-cg5joy


Machine-number inputs can give high‐precision results:

https://wolfram.com/xid/09cdorq2a-bwfqfq


https://wolfram.com/xid/09cdorq2a-bmtdv

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

https://wolfram.com/xid/09cdorq2a-c1jr3


https://wolfram.com/xid/09cdorq2a-e7zau2

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
]}
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
]}