1
1
# Polynomials.jl
2
2
3
- Basic arithmetic, integration, differentiation, evaluation, and root finding over dense univariate polynomials.
3
+ Basic arithmetic, integration, differentiation, evaluation, and root finding over dense univariate [ polynomials] ( https://en.wikipedia.org/wiki/Polynomial ) .
4
4
5
5
[ ![ ] ( https://img.shields.io/badge/docs-stable-blue.svg )] ( https://JuliaMath.github.io/Polynomials.jl/stable )
6
6
[ ![ Build Status] ( https://travis-ci.org/JuliaMath/Polynomials.jl.svg?branch=master )] ( https://travis-ci.org/JuliaMath/Polynomials.jl )
@@ -10,31 +10,33 @@ Basic arithmetic, integration, differentiation, evaluation, and root finding ove
10
10
## Installation
11
11
12
12
``` julia
13
- (v1.4 ) pkg> add Polynomials
14
-
15
- julia> using Polynomials
13
+ (v1.5 ) pkg> add Polynomials
16
14
```
17
15
18
- ## Usage
16
+ ## Available Types of Polynomials
17
+
18
+ * ` Polynomial ` – standard basis polynomials, ` a(x) = a₀ + a₁ x + a₂ x² + … + aₙ xⁿ ` , ` n ∈ ℕ `
19
+ * ` ImmutablePolynomial ` – standard basis polynomials backed by a [ Tuple type] ( https://docs.julialang.org/en/v1/manual/functions/#Tuples-1 ) for faster evaluation of values
20
+ * ` SparsePolynomial ` – standard basis polynomial backed by a [ dictionary] ( https://docs.julialang.org/en/v1/base/collections/#Dictionaries-1 ) to hold sparse high-degree polynomials
21
+ * ` 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ⁿ `
22
+ * ` ChebyshevT ` – [ Chebyshev polynomials] ( https://en.wikipedia.org/wiki/Chebyshev_polynomials ) of the first kind
19
23
20
- #### Available Polynomials
24
+ ## Usage
21
25
22
- * `Polynomial` - Standard basis polynomials, `a_0 + a_1⋅x + a_2⋅x^2 + ⋯ + a_n⋅xⁿ`, `n ∈ ℕ`
23
- * ` ImmutablePolynomial ` - Standard basis polynomials backed by a tuple for faster evaluation of values
24
- * ` SparsePolynomial ` - Standard basis polynomial backed by a dictionary to hold sparse high-degree polynomials
25
- * ` LaurentPolynomial ` - Laurent polynomials, ` a_m⋅x^m + ⋯ a_n⋅x^n ` ` m ≤ n ` , ` m,n ∈ ℤ ` backed by an offset array
26
- * ` ChebyshevT ` - Chebyshev polynomials of the first kind
26
+ ``` julia
27
+ julia> using Polynomials
28
+ ```
27
29
28
- #### Construction and Evaluation
30
+ ### Construction and Evaluation
29
31
30
- Construct a polynomial from its coefficients, lowest order first.
32
+ Construct a polynomial from an array (a vector) of its coefficients, lowest order first.
31
33
32
34
``` julia
33
35
julia> Polynomial ([1 ,0 ,3 ,4 ])
34
36
Polynomial (1 + 3 x^ 2 + 4 x^ 3 )
35
37
```
36
38
37
- An optional variable parameter can be added .
39
+ Optionally, the variable of the polynomial can be specified .
38
40
39
41
``` julia
40
42
julia> Polynomial ([1 ,2 ,3 ], :s )
@@ -56,7 +58,7 @@ julia> p(0.1)
56
58
0.99
57
59
```
58
60
59
- #### Arithmetic
61
+ ### Arithmetic
60
62
61
63
The usual arithmetic operators are overloaded to work on polynomials, and combinations of polynomials and scalars.
62
64
@@ -86,7 +88,7 @@ julia> q ÷ p # `div`, also `rem` and `divrem`
86
88
Polynomial (0.25 - 0.5 x)
87
89
```
88
90
89
- Note that operations involving polynomials with different variables will error.
91
+ Operations involving polynomials with different variables will error.
90
92
91
93
``` julia
92
94
julia> p = Polynomial ([1 , 2 , 3 ], :x )
@@ -95,11 +97,11 @@ julia> p + q
95
97
ERROR: Polynomials must have same variable.
96
98
```
97
99
98
- #### Integrals and Derivatives
100
+ ### Integrals and Derivatives
99
101
100
- Integrate the polynomial ` p ` term by term, optionally adding constant
102
+ Integrate the polynomial ` p ` term by term, optionally adding a constant
101
103
term ` k ` . The degree of the resulting polynomial is one higher than the
102
- degree of ` p ` .
104
+ degree of ` p ` (for a nonzero polynomial) .
103
105
104
106
``` julia
105
107
julia> integrate (Polynomial ([1 , 0 , - 1 ]))
@@ -117,12 +119,11 @@ julia> derivative(Polynomial([1, 3, -1]))
117
119
Polynomial (3 - 2 x)
118
120
```
119
121
120
- #### Root-finding
122
+ ### Root-finding
121
123
122
124
123
125
Return the roots (zeros) of ` p ` , with multiplicity. The number of
124
- roots returned is equal to the degree of ` p ` . By design, this is not type-stable,
125
- the returned roots may be real or complex.
126
+ roots returned is equal to the degree of ` p ` . By design, this is not type-stable, the returned roots may be real or complex.
126
127
127
128
``` julia
128
129
julia> roots (Polynomial ([1 , 0 , - 1 ]))
@@ -141,7 +142,7 @@ julia> roots(Polynomial([0, 0, 1]))
141
142
0.0
142
143
```
143
144
144
- #### Fitting arbitrary data
145
+ ### Fitting arbitrary data
145
146
146
147
Fit a polynomial (of degree ` deg ` or less) to ` x ` and ` y ` using a least-squares approximation.
147
148
@@ -159,7 +160,7 @@ Visual example:
159
160
160
161
![ fit example] ( https://user-images.githubusercontent.com/14099459/70382587-9e055500-1902-11ea-8952-3f03ae08b7dc.png )
161
162
162
- #### Other methods
163
+ ### Other methods
163
164
164
165
Polynomial objects also have other methods:
165
166
0 commit comments