Examples
Construction
This package provides several types to represent polynomials relative to different bases from the standard polynomial basis, 1
,x
,x²
, x³
etc.
For example, the Legendre polynomials are a collection of polynomials on [-1,1]
. The first few may be seen through:
julia> using Polynomials, SpecialPolynomials
julia> p0 = Legendre([1])
Legendre(1⋅P₀(x))
julia> p1 = Legendre([0,1])
Legendre(1⋅P₁(x))
julia> p2 = Legendre([0,0,1])
Legendre(1⋅P₂(x))
julia> p3 = Legendre([0,0,0,1])
Legendre(1⋅P₃(x))
A plot recipe is useful for a graphical view:
n = 6
ψ₁, ψ₂, ψ₃, ψ₄, ψ₅, ψ₆ = basis.(Legendre, 0:n - 1)
kw = (xlabel="r", ylabel="ψₙ(r)")
sps = [
plot( ψ₁, label="ψ₁(r)"; kw...),
plot( ψ₂, label="ψ₂(r)"; kw...),
plot( ψ₃, label="ψ₃(r)"; kw...),
plot( ψ₄, label="ψ₄(r)"; kw...),
plot( ψ₅, label="ψ₅(r)"; kw...),
plot( ψ₆, label="ψ₆(r)"; kw...),
]
plot(sps..., layout=(3, 2))