# dlyap

Solve discrete-time Lyapunov or Sylvester equations.

## Syntax

X = dlyap(A, B) % Lyapunov Equation

X = dlyap(A, B, C) % Sylvester Equation

X = dlyap(A, B, [], E) % Generalized Lyapunov Equation

## Inputs

A
Real square matrix.
B
Real matrix.
C
Real matrix.
E
Real matrix.

## Outputs

X
Returns the solution to the discrete Lyapunov Equation. X is a real matrix.

## Examples

Example based on the Sylvester equation:
A = [1.0   2.0   3.0;
6.0   7.0   8.0 ;
9.0   2.0   3.0];

B = [7.0   2.0   3.0;
2.0   1.0   2.0;
3.0   4.0   1.0];

C = [271.0   135.0   147.0;
923.0   494.0   482.0;
578.0   383.0   287.0];

X = dlyap (A, B, C)
X = [Matrix] 3 x 3
-1.90185   -2.33312  -6.71763
-10.50330   10.91915   1.49666
0.04138  -18.39193  -3.43305
Example based on the Lyapunov equation:
A = [3.0   1.0   1.0;
1.0   3.0   0.0;
0.0   0.0   3.0];

B = [25.0  24.0  15.0;
24.0  32.0   8.0;
15.0   8.0  40.0];

X = dlyap (A, B)
X = [Matrix] 3 x 3
-1.60000  -0.70303   0.43636
-0.70303  -3.27273  -1.16364
0.43636  -1.16364  -5.00000
Example based on a generalized Lyapunov equation:
A = [1.0   2.0   3.0;
6.0   7.0   8.0 ;
9.0   2.0   3.0];

B = [1.0   7.0   3.0;
7.0   4.0   -5.0;
3.0   -5   6];

E = [271.0   135.0   147.0;
923.0   494.0   482.0;
578.0   383.0   287.0];

X = dlyap(A, B, [], E)
X = [Matrix] 3 x 3
-0.06977   0.01503   0.11655
0.01503  -0.00147  -0.02679
0.11655  -0.02679  -0.19308