Function Repository Resource:

NumberExpansion

Source Notebook

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]:=
ResourceFunction["NumberExpansion"][Pi, 10, "Engel"]
Out[1]=

Scope (8) 

Expand a rational number:

In[2]:=
ResourceFunction["NumberExpansion"][11/18, "Lueroth"]
Out[2]=

Compute the original value using the definition of the expansion:

In[3]:=
1/2 + 1/(2*1*5) + 1/(2*1*5*4*3) + 1/(2*1*5*4*3*2*2) + 1/(2*1*5*4*3*2*2*1*3)
Out[3]=

Engel expansion of the number 1.175:

In[4]:=
ResourceFunction["NumberExpansion"][1.175, "Engel"]
Out[4]=

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

In[5]:=
ResourceFunction["NumberExpansion"][1/Sqrt[2], 5, "Pierce"]
Out[5]=

Sylvester expansion of the rational number 3/19:

In[6]:=
ResourceFunction["NumberExpansion"][3/19, "Sylvester"]
Out[6]=

Cantor expansion of the number 384:

In[7]:=
ResourceFunction["NumberExpansion"][384, "Cantor"]
Out[7]=

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

In[8]:=
ResourceFunction["NumberExpansion"][Pi, 5, "CantorProduct"]
Out[8]=

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

In[9]:=
ResourceFunction["NumberExpansion"][5/13, "Lueroth"]
Out[9]=

Lüroth expansion of the golden ration reciprocal:

In[10]:=
ResourceFunction["NumberExpansion"][1/GoldenRatio, 10, "Lueroth"]
Out[10]=

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

In[11]:=
ResourceFunction["NumberExpansion"][1/Pi, 10, 1, 0, 0, 1, "Oppenheim"]
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]:=
ResourceFunction["NumberExpansion"][7/27, "Lueroth"]
Out[12]=
In[13]:=
ResourceFunction["NumberExpansion"][13/81, "Lueroth"]
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 1/GoldenRatio have square terms:

In[14]:=
ResourceFunction["NumberExpansion"][1/Pi, 5, "Sylvester"]
Out[14]=
In[15]:=
ResourceFunction["NumberExpansion"][1/GoldenRatio, 5, "Sylvester"]
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]:=
ResourceFunction["NumberExpansion"][GoldenRatio, 5, "Sylvester"]
Out[16]=

Properties and Relations (1) 

The resource function FromNumberExpansion is effectively the inverse of NumberExpansion:

In[17]:=
ResourceFunction["NumberExpansion"][Pi, 10, "Engel"]
Out[17]=
In[18]:=
ResourceFunction["FromNumberExpansion"][%, "Engel"]
Out[19]=
In[20]:=
N[%]
Out[20]=

Possible Issues (5) 

Expanding an irrational number requires specifying a finite length:

In[21]:=
ResourceFunction["NumberExpansion"][Sqrt[2], "CantorProduct"]
Out[21]=
In[22]:=
ResourceFunction["NumberExpansion"][Sqrt[2], 5, "CantorProduct"]
Out[22]=

In[23]:=
ResourceFunction["NumberExpansion"][Pi, "Engel"]
Out[23]=

In[24]:=
ResourceFunction["NumberExpansion"][Sqrt[2], 20, "Pierce"]
Out[24]=

In[25]:=
ResourceFunction["NumberExpansion"][Sqrt[2], 20, "Lueroth"]
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]:=
ResourceFunction["NumberExpansion"][Pi, 400, "Engel"]
Out[26]=

Publisher

Wolfram Summer School

Version History

  • 1.0.0 – 14 September 2020

Related Resources

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.

License Information