A Linear Quadratic Regulator (LQR) is an optimal control algorithm that computes a static state-feedback gain matrix to drive a linear dynamical system to a desired state while minimizing a quadratic cost function. The cost function penalizes both state deviations and control effort, yielding a controller that balances performance against actuator energy expenditure.
Glossary
Linear Quadratic Regulator (LQR)

What is Linear Quadratic Regulator (LQR)?
An optimal control technique that computes a state-feedback gain matrix by minimizing a quadratic cost function for linear dynamical systems, often used for trajectory stabilization.
LQR solves the continuous-time Algebraic Riccati Equation (ARE) to produce a gain matrix that guarantees closed-loop stability for controllable systems. In robotics, LQR is frequently employed for trajectory stabilization, where it linearizes nonlinear dynamics around a nominal path and computes corrective control inputs to reject disturbances and maintain tracking accuracy.
Key Properties of LQR
The Linear Quadratic Regulator (LQR) is defined by a set of mathematical properties that guarantee stability, optimality, and robustness. These properties make it the foundational algorithm for trajectory stabilization in high-dimensional robotic systems.
Guaranteed Stability Margins
A critical property of the infinite-horizon LQR is its inherent robustness to gain and phase variations. For single-input systems, the LQR guarantees a gain margin of (−6 dB, ∞) and a phase margin of ±60°. This means the system remains stable even if the actuator output is halved or the input phase shifts significantly. This robustness arises from the return difference inequality of the optimal Kalman gain K, making LQR superior to pole placement for physical systems with unmodeled actuator dynamics.
Quadratic Cost Minimization
LQR solves the optimization problem of minimizing a quadratic cost function J = ∫(xᵀQx + uᵀRu) dt. The state weighting matrix Q penalizes deviations from the desired trajectory, while the control weighting matrix R penalizes actuator effort. The solution yields a linear state-feedback law u = −Kx, where the optimal gain matrix K = R⁻¹BᵀP. The matrix P is found by solving the Continuous-time Algebraic Riccati Equation (CARE): AᵀP + PA − PBR⁻¹BᵀP + Q = 0.
Algebraic Riccati Equation Solution
The core computational step in LQR is solving the Algebraic Riccati Equation (ARE). For high-dimensional systems, direct numerical solvers are used:
- Hamiltonian matrix method: Construct a 2n×2n matrix and compute its stable invariant subspace
- Schur decomposition: Numerically stable approach that avoids matrix inversion errors
- Iterative methods: Kleinman's algorithm solves a sequence of Lyapunov equations Modern libraries like SLICOT and ControlSystems.jl provide optimized ARE solvers for systems with hundreds of states.
Time-Varying LQR for Trajectory Tracking
For tracking a finite-horizon trajectory, the time-varying LQR solves the Differential Riccati Equation backward in time from a terminal condition P(t_f) = Q_f. This produces a time-dependent gain matrix K(t) that optimally balances tracking error and control effort at each instant. This is essential for robotic tasks like pick-and-place operations where the final pose accuracy is critical. The backward integration naturally yields a feedforward term that compensates for the reference dynamics.
Controllability and Observability Requirements
LQR requires the pair (A, B) to be stabilizable to guarantee a finite solution to the Riccati equation. Full controllability ensures the Riccati solution P is positive definite. Key conditions:
- Controllability matrix [B, AB, A²B, ..., Aⁿ⁻¹B] must have full row rank
- Uncontrollable modes must be stable (have negative real parts)
- Q must be positive semi-definite and R must be positive definite If these conditions fail, the ARE may have no stabilizing solution, and the closed-loop system will be unstable.
LQR vs. Model Predictive Control (MPC)
Comparing the unconstrained infinite-horizon linear quadratic regulator against the constrained receding-horizon model predictive control strategy for trajectory stabilization and industrial robotics applications.
| Feature | Linear Quadratic Regulator (LQR) | Model Predictive Control (MPC) |
|---|---|---|
Control Horizon | Infinite horizon (steady-state solution) | Finite receding horizon (N steps) |
Constraint Handling | ||
Online Computation | Matrix multiplication (O(n³) offline) | Quadratic programming solve per timestep |
State Feedback Law | Explicit gain matrix K (u = -Kx) | Implicit via optimization (no closed-form gain) |
Handles Nonlinear Dynamics | ||
Typical Update Rate | < 1 ms | 1-100 ms |
Preview of Reference Trajectory | ||
Stability Guarantee | Infinite-horizon LQR is globally asymptotically stable for stabilizable systems | Requires terminal cost/constraint design for recursive feasibility |
LQR Applications in Robotics
The Linear Quadratic Regulator (LQR) is a foundational optimal control technique that computes a state-feedback gain matrix by minimizing a quadratic cost function. In robotics, it provides mathematically elegant solutions for trajectory stabilization, balance control, and precision manipulation.
Trajectory Tracking Stabilization
LQR excels at stabilizing a robot around a nominal trajectory. Given a pre-planned path from a sampling-based planner like RRT*, LQR computes time-varying feedback gains that correct deviations caused by disturbances or modeling errors.
- Linearizes nonlinear dynamics around the reference trajectory at each timestep
- Produces a time-varying LQR (TVLQR) controller that minimizes a running cost on state error and control effort
- Commonly used in quadrotor aggressive maneuvering and autonomous vehicle lane-keeping
- The Q matrix penalizes state error (e.g., position offset), while R penalizes control effort (e.g., motor torque)
Balance and Inverted Pendulum Control
LQR is the classical solution for stabilizing inherently unstable systems like the cart-pole, Segway-style robots, and bipedal walking robots. The controller continuously computes corrective forces to keep the system upright.
- The linearized dynamics of an inverted pendulum fit perfectly into the LQR framework
- The cost function balances deviation from vertical (Q) against motor effort (R)
- Extends naturally to Linear Quadratic Gaussian (LQG) when sensor noise is significant
- Used in the MIT Cheetah and Boston Dynamics Atlas for dynamic balance during locomotion
Precision End-Effector Control
For robotic arms performing high-precision tasks like assembly, welding, or surgical manipulation, LQR provides smooth, optimal convergence to a target pose without overshoot.
- Formulated in operational space using the end-effector Jacobian to map joint torques to Cartesian forces
- The Q matrix heavily penalizes Tool Center Point (TCP) position error
- Outperforms simple PID controllers when dynamic coupling between joints is significant
- Often combined with impedance control to manage contact forces during insertion tasks
Autonomous Vehicle Path Following
LQR-based controllers are widely deployed in autonomous ground vehicles for smooth, stable path following. The controller minimizes both lateral offset from the reference path and steering effort.
- Uses a dynamic bicycle model linearized around the reference path
- The cost function penalizes cross-track error, heading error, and steering rate
- Provides a mathematically optimal alternative to geometric controllers like Pure Pursuit
- Implemented in the Apollo autonomous driving framework and numerous DARPA Grand Challenge entries
Whole-Body Control for Humanoids
Modern humanoid robots use LQR within a whole-body control (WBC) hierarchy. LQR computes optimal ground reaction forces and joint torques to track a desired center of mass trajectory while maintaining balance.
- The linear inverted pendulum model (LIPM) provides the simplified dynamics for LQR design
- Q penalizes Center of Mass (CoM) position and velocity errors
- R penalizes Center of Pressure (CoP) movement, encouraging smooth weight shifts
- Integrated with Model Predictive Control (MPC) for handling future preview information and constraints
LQR vs. MPC: When to Use Each
While both are optimal control methods, LQR and Model Predictive Control (MPC) serve different roles in the robotics control stack.
- LQR: Computes an explicit, closed-form feedback policy. Best for unconstrained problems where computational speed is critical and the system is well-approximated as linear
- MPC: Solves a numerical optimization at each timestep. Handles explicit constraints on joint limits, torque saturation, and obstacle avoidance
- A common architecture uses MPC for high-level planning with constraints, and LQR for low-level stabilization around the MPC-generated trajectory
- LQR provides the infinite-horizon cost-to-go used as the terminal cost in MPC formulations
Frequently Asked Questions
Concise answers to the most common technical questions about the Linear Quadratic Regulator (LQR), covering its mathematical foundation, implementation, and comparison to other optimal control strategies.
A Linear Quadratic Regulator (LQR) is an optimal control strategy that computes a state-feedback gain matrix K to stabilize a linear dynamical system while minimizing a quadratic cost function that penalizes state error and control effort. The controller assumes the system dynamics are linear (ẋ = Ax + Bu) and the cost function J = ∫ (xᵀQx + uᵀRu) dt is quadratic, where Q weights state deviations and R weights control input magnitude. The optimal control law u = -Kx is derived by solving the Continuous-time Algebraic Riccati Equation (CARE): AᵀP + PA - PBR⁻¹BᵀP + Q = 0. The resulting gain matrix K = R⁻¹BᵀP provides a closed-form, globally optimal solution for the infinite-horizon problem, making LQR computationally efficient and analytically tractable compared to iterative numerical optimization methods.
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
LQR is a foundational optimal control technique. These related concepts form the broader ecosystem of trajectory stabilization, constraint handling, and dynamic planning in robotics.
Cost Function Tuning (Q and R Matrices)
The state weighting matrix Q penalizes deviations from desired states, while the input weighting matrix R penalizes control effort. Tuning these matrices defines the performance-aggressiveness trade-off:
- Large Q, small R: Aggressive error correction, high-gain control
- Small Q, large R: Conservative, energy-efficient motions
- Diagonal structure: Common for independent joint penalties
- Bryson's rule: A systematic method for initial Q/R selection based on acceptable state and input ranges
Linear Time-Varying LQR (LTV-LQR)
An extension of standard LQR for systems with time-varying dynamics A(t) and B(t). Instead of a single steady-state gain, LTV-LQR computes a time-varying gain schedule K(t) by integrating the Differential Riccati Equation backward from a terminal cost. This is critical for trajectory tracking in robotics, where the linearization of nonlinear dynamics around a reference trajectory produces time-varying Jacobians at each point along the path.
Differential Dynamic Programming (DDP)
An iterative trajectory optimization algorithm that generalizes LQR to nonlinear systems. DDP performs a backward pass computing local LQR solutions along a nominal trajectory, then a forward pass with a line search. The backward pass solves a time-varying LQR problem at each iteration, making DDP a direct nonlinear extension of LTV-LQR. Widely used in legged locomotion and manipulation for computing locally optimal trajectories with full dynamics.

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