Skip to content

[AUD-005][High] Correct Durand-Kerner for non-monic polynomials #301

Description

@gabrielsantosphilips

Audit finding

  • ID: AUD-005
  • Status: Verified defect
  • Severity: High
  • Confidence: High
  • Audited revision: 2f479320d805a1f9f35ebe4afaaeeded48913a94

Problem

The Durand-Kerner correction divides by the root-difference product but omits the polynomial leading coefficient. Polynomial scaling must not change roots.

Source:

}
template<typename T, std::size_t MaxOrder>
bool DurandKerner<T, MaxOrder>::Iterate(Roots& roots,
std::span<const T> coefficients, std::size_t order, T tolerance)
{
bool converged = true;
for (std::size_t r = 0; r < order; ++r)
{
auto pVal = EvaluatePolynomial(coefficients, roots[r]);
auto denominator = ComputeDenominator(roots, r, order);
auto correction = pVal / denominator;
roots[r] -= correction;
if (math::Abs(correction) > tolerance)
converged = false;
}

Reproduction

10(x-1)(x-2), represented as {10, -30, 20}, returned two NaN roots. All existing nonlinear tests use monic polynomials.

The solver also returns initial/last iterates without convergence status and uses a tolerance-based sort comparator that is not a strict weak ordering.

Acceptance criteria

  • Normalize coefficients or include the leading coefficient in each correction.
  • Root results are invariant under nonzero coefficient scaling.
  • Return explicit convergence/failure status.
  • Replace the comparator with a strict weak ordering.
  • Add non-monic residual and scale-invariance TEST_F coverage.

Activity

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions