number-expansion-spec

Number expansions

The sub number-expansion can express a number as an expansion using any of several methods.

Documentation

Usage

  • number-expansion(x, n, t)

    • generates a list of the first n terms in the series representation of x **for the chosen expansion type t.

  • number-expansion(x, n, t)

    • generates a list of all the terms that can be obtained using arbitrary-precision arithmetic.

Details & Options

  • "Lüroth" can also be written as "Lueroth" when passed as an argument.

  • The Engel expansion representation corresponds to the expression

  • The Pierce expansion (alternating Engel expansion) representation corresponds to the expression

  • The Sylvester expansion representation corresponds to the expression .

  • The Cantor expansion representation corresponds to the expression .

  • The Cantor product expansion representation corresponds to the expression ;

  • The Lüroth expansion representation corresponds to the expression .

  • The Oppenheim expansion representation corresponds to the expression .

  • The Oppenheim expansion requires explicit specification of the constants a and b as defined in the original paper by A. Oppenheim. number-expansion(x, n, r, s, p, q, "Oppenheim") generates a list of the first terms in the Oppenheim series representation of where and .

  • The Zeckendorf representation gives the list that indicates the unique nonconsecutive Fibonacci numbers that sum to the non-negative integer .

  • The x can be either an exact or an inexact number.

  • For exact numbers, number-expansion(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, number-expansion(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 , where is the periodicity.

  • The function from-number-expansion reconstructs a number from the result of number-expansion.

Examples

Basic Examples

10 terms in the Engel expansion of π:

number-expansion(Pi, 10, "Engel")
[1, 1, 1, 8, 8, 17, 19, 300, 1991, 2492]

Scope

Expand a rational number:

number-expansion(11/18, "Lueroth")
[2, 5, 3, 2, 3]

Compute the original value using the definition of the expansion:

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)
11/18

Engel expansion of the number :

number-expansion(1.175, "Engel")
[1, 6, 20]

First 5 terms of the Pierce expansion of the number :

number-expansion(1/sqrt(2), 5, "Pierce")
[1, 3, 8, 33, 35]

Sylvester expansion of the rational number :

number-expansion(3/19, "Sylvester")
[7, 67]

Cantor expansion of the number :

number-expansion(384, "Cantor")
[0, 0, 0, 1, 3]

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

number-expansion(pi, 5, "CantorProduct")
[1, 2, 22, 600, 1800856, 15150670259531]

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

number-expansion(5/13, "Lueroth")
[3, [3, 4, 2]]

Lüroth expansion of the golden ration reciprocal:

number-expansion(1/golden-ratio, 10, "Lueroth")
[2, 5, 2, 3, 2, 4, 2, 2, 162, 2]

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

number-expansion(1/pi, 10, 1, 0, 0, 1, "Oppenheim")
[4, 4, 11, 45, 70, 1111, 4423, 5478, 49340, 94388, 200677]

Applications

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

number-expansion(7/27, "Lueroth")
(4, 9)
number-expansion(13/81, "Lueroth")
(7, 2, 3, 2, 2, 2, 9)

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:

number-expansion(1/pi, 5, "Sylvester")
(4, 15, 609, 845029, 1010073215739)
number-expansion(1/golden-ratio, 5, "Sylvester")
(2, 9, 145, 37986, 2345721887)

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:

number-expansion[GoldenRatio, 5, "Sylvester"]
(1, 2, 9, 145, 37986)

Properties and Relations

The resource function Fromnumber-expansion is effectively the inverse of number-expansion:

number-expansion(pi, 10, "Engel")
(1, 1, 1, 8, 8, 17, 19, 300, 1991, 2492)
from-number-expansion(_, "Engel")
3.14159

Possible Issues

Expanding an irrational number requires specifying a finite length:

number-expansion(sqrt(2), "CantorProduct")
# error
number-expansion(sqrt(2), 5, "CantorProduct")
(3, 17, 577, 665857, 886731088897, 1572584048032918633353217)
number-expansion(pi, "Engel")
# error

Since the function uses arbitrary-precision arithmetic, computing a large number of terms might be very slow depending on the user's hardware.

Source & Additional Information

Keywords

  • Series expansion

  • Real numbers

  • Generalized Number Expansion

  • Engel Expansion

  • Pierce Expansion

  • Alternating Engel Expansion

  • Sylvester Expansion

  • Cantor Expansion

  • Cantor Product

  • Luroth expansion

  • Openheim expansion

Links

Math::NumberTheory v0.1.2

Raku package for number theory functions.

Authors

  • Anton Antonov

License

Artistic-2.0

Dependencies

Test Dependencies

Provides

  • Math::NumberTheory
  • Math::NumberTheory::Constants
  • Math::NumberTheory::ContinuedFraction
  • Math::NumberTheory::Expansions
  • Math::NumberTheory::Fibonacci
  • Math::NumberTheory::Utilities

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.