Accelerating the pace of engineering and science

# harmonic

Harmonic function

### Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

## Syntax

```harmonic(x)
```

## Description

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.

The expand attribute uses the functional equation , the reflection rule and the Gauß multiplication formula for harmonic(kx) with some integer k to rewrite harmonic(x). See Example 3 and Example 4.

## Environment Interactions

When called with a floating-point value x, the function is sensitive to the environment variable DIGITS which determines the numerical working precision.

## Examples

### Example 1

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)`

### Example 2

harmonic is singular for negative integers:

`harmonic(-2)`
```Error: Singularity. [harmonic]
```

### Example 3

For positive integers and rational numbers x with denominators 2, 3, 4 and 6, respectively, the result is expressed in terms of PI and ln, if |x| < 500:

`harmonic(-5/2)`

`harmonic(13/3)`

`harmonic(101/6)`

For larger arguments, the expand attribute can be used to obtain such expressions:

`harmonic(1001)`

`expand(%)`
```
5337003...5042517 / 7128865...3520000  ```

### Example 4

The functions diff, expand, float, limit, and series handle expressions involving harmonic:

`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)`

 x

## Return Values

Arithmetical expression.