How do you calculate determinants and eigenvalues in Mathematica?

3 replies · 6K views · last reply
Lambda96
Messages
233
Reaction score
77
TL;DR
How to calculate eigenvalues, eigenvectors, determinants and inverses of a general nxn matrix
Hi,

In my linear algebra homework, there is a bonus assignment where we are supposed to use Mathematica to calculate matrices and their determinants etc. here is the assignment.

Screenshot of a PDF exercise sheet on linear algebra in Mathematica, with text parts a to d, a matrix element formula A^i_j = a δ^i_j + δ^i_1 − δ^1_j, and a Mathematica Table code snippet for the identity matrix.


Unfortunately, I am a complete newbie when it comes to Mathematica, this is the first time I have worked with Mathematica.

I was able to calculate the task a to c. Here is the solution for task b and the Matrix for the case ##n=5##.
Mathematica notebook cell defining A[n_] as a Table of KroneckerDelta terms, followed by Print and MatrixForm of A[5], which shows a 5 by 5 matrix with a on the diagonal, 1 in the first row and column, and -1 below the diagonal.

I have now problems with the task d, where I should calculate the determinants, eigenvalues, etc for the general case n or rather give a formula.

For the determinant as an example I proceeded as follows and unfortunately I get the following error:

Mathematica notebook showing a definition A[a_, n_] built from KroneckerDelta terms, then Det[A[a, n]] with three Table iterator-bounds warnings and an output of Det of a Table of the delta expression minus Table terms.

Unfortunately I don't know how to fix the error or is my initial equation already wrong?
 
You can't leave n undefined. Mathematica can't find the rule for arbitrary n by itself. You have to calculate the result for explicit values of n, and then find by yourself the general rule.
 
  • Like
Likes   Reactions: Lambda96 and renormalize
As DrClaude says, ##n## must be specified explicitly:
Mathematica notebook output: a table of determinants of matrix A[a, n] for n from 1 to 10, showing a, 1 + a^2, a(2 + a^2), a^2(3 + a^2), a^3(4 + a^2), up to a^8(9 + a^2).

The pattern is pretty obvious.
 
  • Like
Likes   Reactions: DrClaude and Lambda96
Thanks DrClaude and renormalize for your help 👍👍

Thanks also renormalize for the trick with plotting n objects in Mathematica, so I could directly plot the eigenvalues from ##n=1## to ##n=10## without repeating the calculation 10 times 👍

I could now recognize corresponding patterns for the other values :smile:
 
  • Like
Likes   Reactions: renormalize and DrClaude