KEVOS
ArticlesServicesCase studiesAboutContact
ArticlesServicesCase studiesAboutContact
← ArticlesSolving Quadratic CongruencesEngineering · Engineering MathematicsLesson 722/884← PrevNext →
ArticlePublished 7 Aug 20262 min readBy Kevin Joginquadratic congruencecompleting the squarediscriminantmodular equation
On this page

Ask about this page

KEVOS AISolving Quadratic Congruences

KEVOS knowledge first · trusted web sources when needed

Euclidean Algorithms and Congruences

Solving Quadratic Congruences

Reducing a general quadratic congruence to a square root extraction, and handling the degenerate cases the reduction assumes away.

Engineering / MathematicsEuclidean Algorithms and Congruences2 min readKV-MATH-0521

A general quadratic congruence reduces to extracting a square root, by exactly the completion of the square used over the reals. The interest lies entirely in the cases where the reduction breaks down.

The reduction

a x^2 + b x + c = 0 (mod p)With a invertible modulo p.

Solving a quadratic congruence modulo an odd prime

  1. NormaliseMultiply through by the inverse of a, obtaining a monic congruence.
  2. Complete the squareSubstitute to remove the linear term; the constant becomes the discriminant divided by four.
  3. Test solvabilityEvaluate the Legendre symbol of the discriminant. If -1, there is no solution.
  4. Extract the rootApply Shanks-Tonelli.
  5. Back-substituteRecover the two solutions.

Degenerate cases

Cases the standard reduction does not cover
ConditionBehaviour
p divides aCongruence is linear, not quadratic; solve directly
p = 2Completion of the square fails; enumerate the two residues
Discriminant zero mod pA single repeated root
Legendre symbol -1No solution

Pitfall

The prime two is the case most often mishandled. Completing the square requires dividing by two, which is not invertible modulo two. Handle it by direct enumeration — there are only two residues to try.

Prime powers

Modulo a prime power, solve first modulo the prime, then lift. The lifting is straightforward when the derivative of the polynomial at the root is invertible — the non-degenerate case. When it is not, several roots may lift to each root or none may, and the case analysis must be done explicitly.

Note

Congruences modulo powers of two are the awkward case again: the derivative of a quadratic is even, so the standard lifting criterion fails and roots must be tracked with extra care.

Where this appears

Quadratic congruences arise in quadratic sieve initialisation, where the sieve positions are the roots of a quadratic modulo each factor base prime, and in form reduction when representing an ideal by a binary quadratic form.

Source. Henri Cohen, A Course in Computational Algebraic Number Theory, Springer GTM 138 — 1.4.4. Structural reference unverified: the source file was not available during authoring; chapter and section numbers are taken from the published edition and have not been checked against a physical copy.

Related pages

  • Square Roots Modulo a Prime: the Shanks-Tonelli Algorithm
  • Modular Inversion and Simultaneous Inversion

Continue learning

Square Roots Modulo a Prime: the Shanks-Tonelli AlgorithmArticle · Engineering MathematicsNEXT LESSON →Modular Inversion and Simultaneous InversionArticle · Engineering MathematicsLegendre, Jacobi and Kronecker Symbol ComputationArticle · Engineering MathematicsFinite Field Element RepresentationArticle · Engineering Mathematics
KEVOS · Engineering, manufacturing and project improvement
ArticlesServicesCase studiesAboutContact
© 2026 KEVOS®