1
$\begingroup$

Alright, I'm very new to Mathematica and I have yet to learn a lot so please bear with me (sorry if this is a duplicate!):

I want to create an $n\times n$ matrix $C$ with elements $c_{i,j}$ with $i,j \in {1, \ldots n}$ which I would do like this

n = 4;
matC = Array[Subscript[c, #1, #2] &, {n, n}]

Now I want to define each $c_{i,j}=\{0,1\}$ but I have no idea how to effectively delay the assignment! I have tried using the Notation package but I just can't put my mind around it. I would go about it like this:

Do[Subscript[c,i,j] := {0,1}, {i,1,n}, {j,1,n}]

Finally I would like to calculate $det(tI_n - C) = 0$ and return all possible $C$ which I would do as follows:

Solve[Det[t*IdentityMatrix[n] - matC] == 0, matC]

Any help would be much appreciated!


I forgot to mention that I would actually like to find those $C$ where $det(tI_n - C) = a_nt^n - a_{n-1}t^{n-1} - \ldots - a_1t^1 - a_0 = a_nt^n - \sum_{i=0}^{n-1} a_it^i = 0$ for every $a_i = 1$.

As an example if $n = 3$ then

$C = \left\{ \begin{pmatrix} 1 & 1 & 0 \\ 1 & 0 & 1 \\ 1 & 0 & 0 \end{pmatrix}, \begin{pmatrix} 0 & 1 & 0 \\ 0 & 1 & 1 \\ 1 & 1 & 0 \end{pmatrix}, \begin{pmatrix} 0 & 1 & 1 \\ 0 & 0 & 1 \\ 1 & 0 & 1 \end{pmatrix} \right\} $


Actually, I just found out, that the general solution for any $n$ will be

$C = \begin{pmatrix} 1 & 1 & 0 & \ldots & 0\\ 1 & 0 & 1 & \ldots & 0\\ \vdots & \vdots & \vdots & \ddots & \vdots \\ \vdots & \vdots & \vdots & & 1 \\ 1 & 0 & 0 & \ldots & 0 \end{pmatrix} $

and every shift along the diagonal, but I guess I should rather post this somewhere here.

$\endgroup$
0

1 Answer 1

1
$\begingroup$

If I understand you correctly:

f[n_, t_] := Select[{#, Eigenvalues@#} & /@ Tuples[{0, 1}, {n, n}],  MemberQ[#[[2]], t] &][[All, 1]]

But be careful because the tuples thing grows ... quickly :). Finding an efficient way is more complicated.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.