Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect dot product fallback #397

Closed
juliohm opened this issue Feb 18, 2022 · 7 comments
Closed

Incorrect dot product fallback #397

juliohm opened this issue Feb 18, 2022 · 7 comments

Comments

@juliohm
Copy link

juliohm commented Feb 18, 2022

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
@jverzani
Copy link
Member

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.

@juliohm
Copy link
Author

juliohm commented Feb 18, 2022

So you are not implementing the dot product as the integral \int_{-\infty}^{\infty} f(t) * conj(g(t)) dt?

@jverzani
Copy link
Member

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.

@juliohm
Copy link
Author

juliohm commented Apr 2, 2024

This should probably get the bug label.

@jverzani
Copy link
Member

jverzani commented Apr 2, 2024

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?

@juliohm
Copy link
Author

juliohm commented Apr 2, 2024 via email

@jverzani
Copy link
Member

jverzani commented Apr 6, 2024

closed by #563

@jverzani jverzani closed this as completed Apr 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants