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
Audit finding
AUD-0052f479320d805a1f9f35ebe4afaaeeded48913a94Problem
The Durand-Kerner correction divides by the root-difference product but omits the polynomial leading coefficient. Polynomial scaling must not change roots.
Source:
numerical-toolbox-cpp/numerical/solvers/DurandKerner.hpp
Lines 69 to 86 in 2f47932
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
TEST_Fcoverage.