How this calculation works
Find all feasible complementary solution regions of a small rational linear complementarity problem, including degenerate continua.
w = M z + q; z≥0, w≥0, z_i w_i=0 for every iA worked example
For M=[0] and q=[0], w is always zero and every z≥0 is complementary. The solution is an entire nonnegative ray, not one isolated point.
Good to know
Exact rational real matrix order1–5 and matching vector. Enumerate all2^n complementary patterns; obtain each feasible polyhedral region by exact linear equalities/inequalities, rational LP certificates and redundancy tests. Return a union of regions with witnesses, explicitly distinguishing isolated points, continua and no solution. Degenerate patterns retained unless equivalent; cap rational growth and do not assume a P-matrix or convex-QP equivalence.
Reference: Stanford MS&E310 lecture: linear complementarity formulation (opens in a new tab) ↗
Complementarity combines equations and inequalities
The variables z and w are componentwise nonnegative and linked by the affine relation w equals M z plus q. Complementarity requires each matching pair of components to have product zero. A pair may have positive z and zero w, zero z and positive w, or both zero, but not both positive.
These disjunctions make the feasible set a union of polyhedral pieces. It need not be convex or consist only of isolated points. The input matrix is not assumed positive definite or even symmetric. Restricting the calculation to the optimality conditions of a convex quadratic program would therefore omit much of the general linear complementarity problem supported here.
Compare this with the Convex quadratic programming calculator with constraints. Solve general w=Mz+q with z≥0,w≥0 and componentwise z_i*w_i=0, including nonsymmetric or nonmonotone matrices and multiple solution regions. The existing convex QP rejects nonconvex models and returns one optimizer, not the complete complementarity solution set.
Enumerating complementary patterns
For each component, choose a branch that forces either z_i or w_i to zero. Across n components there are two to the power n such patterns. Append the remaining nonnegativity conditions and the affine relation to obtain a polyhedron for that pattern. Exact linear feasibility then determines whether that piece contains any solutions.
When both members of a pair vanish, the same solution can belong to several patterns. This overlap is expected in degenerate problems. It must not be treated as several distinct isolated solutions. Equivalent pieces can be merged or explicitly labeled as overlapping, while every feasible region remains represented in the final union.
Solving a region without losing free variables
The equality system for a pattern can be singular. Rather than discard it, compute a particular solution and its nullspace, then impose the remaining inequalities in those free coordinates. The resulting region may be empty, a single point, a bounded segment, a higher-dimensional polytope or an unbounded polyhedron.
A rank-deficient pattern is therefore not automatically a failure. It is often precisely where a continuum of complementary solutions appears. The output should retain its affine equations, nonnegative inequalities and a feasible rational witness, together with enough dimension or recession information to distinguish an isolated point from a family.
The zero-matrix example
In the scalar default, M and q are both zero. The affine equation gives w equal to zero regardless of z. Nonnegativity then allows every z greater than or equal to zero, and the complementarity product is automatically zero. Thus the complete solution set is the nonnegative z axis with w fixed at zero.
One pattern forces z to zero and produces the origin. The other forces w to zero and produces the full ray. Their union is still the ray, and the origin is not an additional disconnected solution. This example exposes solvers that return only one feasible point and incorrectly imply that they have enumerated all solutions.
No solution and several solution types
A general LCP can have no solution, one point, several isolated points or continuous families. Complete pattern enumeration can distinguish these cases in the supported small dimension, provided every pattern is solved exactly. A failed linear solve alone is not a no-solution certificate because a singular equality system may still define a feasible family.
Infeasibility should be supported by exact linear-program or elimination evidence for each relevant pattern. Conversely, a feasible witness proves only that its own region is nonempty. It does not establish completeness until all complementary patterns have been accounted for. The distinction between a witness and an exhaustive union is central to interpreting the result.
Checking a returned region
For every displayed region, substitute its affine parametrization or a general symbolic point into w equals M z plus q. Confirm that its inequalities imply both vectors are nonnegative. Finally, verify that each pair has at least one identically zero member on that piece, establishing complementarity throughout the entire region rather than at one selected sample.
A rational sample point is useful for replaying the conditions, but sampling cannot certify a whole polyhedron. Recession directions deserve particular attention in unbounded pieces: they must preserve the affine and nonnegativity constraints. If the interface truncates a long region list, retain a clear distinction between a complete mathematical result and a shortened presentation.
Resource limits and interpretations
The small order cap makes enumeration of every complementary pattern practical. Exact rational arithmetic avoids numerical ambiguity in degeneracy, but large fractions or redundant inequalities can still exceed resource limits. An unresolved arithmetic cap must not be converted into either an infeasibility verdict or a complete-solution claim.
Complementarity models appear in equilibrium, contact and optimization, but the calculator does not infer those application assumptions from a matrix. A valid LCP solution need not be a stable physical equilibrium or a global minimizer of an associated nonconvex objective. Use the returned complete region union as an algebraic result for the supplied M and q.
A few questions, answered
Must M be symmetric positive definite?
No. The supported general LCP does not assume symmetry or convex quadratic-program equivalence.
Can the answer be a continuum?
Yes. Singular complementary patterns can define segments, rays or higher-dimensional regions.
Is one feasible vector a complete answer?
No. It is only a witness unless all patterns and solution regions have been accounted for.
Why do some patterns overlap?
At components where both z_i and w_i are zero, more than one complementary branch describes the same solution.