Skip to content

count_eigval_multiplicity undercounts zero clusters next to other zeros or slow poles #1107

Open

Description

@baggepinnen

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.

Reproduction

On master (0097c05):

using ControlSystemsBase
f = ControlSystemsBase.count_eigval_multiplicity
f(ComplexF64[-1, 0, -1e-8, 1e-8], 0)  # (1, 2.2e-14), expected 3
f(ComplexF64[-1, -1e-8, 0, 0], 0)     # (0, 2.2e-14), expected 2
  1. [-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).
  2. [-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.

Related: #1081.


Host: demeter2 · working directory: ~/.julia/dev/ModelingToolkit · session: https://claude.ai/code/session_01JGy8YXPe4Fz8vGQ25FRvtz

🤖 Generated with Claude Code

Activity

  1. baggepinnen commented on Nov 19, 2026

    @baggepinnen
    MemberAuthor

    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:

    using ControlSystemsBase, LinearAlgebra
    P = ss(Diagonal([-1.0, -1e-8, 1e-8]), I(3), I(3), 0)
    ControlSystemsBase.count_integrators(P)  # 2, expected 0
    ControlSystemsBase.count_eigval_multiplicity(ComplexF64[-1, -1e-8, 1e-8], 0)  # (2, 1.49e-7)

    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.


    Host: demeter2 · working directory: ~/.julia/dev/ModelingToolkit · session: https://claude.ai/code/session_01JGy8YXPe4Fz8vGQ25FRvtz

    🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions