Wolfram Research

Function Repository Resource:

SequenceToSum (2.1.0) current version: 3.0.0 »

Source Notebook

Turn a sequence of expressions into a symbolic sum

Contributed by: Wolfram|Alpha Math Team

ResourceFunction["SequenceToSum"][{e1,e2,},n]

attempts to return an inactive sum representing e1+e2+ where the user-supplied variable n is used in forming the generic term.

Details

If successful, ResourceFunction["SequenceToSum"] returns an expression with head Inactive[Sum]. Using Activate on this output will attempt to evaluate the sum.
ResourceFunction["SequenceToSum"] gives special treatment to the global symbol …, representing a sequence of ellided expressions. The ellipsis symbol … can be input with the keyboard shortcut .

Examples

Basic Examples (10) 

Convert a simple finite sequence to a sum:

In[1]:=
ResourceFunction["SequenceToSum"][{1, 2, 3, 4}, n]
Out[1]=

Convert an elided sequence to a sum:

In[2]:=
ResourceFunction["SequenceToSum"][{1, 2, 3, \[Ellipsis], 10}, n]
Out[2]=

Evaluate with Activate:

In[3]:=
% // Activate
Out[3]=

Convert an infinite sequence to a sum:

In[4]:=
ResourceFunction["SequenceToSum"][{1, 1/2, 1/3, \[Ellipsis]}, n]
Out[4]=

Convert an geometric sequence to a sum:

In[5]:=
ResourceFunction["SequenceToSum"][{1, 1/2, 1/4, \[Ellipsis]}, n]
Out[5]=

Convert another geometric sequence to a sum and evaluate:

In[6]:=
ResourceFunction["SequenceToSum"][{1/3, 1/6, 1/12, \[Ellipsis]}, n]
Out[6]=
In[7]:=
% // Activate
Out[7]=

Convert an arithmetic sequence to a sum:

In[8]:=
ResourceFunction["SequenceToSum"][{5, 12, 19, 26, \[Ellipsis]}, n]
Out[8]=

Convert another arithmetic sequence to a sum and evaluate:

In[9]:=
ResourceFunction["SequenceToSum"][{5, 10, 15, \[Ellipsis], 100}, n]
Out[9]=
In[10]:=
% // Activate
Out[10]=

Convert an alternating sequence to a sum and evaluate:

In[11]:=
ResourceFunction["SequenceToSum", ResourceVersion->"2.1.0"][{1/2, -(1/4), 1/8, -(1/16), 1/32, \[Ellipsis], -(1/1024)}, n]
Out[11]=
In[12]:=
% // Activate
Out[12]=

Convert a rational sequence to a sum:

In[13]:=
ResourceFunction["SequenceToSum", ResourceVersion->"2.1.0"][{2, 5/2, 10/3, 17/4, 26/5, 37/6, 50/7, \[Ellipsis]},
  n]
Out[13]=

Convert a hypergeometric sequence to a sum:

In[14]:=
ResourceFunction["SequenceToSum"][{1, 2, 6, 24, 120, 720, 5040}, n]
Out[14]=
In[15]:=
ResourceFunction["SequenceToSum", ResourceVersion->"2.1.0"][{1, 6, 54, 648, 9720, 174960, \[Ellipsis]}, n]
Out[15]=

Scope (1) 

The ellipsis symbol (…) can appear anywhere within the input sequence:

In[16]:=
ResourceFunction["SequenceToSum"][{\[Ellipsis], 1/12, 1/6, 1/3}, n]
Out[16]=
In[17]:=
ResourceFunction["SequenceToSum", ResourceVersion->"2.1.0"][{\[Ellipsis], 3, 6, 9, \[Ellipsis]}, n]
Out[17]=

Properties and Relations (3) 

If successful, SequenceToSum returns an expression with head Inactive[Sum]:

In[18]:=
res = ResourceFunction["SequenceToSum"][{1, 1/2, 1/4, \[Ellipsis]}, n]
Out[18]=
In[19]:=
Head[res]
Out[19]=

If unable to infer the elided part of a sequence, SequenceToSum will return unevaluated:

In[20]:=
ResourceFunction["SequenceToSum", ResourceVersion->"2.1.0"][2, 3, 5, 7, 11, 13, 17, \[Ellipsis], 29]
Out[20]=

SequenceToProduct uses FindSequenceFunction to recognize patterns in the input sequence:

In[21]:=
seq1 = {1, 1, 2, 3, 5, 8, 13};
FindSequenceFunction[seq1, n]
Out[17]=
In[22]:=
ResourceFunction["SequenceToSum"][seq1, n]
Out[22]=
In[23]:=
seq2 = {2, 3, 5, 7, 11};
FindSequenceFunction[seq2, n]
Out[24]=
In[25]:=
ResourceFunction["SequenceToSum"][seq2, n]
Out[25]=

Publisher

Wolfram|Alpha Math Team

Version History

  • 3.0.0 – 23 March 2023
  • 2.1.0 – 20 May 2021
  • 2.0.0 – 24 January 2020
  • 1.0.0 – 16 October 2019

Related Resources

License Information