You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
count_eigval_multiplicity undercounts zero clusters next to other zeros or slow poles #1107
count_eigval_multiplicity (lib/ControlSystemsBase/src/analysis.jl#L57-L85) undercounts eigenvalues at the origin when clusters of different multiplicity are present, or when a slow eigenvalue is located inside the radius of a larger candidate. count_integrators and integrator_excess inherit the error.
[-1, 0, -1e-8, 1e-8]: an exact zero together with a double zero that the eigenvalue computation has split into ±1e-8 (for example an independent integrator and a double integrator in a non-modal basis). The loop returns at i = 1, the first candidate that passes, and never examines the three-element cluster, which also passes the coefficient check (the normalized polynomial is z^3 - 1e-16 z).
[-1, -1e-8, 0, 0]: two exact zeros and a slow pole. The candidate i = 2 is rejected because three eigenvalues lie within radius(2) ≈ 1.5e-7, and the candidate i = 3 is rejected by the coefficient check because it contains the slow pole. The result is 0, although the two exact zeros are located within radius(1).
The requirement that exactly i eigenvalues lie within radius(i), combined with returning the first accepted candidate, makes the result depend on eigenvalues that do not belong to the cluster.
Possible fix
Take the i eigenvalues closest to location as the candidate of multiplicity i, require all of them within radius(i) and the coefficient check, and return the largest accepted i. Building the cluster polynomial incrementally (one factor per candidate) keeps the cost at O(n²). This is implemented for the zero eigenvalues of a Jacobian in SciML/ModelingToolkit.jl#5418 (_zero_eigenvalues in src/jacobian_analysis.jl), where it returns 3 and 2 for the two spectra above. The explicit-radius branch (e given) and the returned tolerance would need to be adapted accordingly.
A review of SciML/ModelingToolkit.jl#5418 found that the multiplicity-based radius also has false positives, which the fix proposed above does not address. The radius (100ϵ)^(1/i) * scale assumes that every eigenvalue near the origin may be a perturbed defective eigenvalue, so well-conditioned small eigenvalues are counted as integrators:
The poles ±1e-8 are computed exactly (diagonal matrix, condition number one), but they lie within radius(2) ≈ 1.5e-7, and the normalized cluster polynomial z^2 - 1e-16 passes the coefficient check. The eigenvalues alone cannot distinguish this case from a double integrator expressed in a non-modal basis, whose double zero is computed as a pair of order √ϵ * scale.
The eigenvectors can. ModelingToolkit now classifies each eigenvalue with the first-order perturbation bound |Δλ_k| ≲ κ_k ‖E‖, where κ_k = ‖v_k‖ ‖w_k‖ / |w_k' v_k| is the eigenvalue condition number (right and left eigenvectors v_k, w_k) and ‖E‖ ≈ δ ‖A‖ with δ the relative accuracy of the matrix. Since the first-order bound is not valid for a defective eigenvalue, it is limited by the perturbation of a double eigenvalue: an eigenvalue is classified as zero when
|λ_k| ≤ 100 * min(δ * ‖A‖ * κ_k, √δ * ‖A‖)
Diagonal example: κ = 1, bound ≈ 2e-14, so ±1e-8 are resolved (no integrators).
Double integrator in a non-modal basis: the computed eigenvectors of the split pair are nearly parallel, κ ≈ 1/(2√ϵ), so the bound is of order √ϵ ‖A‖ and both eigenvalues are classified as zero.
Exact Jordan block away from the origin, [-1 1; 0 -1]: κ is of order 1/ϵ, the limit 100√ϵ ‖A‖ applies, and -1 is not classified as zero.
The implementation is _modes and _eigenvalue_error_bounds in src/jacobian_analysis.jl. This requires the eigenvectors and therefore a state-space realization; for count_integrators on a transfer function, or for the zeros in integrator_excess, the eigenvalue-only rule would remain. A zero eigenvalue of multiplicity three or more that is perturbed beyond 100√δ ‖A‖ is not recognized by this bound.
Activity
baggepinnen commentedon Nov 19, 2026
A review of SciML/ModelingToolkit.jl#5418 found that the multiplicity-based radius also has false positives, which the fix proposed above does not address. The radius
(100ϵ)^(1/i) * scaleassumes that every eigenvalue near the origin may be a perturbed defective eigenvalue, so well-conditioned small eigenvalues are counted as integrators:The poles
±1e-8are computed exactly (diagonal matrix, condition number one), but they lie withinradius(2) ≈ 1.5e-7, and the normalized cluster polynomialz^2 - 1e-16passes the coefficient check. The eigenvalues alone cannot distinguish this case from a double integrator expressed in a non-modal basis, whose double zero is computed as a pair of order√ϵ * scale.The eigenvectors can. ModelingToolkit now classifies each eigenvalue with the first-order perturbation bound
|Δλ_k| ≲ κ_k ‖E‖, whereκ_k = ‖v_k‖ ‖w_k‖ / |w_k' v_k|is the eigenvalue condition number (right and left eigenvectorsv_k,w_k) and‖E‖ ≈ δ ‖A‖withδthe relative accuracy of the matrix. Since the first-order bound is not valid for a defective eigenvalue, it is limited by the perturbation of a double eigenvalue: an eigenvalue is classified as zero whenκ = 1, bound≈ 2e-14, so±1e-8are resolved (no integrators).κ ≈ 1/(2√ϵ), so the bound is of order√ϵ ‖A‖and both eigenvalues are classified as zero.[-1 1; 0 -1]:κis of order1/ϵ, the limit100√ϵ ‖A‖applies, and-1is not classified as zero.The implementation is
_modesand_eigenvalue_error_boundsinsrc/jacobian_analysis.jl. This requires the eigenvectors and therefore a state-space realization; forcount_integratorson a transfer function, or for the zeros inintegrator_excess, the eigenvalue-only rule would remain. A zero eigenvalue of multiplicity three or more that is perturbed beyond100√δ ‖A‖is not recognized by this bound.Host: demeter2 · working directory: ~/.julia/dev/ModelingToolkit · session: https://claude.ai/code/session_01JGy8YXPe4Fz8vGQ25FRvtz
🤖 Generated with Claude Code