I'm trying to solve the sylvester equation, but it won't work for me.
The Sylvester equation is:
$$AX + XB = C$$
Very simple.
And the solution $X$ (if we know $A, B, C$) can be found from this equation:
$$(I \otimes A + B^T \otimes I) vec(X) = vec(C)$$
In MATLAB or GNU Octave, $X$ can be found by this example:
>> A
A =
1 -1 1
1 1 -1
1 1 1
>> B
B =
8 1 6
3 5 7
4 9 2
>> C
C =
Diagonal Matrix
1 0 0
0 1 0
0 0 1
>> X = C(:)\(kron(eye(3), A) + kron(B', eye(3)))
X =
Columns 1 through 6:
3.00000 -0.00000 2.33333 1.33333 2.00000 2.00000
Columns 7 through 9:
1.66667 3.33333 1.00000
>> X = reshape(X, [3 3])
X =
3.00000 1.33333 1.66667
-0.00000 2.00000 3.33333
2.33333 2.00000 1.00000
My question is: Why does matrix $X$ have those values? It will result this equation:
$$AX + XB \neq C$$
Have I compute the solution in wrong way?
Because
>> C = A*X + X*B
C =
40.000 26.000 30.000
20.000 41.333 24.667
34.000 26.667 36.000
I found the solution now.
Insted of this:
It should be:
Example: