Function Repository Resource:

NumberExpansion

Express a number as an expansion using any of several methods

Contributed by: Swastik Banerjee
 ResourceFunction["NumberExpansion"][x,n,t] generates a list of the first n terms in the series representation of x for the chosen expansion type t. ResourceFunction["NumberExpansion"][x,t] generates a list of all the terms that can be obtained using arbitrary-precision arithmetic.

Details and Options

"Lüroth" can also be written as "Lueroth" when passed as an argument.
The Engel expansion representation {a1,a2,a3,} corresponds to the expression 1/a1+1/a1a2+1/a1a2a3+.
The Pierce expansion (alternating Engel expansion) representation {a1,a2,a3,} corresponds to the expression 1/a1-1/a1a2+1/a1a2a3-.
The Sylvester expansion representation {a1,a2,a3,} corresponds to the expression 1/a1+1/a2+1/a3+.
The Cantor expansion representation {a1,a2,a3,} corresponds to the expression a1*1!+a2*2!+a3*3!+.
The Cantor product expansion representation {a1,a2,a3,} corresponds to the expression (1+1/a1)(1+1/a2)(1+1/a3).
The Lüroth expansion representation {a1,a2,a3,} corresponds to the expression 1/a1 + 1/a1(a1-1)a2 + 1/a1(a1-1)a2(a2-1)a3+.
The Oppenheim expansion representation {d1,d2,d3,} corresponds to the expression 1/d1+(a1/b1)(1/d2)+(a1a2/b1b2)(1/d2)+f.
The Oppenheim expansion requires explicit specification of the constants a and b as defined in the original paper by A. Oppenheim. ResourceFunction["NumberExpansion"][x, n, r, s, p, q, "Oppenheim"] generates a list of the first n terms in the Oppenheim series representation of x where ai=r+s*di and bi=p+q*di , i=1,2,.,n.
The x can be either an exact or an inexact number.
For exact numbers, ResourceFunction["NumberExpansion"][x, t ] can be used if x is rational.
Since irrational numbers always yield an infinite sequence, the number of terms has to be specified explicitly.
Since the series expansion representation for a rational number has only a limited number of terms, ResourceFunction["NumberExpansion"][x, n, t] may yield a list with fewer than n elements in this case.
Lüroth expansion always gives a terminating sequence, or an infinite periodic sequence for rational numbers. The latter is represented as {p,{a1,a2,a3,,ap}}, where p is the periodicity.
Resource function FromNumberExpansion reconstructs a number from the result of ResourceFunction["NumberExpansion"].

Examples

Basic Examples (1)

10 terms in the Engel expansion of π:

 In[1]:=
 Out[1]=

Scope (8)

Expand a rational number:

 In[2]:=
 Out[2]=

Compute the original value using the definition of the expansion:

 In[3]:=
 Out[3]=

Engel expansion of the number 1.175:

 In[4]:=
 Out[4]=

First 5 terms of the Pierce expansion of the number 1/√2:

 In[5]:=
 Out[5]=

Sylvester expansion of the rational number 3/19:

 In[6]:=
 Out[6]=

Cantor expansion of the number 384:

 In[7]:=
 Out[7]=

First 5 terms of the Cantor product expansion of the irrational number π:

 In[8]:=
 Out[8]=

Lüroth expansion of the rational number 5/13. It returns an infinite expansion series with periodicity 3:

 In[9]:=
 Out[9]=

Lüroth expansion of the golden ration reciprocal:

 In[10]:=
 Out[10]=

Oppenheim expansion of 1/π. See Details and Options for the extra parameters in the Oppenheim expansion:

 In[11]:=
 Out[11]=

Applications (2)

Fractions of the form a/3k are conjectured to always have a finite Lüroth expansion. This can be investigated with the following:

 In[12]:=
 Out[12]=
 In[13]:=
 Out[13]=

Whether all terms of the Sylvester series (Sylvester expansion of the number 1) are square-free is an open problem. All known terms till now are square-free. This urges us to further investigate which terms might have all square-free terms. The Sylvester expansions for 1/Pi and have square terms:

 In[14]:=
 Out[14]=
 In[15]:=
 Out[15]=

From this, it might seem numbers greater than or equal to 1 might have all square-free terms. But the Sylvester expansion of ϕ seems to have a square term:

 In[16]:=
 Out[16]=

Properties and Relations (1)

The resource function FromNumberExpansion is effectively the inverse of NumberExpansion:

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

Possible Issues (5)

Expanding an irrational number requires specifying a finite length:

 In[21]:=
 Out[21]=
 In[22]:=
 Out[22]=

 In[23]:=
 Out[23]=

 In[24]:=
 Out[24]=

 In[25]:=
 Out[25]=

Since the function uses arbitrary-precision arithmetic, computing a large number of terms might be very slow depending on the user's hardware, or might run past the limit imposed by \$MaxExtraPrecision:

 In[26]:=
 Out[26]=

Publisher

Wolfram Summer School

Version History

• 1.0.0 – 14 September 2020

Author Notes

Only 2 or 3 test cases seem to give inconsistent results for Cantor product expansion, like 1/Pi, 1/GoldenRatio and 1/Sech. Otherwise, all other test cases seem to give consistent results after rigorous testing on varied test cases.