Advanced maths

Discrete algebraic Riccati equation calculator

This bounded numerical solver seeks the stabilizing infinite-horizon discrete-time Riccati solution for a one-input system with one or two states.

Your numbers

Square 1×1 or 2×2; rows separated by semicolons/newlines.
One column, with the same number of rows as A.
Exactly symmetric, same square size as A.
Positive rational value. Matrix entries within ±1,000.

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

This bounded numerical solver seeks the stabilizing infinite-horizon discrete-time Riccati solution for a one-input system with one or two states. It iterates the finite-horizon cost recursion from zero, then checks the equation residual, positive definiteness of the solution and stability of A−BK. A returned matrix is therefore supported by numerical certificates rather than by convergence of an arbitrary fixed-point iteration alone.

THE FORMULAP=AᵀPA−AᵀPB(R+BᵀPB)^−1BᵀPA+Q; K=(R+BᵀPB)^−1BᵀPA; u=−Kx.

A worked example

For scalar A=B=Q=R=1, the equation reduces to P²−P−1=0. The positive stabilizing solution is (1+sqrt(5))/2, about 1.61803398875. The gain is P/(1+P), about 0.61803398875, and the closed-loop state multiplier is 1−K, about 0.38196601125. Its absolute value is below one, so repeated zero-input closed-loop updates decay toward zero.

Good to know

One or two real states and one control input. Q must be exactly symmetric positive definite and R a positive scalar; entries are bounded by ±1,000. The solver uses at most 5,000 iterations and rejects results that fail the residual, positive-definiteness or strict stability checks. Descriptor equations, cross terms, indefinite costs and unit-circle borderline cases are unsupported. Failure is not proof of nonexistence.

Separate the equation from its stabilizing branch

An algebraic Riccati equation can have solutions that do not stabilize the feedback system. For the scalar worked case, the negative root of P²−P−1 is a genuine algebraic root, but it is not the positive cost matrix selected by the infinite-horizon regulator problem. Reporting any root without the closed-loop check would answer a different question.

The feedback convention is u=−Kx, giving next-state matrix A−BK. The sign matters: applying +K to a gain derived for negative feedback can turn a contracting system into a growing one. The table supplies both K and A−BK, and lists the real and imaginary parts of the one or two closed-loop eigenvalues.

The scalar Riccati feedback contracts the state by about zero point three eight two per stepk=0k=1k=2k=3k=4|A − BK| ≈ 0.382 < 1
For A=B=Q=R=1, P=(1+sqrt(5))/2, K≈0.618034 and A−BK≈0.381966. Starting at state one, the shown values are successive closed-loop powers, not the Riccati iteration itself.

The Sylvester matrix equation calculator AX + XB = C solves linear matrix equations. This Riccati equation is nonlinear in its unknown cost matrix and additionally checks a feedback stability certificate.

Read a small residual together with the stability margin

The residual compares the returned P with one further Riccati update, scaled by the size of P or one. A small residual measures agreement with the equation in the entered coordinates. It does not by itself prove that the chosen solution is stabilizing or that a badly conditioned input has an accurate solution.

The solver separately requires all closed-loop eigenvalue moduli to be smaller than one by a stated numerical margin. Results extremely close to the unit circle are rejected rather than rounded into a stable classification. Likewise, a zero input column and an unstable open-loop mode can make the iteration diverge; that runtime outcome is not presented as a general theorem about every Riccati equation.

The supported cost assumptions keep the numerical contract explicit

Positive-definite Q assigns positive cost to every nonzero state, and positive R penalizes the one-dimensional control effort. The input family deliberately excludes semidefinite and indefinite variants, which need additional existence and branch analysis. Symmetry is checked on the exact rational inputs before conversion to floating point.

The reference implementation for independent tests is SciPy’s stabilizing DARE solver, which uses a different numerical method. Comparing P, K and the original equation residual on small controllable systems tests more than reproducing the same iteration twice. These are educational numerical results, not an automatically approved controller for a physical process.

A few questions, answered

Does failure mean no Riccati solution exists?

No. It can indicate unsupported costs, failed convergence, poor numerical conditioning or a stability margin too close to the boundary.

Is the result exact?

No. P and K are numerical approximations with reported residual and stability checks. The scalar formula in the example is an independent exact reference.

Find your calculator

Start typing to explore the library.