-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathpolynomial.d.ts
162 lines (134 loc) · 3.54 KB
/
polynomial.d.ts
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
declare module 'Polynomial';
export class Polynomial {
coeff: Record<string, any>;
constructor(x: string | object);
/**
* Calculates the gcd of two polynomials
* @param x The denominator polynomial
* @returns Polynomial
*/
gcd(x: string | object): Polynomial;
/**
* Negate all coefficients of the polynomial
* @returns Polynomial
*/
neg(): Polynomial;
/**
* Return the reciprocal polynomial, where the coefficients appear in opposite order
* @returns Polynomial
*/
reciprocal(): Polynomial;
/**
* Numerically evaluate the polynomial at a specific point x using Horner's method
* @param x The point where to evaluate this polynomial
* @returns number The value P(x)
*/
eval(x: number): number;
/**
* Gets the leading coefficient
* @returns Polynomial
*/
lc(): Polynomial;
/**
* Gets the leading monomial
* @returns Polynomial
*/
lm(): Polynomial;
/**
* Divide all coefficients by lc(f)
* @returns Polynomial
*/
monic(): Polynomial;
/**
* Calculates the sum of two polynomials
* @param x The summand polynomial
* @returns Polynomial
*/
add(x: string | object): Polynomial;
/**
* Calculates the difference of two polynomials
* @param x The subtrahend polynomial
* @returns Polynomial
*/
sub(x: string | object): Polynomial;
/**
* Calculates the product of two polynomials
* @param x The minuend polynomial
* @returns Polynomial
*/
mul(x: string | object): Polynomial;
/**
* Calculates the product of the two parameters and adds it to the current number (linear combination)
* @param x The first factor polynomial
* @param y The second factor polynomial
* @returns Polynomial
*/
addmul(x: string | object, y: string | object): Polynomial;
/**
* Calculates the quotient of two polynomials
* @param x The denominator polynomial
* @returns Polynomial
*/
div(x: string | object): Polynomial;
/**
* Calculates the power of a polynomial to the exponent e
* @param e The exponent
* @returns Polynomial
*/
pow(e: number): Polynomial;
/**
* Calculates the modulo of a polynomial to another
* @param x The second polynomial
* @returns Polynomial
*/
mod(x: string | object): Polynomial;
/**
* Calculates the nth derivative of the polynomial
* @param n The nth derivative
* @returns Polynomial
*/
derive(n: number): Polynomial;
/**
* Calculates the nth integral of the polynomial
* @param n The nth integral
* @returns Polynomial
*/
integrate(n: number): Polynomial;
/**
* Formats the polynomial as a string
* @returns string The polynomial string
*/
toString(): string;
/**
* Formats the polynomial as a LaTeX representation
* @returns string The polynomial LaTeX string
*/
toLatex(): string;
/**
* Returns the actual polynomial in Horner scheme
* @returns string
*/
toHorner(): string;
/**
* Clones the polynomial object
* @returns Polynomial
*/
clone(): Polynomial;
/**
* Returns the degree of the polynomial
* @returns number
*/
degree(): number;
/**
* Set the field globally
* @param field One of: C (complex), H (quaternion), Q (rational), R (real), or an object with methods for the field
*/
static setField(field: string | object): void;
/**
* Form a (monic) polynomial out of an array of roots
* @param roots Array of roots
* @returns Polynomial The monic polynomial with those roots
*/
static fromRoots(roots: number[]): Polynomial;
}
export default Polynomial;