# System of unknown matrices

I am very new to Mathematica. I am attempting to solve a system of equations with 4 unknown matrices (B, C, D and S). B, D and S are symmetric. This is what I have:

A = {{ε, 0, 0}, {0, ε, 0}, {0,
0, -2 ε}}

B1 = Array[b, {3, 3}];
C1 = Array[c, {3, 3}];
D1 = Array[d, {3, 3}];
S1 = Array[s, {3, 3}];

Z = {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}};

f1[D2_] := n γ + σ^2/2 Tr[D2];
f2[C2_, D2_] := -C2 - Transpose[C2] + 2 γ D2 - Transpose[A].D2 - D2.A + σ^2 D2.D2;
f3[B2_, C2_, D2_, S2_] := -Transpose[B2] - γ Transpose[A].D2 + γ C2 - C2.A + S2.D2 + σ^2 C2.D2;
f4[C2_, S2_] := -γ C2.A + γ Transpose[A].Transpose[C2] + C2.S2 + S2.Transpose[C2] + σ^2 Transpose[C2].C2;

Solve[{f1[D1]\[Equal]0,f2[C1,D1]\[Equal]Z,f3[B1,C1,D1,S1]\[Equal]Z,\
f4[C1,S1]\[Equal]Z},{Flatten[B1],Flatten[C1],Flatten[D1],Flatten[S1]}]\


But it gives me the error:

Solve::ivar: {b[1,1],b[1,2],b[1,3],b[2,1],b[2,2],b[2,3],b[3,1],b[3,2],b[3,3]} is not a valid variable.

Is my code just plain wrong, or is it that I am being unrealistic by trying to solve this symbolically? Any feedback/suggestions are much appreciated.

Thanks a lot in advance!

• What happens if you do Solve[(* equations *), Join[Flatten[B1], Flatten[C1], Flatten[D1], Flatten[S1]]]? – J. M. will be back soon Mar 9 '18 at 22:48
• Or use Flatten[{B1, C1, D1, S1}] – mikado Mar 9 '18 at 22:51
• I tried your suggestions - and the code says "Running" and never actually finishes. I attempted running a single function at a time (f2 for instance) and it would either do the same thing, it output "{}", which as I understand, means that there is no solution? – Renato Mar 12 '18 at 19:05