Polynomials
A set of polynomials can be regarded as the elements of a vector space. As an example we consider the set of all real polynomials of degree $d$,
\[P_α(x) = α_0 + α_1 x + ⋯ + α_d x^d.\]
These are maps $P_α:\mathbb{\mathbb{R\rightarrow\mathbb{R}}}$ that satisfy the group operation 'addition of polynomials' because the sum of two polynomials of degree $d$ is again a polynomial of degree $d$,
\[(P_α + P_β)(x) ≡ (α_0 + β_{0})+(α_1 + β_1)x + ⋯ + (α_d + β_d) x^d = P_α(x) + P_β(x),\]
and remains a polynomial of degree $d$ under 'scalar multiplication',
\[(λ P_α)(x) ≡ P_{\lambdaα}(x)=\lambdaα_0+\lambdaα_1 x + ⋯ + \lambdaα_d x^d = λ P_α(x).\]
The 'zero element' of the vector space is the polynomial $P_α(x)=0$ and the 'inverse element' of the element $P_α(x)$ is the polynomial $-P_α(x)$. Also the 'associative' and 'distributive' properties are easily verified.
Hence, the set of all real polynomials of degree $d$ defines a vector space (of dimension $d + 1$) over the field $\mathbb{R}$ and the polynomials $1,x,x^{2},\cdots x^d$ represent a basis. The coefficients $α_0, ⋯, α_d$, represent the coordinates of the vector $P_α$ with respect to this basis.
In CamiMath
we define a polynomial by specifying the coordinate vector polynom
.
polynom
CamiMath.polynom
— Typepolynom
The set of coordinates defining the vector or tuple representation of a polynomial
.
Example:
julia> polynom = (1, 1, 1, 1, 1)
(1, 1, 1, 1, 1)
polynom power
CamiMath.polynom_power
— Methodpolynom_power(polynom, p)
The polynom
of a polynomial of degree $d$ raised to the power p
, which define a polynomial in a vector space of dimension $p d + 1$.
Examples:
julia> polynom = (1,1,1) # coordinates of polynomial vector of degree d = 2
(1, 1, 1)
julia> polynom = (1,1,1);
julia> polynom_power(polynom, 3)
7-element Vector{Int64}:
1
3
6
7
6
3
1
polynom product
CamiMath.polynom_product
— Methodpolynom_product(polynom1, polynom2)
The coefficients of the product of two polynomials, a = polynom1
and b = polynom2
of degree $m$ and $n$, which represents a polynomial in a vector space of dimension $d=m+n+1$,
\[ P(x)=a_0b_0 + (a_0b_1 + b_0a_1)x + ⋯ + a_n b_m x^{n+m}.\]
Examples:
julia> polynom_product((1, 1), (1, -1, 2))
4-element Vector{Int64}:
1
0
1
2
julia> polynom_product((1, 1), (1, -1.0, 2))
4-element Vector{Real}:
1
0.0
1.0
2
polynom product expansion
CamiMath.polynom_product_expansion
— Methodpolynom_product_expansion(polynom1, polynom2, p::Int)
The coefficients of the product of two polynomials, a = polynom1
(of degree $n$) and b = polynom2
(of degree $m$), truncated at the order p
, which represents a polynomial in a vector space of dimension $d=p+1$
Examples:
julia> a = (1,-1,1);
julia> b = (1,1,-1,1,1,1);
julia> o = polynom_product(a, b); println(o)
[1, 0, -1, 3, -1, 1, 0, 1]
julia> o = polynom_product_expansion(a, b, 4); println(o)
[1, 0, -1, 3, -1]
polynomial
CamiMath.polynomial
— Methodpolynomial(polynom, x::T [; deriv=0]) where T<:Real
Polynomial of degree $d$,
\[ P(x)=c_0 + c_1 x + ⋯ + c_d x^d,\]
where the coefficients polynom
= $(c_0,⋯\ c_d)$ define the vector representation of the polynomial in a vector space of dimension $d+1$.
Examples:
julia> polynom = (1, 1, 1, 1, 1);
julia> P(x) = polynomial(polynom,x);
julia> P(1)
5
julia> polynomial(polynom, 1; deriv=1) # P′(1)
10
julia> polynomial(polynom, 2; deriv=2) # P″(1)
20
julia> polynomial(polynom, 1; deriv=-1) # primitive (zero integration constant)
137 // 60