-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcontinuedfraction.d.mts
More file actions
69 lines (59 loc) · 2.38 KB
/
continuedfraction.d.mts
File metadata and controls
69 lines (59 loc) · 2.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import type Fraction from 'fraction.js';
/**
* A term of a generalized continued fraction.
*/
export interface CFTerm {
/** The aₙ coefficient */
a: number;
/** The bₙ coefficient */
b: number;
}
/**
* Utility class for generating continued-fraction expansions of various constants.
* All methods are static.
*/
declare class ContinuedFraction {
/**
* Infinite generator for the continued‐fraction terms of √N.
* @param N Integer whose square‐root CF expansion is desired (N ≥ 0)
* @yields Next continued‐fraction term of √N
*/
static sqrt(N: number): Generator<number, void, unknown>;
/**
* Generator for continued‐fraction terms of any real number via Fraction.js.
* @param n The real number to convert (as number, string, or bigint)
* @yields Next continued‐fraction term of n
*/
static fromNumber(n: number | string | bigint): Generator<number, void, unknown>;
/**
* Generator for continued‐fraction terms of a rational a/b via Fraction.js.
* @param a Numerator (number, string, bigint, or Fraction)
* @param b Denominator (number, string, or bigint)
* @yields Next continued‐fraction term of a/b
*/
static fromFraction(
a: number | string | bigint | Fraction,
b: number | string | bigint
): Generator<number, void, unknown>;
/** Infinite generator of the golden ratio φ = [1; 1, 1, 1, …]. */
static PHI(): Generator<number, void, unknown>;
/** Infinite generator for the generalized continued‐fraction terms of 4/π. */
static FOUR_OVER_PI(): Generator<CFTerm, void, unknown>;
/** Infinite generator for the generalized continued‐fraction terms of π. */
static PI(): Generator<CFTerm, void, unknown>;
/** Infinite generator of e = [2; 1, 2, 1, 1, 4, 1, …]. */
static E(): Generator<number, void, unknown>;
/**
* Evaluate a (simple or generalized) continued fraction generator.
* @param generator A CF term generator or a function returning one
* @param steps Number of terms to include (default 10)
* @returns Rational approximation as a Fraction
*/
static eval(
generator:
| Generator<number | CFTerm, any, any>
| (() => Generator<number | CFTerm, any, any>),
steps?: number
): Fraction;
}
export { ContinuedFraction as default, ContinuedFraction };