Quick question about determinants in mathematica

In summary, you can define functions and variables in the same cell, but when you want to use them in a computation, you need to use subscripts.
  • #1
Amok
256
2
Sup guys,

So, I'm totally new to mathematica. I need to use it in order to compute a determinant of a
4x4 matrix that is made up entirely of functions. I almost managed to do this in wolfram alpha, but for a 4x4 matrix, the input is too long. Do you guys know how to do this (and if it even possible)?
 
Physics news on Phys.org
  • #2
Is this example enough to show you how to do this?

In[1]:= Det[{{Sin[t],Log[t]},{t^2,1+t}}]

Out[1]= -t^2 Log[t] + Sin[t] + t Sin[t]
 
  • #3
Are you totally new to mathematics, too? Working out a determinant for a 4x4 matrix by hand is not much of a problem.
 
  • #4
gsal said:
Are you totally new to mathematics, too? Working out a determinant for a 4x4 matrix by hand is not much of a problem.

I assume the functions are rather lengthy, and Mathematica is great for simplifying. I think you are assuming its a 4x4 of constants.

The above example should be enough.
Det[] is the function.
Tables/Matrices are entered as:

nameofmatrix = {{1,2,3,4},{5,6,7,8},{9,1,2,3},{4,5,6,7}}

for a 4x4 of constants. You can put the functions in by yourself, or define them prior:

F[1,1] = x^2;
F[1,2] = 3 x + 4;
F[1,3] = Sin[x];
F[1,4] = x^2;
F[2,1] = 3 x + 4;
F[2,2] = Sin[x];
F[2,3] = x^2;
F[2,4] = 3 x + 4;
and so forth for all 16 functions;

Then if you have all 16 functions defined as F[i,j] do:

matrix = Table[F[i,j],{i,1,4},{j,1,4}];
det = Det[matrix]

And you can simplify with :

detS = Simplify[det]

oor detFS = FullSimplify[det]And if you don't know, since you're new, to execute the command you use "SHIFT ENTER" to run the statement.
 
  • #5
gsal said:
Are you totally new to mathematics, too? Working out a determinant for a 4x4 matrix by hand is not much of a problem.

Honestly, that was uncalled for. If you want to know, I want to compute more than one determinant (I have a linear combination of them) and then collect terms and look for pattern in these functions. Moreover there are four different variables involved. I've been trying by hand, but it's obviously a lengthy procedure and keeping track of all the variables and indexes without making a single mistake is hard...

Hepth said:
The above example should be enough.
Det[] is the function.
Tables/Matrices are entered as:

nameofmatrix = {{1,2,3,4},{5,6,7,8},{9,1,2,3},{4,5,6,7}}

for a 4x4 of constants. You can put the functions in by yourself, or define them prior:

F[1,1] = x^2;
F[1,2] = 3 x + 4;
F[1,3] = Sin[x];
F[1,4] = x^2;
F[2,1] = 3 x + 4;
F[2,2] = Sin[x];
F[2,3] = x^2;
F[2,4] = 3 x + 4;
and so forth for all 16 functions;

Then if you have all 16 functions defined as F[i,j] do:

matrix = Table[F[i,j],{i,1,4},{j,1,4}];
det = Det[matrix]

And you can simplify with :

detS = Simplify[det]

oor detFS = FullSimplify[det]And if you don't know, since you're new, to execute the command you use "SHIFT ENTER" to run the statement.

Thank you for you reply. I tried something like that, but I don't have the explicit form of the functions, I have to write something like f1(x1)*a(y1), f2(x2)*a(y2), f3(x3)*a(y3)... (and permutations). I see that you wrote Sin[X] and not sin(x), so that might help. Gonna try it ASAP

:P

EDIT: Waddya know, it worked! Thx a bunch.
EDIT2: Holy crap! This program is awesome, it actually simplifies stuff :)
EDIT3: Hey, it worked while I called my matrix 'mat' and my determinant 'det', but then I changed them to matrix, or mat1 or det1 and the name became blue and the operations didn't work anymore. I'm having a hard time defining two matrices to use in my computations. Do I have to open a new cell to define each one of them? Or variables for that matter? Why do some names become blue, while others are black? I've read an intro to mathematica, but I'm still confused about this.
 
Last edited:
  • #6
blue = undefined variable, black = defined variable

You need to set a blue variable to something to make it black. You can do it in the same cell as the previous work, separating with a ; or you can create a new cell. I suggest practicing on simple operations if you are unfamiliar with Mma. Like

Expand[(1+x)^4]
Factor[x^2+x-2]
 
  • #7
lpetrich said:
blue = undefined variable, black = defined variable

You need to set a blue variable to something to make it black. You can do it in the same cell as the previous work, separating with a ; or you can create a new cell. I suggest practicing on simple operations if you are unfamiliar with Mma. Like

Expand[(1+x)^4]
Factor[x^2+x-2]

I found out that I need to use subscripts in order to label variables and especially functions, because mathematica was getting confused about wether the numbers were labels or actual numbers (hence variables that remained undefined). Everything's working fine now. Thanks.
 

1. How do I calculate the determinant of a matrix in Mathematica?

To calculate the determinant of a matrix in Mathematica, you can use the built-in function Det[matrix], where "matrix" is the name of your matrix. This will return the value of the determinant as a number.

2. Can I use Mathematica to find the eigenvalues of a matrix?

Yes, you can use the built-in function Eigenvalues[matrix] to find the eigenvalues of a matrix in Mathematica. This function will return a list of all the eigenvalues of the given matrix.

3. What is the purpose of calculating determinants in mathematics?

Calculating determinants is an important concept in linear algebra, as it helps in solving systems of linear equations and finding the inverse of a matrix. It is also used in various other areas of mathematics, such as in calculating areas and volumes in geometry.

4. How can I use Mathematica to solve systems of linear equations?

In Mathematica, you can use the built-in function Solve[{equations}, {variables}] to solve systems of linear equations. The "equations" should be written in the form of a list, and the "variables" should be specified as a list as well. This function will return a list of solutions for the given system of equations.

5. Is it possible to use Mathematica to find the inverse of a matrix?

Yes, you can use the built-in function Inverse[matrix] to find the inverse of a matrix in Mathematica. This function will return the inverse matrix if it exists, or an error if the matrix is singular.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
21
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • Calculus and Beyond Homework Help
Replies
6
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • Linear and Abstract Algebra
Replies
6
Views
1K
Replies
24
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
2
Replies
37
Views
19K
Back
Top