# Does anyone know a function that can describe a harmonic series?

I want to find a function that satisfies the following functional equation: $F(z+1)=1/z+F(z)$

This is a generalization of harmonic series 1 + 1/2 + 1/3 + 1/4 + ..., and is similar to the gamma function which satisfies the relation $F(z+1)=zF(z)$.

I searched the internet. However, I didn't find such a function. Could anyone tell me something about this function?

• Welcome to Mathematica.SE. Are you sure you are posting on the right site? There is nothing in your question making it clear that it is concerned with Mathematica software. Mar 6 '16 at 14:32
• You'll want to look up the digamma function. Mar 6 '16 at 18:00
• Yes, thank you.
– XIN
Mar 7 '16 at 10:20

In Mathematica, such a recursion may be solved with

RSolve[{f[z + 1] == f[z] + 1/z, f[1] == 1}, f[z], z]

where I assumed an initial condition of $f[1]=1$. The solution returned is

f[z] -> 1 + EulerGamma + PolyGamma[0, z]
Clear[f, f1, f2]

f1[z_] = Sum[1/k, {k, z - 1}]

(*  HarmonicNumber[-1 + z]  *)

Although this definition is for positive integers, the result is valid for all z except non-positive integers.

Plot[f1[z], {z, -5.9, 10}, Exclusions -> Range[-5, 0],
PlotRange -> {-5, 5}]

HarmonicNumber[-1 + z] // FunctionExpand

(*  EulerGamma + PolyGamma[0, z]  *)

Alternatively,

f2[z_] = f[z] /.
RSolve[{f[z + 1] == 1/z + f[z], f[1] == 0}, f[z], z][[1]]

(*  EulerGamma + PolyGamma[0, z]  *)

Plot[f2[z], {z, -5.9, 10}, Exclusions -> Range[-5, 0],
PlotRange -> {-5, 5}]

FullSimplify[f1[z] == f2[z], z > 0]

(*  True  *)

FullSimplify[f1[z] == f2[z], z < 0 && Not[Element[z, Integers]]]

(*  True  *)

Even for complex numbers

f1[1. + I]

(*  0.671866 + 1.07667 I  *)

f1[1. + I] == f2[1. + I]

(*  True  *)
• An interesting series representation of HarmonicNumber is FullSimplify[ Sum[z/(n (n + z)), {n, 1, [Infinity]}] == HarmonicNumber[z]] Out[1289]= True Mar 6 '16 at 20:39