# How to define a function, that generates matrix of variables, which can be later used in Reduce?

My goal is to generate matrices, on which I will put different constraints in Reduce funcion, e.g.:

M = {{a, b}, {c, d}}
Reduce[M == {{1,2},{3,4}}, {a,b,c,d}]


I want to create a function, that will generate a matrix of variables (of given size), which I could later use in such a case as the above one. So far I figured out only something like this:

TabGen[a_, n_] := Table[a <> ToString[i] <> ToString[j], {i, 1, n}, {j, 1, n}]


but when I used it in a similar case, as the first one:

A = TabGen["a", 2]
Reduce[A == {{1, 2}, {3, 4}}, {a11, a12, a21, a22}]


I got:

{{"a11", "a12"}, {"a21", "a22"}}
False


My gues is that this function creates a matrix of strings, which cannot be considered as variables and used later in Reduce. How could I solve this problem?

• TabGen[a_, n_] := Table[Symbol[a <> ToString[i] <> ToString[j]], {i, 1, n}, {j, 1, n}] – Henrik Schumacher Apr 5 '19 at 11:30
• This works perfectly, thank you! – brzepkowski Apr 5 '19 at 11:41
• You're welcome. – Henrik Schumacher Apr 5 '19 at 11:42

A = Array[a, {2, 2}];