ConFrac

com.phasmidsoftware.number.core.misc.ConFrac
See theConFrac companion class
object ConFrac

Companion object for ConFrac.

This object defines an apply method which takes a LazyList of Pairs and returns a ConFrac. This object defines a "simple" method which takes a LazyList of Int and returns a ConFrac.

In addition, several ConFrac objects are defined, one each for pi, e, phi, and sqrt(19).

Attributes

Companion
class
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
ConFrac.type

Members list

Value members

Concrete methods

def LongLazyListFrom(n: Int): LazyList[Long]

Utility method to construct a LazyList[Long] of increasing values, starting at m.

Utility method to construct a LazyList[Long] of increasing values, starting at m.

Value parameters

n

the starting value (an Int).

Attributes

Returns

a LazyList[Long] whose first value is n as a Long.

def apply(ps: LazyList[Pair]): ConFrac

Method to construct a General ConFrac from a lazy list of Pair elements.

Method to construct a General ConFrac from a lazy list of Pair elements.

Value parameters

ps

a lazy list of Pairs.

Attributes

Returns

a ConFrac where the a and b coefficients derive from successive Pairs.

def hurwitz(epsilon: Double, markov: Double)(r: Rational): Boolean

Method to measure the Hurwitz factor.

Method to measure the Hurwitz factor.

CONSIDER factoring the markov constant into the epsilon so that we could eliminate one parameter.

Value parameters

epsilon

the allowable error (must be positive).

markov

the Markov constant to be considered.

r

the Rational value to be tested (we only look at the denominator).

Attributes

Returns

true if the error estimate is greater than the epsilon value.

def simple(xs: LazyList[Long]): ConFrac

Method to construct a Simple ConFrac from a lazy list of Int elements.

Method to construct a Simple ConFrac from a lazy list of Int elements.

Value parameters

xs

a lazy list of Ints.

Attributes

Returns

a ConFrac where all the "a" coefficients (the ones on top) are 1.

def unapply(x: Any): Option[(Long, Option[CF])]

Unapply method for ConFrac.

Unapply method for ConFrac.

Value parameters

x

any object.

Attributes

Returns

Some((Long), Option[CF]) is x is a ConFrac, otherwise, None.

Concrete fields

val E: ConFrac

A constant value representing the continued fraction for the mathematical constant e. Defined using the simple construction method of the ConFrac class, which produces a continued fraction with all "a" coefficients set to 1.

A constant value representing the continued fraction for the mathematical constant e. Defined using the simple construction method of the ConFrac class, which produces a continued fraction with all "a" coefficients set to 1.

Attributes

Represents a simplified continued fraction for Pi using the simple method of ConFrac. Constructs a continued fraction where all the "a" coefficients (numerators) are 1, utilizing the predefined lazy list lPi.

Represents a simplified continued fraction for Pi using the simple method of ConFrac. Constructs a continued fraction where all the "a" coefficients (numerators) are 1, utilizing the predefined lazy list lPi.

Attributes

val lPi: LazyList[Long]

Continued Fraction for Pi from the sequence https://oeis.org/A001203. NOTE: there is no repeating sequence.

Continued Fraction for Pi from the sequence https://oeis.org/A001203. NOTE: there is no repeating sequence.

Attributes

val lRoot19: LazyList[Long]

A LazyList representing the continued fraction coefficients for the square root of 19. The sequence is constructed with an initial term of 4 followed by a repeating cycle of [2, 1, 3, 1, 2, 8].

A LazyList representing the continued fraction coefficients for the square root of 19. The sequence is constructed with an initial term of 4 followed by a repeating cycle of [2, 1, 3, 1, 2, 8].

Attributes

val lRoot2: LazyList[Long]

A LazyList representing the continued fraction coefficients for the square root of 2. The first element is 1, followed by a repeated sequence of 2.

A LazyList representing the continued fraction coefficients for the square root of 2. The first element is 1, followed by a repeated sequence of 2.

Attributes

val lRoot3: LazyList[Long]

A LazyList of Long values starting with 1 and followed by a repeating pattern of values 1 and 2.

A LazyList of Long values starting with 1 and followed by a repeating pattern of values 1 and 2.

This structure is formed by prepending the value 1 (1L) to a continuously generated LazyList of alternating values 1 (1L) and 2 (2). The LazyList.continually creates an infinite sequence of a given pattern, and the .flatten ensures the sequence elements are expanded into the resulting LazyList.

The sequence is intended for generating elements of a continued fraction or a related numerical sequence.

Attributes

val phi: ConFrac

Represents the golden ratio (φ) as a continued fraction. This value is constructed using the ConFrac.simple method applied to the predefined lazy list lPhi.

Represents the golden ratio (φ) as a continued fraction. This value is constructed using the ConFrac.simple method applied to the predefined lazy list lPhi.

Attributes

Represents the continued fraction expansion of the square root of 19 as a simple continued fraction. It is constructed using the ConFrac.simple method with a predefined lazy list of coefficients (lRoot19).

Represents the continued fraction expansion of the square root of 19 as a simple continued fraction. It is constructed using the ConFrac.simple method with a predefined lazy list of coefficients (lRoot19).

Attributes

val root2: ConFrac

A constant Continued Fraction representation of the square root of 2.

A constant Continued Fraction representation of the square root of 2.

Constructs a simple Continued Fraction (ConFrac) using a predefined lazy list lRoot2 representing the sequence of coefficients providing the continued fraction expansion for the square root of 2.

Attributes

val root3: ConFrac

A constant ConFrac representing the continued fraction approximation for the square root of 3. Constructed as a simple continued fraction using a lazy list of integers.

A constant ConFrac representing the continued fraction approximation for the square root of 3. Constructed as a simple continued fraction using a lazy list of integers.

Attributes