Message Boards Message Boards

1
|
1984 Views
|
2 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Write a program, using a do-loop, feeding into a matrix.

Posted 11 years ago

I want to write a program in which I will read values from a loop e.g. $a_k = \cos{nk/N}$, where the loop will run from 1 to N and feed $a_k$ at each step into a matrix. Then I want to use those values to diagonalize the matrix.

POSTED BY: Lavi Kumar
2 Replies

In[12]:= m = Table[i^2*(j + 1) + 2, {i, 5}, {j, 5}]

Out[12]= {{4, 5, 6, 7, 8}, {10, 14, 18, 22, 26}, {20, 29, 38, 47, 
  56}, {34, 50, 66, 82, 98}, {52, 77, 102, 127, 152}}

In[13]:= Eigenvalues[m]

Out[13]= {5 (29 + Sqrt[817]), 5 (29 - Sqrt[817]), 0, 0, 0}
POSTED BY: Frank Kampas

It would be better to use Table rather than a Do loop to construct your matrix. Also, I don't see how you'll construct a matrix since the formula you give as an example only has one index.

POSTED BY: Frank Kampas
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract