You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*`Polynomial` – standard basis polynomials, $a(x) = a_0 + a_1 x + a_2 x^2 + … + a_n x^n$ for $n ≥ 0$.
21
21
*`ImmutablePolynomial` – standard basis polynomials backed by a [Tuple type](https://docs.julialang.org/en/v1/manual/functions/#Tuples-1) for faster evaluation of values
22
22
*`SparsePolynomial` – standard basis polynomial backed by a [dictionary](https://docs.julialang.org/en/v1/base/collections/#Dictionaries-1) to hold sparse high-degree polynomials
23
-
*`LaurentPolynomial` – [Laurent polynomials](https://docs.julialang.org/en/v1/base/collections/#Dictionaries-1), `a(x) = aₘ xᵐ + … + aₙ xⁿ``m ≤ n`, `m,n ∈ ℤ`backed by an [offset array](https://github.com/JuliaArrays/OffsetArrays.jl); for example, if `m<0` and `n>0`, `a(x) = aₘ xᵐ + … + a₋₁ x⁻¹ + a₀ + a₁ x + … + aₙ xⁿ`
23
+
*`LaurentPolynomial` – [Laurent polynomials](https://docs.julialang.org/en/v1/base/collections/#Dictionaries-1), $a(x) = a_m x^m + … + a_n x^n$ for $m ≤ n$ and $m,n ∈ ℤ$. This is backed by an [offset array](https://github.com/JuliaArrays/OffsetArrays.jl); for example, if $m<0$ and $n>0$, we obtain $a(x) = a_m x^m + … + a_{-1} x^{-1} + a_0 + a_1 x + … + a_n x^n$
24
24
*`FactoredPolynomial` – standard basis polynomials, storing the roots, with multiplicity, and leading coefficient of a polynomial
25
25
*`ChebyshevT` – [Chebyshev polynomials](https://en.wikipedia.org/wiki/Chebyshev_polynomials) of the first kind
26
26
*`RationalFunction` - a type for ratios of polynomials.
27
27
28
28
## Usage
29
29
30
-
```jldoctest
30
+
```julia
31
31
julia>using Polynomials
32
32
```
33
33
34
34
### Construction and Evaluation
35
35
36
36
Construct a polynomial from an array (a vector) of its coefficients, lowest order first.
37
37
38
-
```jldoctest
38
+
```julia
39
39
julia>Polynomial([1,0,3,4])
40
40
Polynomial(1+3*x^2+4*x^3)
41
41
```
42
42
43
43
Optionally, the variable of the polynomial can be specified.
44
44
45
-
```jldoctest
45
+
```julia
46
46
julia>Polynomial([1,2,3], :s)
47
47
Polynomial(1+2*s +3*s^2)
48
48
```
49
49
50
50
Construct a polynomial from its roots.
51
51
52
-
```jldoctest
52
+
```julia
53
53
julia>fromroots([1,2,3]) # (x-1)*(x-2)*(x-3)
54
54
Polynomial(-6+11*x -6*x^2+ x^3)
55
55
```
56
56
57
57
Evaluate the polynomial `p` at `x`.
58
58
59
-
```jldoctest
59
+
```julia
60
60
julia> p =Polynomial([1, 0, -1]);
61
61
julia>p(0.1)
62
62
0.99
@@ -66,7 +66,7 @@ julia> p(0.1)
66
66
67
67
Methods are added to the usual arithmetic operators so that they work on polynomials, and combinations of polynomials and scalars.
68
68
69
-
```jldoctest
69
+
```julia
70
70
julia> p =Polynomial([1,2])
71
71
Polynomial(1+2*x)
72
72
@@ -103,7 +103,7 @@ Polynomial(0.25 - 0.5*x)
103
103
104
104
Most operations involving polynomials with different variables will error.
105
105
106
-
```jldoctest
106
+
```julia
107
107
julia> p =Polynomial([1, 2, 3], :x);
108
108
julia> q =Polynomial([1, 2, 3], :s);
109
109
julia> p + q
@@ -183,7 +183,7 @@ Integrate the polynomial `p` term by term, optionally adding a constant
183
183
term `k`. The degree of the resulting polynomial is one higher than the
184
184
degree of `p` (for a nonzero polynomial).
185
185
186
-
```jldoctest
186
+
```julia
187
187
julia>integrate(Polynomial([1, 0, -1]))
188
188
Polynomial(1.0*x -0.3333333333333333*x^3)
189
189
@@ -195,7 +195,7 @@ Differentiate the polynomial `p` term by term. For non-zero
195
195
polynomials the degree of the resulting polynomial is one lower than
196
196
the degree of `p`.
197
197
198
-
```jldoctest
198
+
```julia
199
199
julia>derivative(Polynomial([1, 3, -1]))
200
200
Polynomial(3-2*x)
201
201
```
@@ -206,7 +206,7 @@ Polynomial(3 - 2*x)
206
206
Return the roots (zeros) of `p`, with multiplicity. The number of
207
207
roots returned is equal to the degree of `p`. By design, this is not type-stable, the returned roots may be real or complex.
0 commit comments