This functionality does not run in MATLAB.
harmonic(x) = represents the harmonic function.
The harmonic function is defined for all complex arguments x apart from the singular points - 1, - 2, … (first order poles).
For positive integers x not larger than the value Pref::autoExpansionLimit(), the harmonic function procudes the harmonic number . Use expand(harmonic(x)) to compute an explicit result for integers x larger than Pref::autoExpansionLimit().
If x is a floating-point value, then a floating point value is returned.
Simplifcations are implemented for rational numbers x with |x| ≤ Pref::autoExpansionLimit(). In particular, if x = numer(x)/k with denominators k = 1, 2, 3, 4, or 6, then an explicit result is computed and returned. For other rational numbers the functional equation is used to obtain a result with an argument x from the interval .
For rational numbers x with |x| > Pref::autoExpansionLimit(), these simplifications can be enforced via expand.
Some explicit formulas are implemented including
The special value harmonic(∞) = ∞ is implemented.
For all other arguments, a symbolic function call of harmonic is returned.
When called with a floating-point value x, the function is sensitive to the environment variable DIGITS which determines the numerical working precision.
We demonstrate some calls with exact and symbolic input data:
harmonic(3), harmonic(10), harmonic(3/2), harmonic(25/7)
harmonic(x + sqrt(2)), harmonic(infinity)
Floating point values are computed for floating-point arguments:
harmonic(-5.2), harmonic(27.0), harmonic(2.0 + 3.0*I)
harmonic is singular for negative integers:
Error: Singularity. [harmonic]
For larger arguments, the expand attribute can be used to obtain such expressions:
5337003...5042517 / 7128865...3520000
diff(harmonic(x^2 + 1), x), float(ln(3 + harmonic(sqrt(PI))))
expand(harmonic(2*x + 3))
limit((x + 1)*harmonic(x), x = -1), limit(harmonic(x), x = infinity)
series(harmonic(x), x = 0)
series(harmonic(x), x = infinity, 3)