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
* add some references; close issue #311
* close issue #312
* merge in master; better fix for issue #320
* update doctests for v1.6 change to print of Vectors
Copy file name to clipboardExpand all lines: README.md
+7-2Lines changed: 7 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -206,15 +206,20 @@ Polynomial objects also have other methods:
206
206
207
207
*[MultivariatePolynomials.jl](https://github.com/JuliaAlgebra/MultivariatePolynomials.jl) for multivariate polynomials and moments of commutative or non-commutative variables
208
208
209
-
*[PolynomialRings](https://github.com/tkluck/PolynomialRings.jl) A library for arithmetic and algebra with multi-variable polynomials.
209
+
*[PolynomialRings.jl](https://github.com/tkluck/PolynomialRings.jl) A library for arithmetic and algebra with multi-variable polynomials.
210
210
211
211
*[AbstractAlgebra.jl](https://github.com/wbhart/AbstractAlgebra.jl), [Nemo.jl](https://github.com/wbhart/Nemo.jl) for generic polynomial rings, matrix spaces, fraction fields, residue rings, power series, [Hecke.jl](https://github.com/thofma/Hecke.jl) for algebraic number theory.
212
212
213
-
*[CommutativeAlgebra](https://github.com/KlausC/CommutativeRings.jl) the start of a computer algebra system specialized to discrete calculations with support for polynomials.
213
+
*[CommutativeAlgebra.jl](https://github.com/KlausC/CommutativeRings.jl) the start of a computer algebra system specialized to discrete calculations with support for polynomials.
214
214
215
215
*[PolynomialRoots.jl](https://github.com/giordano/PolynomialRoots.jl) for a fast complex polynomial root finder. For larger degree problems, also [FastPolynomialRoots](https://github.com/andreasnoack/FastPolynomialRoots.jl) and [AMRVW](https://github.com/jverzani/AMRVW.jl).
216
216
217
217
218
+
*[SpecialPolynomials.jl](https://github.com/jverzani/SpecialPolynomials.jl) A package providing various polynomial types beyond the standard basis polynomials in `Polynomials.jl`. Includes interpolating polynomials, Bernstein polynomials, and classical orthogonal polynomials.
219
+
220
+
*[ClassicalOrthogonalPolynomials.jl](https://github.com/JuliaApproximation/ClassicalOrthogonalPolynomials.jl) A Julia package for classical orthogonal polynomials and expansions. Includes `chebyshevt`, `chebyshevu`, `legendrep`, `jacobip`, `ultrasphericalc`, `hermiteh`, and `laguerrel`. The same repository includes `FastGaussQuadrature.jl`, `FastTransforms.jl`, and the `ApproxFun` packages.
221
+
222
+
218
223
## Legacy code
219
224
220
225
As of v0.7, the internals of this package were greatly generalized and new types and method names were introduced. For compatability purposes, legacy code can be run after issuing `using Polynomials.PolyCompat`.
julia> collect(pairs(sp)) # unordered dictionary with only non-zero terms
249
-
3-element Array{Pair{Int64,Int64},1}:
249
+
3-element Vector{Pair{Int64,Int64}}:
250
250
0 => 1
251
251
3 => 4
252
252
1 => 2
253
253
254
254
julia> collect(pairs(lp))
255
-
4-element Array{Pair{Int64,Int64},1}:
255
+
4-element Vector{Pair{Int64,Int64}}:
256
256
-1 => 1
257
257
0 => 2
258
258
1 => 0
@@ -267,13 +267,126 @@ julia> p = Polynomial([1,2,0,4], :u)
267
267
Polynomial(1 + 2*u + 4*u^3)
268
268
269
269
julia> collect(Polynomials.monomials(p))
270
-
4-element Array{Any,1}:
270
+
4-element Vector{Any}:
271
271
Polynomial(1)
272
272
Polynomial(2*u)
273
273
Polynomial(0)
274
274
Polynomial(4*u^3)
275
275
```
276
276
277
+
## Relationship between the `T` and `P{T,X}`
278
+
279
+
The addition of a polynomial and a scalar, such as
280
+
281
+
```jldoctest natural_inclusion
282
+
julia> using Polynomials
283
+
284
+
julia> p = Polynomial([1,2,3], :x)
285
+
Polynomial(1 + 2*x + 3*x^2)
286
+
287
+
julia> p + 3
288
+
Polynomial(4 + 2*x + 3*x^2)
289
+
```
290
+
291
+
seems natural, but in `Julia`, as `3` is of type `Int` and `p` of type `Polynomial{Int,:x}` some addition must be defined. The basic idea is that `3` is promoted to the *constant* polynomial `3` with indeterminate `:x` as `3*one(p)` and then addition of `p + 3*one(p)` is performed.
292
+
293
+
This identification of a scalar with a constant polynomial can go both ways. If `q` is a *constant* polynomial of type `Polynomial{Int, :y}` then we should expect that `p+q` would be defined, as `p` plus the constant term of `q`. Indeed this is the case
294
+
295
+
```jldoctest natural_inclusion
296
+
julia> q = Polynomial(3, :y)
297
+
Polynomial(3)
298
+
299
+
julia> p + q
300
+
Polynomial(4 + 2*x + 3*x^2)
301
+
```
302
+
303
+
If `q` is non-constant, such as `variable(Polynomial, :y)`, then there would be an error due to the mismatched symbols. (The mathematical result would need a multivariate polynomial, not a univariate polynomial, as this package provides.)
304
+
305
+
The same conversion is done for polynomial multiplication: constant polynomials are treated as numbers; non-constant polynomials must have their symbols match.
306
+
307
+
There is an oddity though the following two computations look the same, they are technically different:
308
+
309
+
```jldoctest natural_inclusion
310
+
julia> one(Polynomial, :x) + one(Polynomial, :y)
311
+
Polynomial(2.0)
312
+
313
+
julia> one(Polynomial, :y) + one(Polynomial, :x)
314
+
Polynomial(2.0)
315
+
```
316
+
317
+
Both are constant polynomials over `Int`, but the first has the indeterminate `:y`, the second `:x`.
318
+
319
+
This technical difference causes no issues with polynomial addition or multiplication, as there constant polynomials are treated as numbers, but can be an issue when constant polynomials are used as array elements.
320
+
321
+
For arrays, the promotion of numbers to polynomials, allows natural constructions like:
322
+
323
+
```jldoctest natural_inclusion
324
+
julia> p = Polynomial([1,2],:x)
325
+
Polynomial(1 + 2*x)
326
+
327
+
julia> q = Polynomial([1,2],:y) # non-constant polynomials with different indeterminates
328
+
Polynomial(1 + 2*y)
329
+
330
+
julia> [1 p]
331
+
1×2 Matrix{Polynomial{Int64, :x}}:
332
+
Polynomial(1) Polynomial(1 + 2*x)
333
+
334
+
julia> [1 one(q)]
335
+
1×2 Matrix{Polynomial{Int64, :y}}:
336
+
Polynomial(1) Polynomial(1)
337
+
```
338
+
339
+
However, as there would be an ambiguous outcome of the following
340
+
341
+
```jldoctest natural_inclusion
342
+
julia> [one(p) one(q)]
343
+
ERROR: ArgumentError: Polynomials have different indeterminates
344
+
[...]
345
+
```
346
+
347
+
an error thrown.
348
+
349
+
In general, arrays with mixtures of non-constant polynomials with *different* indeterminates will error. By default, an error will occur when constant polynomials with different indeterminates are used as components. However, for *typed* arrays, conversion will allow such constructs to be used.
350
+
351
+
Using `one(q)` for a constant polynomial with indeterminate `:y` we have:
352
+
353
+
```jldoctest natural_inclusion
354
+
julia> P = typeof(p)
355
+
Polynomial{Int64, :x}
356
+
357
+
julia> P[one(p) one(q)]
358
+
1×2 Matrix{Polynomial{Int64, :x}}:
359
+
Polynomial(1) Polynomial(1)
360
+
```
361
+
362
+
Of course, by not being explicit, there are sill gotchas. For example, we can construct this matrix without a specific types:
363
+
364
+
```jldoctest natural_inclusion
365
+
julia> [one(p), one(q)+one(p)]
366
+
2-element Vector{Polynomial{Int64, :x}}:
367
+
Polynomial(1)
368
+
Polynomial(2)
369
+
```
370
+
371
+
but not this one:
372
+
373
+
```jldoctest natural_inclusion
374
+
julia> [one(p), one(p) + one(q)]
375
+
ERROR: ArgumentError: Polynomials have different indeterminates
376
+
[...]
377
+
```
378
+
379
+
Also, mixing types can result in unspecific symbols, as this example shows:
*[MultivariatePolynomials.jl](https://github.com/JuliaAlgebra/MultivariatePolynomials.jl) for multivariate polynomials and moments of commutative or non-commutative variables
287
400
288
-
*[PolynomialRings](https://github.com/tkluck/PolynomialRings.jl) A library for arithmetic and algebra with multi-variable polynomials.
401
+
*[PolynomialRings.jl](https://github.com/tkluck/PolynomialRings.jl) A library for arithmetic and algebra with multi-variable polynomials.
289
402
290
403
*[AbstractAlgebra.jl](https://github.com/wbhart/AbstractAlgebra.jl), [Nemo.jl](https://github.com/wbhart/Nemo.jl) for generic polynomial rings, matrix spaces, fraction fields, residue rings, power series, [Hecke.jl](https://github.com/thofma/Hecke.jl) for algebraic number theory.
291
404
292
-
*[CommutativeAlgebra](https://github.com/KlausC/CommutativeRings.jl) the start of a computer algebra system specialized to discrete calculations with support for polynomials.
405
+
*[CommutativeAlgebra.jl](https://github.com/KlausC/CommutativeRings.jl) the start of a computer algebra system specialized to discrete calculations with support for polynomials.
293
406
294
407
*[PolynomialRoots.jl](https://github.com/giordano/PolynomialRoots.jl) for a fast complex polynomial root finder. For larger degree problems, also [FastPolynomialRoots](https://github.com/andreasnoack/FastPolynomialRoots.jl) and [AMRVW](https://github.com/jverzani/AMRVW.jl).
295
408
409
+
*[SpecialPolynomials.jl](https://github.com/jverzani/SpecialPolynomials.jl) A package providing various polynomial types beyond the standard basis polynomials in `Polynomials.jl`. Includes interpolating polynomials, Bernstein polynomials, and classical orthogonal polynomials.
410
+
411
+
*[ClassicalOrthogonalPolynomials.jl](https://github.com/JuliaApproximation/ClassicalOrthogonalPolynomials.jl) A Julia package for classical orthogonal polynomials and expansions. Includes `chebyshevt`, `chebyshevu`, `legendrep`, `jacobip`, `ultrasphericalc`, `hermiteh`, and `laguerrel`. The same repository includes `FastGaussQuadrature.jl`, `FastTransforms.jl`, and the `ApproxFun` packages.
Copy file name to clipboardExpand all lines: src/polynomials/ChebyshevT.jl
+4-1Lines changed: 4 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -35,6 +35,9 @@ julia> Polynomials.evalpoly(5.0, p, false) # bypasses the domain check done in p
35
35
36
36
The latter shows how to evaluate a `ChebyshevT` polynomial outside of its domain, which is `[-1,1]`. (For newer versions of `Julia`, `evalpoly` is an exported function from Base with methods extended in this package, so the module qualification is unnecessary.
37
37
38
+
!!! Note:
39
+
The Chebyshev polynomials are also implemented in `ApproxFun`, `ClassicalOrthogonalPolynomials.jl`, `FastTransforms.jl`, and `SpecialPolynomials.jl`.
0 commit comments