Incorrect dot product fallback
The fallback is producing results that are not mathematically correct:
julia> using Polynomials
julia> using LinearAlgebra
julia> p = Polynomial([0,1])
julia> p ⋅ p
1
At one time, we had p ⋅ p mean multiplication, now it falls back to LinearAlgebra.dot for arbitrary iterables. It should be that for vector v P(v) ⋅ P(v) == v ⋅ v.
So you are not implementing the dot product as the integral \int_{-\infty}^{\infty} f(t) * conj(g(t)) dt?
No, right now we don't have it implemented for the AbstractPolynomial type, so it fallsback to the generic for iterables. In SpecialPolynomials, for orthogonal polynomials, we have something defined like that internally which should be exposed through dot. I'll definitely add that in.
This should probably get the bug label.
Is it a bug? Or does it need a special method. Right now the fall back is to the dot method for two iterables which will error for polynomials of different degree. For orthogonal polynomials, we could use the integral over [-1,1], but in general the integral over (-oo, oo) will always yield an infinite answer, so that isn't the best.
So would having
Polynomials.dot(p::AbstractPolynomial, q::AbstractPolynomial) = throw(ArgumentError("..."))
and
SpecialPolynomials.dot(p::AbstractOrthogonalPolynomial, q::AbstractOrthogonalPolynomial) = integrate(p * conj(q), domain(p)...)
suffice?
The result is incorrect or throws an error. Clearly a bug.
Em ter., 2 de abr. de 2024, 12:27, john verzani @.***> escreveu:
Is it a bug? Or does it need a special method. Right now the fall back is to the dot method for two iterables which will error for polynomials of different degree. For orthogonal polynomials, we could use the integral over [-1,1], but in general the integral over (-oo, oo) will always yield an infinite answer, so that isn't the best.
So would having
Polynomials.dot(p::AbstractPolynomial, q::AbstractPolynomial) = throw(ArgumentError("..."))
and
SpecialPolynomials.dot(p::AbstractOrthogonalPolynomial, q::AbstractOrthogonalPolynomial) = integrate(p * conj(q), domain(p)...)
suffice?
— Reply to this email directly, view it on GitHub https://github.com/JuliaMath/Polynomials.jl/issues/397#issuecomment-2032363796, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZQW3IBATYDM5KZWWH4QH3Y3LE7PAVCNFSM5OXVHNE2U5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TEMBTGIZTMMZXHE3A . You are receiving this because you authored the thread.Message ID: @.***>
closed by #563