-
Notifications
You must be signed in to change notification settings - Fork 113
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
Accuracy of ZeroPoleGain
to PolynomialRatio
conversion
#584
Comments
Note that |
If a better algorithm exists, I'm open to including it in Polynomials.jl. |
At least in this case, the order of the roots as returned by julia> p = Polynomial(remez(151, [0, 0.2, 0.25, 0.5], [1, 0]; weight=[1, 2000]));
julia> fromroots(roots(p)) * p[end] ≈ p
false
julia> fromroots(shuffle(roots(p))) * p[end] ≈ p
true
julia> fromroots(shuffle(roots(p))) * p[end] ≈ p
true
julia> fromroots(shuffle(roots(p))) * p[end] ≈ p
false
julia> fromroots(shuffle(roots(p))) * p[end] ≈ p
true
julia> fromroots(shuffle(roots(p))) * p[end] ≈ p
true Some basic monte-carlo testing indicates that This makes me think that there might be a better reduction strategy (in the sense that |
Some googling later, it appears that Leja Ordering is the answer. Best reference seems to be https://link.springer.com/article/10.1023/A:1025555803588 - unfortunately, behind a paywall, but I have access through my institution. If I can make anything out of it, I'll open a PR a Polynomials.jl. |
I can have a look. Our institution has access. Thanks! I'll let you know if I get anywhere. |
FWIW, I've tried a quick-and-dirty implementation and it did solve the problems reported above. I also have an idea how the mentioned O(n^2) algorithm might work. I'll keep you updated. |
Great. I'd love a PR if you get to that point. |
JuliaMath/Polynomials.jl#586 should fix this, so once there is a new release of Polynomials.jl, this should be resolved. |
I just initiated a tag for Polynomials with Martin's fix. |
Fixed with Polynomials.jl v4.0.12. |
Consider an FIR filter converted to ZPK and back:
One may wonder whether that is numerically sound, and it turns out the first conversion is, the second is not:
I.e. the frequency response of the ZPK form is ok, but going back to the polynomial is problematic. And spectacularly so:
However, as the frequency response is ok, we can also transform that back to time domain to get the impulse response which at the same time gives the polynomial coefficients. And indeed, that works:
For the IIR case, numerator and denominator could probably be transformed individually in a similar fashion. Does anyone have an insight to share whether that is more generally numerically better or have I just hit an example where that is the case by accident? In any case, it would be nice if
PolynomialRatio(::ZeroPoleGain)
worker properly in cases like this, where obviously, it could.The text was updated successfully, but these errors were encountered: