A Linear Complementarity Problem (LCP) is a mathematical framework for finding vectors w and z that satisfy the conditions w = Mz + q, w ≥ 0, z ≥ 0, and wᵀz = 0, where M is a matrix and q is a vector. In physics simulation, it is the canonical form for solving contact constraints and Coulomb friction, ensuring that contact forces are non-adhesive (non-negative) and only act when bodies are touching (the complementarity condition).
Glossary
Linear Complementarity Problem (LCP)

What is Linear Complementarity Problem (LCP)?
A mathematical formulation central to physics engines for modeling contact and friction constraints, ensuring non-penetration and realistic force interactions.
Within a constraint solver, the LCP encodes the Karush–Kuhn–Tucker (KKT) conditions for rigid body dynamics with unilateral constraints. Solving it yields the normal impulses and friction impulses required to prevent interpenetration while respecting the friction cone. Algorithms like Projected Gauss-Seidel (PGS) or Lemke's algorithm are used iteratively, often with warm starting from the previous time step to accelerate convergence in real-time engines.
Key Characteristics of the LCP Formulation
The Linear Complementarity Problem (LCP) provides a compact, algebraic framework for modeling unilateral constraints like contact and friction. Its defining features make it particularly suited for real-time physics simulation.
Complementarity Condition
The core of an LCP is the complementarity condition, expressed as 0 ≤ z ⟂ w ≥ 0. This means the solution variables z and w must be non-negative and orthogonal: for each component i, either z_i = 0 or w_i = 0 (or both). In physics, this elegantly encodes the non-penetration and non-adhesion of contact: a contact force (z) can only be positive if the bodies are exactly touching (w=0), and if bodies are separating (w>0), the contact force must be zero.
Linear Relationship
The 'Linear' in LCP refers to the relationship w = Mz + q, where M is a known matrix and q is a known vector. This linear system is derived from the physics of the problem. For contact, M encodes the system's mass matrix and contact geometry (Jacobians), while q contains external forces and relative velocities. This structure allows the problem to be solved with efficient, specialized numerical algorithms rather than general non-linear solvers.
Unilateral Constraints
LCPs naturally model unilateral constraints, which are inequalities that can be active or inactive. A classic example is contact: bodies cannot push into each other (the normal force must be ≥ 0), but they can freely separate. This is distinct from bilateral constraints (like a hinge joint), which are always active equalities. The LCP's solution automatically determines which contacts are active (exerting force) and which are inactive (separating), a process known as contact state determination.
Friction Cone Approximation
Coulomb friction is non-linear, but it can be incorporated into an LCP through a polyhedral approximation of the friction cone. The continuous cone of allowable friction forces is approximated by a pyramid with 4, 8, or more sides. Each side becomes a linear complementarity constraint. This transforms the non-linear friction problem into a larger, but still linear, complementarity problem that can be solved with the same numerical machinery, enabling stable simulation of sticking and sliding.
Solution Algorithms (Lemke's Pivoting)
A standard algorithm for solving LCPs is Lemke's algorithm, a pivotal method similar to the simplex algorithm for linear programming. It systematically explores vertices of a complementary cone to find a solution. For physics simulation, the Projected Gauss-Seidel (PGS) method is often preferred for its simplicity and efficiency in handling large, sparse systems, even though it provides an approximate solution. The choice of solver balances accuracy, speed, and robustness for real-time applications.
Connection to Optimization
The LCP is intimately related to convex optimization. Solving the LCP 0 ≤ z ⟂ Mz + q ≥ 0 is equivalent to finding a Karush-Kuhn-Tucker (KKT) point for a specific Quadratic Program (QP) when M is positive semi-definite. This link provides a rich theoretical foundation and allows the use of optimization-based techniques like Sequential Quadratic Programming (SQP) for more complex, non-linear contact problems, bridging the gap between game physics and high-precision engineering simulation.
LCP vs. Other Constraint Resolution Methods
A feature and performance comparison of the Linear Complementarity Problem (LCP) formulation against other common methods for resolving contact and friction constraints in physics simulation.
| Feature / Metric | Linear Complementarity Problem (LCP) | Penalty Method | Impulse-Based Dynamics |
|---|---|---|---|
Mathematical Foundation | Complementarity conditions (w ≥ 0, z ≥ 0, wᵀz = 0) | Spring-damper force law (F = -kx - bv) | Instantaneous velocity change via impulse (Δv = M⁻¹Jᵀλ) |
Constraint Enforcement | Exact (within solver tolerance) | Approximate (penetration-dependent) | Exact (per-iteration) |
Handles Friction Cone | |||
Guarantees Non-Penetration | |||
Guarantees Non-Adhesive Forces | |||
Solution Stability (Stiffness) | High (no artificial stiffness parameters) | Low (requires careful tuning of k, b) | Medium (depends on iteration count) |
Typical Solver Type | Iterative (Projected Gauss-Seidel) or Pivoting (Lemke) | Explicit force integration | Sequential impulse application |
Computational Cost per Contact | High (solves matrix/MLCP) | Low (direct calculation) | Medium (iterative per contact) |
Simulation Scale Performance | O(n²) to O(n) with good warm-starting | O(n) | O(n) |
Common Use Case | High-accuracy robotics, off-line simulation | Real-time games, simple interactions | Real-time games, interactive applications |
Where is the LCP Used?
The Linear Complementarity Problem is a foundational mathematical formulation with critical applications in computational physics, optimization, and robotics. Its structure elegantly captures the 'either-or' conditions inherent in unilateral constraints like contact and friction.
Frequently Asked Questions
The Linear Complementarity Problem (LCP) is a fundamental mathematical formulation in physics simulation engines, used to model contact and friction constraints between rigid bodies. These questions address its core mechanics, applications, and role in bridging simulation to reality.
A Linear Complementarity Problem (LCP) is a mathematical framework used in physics engines to model contact constraints and Coulomb friction between rigid bodies, where the solution must satisfy conditions that forces are non-penetrating and non-adhesive. Formally, it solves for vectors z and w such that w = Mz + q, z ≥ 0, w ≥ 0, and z^T w = 0. This last condition, the complementarity condition, is key: it enforces that for each contact, either the normal force is zero (bodies are separating) or the penetration depth/velocity is zero (bodies are in contact but not penetrating). This elegantly captures the "either/or" nature of contact—objects cannot both be pushing on each other and moving apart at the same point.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
The Linear Complementarity Problem (LCP) is a core mathematical formulation within physics engines. It is closely related to these other concepts in the simulation of contact, friction, and constrained motion.
Constraint Solver
A constraint solver is the algorithmic core of a physics engine that calculates the forces or impulses necessary to satisfy a set of constraints—such as contact non-penetration, joint limits, or friction—within a numerical tolerance. The LCP is a specific mathematical framework often used to formulate and solve these constraints. The solver iteratively adjusts velocities and positions to prevent interpenetration while respecting physical laws like Coulomb friction.
- Primary Role: Enforces physical rules (no sinking, sliding limits) in a simulated world.
- Iterative Nature: Typically uses algorithms like Projected Gauss-Seidel (PGS) to find a feasible solution.
- Connection to LCP: Many modern solvers frame contact and friction constraints as an LCP or a related optimization problem to find a globally consistent set of forces.
Coulomb Friction
Coulomb friction is the classical, dry friction model used in physics simulation. It defines two regimes:
- Static Friction: The force that resists the initiation of sliding, with a maximum magnitude proportional to the normal force.
- Kinetic Friction: A constant opposing force during sliding, also proportional to the normal force.
The LCP is instrumental in modeling Coulomb friction because it naturally encodes the complementarity conditions between force and motion:
- If there is no sliding (relative tangential velocity is zero), the friction force can be anywhere within its allowable friction cone.
- If sliding occurs, the friction force must be at the cone's boundary, opposing the direction of slip. The LCP solver finds the exact force that satisfies these either-or conditions at every contact point.
Friction Cone
A friction cone is the geometric representation of all allowable friction forces at a contact point, as defined by Coulomb's law. It is a cone whose:
- Axis is aligned with the contact normal.
- Angle is given by
arctan(μ), whereμis the coefficient of friction. Any resultant tangential force must lie within or on the surface of this cone to be physically admissible.
In LCP formulations, the friction cone is often linearized into a polyhedral approximation (e.g., a pyramid with 4 or 8 edges) to transform the nonlinear friction constraints into a set of linear complementarity conditions. This allows the use of efficient, dedicated LCP solvers to determine if a contact is sticking (force inside cone) or sliding (force on cone's edge).
Penalty Method
The penalty method is an alternative to LCP-based constraint resolution. Instead of solving for exact non-penetration constraints, it models contacts as stiff spring-damper systems.
- Mechanism: When two bodies penetrate, a spring force proportional to the penetration depth pushes them apart. A damping term proportional to penetration velocity adds stability.
- Contrast with LCP: The LCP is a hard constraint method that strictly enforces no penetration at the velocity level. The penalty method is a soft constraint that allows small, numerical penetrations to generate a counteracting force.
- Use Cases: Penalty methods are simpler to implement and can be more stable for very stiff, non-interacting constraints, but they can cause "bouncing" and are less accurate for complex, simultaneous contacts compared to LCP solvers.
Impulse-Based Dynamics
Impulse-based dynamics is a simulation method that resolves collisions and contacts by applying instantaneous changes in velocity (impulses) rather than computing continuous forces over a time step.
- Process: When a collision is detected, an impulse is calculated and applied to instantly change the bodies' velocities to satisfy conservation laws and collision properties (like restitution).
- Relation to LCP: Sequential impulse-based solvers, a popular variant, are mathematically similar to solving an LCP using the Projected Gauss-Seidel method. Each iteration applies impulses to satisfy one constraint at a time, progressively converging to a solution that respects all contacts and friction conditions simultaneously.
- Advantage: Known for stability and efficiency in real-time applications like video games, where exact physical accuracy is less critical than robust performance.
Baumgarte Stabilization
Baumgarte stabilization is a constraint stabilization technique used to control numerical drift in simulations that use constraint-based methods like the LCP. Constraint drift is the accumulation of small numerical errors causing bodies to slowly penetrate or joints to separate.
- Function: It modifies the constraint equation by adding a corrective feedback term. For a position constraint
C(p)=0, the solver is told to achieveĊ + βC = 0, whereβis a damping parameter. This term acts like a virtual spring pulling the system back to a valid state. - Role in LCP: While the LCP is often formulated at the velocity level, Baumgarte stabilization provides a practical way to incorporate position-level correction, ensuring long-term simulation stability without requiring perfectly solved, drift-free constraints at every infinitesimal step.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us