# Given A and B, how to find C if A = CBC?

Given

A={{0,1,1,0},{1,0,0,-1},{-1,0,0,1},{0,1,1,0}}

and

B={{0,1,0,0},{0,0,0,0},{0,0,0,1},{0,0,0,0}}

and

A=C.B.C, how to find C?

• There are over 1000 valid C even when restricted to [-1,1] integer domain for elements. What C are you after?
– ciao
Commented Jun 19, 2021 at 0:04
• Commented Jun 19, 2021 at 0:29
• All I need is that C should be invertible!
– Mike
Commented Jun 19, 2021 at 9:27

a = {{0, 1, 1, 0}, {1, 0, 0, -1}, {-1, 0, 0, 1}, {0, 1, 1, 0}};
b = {{0, 1, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 1}, {0, 0, 0, 0}};
c = Array[x, {4, 4}];
sol1 = FindInstance[a == c . b . c, Flatten[c], Reals, 1];
c /. sol1[[1]]
a == c . b . c /. sol1[[1]]

{{0, 99/5, -1, 12/5}, {1, 0, 0, -1}, {-1, -(28/5), 0, 79/ 5}, {0, -1, -1, 0}}

True

• Thanks. Unfortunately this particular choice of C doesn't seem good for me. How can I obtain more such forms?
– Mike
Commented Jun 19, 2021 at 9:28
• @Mike a = {{0, 1, 1, 0}, {1, 0, 0, -1}, {-1, 0, 0, 1}, {0, 1, 1, 0}}; b = {{0, 1, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 1}, {0, 0, 0, 0}}; c = Array[x, {4, 4}]; sol1 = Solve[a == c . b . c, Flatten[c]]; c /. sol1[[1]] /. {x[2, 3] -> x, x[1, 2] -> y, x[2, 1] -> z, x[1, 4] -> w, x[3, 2] -> t, x[3, 4] -> s} Commented Jun 19, 2021 at 10:17
• Thanks....my question definitely deserves a like:-)
– Mike
Commented Jun 19, 2021 at 13:52

Brute force?

A={{0,1,1,0},{1,0,0,-1},{-1,0,0,1},{0,1,1,0}};
B={{0,1,0,0},{0,0,0,0},{0,0,0,1},{0,0,0,0}};
cC={{a,b,c,d},{e,f,g,h},{i,j,k,l},{m,n,o,p}};
cC/.Solve[A==cC.B.cC,{a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p}]

which returns a caution that this may not be all solutions, but gives seven solutions.

{{{(1-e^2)/g,b,-e,d},{e,g,g,-e},{-e,j,-g,l},{(1-e^2)/g,-e,-e,(-1+e^2)/g}},
{{m,b,1,d},{-1,0,0,1},{1,j,0,l},{m,1,1,-m}},
{{m,b,-1,d},{1,0,0,-1},{-1,j,0,l},{m,-1,-1,-m}},
{{0,b,-1,d},{-1,0,0,1},{1,j,0,l},{0,-1,-1,0}},
{{0,b,1,d},{-1,0,0,1},{1,j,0,l},{0,1,1,0}},
{{0,b,-1,d},{1,0,0,-1},{-1,j,0,l},{0,-1,-1,0}},
{{0,b,1,d},{1,0,0,-1},{-1,j,0,l},{0,1,1,0}}}
• The warning is that only some of the variable are solved for (that is, given rules var -> expression). The others are free variables that parametrize the solution space. (+1) Commented Jun 19, 2021 at 4:53