Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Evaluate an alternating sum using the Cohen-Rodriguez Villegas-Zagier method
ResourceFunction["CRVZSum"][f,{i,imin,∞}] numerically evaluates the sum |
| "ExtraTerms" | 15 | number of terms to use in the CRVZ method |
| "Terms” | 15 | number of terms to sum directly |
| WorkingPrecision | MachinePrecision | the precision used in internal computations |
Evaluate the alternating harmonic series:
| In[1]:= |
| Out[1]= |
Compare with the closed form:
| In[2]:= |
| Out[2]= |
Use 25 terms for the CRVZ extrapolation:
| 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]= |
Directly sum the first 25 terms before applying CRVZ extrapolation:
| In[7]:= |
| Out[7]= |
Compare with the exact result:
| In[8]:= |
| Out[8]= |
Use CRVZSum to evaluate the Dirichlet eta function:
| In[11]:= |
Compare with the built-in DirichletEta:
| In[12]:= |
| Out[12]= | ![]() |
Plot the relative error:
| In[13]:= |
| Out[13]= | ![]() |
Use CRVZSum with NIntegrate to numerically evaluate an oscillatory integral:
| In[14]:= |
| Out[14]= |
Compare with the exact result:
| In[15]:= |
| Out[15]= |
Directly summing the first few terms of an alternating series usually does not give sufficient accuracy:
| In[16]:= |
| Out[16]= |
| In[17]:= |
| Out[17]= |
Using the CRVZ method on an alternating series often gives better results:
| In[18]:= |
| Out[18]= |
| In[19]:= |
| Out[19]= |
CRVZSum usually gives poor results for non-alternating series:
| In[20]:= |
| Out[20]= |
CRVZSum may give results for formally divergent series:
| In[21]:= |
| Out[21]= |
Compare with the Borel sum:
| In[22]:= |
| Out[22]= |
This work is licensed under a Creative Commons Attribution 4.0 International License