You are solving a system of equations organized in a matrix, hence you have to Equal
(==
) each of the four equations - MMA doesn't know that your 0
is a $2\times 2$ zero matrix. Next, you only provide a[0]
but the loop goes through a[1]
, a[2]
etc.
n = 5;
c = {{1, 2}, {1, 4}};
a[0] = {{0, 1}, {2, 3}};
a[i_] := a[i - 1] + IdentityMatrix[2];
p[k_] := {{p1[k], p2[k]}, {p3[k], p4[k]}};
Do[
m = Solve[
Transpose[a[k]].p[k] + p[k].a[k] + c == {{0, 0}, {0, 0}}, {p1[k],
p2[k], p3[k], p4[k]}]
, {k, 0, n}];
p[n] /. m[[1]] // MatrixForm
I set an arbitrary a[i]
through recursion for illustration, changed p[k]
to an explicit function and gave n = 5
as the max iterator of the loop (works for arbitrary n
, e.g. n = 500
).