Function Repository Resource:

# LevinSum

Evaluate an infinite sum using the Levin transformation

Contributed by: Jan Mangaldan
 ResourceFunction["LevinSum"][f,{i,imin,∞}] numerically evaluates the sum using the Levin transformation.

## Details and Options

Levin's transformation is based on the evaluation of the expression , where Sn is the nth partial sum of the series, gn is an auxiliary sequence representing an error estimate of the infinite sum, and is DifferenceDelta[f,{i,n}].
The following options can be given:
 "ExtraTerms" 15 number of terms to use in the Levin transform "Terms" 15 number of terms to sum directly "Type" Automatic the type of Levin transformation to use WorkingPrecision MachinePrecision the precision used in internal computations
"Type" can be set to any one of the following types, corresponding to different Levin transforms:
 "T" t-transformation, gn=Sn-Sn-1 "U" u-transformation, gn=(n+1)(Sn-Sn-1) "V" v-transformation, gn=-(Sn+1-Sn)(Sn-Sn-1)/(Sn+1-2Sn+Sn-1) "D" d-transformation, gn=Sn+1-Sn
The t and d transformations work best with alternating series, while the u and v transformations are more flexible.
You should realize that with sufficiently pathological summands, ResourceFunction["LevinSum"] can give wrong answers. In most cases, you can test the answer by looking at its sensitivity to changes in the setting of options for ResourceFunction["LevinSum"].
ResourceFunction["LevinSum"] has attribute HoldAll, and effectively uses Block to localize variables.

## Examples

### Basic Examples (2)

Evaluate the alternating harmonic series:

 In[1]:=
 Out[1]=

Compare with the closed form:

 In[2]:=
 Out[2]=

### Options (8)

#### ExtraTerms (2)

Use 25 terms for the Levin transformation:

 In[3]:=
 Out[3]=

Compare with the exact result:

 In[4]:=
 Out[4]=

Set "Terms" to 0 so that all terms are used in extrapolation:

 In[5]:=
 Out[5]=

Compare with the exact result:

 In[6]:=
 Out[6]=

#### Terms (2)

Directly sum the first 25 terms before applying the Levin transformation:

 In[7]:=
 Out[7]=

Compare with the exact result:

 In[8]:=
 Out[8]=

#### Type (2)

Show the results of the different Levin transformations on an alternating series:

 In[9]:=
 Out[9]=

Show the results of the different Levin transformations on a non-alternating series:

 In[10]:=
 Out[10]=

#### WorkingPrecision (2)

Use a higher setting of WorkingPrecision:

 In[11]:=
 Out[11]=

Compare with the exact result:

 In[12]:=
 Out[12]=

### Applications (2)

Use the Levin d-transform to evaluate the Dirichlet eta function:

 In[13]:=

Compare with the built-in DirichletEta:

 In[14]:=
 Out[14]=

Plot the relative error:

 In[15]:=
 Out[15]=

Use the Levin v-transform with NIntegrate to numerically evaluate an oscillatory integral:

 In[16]:=
 Out[16]=

Compare with the exact result:

 In[17]:=
 Out[17]=

### Properties and Relations (2)

Directly summing the first few terms of a series usually does not give sufficient accuracy:

 In[18]:=
 Out[18]=
 In[19]:=
 Out[19]=

Using the Levin transform on a series often gives better results:

 In[20]:=
 Out[20]=
 In[21]:=
 Out[21]=

### Possible Issues (2)

LevinSum may give finite results for formally divergent series:

 In[22]:=
 Out[22]=

Compare with the exact result:

 In[23]:=
 Out[23]=

### Neat Examples (2)

Numerically evaluate a formally divergent oscillatory integral:

 In[24]:=
 Out[24]=

 In[25]:=
 Out[25]=
 In[26]:=
 Out[26]=

## Version History

• 1.0.0 – 05 April 2021